Skip to content

Commit 5ed66d2

Browse files
committed
Apply FreeRTOSV10_Core.patch
Of course, had to apply them manually, as the patch file did not apply directly. This is because some files were renamed / moved relative to the original distribution, while others were deleted because they did not apply.
1 parent beb5c1b commit 5ed66d2

File tree

5 files changed

+101
-4
lines changed

5 files changed

+101
-4
lines changed

cores/nRF5/freertos/Source/include/FreeRTOS.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ extern "C" {
156156
#define INCLUDE_uxTaskGetStackHighWaterMark 0
157157
#endif
158158

159+
#ifndef INCLUDE_pxTaskGetStackStart
160+
#define INCLUDE_pxTaskGetStackStart 0
161+
#endif
162+
159163
#ifndef INCLUDE_eTaskGetState
160164
#define INCLUDE_eTaskGetState 0
161165
#endif
@@ -392,6 +396,22 @@ extern "C" {
392396
#define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
393397
#endif
394398

399+
#ifndef traceREADDED_TASK_TO_READY_STATE
400+
#define traceREADDED_TASK_TO_READY_STATE( pxTCB ) traceMOVED_TASK_TO_READY_STATE( pxTCB )
401+
#endif
402+
403+
#ifndef traceMOVED_TASK_TO_DELAYED_LIST
404+
#define traceMOVED_TASK_TO_DELAYED_LIST()
405+
#endif
406+
407+
#ifndef traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST
408+
#define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST()
409+
#endif
410+
411+
#ifndef traceMOVED_TASK_TO_SUSPENDED_LIST
412+
#define traceMOVED_TASK_TO_SUSPENDED_LIST( pxTCB )
413+
#endif
414+
395415
#ifndef traceQUEUE_CREATE
396416
#define traceQUEUE_CREATE( pxNewQueue )
397417
#endif
@@ -636,6 +656,18 @@ extern "C" {
636656
#define traceTASK_NOTIFY_GIVE_FROM_ISR()
637657
#endif
638658

659+
#ifndef traceISR_EXIT_TO_SCHEDULER
660+
#define traceISR_EXIT_TO_SCHEDULER()
661+
#endif
662+
663+
#ifndef traceISR_EXIT
664+
#define traceISR_EXIT()
665+
#endif
666+
667+
#ifndef traceISR_ENTER
668+
#define traceISR_ENTER()
669+
#endif
670+
639671
#ifndef traceSTREAM_BUFFER_CREATE_FAILED
640672
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
641673
#endif

cores/nRF5/freertos/Source/include/task.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,25 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
14211421
*/
14221422
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
14231423

1424+
/**
1425+
* task.h
1426+
* <PRE>uint8_t* pxTaskGetStackStart( TaskHandle_t xTask);</PRE>
1427+
*
1428+
* INCLUDE_pxTaskGetStackStart must be set to 1 in FreeRTOSConfig.h for
1429+
* this function to be available.
1430+
*
1431+
* Returns the start of the stack associated with xTask. That is,
1432+
* the highest stack memory address on architectures where the stack grows down
1433+
* from high memory, and the lowest memory address on architectures where the
1434+
* stack grows up from low memory.
1435+
*
1436+
* @param xTask Handle of the task associated with the stack returned.
1437+
* Set xTask to NULL to return the stack of the calling task.
1438+
*
1439+
* @return A pointer to the start of the stack.
1440+
*/
1441+
uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION;
1442+
14241443
/* When using trace macros it is sometimes necessary to include task.h before
14251444
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
14261445
so the following two prototypes will cause a compilation error. This can be

cores/nRF5/freertos/Source/tasks.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,19 @@ count overflows. */
239239
tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
240240
/*-----------------------------------------------------------*/
241241

242+
/*
243+
* Place the task represented by pxTCB which has been in a ready list before
244+
* into the appropriate ready list for the task.
245+
* It is inserted at the end of the list.
246+
*/
247+
#define prvReaddTaskToReadyList( pxTCB ) \
248+
traceREADDED_TASK_TO_READY_STATE( pxTCB ); \
249+
taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \
250+
vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \
251+
tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
252+
/*-----------------------------------------------------------*/
253+
254+
242255
/*
243256
* Several functions take an TaskHandle_t parameter that can optionally be NULL,
244257
* where NULL is used to indicate that the handle of the currently executing
@@ -1598,7 +1611,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
15981611
{
15991612
mtCOVERAGE_TEST_MARKER();
16001613
}
1601-
prvAddTaskToReadyList( pxTCB );
1614+
prvReaddTaskToReadyList( pxTCB );
16021615
}
16031616
else
16041617
{
@@ -1660,6 +1673,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
16601673
mtCOVERAGE_TEST_MARKER();
16611674
}
16621675

1676+
traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB);
16631677
vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xStateListItem ) );
16641678

16651679
#if( configUSE_TASK_NOTIFICATIONS == 1 )
@@ -3671,6 +3685,20 @@ static void prvCheckTasksWaitingTermination( void )
36713685
#endif /* INCLUDE_uxTaskGetStackHighWaterMark */
36723686
/*-----------------------------------------------------------*/
36733687

3688+
#if (INCLUDE_pxTaskGetStackStart == 1)
3689+
uint8_t* pxTaskGetStackStart( TaskHandle_t xTask)
3690+
{
3691+
TCB_t *pxTCB;
3692+
UBaseType_t uxReturn;
3693+
(void)uxReturn;
3694+
3695+
pxTCB = prvGetTCBFromHandle( xTask );
3696+
return ( uint8_t * ) pxTCB->pxStack;
3697+
}
3698+
#endif /* INCLUDE_pxTaskGetStackStart */
3699+
/*-----------------------------------------------------------*/
3700+
3701+
36743702
#if ( INCLUDE_vTaskDelete == 1 )
36753703

36763704
static void prvDeleteTCB( TCB_t *pxTCB )
@@ -3840,7 +3868,7 @@ TCB_t *pxTCB;
38403868

38413869
/* Inherit the priority before being moved into the new list. */
38423870
pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority;
3843-
prvAddTaskToReadyList( pxMutexHolderTCB );
3871+
prvReaddTaskToReadyList( pxMutexHolderTCB );
38443872
}
38453873
else
38463874
{
@@ -3930,7 +3958,7 @@ TCB_t *pxTCB;
39303958
any other purpose if this task is running, and it must be
39313959
running to give back the mutex. */
39323960
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
3933-
prvAddTaskToReadyList( pxTCB );
3961+
prvReaddTaskToReadyList( pxTCB );
39343962

39353963
/* Return true to indicate that a context switch is required.
39363964
This is only actually required in the corner case whereby
@@ -4943,6 +4971,7 @@ const TickType_t xConstTickCount = xTickCount;
49434971
/* Add the task to the suspended task list instead of a delayed task
49444972
list to ensure it is not woken by a timing event. It will block
49454973
indefinitely. */
4974+
traceMOVED_TASK_TO_SUSPENDED_LIST(pxCurrentTCB);
49464975
vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) );
49474976
}
49484977
else
@@ -4959,12 +4988,14 @@ const TickType_t xConstTickCount = xTickCount;
49594988
{
49604989
/* Wake time has overflowed. Place this item in the overflow
49614990
list. */
4991+
traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
49624992
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
49634993
}
49644994
else
49654995
{
49664996
/* The wake time has not overflowed, so the current block list
49674997
is used. */
4998+
traceMOVED_TASK_TO_DELAYED_LIST();
49684999
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
49695000

49705001
/* If the task entering the blocked state was placed at the
@@ -4994,11 +5025,13 @@ const TickType_t xConstTickCount = xTickCount;
49945025
if( xTimeToWake < xConstTickCount )
49955026
{
49965027
/* Wake time has overflowed. Place this item in the overflow list. */
5028+
traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
49975029
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
49985030
}
49995031
else
50005032
{
50015033
/* The wake time has not overflowed, so the current block list is used. */
5034+
traceMOVED_TASK_TO_DELAYED_LIST();
50025035
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
50035036

50045037
/* If the task entering the blocked state was placed at the head of the

cores/nRF5/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
void xPortSysTickHandler( void )
5656
{
57+
traceISR_ENTER();
5758
#if configUSE_TICKLESS_IDLE == 1
5859
nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_COMPARE_0);
5960
#endif
@@ -89,11 +90,16 @@ void xPortSysTickHandler( void )
8990
/* Increment the RTOS tick as usual which checks if there is a need for rescheduling */
9091
if ( switch_req != pdFALSE )
9192
{
93+
traceISR_EXIT_TO_SCHEDULER();
9294
/* A context switch is required. Context switching is performed in
9395
the PendSV interrupt. Pend the PendSV interrupt. */
9496
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
9597
__SEV();
9698
}
99+
else
100+
{
101+
traceISR_EXIT();
102+
}
97103

98104
portCLEAR_INTERRUPT_MASK_FROM_ISR( isrstate );
99105
}

cores/nRF5/freertos/portable/CMSIS/nrf52/portmacro_cmsis.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ typedef unsigned long UBaseType_t;
9797
__ISB(); \
9898
}while (0)
9999

100-
#define portEND_SWITCHING_ISR( xSwitchRequired ) if ( (xSwitchRequired) != pdFALSE ) portYIELD()
100+
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { \
101+
if( xSwitchRequired != pdFALSE ) { \
102+
traceISR_EXIT_TO_SCHEDULER(); \
103+
portYIELD(); \
104+
} else { \
105+
traceISR_EXIT(); \
106+
} \
107+
} while (0)
101108
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
102109
/*-----------------------------------------------------------*/
103110

0 commit comments

Comments
 (0)