Skip to content

Commit 9bfd85a

Browse files
authored
Update system call entry mechanism (#896)
Earlier the System Call entry from an unprivileged task looked like: 1. SVC for entering system call. 2. System call implementation. 3. SVC for exiting system call. Now, the system call entry needs to make only one system call and everything else is handled internally. This PR also makes the following small changes: 1. Add one struct param for system calls with 5 parameters. This removes the need for special handling for system calls with 5 parameters. 2. Remove raise privilege SVC when MPU wrapper v2 is used. 3. Add additional run time parameter checks to MPU wrappers for xTaskGenericNotify and xQueueTakeMutexRecursive APIs. These changes are tested on the following platforms: 1. STM32H743ZI (Cortex-M7) 2. STM32L152RE (Cortex-M3) 3. Nuvoton M2351 (Cortex-M23) 4. NXP LPC55S69 (Cortex-M33)
1 parent 52c1c6e commit 9bfd85a

File tree

115 files changed

+50432
-58968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+50432
-58968
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout Parent Repository
99
uses: actions/checkout@v2
1010
with:
11-
ref: main
11+
ref: 80db00d98bfac8b22289a2668d9e6b0265946d24
1212
repository: FreeRTOS/FreeRTOS
1313
submodules: 'recursive'
1414
fetch-depth: 1

include/mpu_prototypes.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@
3838
#ifndef MPU_PROTOTYPES_H
3939
#define MPU_PROTOTYPES_H
4040

41+
typedef struct xTaskGenericNotifyParams
42+
{
43+
TaskHandle_t xTaskToNotify;
44+
UBaseType_t uxIndexToNotify;
45+
uint32_t ulValue;
46+
eNotifyAction eAction;
47+
uint32_t * pulPreviousNotificationValue;
48+
} xTaskGenericNotifyParams_t;
49+
50+
typedef struct xTaskGenericNotifyWaitParams
51+
{
52+
UBaseType_t uxIndexToWaitOn;
53+
uint32_t ulBitsToClearOnEntry;
54+
uint32_t ulBitsToClearOnExit;
55+
uint32_t * pulNotificationValue;
56+
TickType_t xTicksToWait;
57+
} xTaskGenericNotifyWaitParams_t;
58+
59+
typedef struct xTimerGenericCommandParams
60+
{
61+
TimerHandle_t xTimer;
62+
BaseType_t xCommandID;
63+
TickType_t xOptionalValue;
64+
BaseType_t * pxHigherPriorityTaskWoken;
65+
TickType_t xTicksToWait;
66+
} xTimerGenericCommandParams_t;
67+
68+
typedef struct xEventGroupWaitBitsParams
69+
{
70+
EventGroupHandle_t xEventGroup;
71+
EventBits_t uxBitsToWaitFor;
72+
BaseType_t xClearOnExit;
73+
BaseType_t xWaitForAllBits;
74+
TickType_t xTicksToWait;
75+
} xEventGroupWaitBitsParams_t;
76+
4177
/* MPU versions of task.h API functions. */
4278
void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL;
4379
BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
@@ -77,11 +113,13 @@ BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
77113
uint32_t ulValue,
78114
eNotifyAction eAction,
79115
uint32_t * pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL;
116+
BaseType_t MPU_xTaskGenericNotifyEntry( const xTaskGenericNotifyParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
80117
BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
81118
uint32_t ulBitsToClearOnEntry,
82119
uint32_t ulBitsToClearOnExit,
83120
uint32_t * pulNotificationValue,
84121
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
122+
BaseType_t MPU_xTaskGenericNotifyWaitEntry( const xTaskGenericNotifyWaitParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
85123
uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
86124
BaseType_t xClearCountOnExit,
87125
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
@@ -228,9 +266,10 @@ BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer,
228266
const TickType_t xOptionalValue,
229267
BaseType_t * const pxHigherPriorityTaskWoken,
230268
const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
269+
BaseType_t MPU_xTimerGenericCommandEntry( const xTimerGenericCommandParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
231270
const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
232271
void MPU_vTimerSetReloadMode( TimerHandle_t xTimer,
233-
const UBaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL;
272+
const BaseType_t uxAutoReload ) FREERTOS_SYSTEM_CALL;
234273
BaseType_t MPU_xTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
235274
UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
236275
TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
@@ -259,6 +298,7 @@ EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
259298
const BaseType_t xClearOnExit,
260299
const BaseType_t xWaitForAllBits,
261300
TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
301+
EventBits_t MPU_xEventGroupWaitBitsEntry( const xEventGroupWaitBitsParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
262302
EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup,
263303
const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL;
264304
EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup,

include/mpu_syscall_numbers.h

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* FreeRTOS Kernel V10.6.1
3+
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
*
5+
* SPDX-License-Identifier: MIT
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
* this software and associated documentation files (the "Software"), to deal in
9+
* the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
* the Software, and to permit persons to whom the Software is furnished to do so,
12+
* subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* https://www.FreeRTOS.org
25+
* https://github.com/FreeRTOS
26+
*
27+
*/
28+
29+
#ifndef MPU_SYSCALL_NUMBERS_H
30+
#define MPU_SYSCALL_NUMBERS_H
31+
32+
/* Numbers assigned to various system calls. */
33+
#define SYSTEM_CALL_xTaskGenericNotify 0
34+
#define SYSTEM_CALL_xTaskGenericNotifyWait 1
35+
#define SYSTEM_CALL_xTimerGenericCommand 2
36+
#define SYSTEM_CALL_xEventGroupWaitBits 3
37+
#define SYSTEM_CALL_xTaskDelayUntil 4
38+
#define SYSTEM_CALL_xTaskAbortDelay 5
39+
#define SYSTEM_CALL_vTaskDelay 6
40+
#define SYSTEM_CALL_uxTaskPriorityGet 7
41+
#define SYSTEM_CALL_eTaskGetState 8
42+
#define SYSTEM_CALL_vTaskGetInfo 9
43+
#define SYSTEM_CALL_xTaskGetIdleTaskHandle 10
44+
#define SYSTEM_CALL_vTaskSuspend 11
45+
#define SYSTEM_CALL_vTaskResume 12
46+
#define SYSTEM_CALL_xTaskGetTickCount 13
47+
#define SYSTEM_CALL_uxTaskGetNumberOfTasks 14
48+
#define SYSTEM_CALL_pcTaskGetName 15
49+
#define SYSTEM_CALL_ulTaskGetRunTimeCounter 16
50+
#define SYSTEM_CALL_ulTaskGetRunTimePercent 17
51+
#define SYSTEM_CALL_ulTaskGetIdleRunTimePercent 18
52+
#define SYSTEM_CALL_ulTaskGetIdleRunTimeCounter 19
53+
#define SYSTEM_CALL_vTaskSetApplicationTaskTag 20
54+
#define SYSTEM_CALL_xTaskGetApplicationTaskTag 21
55+
#define SYSTEM_CALL_vTaskSetThreadLocalStoragePointer 22
56+
#define SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer 23
57+
#define SYSTEM_CALL_uxTaskGetSystemState 24
58+
#define SYSTEM_CALL_uxTaskGetStackHighWaterMark 25
59+
#define SYSTEM_CALL_uxTaskGetStackHighWaterMark2 26
60+
#define SYSTEM_CALL_xTaskGetCurrentTaskHandle 27
61+
#define SYSTEM_CALL_xTaskGetSchedulerState 28
62+
#define SYSTEM_CALL_vTaskSetTimeOutState 29
63+
#define SYSTEM_CALL_xTaskCheckForTimeOut 30
64+
#define SYSTEM_CALL_ulTaskGenericNotifyTake 31
65+
#define SYSTEM_CALL_xTaskGenericNotifyStateClear 32
66+
#define SYSTEM_CALL_ulTaskGenericNotifyValueClear 33
67+
#define SYSTEM_CALL_xQueueGenericSend 34
68+
#define SYSTEM_CALL_uxQueueMessagesWaiting 35
69+
#define SYSTEM_CALL_uxQueueSpacesAvailable 36
70+
#define SYSTEM_CALL_xQueueReceive 37
71+
#define SYSTEM_CALL_xQueuePeek 38
72+
#define SYSTEM_CALL_xQueueSemaphoreTake 39
73+
#define SYSTEM_CALL_xQueueGetMutexHolder 40
74+
#define SYSTEM_CALL_xQueueTakeMutexRecursive 41
75+
#define SYSTEM_CALL_xQueueGiveMutexRecursive 42
76+
#define SYSTEM_CALL_xQueueSelectFromSet 43
77+
#define SYSTEM_CALL_xQueueAddToSet 44
78+
#define SYSTEM_CALL_vQueueAddToRegistry 45
79+
#define SYSTEM_CALL_vQueueUnregisterQueue 46
80+
#define SYSTEM_CALL_pcQueueGetName 47
81+
#define SYSTEM_CALL_pvTimerGetTimerID 48
82+
#define SYSTEM_CALL_vTimerSetTimerID 49
83+
#define SYSTEM_CALL_xTimerIsTimerActive 50
84+
#define SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle 51
85+
#define SYSTEM_CALL_pcTimerGetName 52
86+
#define SYSTEM_CALL_vTimerSetReloadMode 53
87+
#define SYSTEM_CALL_xTimerGetReloadMode 54
88+
#define SYSTEM_CALL_uxTimerGetReloadMode 55
89+
#define SYSTEM_CALL_xTimerGetPeriod 56
90+
#define SYSTEM_CALL_xTimerGetExpiryTime 57
91+
#define SYSTEM_CALL_xEventGroupClearBits 58
92+
#define SYSTEM_CALL_xEventGroupSetBits 59
93+
#define SYSTEM_CALL_xEventGroupSync 60
94+
#define SYSTEM_CALL_uxEventGroupGetNumber 61
95+
#define SYSTEM_CALL_vEventGroupSetNumber 62
96+
#define SYSTEM_CALL_xStreamBufferSend 63
97+
#define SYSTEM_CALL_xStreamBufferReceive 64
98+
#define SYSTEM_CALL_xStreamBufferIsFull 65
99+
#define SYSTEM_CALL_xStreamBufferIsEmpty 66
100+
#define SYSTEM_CALL_xStreamBufferSpacesAvailable 67
101+
#define SYSTEM_CALL_xStreamBufferBytesAvailable 68
102+
#define SYSTEM_CALL_xStreamBufferSetTriggerLevel 69
103+
#define SYSTEM_CALL_xStreamBufferNextMessageLengthBytes 70
104+
#define NUM_SYSTEM_CALLS 71 /* Total number of system calls. */
105+
106+
#endif /* MPU_SYSCALL_NUMBERS_H */

0 commit comments

Comments
 (0)