Skip to content

Commit 3f44440

Browse files
authored
Merge branch 'main' into atomic-msgbuf
2 parents 3222f6f + 086d52f commit 3f44440

File tree

14 files changed

+1460
-1337
lines changed

14 files changed

+1460
-1337
lines changed

.github/lexicon.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ prvinitialisenewstreambuffer
15291529
prvinitialisenewtimer
15301530
prvinsertblockintofreelist
15311531
prvlockqueue
1532+
prvnotifyqueuesetcontainer
15321533
prvportmalloc
15331534
prvportresetpic
15341535
prvprocesssimulatedinterrupts
@@ -1617,6 +1618,7 @@ pvowner
16171618
pvparameter
16181619
pvparameters
16191620
pvportmalloc
1621+
pvportmallocstack
16201622
pvportrealloc
16211623
pvreg
16221624
pvrxdata
@@ -1630,7 +1632,6 @@ pvyieldevent
16301632
pwdtc
16311633
pwm
16321634
pwmc
1633-
pxtaskcode
16341635
pxblock
16351636
pxblocktoinsert
16361637
pxcallbackfunction
@@ -1687,6 +1688,7 @@ pxprevious
16871688
pxpreviouswaketime
16881689
pxqueue
16891690
pxqueuebuffer
1691+
pxqueuesetcontainer
16901692
pxramstack
16911693
pxreadycoroutinelists
16921694
pxreadytaskslists
@@ -1706,6 +1708,7 @@ pxstreambuffercreatestatic
17061708
pxtagvalue
17071709
pxtask
17081710
pxtaskbuffer
1711+
pxtaskcode
17091712
pxtaskdefinition
17101713
pxtaskstatus
17111714
pxtaskstatusarray
@@ -2652,7 +2655,6 @@ wu
26522655
www
26532656
wwwfreertos
26542657
wxr
2655-
xtasktodelete
26562658
xa
26572659
xaa
26582660
xaaaa
@@ -3019,6 +3021,7 @@ xtaskswaitingforbits
30193021
xtaskswaitingtermination
30203022
xtaskswaitingtoreceive
30213023
xtaskswaitingtosend
3024+
xtasktodelete
30223025
xtasktonotify
30233026
xtasktoquery
30243027
xtasktoresume

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ jobs:
4444
- name: URL Checker
4545
run: |
4646
bash kernel/.github/actions/url_verifier.sh kernel
47+

.github/workflows/git-secrets.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: git-secrets Check
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
jobs:
7+
git-secrets:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
with:
12+
submodules: recursive
13+
- name: Checkout awslabs/git-secrets
14+
uses: actions/checkout@v2
15+
with:
16+
repository: awslabs/git-secrets
17+
ref: master
18+
path: git-secrets
19+
- name: Install git-secrets
20+
run: cd git-secrets && sudo make install && cd ..
21+
- name: Run git-secrets
22+
run: |
23+
git-secrets --register-aws
24+
git-secrets --scan

.github/workflows/unit-tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CMock Unit Tests
2+
on: [push]
3+
4+
jobs:
5+
run:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout Parent Repo
9+
uses: actions/checkout@v2
10+
with:
11+
ref: master
12+
repository: FreeRTOS/FreeRTOS
13+
submodules: 'recursive'
14+
fetch-depth: 1
15+
- name: Clone This Repo
16+
uses: actions/checkout@v2
17+
with:
18+
path: ./FreeRTOS/Source
19+
20+
- name: Setup Python
21+
uses: actions/setup-python@master
22+
with:
23+
python-version: 3.8
24+
25+
- name: Install packages
26+
run: |
27+
sudo apt-get install lcov cflow ruby doxygen build-essential
28+
- name: Run Unit Tests with ENABLE_SANITIZER=1
29+
run: |
30+
make -C FreeRTOS/Test/CMock clean
31+
make -C FreeRTOS/Test/CMock ENABLE_SANITIZER=1 run_col_formatted
32+
- name: Run Unit Tests for coverage
33+
run: |
34+
make -C FreeRTOS/Test/CMock clean
35+
make -C FreeRTOS/Test/CMock lcovhtml
36+
lcov --config-file FreeRTOS/Test/CMock/lcovrc --summary FreeRTOS/Test/CMock/build/cmock_test.info > FreeRTOS/Test/CMock/build/cmock_test_summary.txt
37+
- name: Upload coverage to Codecov
38+
uses: codecov/codecov-action@v1
39+
with:
40+
files: FreeRTOS/Test/CMock/build/cmock_test.info
41+
working-directory: .
42+
root_dir: FreeRTOS/Source
43+
flags: unittests
44+
fail_ci_if_error: false
45+
path_to_write_report: coverage/codecov_report.txt
46+
verbose: false
47+
- name: Archive code coverage data
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: coverage-data
51+
path: FreeRTOS/Test/CMock/build/cmock_test*
52+
- name: Archive code coverage html report
53+
uses: actions/upload-artifact@v2
54+
with:
55+
name: coverage-report
56+
path: FreeRTOS/Test/CMock/build/coverage

include/FreeRTOS.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,11 @@
896896
#define configSUPPORT_DYNAMIC_ALLOCATION 1
897897
#endif
898898

899+
#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP
900+
/* Defaults to 0 for backward compatibility. */
901+
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
902+
#endif
903+
899904
#ifndef configSTACK_DEPTH_TYPE
900905

901906
/* Defaults to uint16_t for backward compatibility, but can be overridden
@@ -1054,6 +1059,11 @@
10541059
#define configRUN_FREERTOS_SECURE_ONLY 0
10551060
#endif
10561061

1062+
#ifndef configRUN_ADDITIONAL_TESTS
1063+
#define configRUN_ADDITIONAL_TESTS 0
1064+
#endif
1065+
1066+
10571067
/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using
10581068
* dynamically allocated RAM, in which case when any task is deleted it is known
10591069
* that both the task's stack and TCB need to be freed. Sometimes the

include/mpu_wrappers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
/* This file redefines API functions to be called through a wrapper macro, but
3131
* only for ports that are using the MPU. */
32-
#ifdef portUSING_MPU_WRAPPERS
32+
#if ( portUSING_MPU_WRAPPERS == 1 )
3333

3434
/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
3535
* included from queue.c or task.c to prevent it from having an effect within

include/portable.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
179179
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
180180
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
181181

182+
#if( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 )
183+
void *pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION;
184+
void vPortFreeStack( void *pv ) PRIVILEGED_FUNCTION;
185+
#else
186+
#define pvPortMallocStack pvPortMalloc
187+
#define vPortFreeStack vPortFree
188+
#endif
189+
182190
/*
183191
* Setup the hardware ready for the scheduler to take control. This generally
184192
* sets up a tick interrupt and sets timers for the correct tick frequency.

include/task.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,8 +1795,10 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
17951795
* demo applications. Do not consider it to be part of the scheduler.
17961796
*
17971797
* vTaskList() calls uxTaskGetSystemState(), then formats part of the
1798-
* uxTaskGetSystemState() output into a human readable table that displays task
1799-
* names, states and stack usage.
1798+
* uxTaskGetSystemState() output into a human readable table that displays task:
1799+
* names, states, priority, stack usage and task number.
1800+
* Stack usage specified as the number of unused StackType_t words stack can hold
1801+
* on top of stack - not the number of bytes.
18001802
*
18011803
* vTaskList() has a dependency on the sprintf() C library function that might
18021804
* bloat the code size, use a lot of stack, and provide different results on
@@ -1932,9 +1934,8 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
19321934
* that way task notifications can be used to send data to a task, or be used as
19331935
* light weight and fast binary or counting semaphores.
19341936
*
1935-
* A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
1936-
* notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
1937-
* to wait for a notification value to have a non-zero value. The task does
1937+
* A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
1938+
* [optionally] block to wait for a notification to be pending. The task does
19381939
* not consume any CPU time while it is in the Blocked state.
19391940
*
19401941
* A notification sent to a task will remain pending until it is cleared by the
@@ -2520,8 +2521,8 @@ void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
25202521
* value acts like a counting semaphore.
25212522
*
25222523
* A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
2523-
* the task's notification value to be non-zero. The task does not consume any
2524-
* CPU time while it is in the Blocked state.
2524+
* a notification. The task does not consume any CPU time while it is in the
2525+
* Blocked state.
25252526
*
25262527
* Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
25272528
* ulTaskNotifyTakeIndexed() will return when the task's notification value is

list.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ void vListInsert( List_t * const pxList,
158158
* 4) Using a queue or semaphore before it has been initialised or
159159
* before the scheduler has been started (are interrupts firing
160160
* before vTaskStartScheduler() has been called?).
161+
* 5) If the FreeRTOS port supports interrupt nesting then ensure that
162+
* the priority of the tick interrupt is at or below
163+
* configMAX_SYSCALL_INTERRUPT_PRIORITY.
161164
**********************************************************************/
162165

163166
for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */

portable/GCC/ATMega323/portmacro.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* https://www.FreeRTOS.org
2323
* https://github.com/FreeRTOS
2424
*
25-
* 1 tab == 4 spaces!
2625
*/
2726

2827
/*
@@ -58,6 +57,8 @@ extern "C" {
5857
#define portSTACK_TYPE uint8_t
5958
#define portBASE_TYPE char
6059

60+
#define portPOINTER_SIZE_TYPE uint16_t
61+
6162
typedef portSTACK_TYPE StackType_t;
6263
typedef signed char BaseType_t;
6364
typedef unsigned char UBaseType_t;

portable/RVDS/ARM_CM7/r0p1/port.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@ __asm uint32_t vPortGetIPSR( void )
762762
* be set to a value equal to or numerically *higher* than
763763
* configMAX_SYSCALL_INTERRUPT_PRIORITY.
764764
*
765-
* Interrupts that use the FreeRTOS API must not be left at their
766-
* default priority of zero as that is the highest possible priority,
765+
* Interrupts that use the FreeRTOS API must not be left at their
766+
* default priority of zero as that is the highest possible priority,
767767
* which is guaranteed to be above configMAX_SYSCALL_INTERRUPT_PRIORITY,
768-
* and therefore also guaranteed to be invalid.
768+
* and therefore also guaranteed to be invalid.
769769
*
770770
* FreeRTOS maintains separate thread and ISR API functions to ensure
771771
* interrupt entry is as fast and simple as possible.

queue.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
342342
* variable of type StaticQueue_t or StaticSemaphore_t equals the size of
343343
* the real queue and semaphore structures. */
344344
volatile size_t xSize = sizeof( StaticQueue_t );
345-
configASSERT( xSize == sizeof( Queue_t ) );
346-
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
345+
346+
/* This assertion cannot be branch covered in unit tests */
347+
configASSERT( xSize == sizeof( Queue_t ) ); /* LCOV_EXCL_BR_LINE */
348+
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
347349
}
348350
#endif /* configASSERT_DEFINED */
349351

@@ -398,7 +400,7 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
398400
configASSERT( ( uxItemSize == 0 ) || ( uxQueueLength == ( xQueueSizeInBytes / uxItemSize ) ) );
399401

400402
/* Check for addition overflow. */
401-
configASSERT( ( sizeof( Queue_t ) + xQueueSizeInBytes ) > xQueueSizeInBytes );
403+
configASSERT( ( sizeof( Queue_t ) + xQueueSizeInBytes ) > xQueueSizeInBytes );
402404

403405
/* Allocate the queue and storage area. Justification for MISRA
404406
* deviation as follows: pvPortMalloc() always ensures returned memory
@@ -561,6 +563,8 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,
561563
TaskHandle_t pxReturn;
562564
Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore;
563565

566+
configASSERT( xSemaphore );
567+
564568
/* This function is called by xSemaphoreGetMutexHolder(), and should not
565569
* be called directly. Note: This is a good way of determining if the
566570
* calling task is the mutex holder, but not a good way of determining the
@@ -944,15 +948,15 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
944948
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
945949

946950
/* Unlocking the queue means queue events can effect the
947-
* event list. It is possible that interrupts occurring now
951+
* event list. It is possible that interrupts occurring now
948952
* remove this task from the event list again - but as the
949953
* scheduler is suspended the task will go onto the pending
950-
* ready last instead of the actual ready list. */
954+
* ready list instead of the actual ready list. */
951955
prvUnlockQueue( pxQueue );
952956

953957
/* Resuming the scheduler will move tasks from the pending
954958
* ready list into the ready list - so it is feasible that this
955-
* task is already in a ready list before it yields - in which
959+
* task is already in the ready list before it yields - in which
956960
* case the yield will not cause a context switch unless there
957961
* is also a higher priority task in the pending ready list. */
958962
if( xTaskResumeAll() == pdFALSE )
@@ -1774,7 +1778,7 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue,
17741778
taskEXIT_CRITICAL();
17751779

17761780
/* Interrupts and other tasks can send to and receive from the queue
1777-
* now the critical section has been exited. */
1781+
* now that the critical section has been exited. */
17781782

17791783
vTaskSuspendAll();
17801784
prvLockQueue( pxQueue );
@@ -2723,6 +2727,9 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
27232727
{
27242728
UBaseType_t ux;
27252729

2730+
configASSERT( xQueue );
2731+
configASSERT( pcQueueName );
2732+
27262733
/* See if there is an empty space in the registry. A NULL name denotes
27272734
* a free slot. */
27282735
for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )
@@ -2753,6 +2760,8 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
27532760
UBaseType_t ux;
27542761
const char * pcReturn = NULL; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
27552762

2763+
configASSERT( xQueue );
2764+
27562765
/* Note there is nothing here to protect against another task adding or
27572766
* removing entries from the registry while it is being searched. */
27582767

@@ -2781,6 +2790,8 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
27812790
{
27822791
UBaseType_t ux;
27832792

2793+
configASSERT( xQueue );
2794+
27842795
/* See if the handle of the queue being unregistered in actually in the
27852796
* registry. */
27862797
for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )
@@ -2967,7 +2978,10 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
29672978

29682979
/* This function must be called form a critical section. */
29692980

2970-
configASSERT( pxQueueSetContainer );
2981+
/* The following line is not reachable in unit tests because every call
2982+
* to prvNotifyQueueSetContainer is preceded by a check that
2983+
* pxQueueSetContainer != NULL */
2984+
configASSERT( pxQueueSetContainer ); /* LCOV_EXCL_BR_LINE */
29712985
configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength );
29722986

29732987
if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )

0 commit comments

Comments
 (0)