Skip to content

Commit bfb4378

Browse files
authored
Merge branch 'main' into ARM_CRx_MPU
2 parents 34c9579 + 1a500f1 commit bfb4378

File tree

12 files changed

+215
-12
lines changed

12 files changed

+215
-12
lines changed

croutine.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@
5252

5353
/* Other file private variables. --------------------------------*/
5454
CRCB_t * pxCurrentCoRoutine = NULL;
55-
static UBaseType_t uxTopCoRoutineReadyPriority = 0;
56-
static TickType_t xCoRoutineTickCount = 0, xLastTickCount = 0, xPassedTicks = 0;
55+
static UBaseType_t uxTopCoRoutineReadyPriority = ( UBaseType_t ) 0U;
56+
static TickType_t xCoRoutineTickCount = ( TickType_t ) 0U;
57+
static TickType_t xLastTickCount = ( TickType_t ) 0U;
58+
static TickType_t xPassedTicks = ( TickType_t ) 0U;
5759

5860
/* The initial state of the co-routine when it is created. */
5961
#define corINITIAL_STATE ( 0 )
@@ -378,5 +380,26 @@
378380

379381
return xReturn;
380382
}
383+
/*-----------------------------------------------------------*/
384+
385+
/*
386+
* Reset state in this file. This state is normally initialized at start up.
387+
* This function must be called by the application before restarting the
388+
* scheduler.
389+
*/
390+
void vCoRoutineResetState( void )
391+
{
392+
/* Lists for ready and blocked co-routines. */
393+
pxDelayedCoRoutineList = NULL;
394+
pxOverflowDelayedCoRoutineList = NULL;
395+
396+
/* Other file private variables. */
397+
pxCurrentCoRoutine = NULL;
398+
uxTopCoRoutineReadyPriority = ( UBaseType_t ) 0U;
399+
xCoRoutineTickCount = ( TickType_t ) 0U;
400+
xLastTickCount = ( TickType_t ) 0U;
401+
xPassedTicks = ( TickType_t ) 0U;
402+
}
403+
/*-----------------------------------------------------------*/
381404

382405
#endif /* configUSE_CO_ROUTINES == 0 */

include/croutine.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,13 @@ void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay,
746746
*/
747747
BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList );
748748

749+
750+
/*
751+
* This function resets the internal state of the coroutine module. It must be
752+
* called by the application before restarting the scheduler.
753+
*/
754+
void vCoRoutineResetState( void ) PRIVILEGED_FUNCTION;
755+
749756
/* *INDENT-OFF* */
750757
#ifdef __cplusplus
751758
}

include/portable.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
194194
#define vPortFreeStack vPortFree
195195
#endif
196196

197+
/*
198+
* This function resets the internal state of the heap module. It must be called
199+
* by the application before restarting the scheduler.
200+
*/
201+
void vPortHeapResetState( void ) PRIVILEGED_FUNCTION;
202+
197203
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
198204

199205
/**

include/task.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,6 +3438,20 @@ BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
34383438
*/
34393439
BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
34403440

3441+
/**
3442+
* task.h
3443+
* @code{c}
3444+
* void vTaskResetState( void );
3445+
* @endcode
3446+
*
3447+
* This function resets the internal state of the task. It must be called by the
3448+
* application before restarting the scheduler.
3449+
*
3450+
* \defgroup vTaskResetState vTaskResetState
3451+
* \ingroup SchedulerControl
3452+
*/
3453+
void vTaskResetState( void ) PRIVILEGED_FUNCTION;
3454+
34413455

34423456
/*-----------------------------------------------------------
34433457
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES

include/timers.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,12 @@ BaseType_t xTimerGenericCommandFromISR( TimerHandle_t xTimer,
14171417

14181418
#endif
14191419

1420+
/*
1421+
* This function resets the internal state of the timer module. It must be called
1422+
* by the application before restarting the scheduler.
1423+
*/
1424+
void vTimerResetState( void ) PRIVILEGED_FUNCTION;
1425+
14201426
/* *INDENT-OFF* */
14211427
#ifdef __cplusplus
14221428
}

portable/MemMang/heap_1.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#endif /* configAPPLICATION_ALLOCATED_HEAP */
6565

6666
/* Index into the ucHeap array. */
67-
static size_t xNextFreeByte = ( size_t ) 0;
67+
static size_t xNextFreeByte = ( size_t ) 0U;
6868

6969
/*-----------------------------------------------------------*/
7070

@@ -150,3 +150,16 @@ size_t xPortGetFreeHeapSize( void )
150150
{
151151
return( configADJUSTED_HEAP_SIZE - xNextFreeByte );
152152
}
153+
154+
/*-----------------------------------------------------------*/
155+
156+
/*
157+
* Reset the state in this file. This state is normally initialized at start up.
158+
* This function must be called by the application before restarting the
159+
* scheduler.
160+
*/
161+
void vPortHeapResetState( void )
162+
{
163+
xNextFreeByte = ( size_t ) 0U;
164+
}
165+
/*-----------------------------------------------------------*/

portable/MemMang/heap_2.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ PRIVILEGED_DATA static BlockLink_t xStart, xEnd;
113113
* fragmentation. */
114114
PRIVILEGED_DATA static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
115115

116+
/* Indicates whether the heap has been initialised or not. */
117+
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
118+
116119
/*-----------------------------------------------------------*/
117120

118121
/*
@@ -155,7 +158,6 @@ void * pvPortMalloc( size_t xWantedSize )
155158
BlockLink_t * pxBlock;
156159
BlockLink_t * pxPreviousBlock;
157160
BlockLink_t * pxNewBlockLink;
158-
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
159161
void * pvReturn = NULL;
160162
size_t xAdditionalRequiredSize;
161163

@@ -384,3 +386,16 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
384386
pxFirstFreeBlock->pxNextFreeBlock = &xEnd;
385387
}
386388
/*-----------------------------------------------------------*/
389+
390+
/*
391+
* Reset the state in this file. This state is normally initialized at start up.
392+
* This function must be called by the application before restarting the
393+
* scheduler.
394+
*/
395+
void vPortHeapResetState( void )
396+
{
397+
xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
398+
399+
xHeapHasBeenInitialised = pdFALSE;
400+
}
401+
/*-----------------------------------------------------------*/

portable/MemMang/heap_3.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,15 @@ void vPortFree( void * pv )
9292
( void ) xTaskResumeAll();
9393
}
9494
}
95+
/*-----------------------------------------------------------*/
96+
97+
/*
98+
* Reset the state in this file. This state is normally initialized at start up.
99+
* This function must be called by the application before restarting the
100+
* scheduler.
101+
*/
102+
void vPortHeapResetState( void )
103+
{
104+
/* No state needs to be re-initialised in heap_3. */
105+
}
106+
/*-----------------------------------------------------------*/

portable/MemMang/heap_4.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ PRIVILEGED_DATA static BlockLink_t * pxEnd = NULL;
163163

164164
/* Keeps track of the number of calls to allocate and free memory as well as the
165165
* number of free bytes remaining, but says nothing about fragmentation. */
166-
PRIVILEGED_DATA static size_t xFreeBytesRemaining = 0U;
167-
PRIVILEGED_DATA static size_t xMinimumEverFreeBytesRemaining = 0U;
168-
PRIVILEGED_DATA static size_t xNumberOfSuccessfulAllocations = 0;
169-
PRIVILEGED_DATA static size_t xNumberOfSuccessfulFrees = 0;
166+
PRIVILEGED_DATA static size_t xFreeBytesRemaining = ( size_t ) 0U;
167+
PRIVILEGED_DATA static size_t xMinimumEverFreeBytesRemaining = ( size_t ) 0U;
168+
PRIVILEGED_DATA static size_t xNumberOfSuccessfulAllocations = ( size_t ) 0U;
169+
PRIVILEGED_DATA static size_t xNumberOfSuccessfulFrees = ( size_t ) 0U;
170170

171171
/*-----------------------------------------------------------*/
172172

@@ -608,3 +608,19 @@ void vPortGetHeapStats( HeapStats_t * pxHeapStats )
608608
taskEXIT_CRITICAL();
609609
}
610610
/*-----------------------------------------------------------*/
611+
612+
/*
613+
* Reset the state in this file. This state is normally initialized at start up.
614+
* This function must be called by the application before restarting the
615+
* scheduler.
616+
*/
617+
void vPortHeapResetState( void )
618+
{
619+
pxEnd = NULL;
620+
621+
xFreeBytesRemaining = ( size_t ) 0U;
622+
xMinimumEverFreeBytesRemaining = ( size_t ) 0U;
623+
xNumberOfSuccessfulAllocations = ( size_t ) 0U;
624+
xNumberOfSuccessfulFrees = ( size_t ) 0U;
625+
}
626+
/*-----------------------------------------------------------*/

portable/MemMang/heap_5.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ PRIVILEGED_DATA static BlockLink_t * pxEnd = NULL;
187187

188188
/* Keeps track of the number of calls to allocate and free memory as well as the
189189
* number of free bytes remaining, but says nothing about fragmentation. */
190-
PRIVILEGED_DATA static size_t xFreeBytesRemaining = 0U;
191-
PRIVILEGED_DATA static size_t xMinimumEverFreeBytesRemaining = 0U;
192-
PRIVILEGED_DATA static size_t xNumberOfSuccessfulAllocations = 0;
193-
PRIVILEGED_DATA static size_t xNumberOfSuccessfulFrees = 0;
190+
PRIVILEGED_DATA static size_t xFreeBytesRemaining = ( size_t ) 0U;
191+
PRIVILEGED_DATA static size_t xMinimumEverFreeBytesRemaining = ( size_t ) 0U;
192+
PRIVILEGED_DATA static size_t xNumberOfSuccessfulAllocations = ( size_t ) 0U;
193+
PRIVILEGED_DATA static size_t xNumberOfSuccessfulFrees = ( size_t ) 0U;
194194

195195
#if ( configENABLE_HEAP_PROTECTOR == 1 )
196196

@@ -707,3 +707,24 @@ void vPortGetHeapStats( HeapStats_t * pxHeapStats )
707707
taskEXIT_CRITICAL();
708708
}
709709
/*-----------------------------------------------------------*/
710+
711+
/*
712+
* Reset the state in this file. This state is normally initialized at start up.
713+
* This function must be called by the application before restarting the
714+
* scheduler.
715+
*/
716+
void vPortHeapResetState( void )
717+
{
718+
pxEnd = NULL;
719+
720+
xFreeBytesRemaining = ( size_t ) 0U;
721+
xMinimumEverFreeBytesRemaining = ( size_t ) 0U;
722+
xNumberOfSuccessfulAllocations = ( size_t ) 0U;
723+
xNumberOfSuccessfulFrees = ( size_t ) 0U;
724+
725+
#if ( configENABLE_HEAP_PROTECTOR == 1 )
726+
pucHeapHighAddress = NULL;
727+
pucHeapLowAddress = NULL;
728+
#endif /* #if ( configENABLE_HEAP_PROTECTOR == 1 ) */
729+
}
730+
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)