Skip to content

Commit 8f378b4

Browse files
authored
Merge pull request #707 from ourairquality/freertos-v10.2.0
FreeRTOS: update to v10.2.0
2 parents 3ca6b84 + 25e155b commit 8f378b4

28 files changed

+1157
-713
lines changed

FreeRTOS/License/license.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ source file.
1717
License text:
1818
-------------
1919

20-
Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
20+
Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2121
Permission is hereby granted, free of charge, to any person obtaining a copy of
2222
this software and associated documentation files (the "Software"), to deal in
2323
the Software without restriction, including without limitation the rights to
@@ -26,8 +26,7 @@ the Software, and to permit persons to whom the Software is furnished to do so,
2626
subject to the following conditions:
2727

2828
The above copyright notice and this permission notice shall be included in all
29-
copies or substantial portions of the Software. If you wish to use our Amazon
30-
FreeRTOS name, please do so in a fair use way that does not cause confusion.
29+
copies or substantial portions of the Software.
3130

3231
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3332
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS

FreeRTOS/Source/croutine.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FreeRTOS Kernel V10.0.1
3-
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* FreeRTOS Kernel V10.2.0
3+
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy of
66
* this software and associated documentation files (the "Software"), to deal in
@@ -260,7 +260,7 @@ CRCB_t *pxCRCB;
260260
( void ) uxListRemove( &( pxCRCB->xGenericListItem ) );
261261

262262
/* Is the co-routine waiting on an event also? */
263-
if( pxCRCB->xEventListItem.pvContainer )
263+
if( pxCRCB->xEventListItem.pxContainer )
264264
{
265265
( void ) uxListRemove( &( pxCRCB->xEventListItem ) );
266266
}

FreeRTOS/Source/event_groups.c

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FreeRTOS Kernel V10.0.1
3-
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* FreeRTOS Kernel V10.2.0
3+
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy of
66
* this software and associated documentation files (the "Software"), to deal in
@@ -39,11 +39,11 @@ task.h is included from an application file. */
3939
#include "timers.h"
4040
#include "event_groups.h"
4141

42-
/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
43-
MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
44-
header files above, but not in this file, in order to generate the correct
45-
privileged Vs unprivileged linkage and placement. */
46-
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
42+
/* Lint e961, e750 and e9021 are suppressed as a MISRA exception justified
43+
because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
44+
for the header files above, but not in this file, in order to generate the
45+
correct privileged Vs unprivileged linkage and placement. */
46+
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021 See comment above. */
4747

4848
/* The following bit fields convey control information in a task's event list
4949
item value. It is important they don't clash with the
@@ -60,7 +60,7 @@ taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
6060
#define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL
6161
#endif
6262

63-
typedef struct xEventGroupDefinition
63+
typedef struct EventGroupDef_t
6464
{
6565
EventBits_t uxEventBits;
6666
List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */
@@ -104,11 +104,11 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co
104104
event group structure. */
105105
volatile size_t xSize = sizeof( StaticEventGroup_t );
106106
configASSERT( xSize == sizeof( EventGroup_t ) );
107-
}
107+
} /*lint !e529 xSize is referenced if configASSERT() is defined. */
108108
#endif /* configASSERT_DEFINED */
109109

110110
/* The user has provided a statically allocated event group - use it. */
111-
pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 EventGroup_t and StaticEventGroup_t are guaranteed to have the same size and alignment requirement - checked by configASSERT(). */
111+
pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 !e9087 EventGroup_t and StaticEventGroup_t are deliberately aliased for data hiding purposes and guaranteed to have the same size and alignment requirement - checked by configASSERT(). */
112112

113113
if( pxEventBits != NULL )
114114
{
@@ -128,10 +128,13 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co
128128
}
129129
else
130130
{
131+
/* xEventGroupCreateStatic should only ever be called with
132+
pxEventGroupBuffer pointing to a pre-allocated (compile time
133+
allocated) StaticEventGroup_t variable. */
131134
traceEVENT_GROUP_CREATE_FAILED();
132135
}
133136

134-
return ( EventGroupHandle_t ) pxEventBits;
137+
return pxEventBits;
135138
}
136139

137140
#endif /* configSUPPORT_STATIC_ALLOCATION */
@@ -143,8 +146,20 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co
143146
{
144147
EventGroup_t *pxEventBits;
145148

146-
/* Allocate the event group. */
147-
pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );
149+
/* Allocate the event group. Justification for MISRA deviation as
150+
follows: pvPortMalloc() always ensures returned memory blocks are
151+
aligned per the requirements of the MCU stack. In this case
152+
pvPortMalloc() must return a pointer that is guaranteed to meet the
153+
alignment requirements of the EventGroup_t structure - which (if you
154+
follow it through) is the alignment requirements of the TickType_t type
155+
(EventBits_t being of TickType_t itself). Therefore, whenever the
156+
stack alignment requirements are greater than or equal to the
157+
TickType_t alignment requirements the cast is safe. In other cases,
158+
where the natural word size of the architecture is less than
159+
sizeof( TickType_t ), the TickType_t variables will be accessed in two
160+
or more reads operations, and the alignment requirements is only that
161+
of each individual read. */
162+
pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) ); /*lint !e9087 !e9079 see comment above. */
148163

149164
if( pxEventBits != NULL )
150165
{
@@ -164,10 +179,10 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co
164179
}
165180
else
166181
{
167-
traceEVENT_GROUP_CREATE_FAILED();
182+
traceEVENT_GROUP_CREATE_FAILED(); /*lint !e9063 Else branch only exists to allow tracing and does not generate code if trace macros are not defined. */
168183
}
169184

170-
return ( EventGroupHandle_t ) pxEventBits;
185+
return pxEventBits;
171186
}
172187

173188
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
@@ -176,7 +191,7 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, co
176191
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )
177192
{
178193
EventBits_t uxOriginalBitValue, uxReturn;
179-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
194+
EventGroup_t *pxEventBits = xEventGroup;
180195
BaseType_t xAlreadyYielded;
181196
BaseType_t xTimeoutOccurred = pdFALSE;
182197

@@ -295,7 +310,7 @@ BaseType_t xTimeoutOccurred = pdFALSE;
295310

296311
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait )
297312
{
298-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
313+
EventGroup_t *pxEventBits = xEventGroup;
299314
EventBits_t uxReturn, uxControlBits = 0;
300315
BaseType_t xWaitConditionMet, xAlreadyYielded;
301316
BaseType_t xTimeoutOccurred = pdFALSE;
@@ -445,7 +460,7 @@ BaseType_t xTimeoutOccurred = pdFALSE;
445460

446461
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
447462
{
448-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
463+
EventGroup_t *pxEventBits = xEventGroup;
449464
EventBits_t uxReturn;
450465

451466
/* Check the user is not attempting to clear the bits used by the kernel
@@ -477,7 +492,7 @@ EventBits_t uxReturn;
477492
BaseType_t xReturn;
478493

479494
traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );
480-
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL );
495+
xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
481496

482497
return xReturn;
483498
}
@@ -488,7 +503,7 @@ EventBits_t uxReturn;
488503
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup )
489504
{
490505
UBaseType_t uxSavedInterruptStatus;
491-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
506+
EventGroup_t const * const pxEventBits = xEventGroup;
492507
EventBits_t uxReturn;
493508

494509
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
@@ -498,16 +513,16 @@ EventBits_t uxReturn;
498513
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
499514

500515
return uxReturn;
501-
}
516+
} /*lint !e818 EventGroupHandle_t is a typedef used in other functions to so can't be pointer to const. */
502517
/*-----------------------------------------------------------*/
503518

504519
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet )
505520
{
506521
ListItem_t *pxListItem, *pxNext;
507522
ListItem_t const *pxListEnd;
508-
List_t *pxList;
523+
List_t const * pxList;
509524
EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;
510-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
525+
EventGroup_t *pxEventBits = xEventGroup;
511526
BaseType_t xMatchFound = pdFALSE;
512527

513528
/* Check the user is not attempting to set the bits used by the kernel
@@ -516,7 +531,7 @@ BaseType_t xMatchFound = pdFALSE;
516531
configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
517532

518533
pxList = &( pxEventBits->xTasksWaitingForBits );
519-
pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
534+
pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
520535
vTaskSuspendAll();
521536
{
522537
traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
@@ -597,7 +612,7 @@ BaseType_t xMatchFound = pdFALSE;
597612

598613
void vEventGroupDelete( EventGroupHandle_t xEventGroup )
599614
{
600-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
615+
EventGroup_t *pxEventBits = xEventGroup;
601616
const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
602617

603618
vTaskSuspendAll();
@@ -641,15 +656,15 @@ const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
641656
an interrupt. */
642657
void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet )
643658
{
644-
( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet );
659+
( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet ); /*lint !e9079 Can't avoid cast to void* as a generic timer callback prototype. Callback casts back to original type so safe. */
645660
}
646661
/*-----------------------------------------------------------*/
647662

648663
/* For internal use only - execute a 'clear bits' command that was pended from
649664
an interrupt. */
650665
void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear )
651666
{
652-
( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear );
667+
( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear ); /*lint !e9079 Can't avoid cast to void* as a generic timer callback prototype. Callback casts back to original type so safe. */
653668
}
654669
/*-----------------------------------------------------------*/
655670

@@ -695,7 +710,7 @@ BaseType_t xWaitConditionMet = pdFALSE;
695710
BaseType_t xReturn;
696711

697712
traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );
698-
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken );
713+
xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ); /*lint !e9087 Can't avoid cast to void* as a generic callback function not specific to this use case. Callback casts back to original type so safe. */
699714

700715
return xReturn;
701716
}
@@ -708,7 +723,7 @@ BaseType_t xWaitConditionMet = pdFALSE;
708723
UBaseType_t uxEventGroupGetNumber( void* xEventGroup )
709724
{
710725
UBaseType_t xReturn;
711-
EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
726+
EventGroup_t const *pxEventBits = ( EventGroup_t * ) xEventGroup; /*lint !e9087 !e9079 EventGroupHandle_t is a pointer to an EventGroup_t, but EventGroupHandle_t is kept opaque outside of this file for data hiding purposes. */
712727

713728
if( xEventGroup == NULL )
714729
{
@@ -729,7 +744,7 @@ BaseType_t xWaitConditionMet = pdFALSE;
729744

730745
void vEventGroupSetNumber( void * xEventGroup, UBaseType_t uxEventGroupNumber )
731746
{
732-
( ( EventGroup_t * ) xEventGroup )->uxEventGroupNumber = uxEventGroupNumber;
747+
( ( EventGroup_t * ) xEventGroup )->uxEventGroupNumber = uxEventGroupNumber; /*lint !e9087 !e9079 EventGroupHandle_t is a pointer to an EventGroup_t, but EventGroupHandle_t is kept opaque outside of this file for data hiding purposes. */
733748
}
734749

735750
#endif /* configUSE_TRACE_FACILITY */

0 commit comments

Comments
 (0)