Verified Commit 39c5e25c authored by Vincent Coubard's avatar Vincent Coubard
Browse files

RTOS: Make configuration OS independant


- Extract base types definitions into basetypes.h
- move configurations around to avoid making FreeRTOS dependant config
visible from RTOS_config.h
Signed-off-by: Vincent Coubard's avatarVincent Coubard <vincent.coubard@arm.com>
parent 409923e3
......@@ -7,16 +7,6 @@
#define RTE_COMPONENTS_H
// TrustZone support
#define DOMAIN_NS 1
// Pool of mutex objects, required by TF-M NS interface
#define OS_MUTEX_OBJ_MEM 1
#define OS_MUTEX_NUM 4
// Memory allocation related definitions.
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE 512000 // should be enough
#define configAPPLICATION_ALLOCATED_HEAP 1
#define DOMAIN_NS 1
#define OS_DYNAMIC_MEM_SIZE (32768 * 3)
#endif // RTE_COMPONENTS_H
/*
* Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef RTOS_CONFIG_H
#define RTOS_CONFIG_H
#include <stddef.h>
#include "basetypes.h"
#define configPRINT_STRING(X) print_log(X) // used by vLoggingPrintf
#define configPRINT(X) print_log X // used by dumb logging
#define configPRINTF(X) print_log X // used by dumb logging
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE 512000 // should be enough
#define configAPPLICATION_ALLOCATED_HEAP 1
#define configENABLE_FPU 0
#define configENABLE_MPU 0
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 0
/* Sets the length of the buffers into which logging messages are written - so
* also defines the maximum length of each log message. */
#define configLOGGING_MAX_MESSAGE_LENGTH 200
/* Set to 1 to prepend each log message with a message number, the task name,
* and a time stamp. */
#define configLOGGING_INCLUDE_TIME_AND_TASK_NAME 1
// somehow 300 tick per second gives similar timing (~85%) as 1000 did on the FPGA, so with this 1 ms to 1 tick can be
// kept...
#define configTICK_RATE_HZ ((uint32_t)300) /* Scheduler polling rate of 1000 Hz */
#define configMINIMAL_STACK_SIZE 4096
#define configUSE_16_BIT_TICKS 0
#define portTICK_TYPE_IS_ATOMIC 1
#define democonfigDEMO_STACKSIZE (2 * configMINIMAL_STACK_SIZE)
#define democonfigDEMO_PRIORITY osPriorityNormal
#define configSTACK_DEPTH_TYPE uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
#define pdMS_TO_TICKS(ms) (((uint64_t)ms * osKernelGetTickFreq()) / 1000)
// Prevent redefinition if this file is included by FreeRTOS itself
#ifndef FREERTOS_CONFIG_H
#define pdFALSE ((BaseType_t)0)
#define pdTRUE ((BaseType_t)1)
#define pdPASS pdTRUE
#define pdFAIL pdFALSE
#endif
extern void configASSERT(uint32_t condition);
extern void print_log(const char *format, ...);
extern void *pvPortMalloc(size_t size);
extern void vPortFree(void *p);
#endif // RTOS_CONFIG_H
/*
* Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef BASETYPES_H_
#define BASETYPES_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#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;
#ifdef __cplusplus
}
#endif
#endif /* BASETYPES_H_ */
......@@ -30,6 +30,7 @@
your application. */
#include <stdint.h>
#include "aws_secure_sockets_config.h"
#include "RTOS_config.h"
#ifndef __USED
#define __USED __attribute__((used))
......@@ -41,45 +42,15 @@ your application. */
extern uint32_t SystemCoreClock;
#define configENABLE_FPU 0
#define configENABLE_MPU 0
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 0
void vAssertCalled( const char * pcFile, unsigned long ulLine );
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ );
// /* Non-format version thread-safe print */
// extern void vLoggingPrint( const char * pcMessage );
// #define configPRINT( X ) printf X; printf("\r\n")
/* Map the logging task's printf to the board specific output function. */
extern void vLoggingPrintf( const char *format, ... );
extern void print_log( const char *format, ... );
#define configPRINT_STRING( X ) print_log( X ) // used by vLoggingPrintf
#define configPRINT( X ) print_log X // used by dumb logging
#define configPRINTF( X ) print_log X // used by dumb logging
/* Sets the length of the buffers into which logging messages are written - so
* also defines the maximum length of each log message. */
#define configLOGGING_MAX_MESSAGE_LENGTH 200
/* Set to 1 to prepend each log message with a message number, the task name,
* and a time stamp. */
#define configLOGGING_INCLUDE_TIME_AND_TASK_NAME 1
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) SystemCoreClock )
// this is commented out so freeRTOS uses cpu clock for systick
//#define configSYSTICK_CLOCK_HZ ( ( unsigned long ) 100000 ) // ruomor has it that FVP runs around 100kHz systic clock /* freeRTOS port uses CPU systick counter and that runs from the CPU clock */
// somehow 300 tick per second gives similar timing (~85%) as 1000 did on the FPGA, so with this 1 ms to 1 tick can be kept...
#define configTICK_RATE_HZ ( ( TickType_t ) 300 ) /* Scheduler polling rate of 1000 Hz */
#define configMS_TO_RTOS_TICK( ms ) ( ms ) /* Tick rate is 1000 Hz, so 1 tick is 1 ms */
#define configMAX_PRIORITIES 56
#define configMINIMAL_STACK_SIZE 1024
#define configMAX_TASK_NAME_LEN 16
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
......@@ -93,14 +64,6 @@ extern void print_log( const char *format, ... );
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 0
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
#define configSTACK_DEPTH_TYPE uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE 512000 // should be enough
#define configAPPLICATION_ALLOCATED_HEAP 1
/* Hook function related definitions. */
#define configUSE_IDLE_HOOK 0
......@@ -227,11 +190,6 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configNET_MASK3 0
#define democonfigNETWORK_TYPES ( AWSIOT_NETWORK_TYPE_ETH )
#define democonfigDEMO_PRIORITY ( configMAX_PRIORITIES-2 )
#ifndef democonfigDEMO_STACKSIZE
# define democonfigDEMO_STACKSIZE ( configMINIMAL_STACK_SIZE*8 )
#endif
/* Map the FreeRTOS port interrupt handlers to their CMSIS standard names. */
#define xPortPendSVHandler PendSV_Handler
......
......@@ -28,6 +28,8 @@
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "basetypes.h"
#ifdef __cplusplus
extern "C" {
#endif
......@@ -57,31 +59,14 @@
/*-----------------------------------------------------------*/
/**
* @brief Type definitions.
* @brief Tick 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
#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
#define portTICK_TYPE_IS_ATOMIC 1
/*-----------------------------------------------------------*/
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment