From 4bad316700f74afb5b9ad4d095998a52cc278821 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Tue, 31 Aug 2021 10:32:54 +0800 Subject: [PATCH] freertos: several ESP specific things clearly marked --- components/freertos/event_groups.c | 9 ++++++--- components/freertos/include/freertos/event_groups.h | 5 ++++- components/freertos/include/freertos/task.h | 9 ++++++++- components/freertos/include/freertos/timers.h | 5 ++++- components/freertos/queue.c | 13 ++++++++----- components/freertos/timers.c | 9 +++++++-- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/components/freertos/event_groups.c b/components/freertos/event_groups.c index c3ad94f214..f4be8973ae 100644 --- a/components/freertos/event_groups.c +++ b/components/freertos/event_groups.c @@ -84,7 +84,9 @@ typedef struct EventGroupDef_t uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */ #endif +#ifdef ESP_PLATFORM portMUX_TYPE eventGroupMux; //Mutex required due to SMP +#endif // ESP_PLATFORM } EventGroup_t; /*-----------------------------------------------------------*/ @@ -140,8 +142,9 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ traceEVENT_GROUP_CREATE( pxEventBits ); - +#ifdef ESP_PLATFORM vPortCPUInitializeMutex( &pxEventBits->eventGroupMux ); +#endif // ESP_PLATFORM } else { @@ -191,9 +194,9 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, pxEventBits->ucStaticallyAllocated = pdFALSE; } #endif /* configSUPPORT_STATIC_ALLOCATION */ - +#ifdef ESP_PLATFORM vPortCPUInitializeMutex( &pxEventBits->eventGroupMux ); - +#endif // ESP_PLATFORM traceEVENT_GROUP_CREATE( pxEventBits ); } else diff --git a/components/freertos/include/freertos/event_groups.h b/components/freertos/include/freertos/event_groups.h index 8d7f6f8039..4d74120bc4 100644 --- a/components/freertos/include/freertos/event_groups.h +++ b/components/freertos/include/freertos/event_groups.h @@ -84,8 +84,11 @@ * \ingroup EventGroup */ struct EventGroupDef_t; +#ifdef ESP_PLATFORM // IDF-3770 typedef void * EventGroupHandle_t; -// typedef struct EventGroupDef_t * EventGroupHandle_t; +#else +typedef struct EventGroupDef_t * EventGroupHandle_t; +#endif // ESP_PLATFORM /* * The type that holds event bits always matches TickType_t - therefore the * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, diff --git a/components/freertos/include/freertos/task.h b/components/freertos/include/freertos/task.h index 8053c80645..2f6798caea 100644 --- a/components/freertos/include/freertos/task.h +++ b/components/freertos/include/freertos/task.h @@ -33,7 +33,9 @@ #endif #include "list.h" +#ifdef ESP_PLATFORM // IDF-3793 #include "freertos/portmacro.h" +#endif // ESP_PLATFORM /* *INDENT-OFF* */ #ifdef __cplusplus @@ -72,8 +74,11 @@ * \ingroup Tasks */ struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tskTaskControlBlock* TaskHandle_t; +#ifdef ESP_PLATFORM // IDF-3769 typedef void* TaskHandle_t; +#else +typedef struct tskTaskControlBlock* TaskHandle_t; +#endif // ESP_PLATFORM /** * Defines the prototype to which the application task hook function must * conform. @@ -2768,8 +2773,10 @@ TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; */ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; +#ifdef ESP_PLATFORM /* TODO: IDF-3683 */ #include "freertos/task_snapshot.h" +#endif // ESP_PLATFORM /** @endcond */ diff --git a/components/freertos/include/freertos/timers.h b/components/freertos/include/freertos/timers.h index 69512f949e..6f3648aa77 100644 --- a/components/freertos/include/freertos/timers.h +++ b/components/freertos/include/freertos/timers.h @@ -75,8 +75,11 @@ * (for example, xTimerStart(), xTimerReset(), etc.). */ struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ -//typedef struct tmrTimerControl * TimerHandle_t; +#ifdef ESP_PLATFORM // IDF-3768 typedef void* TimerHandle_t; +#else +typedef struct tmrTimerControl * TimerHandle_t; +#endif // ESP_PLATFORM /* * Defines the prototype to which timer callback functions must conform. */ diff --git a/components/freertos/queue.c b/components/freertos/queue.c index 2557117988..712fbd2119 100644 --- a/components/freertos/queue.c +++ b/components/freertos/queue.c @@ -139,9 +139,9 @@ typedef struct QueueDefinition /* The old naming convention is used to prevent b UBaseType_t uxQueueNumber; uint8_t ucQueueType; #endif - +#ifdef ESP_PLATFORM portMUX_TYPE mux; //Mutex required due to SMP - +#endif // ESP_PLATFORM } xQUEUE; /* The old xQUEUE name is maintained above then typedefed to the new Queue_t @@ -174,10 +174,10 @@ typedef xQUEUE Queue_t; * The pcQueueName member of a structure being NULL is indicative of the * array position being vacant. */ PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ]; - +#ifdef ESP_PLATFORM //Need to add queue registry mutex to protect against simultaneous access static portMUX_TYPE queue_registry_spinlock = portMUX_INITIALIZER_UNLOCKED; - +#endif // ESP_PLATFORM #endif /* configQUEUE_REGISTRY_SIZE */ /* @@ -285,10 +285,12 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, configASSERT( pxQueue ); +#ifdef ESP_PLATFORM if( xNewQueue == pdTRUE ) { vPortCPUInitializeMutex(&pxQueue->mux); } +#endif // ESP_PLATFORM taskENTER_CRITICAL(); { @@ -532,8 +534,9 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, /* In case this is a recursive mutex. */ pxNewQueue->u.xSemaphore.uxRecursiveCallCount = 0; +#ifdef ESP_PLATFORM vPortCPUInitializeMutex(&pxNewQueue->mux); - +#endif // ESP_PLATFORM traceCREATE_MUTEX( pxNewQueue ); /* Start with the semaphore in the expected state. */ diff --git a/components/freertos/timers.c b/components/freertos/timers.c index 9783299f76..76fc364fb6 100644 --- a/components/freertos/timers.c +++ b/components/freertos/timers.c @@ -152,8 +152,10 @@ PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL; PRIVILEGED_DATA static TaskHandle_t xTimerTaskHandle = NULL; +#ifdef ESP_PLATFORM /* Mux. We use a single mux for all the timers for now. ToDo: maybe increase granularity here? */ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED; +#endif // ESP_PLATFORM /*lint -restore */ @@ -521,13 +523,15 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED; } /*-----------------------------------------------------------*/ - static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) + static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, + const TickType_t xTimeNow ) { BaseType_t xResult; Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ /* Remove the timer from the list of active timers. A check has already * been performed to ensure the list is not empty. */ + ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); traceTIMER_EXPIRED( pxTimer ); @@ -965,8 +969,9 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED; /* Check that the list from which active timers are referenced, and the * queue used to communicate with the timer service, have been * initialised. */ - +#ifdef ESP_PLATFORM if( xTimerQueue == NULL ) vPortCPUInitializeMutex( &xTimerMux ); +#endif // ESP_PLATFORM taskENTER_CRITICAL(); {