Skip to content

Commit 1cb8042

Browse files
authored
Update MPU prototypes (FreeRTOS#1150)
Add missing MPU prototypes This commit address the following issues with MPU prototypes: 1. Fix the decorator according to which MPU wrapper is used. 2. Add the missing prototypes for v1. 3. Add the corresponding mapping to mpu_wrappers.h. 4. Update MPU v1 wrappers for vTaskList and vTaskGetRunTimeStats. This was reported here - https://forums.freertos.org/t/cortex-m55-and-16-region-mpu-support/21470/5. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent de7c014 commit 1cb8042

File tree

3 files changed

+180
-66
lines changed

3 files changed

+180
-66
lines changed

include/mpu_prototypes.h

Lines changed: 156 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,59 @@ BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL;
136136
/* Privileged only wrappers for Task APIs. These are needed so that
137137
* the application can use opaque handles maintained in mpu_wrappers.c
138138
* with all the APIs. */
139-
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
140-
const char * const pcName,
141-
const configSTACK_DEPTH_TYPE uxStackDepth,
142-
void * const pvParameters,
143-
UBaseType_t uxPriority,
144-
TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
145-
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
146-
const char * const pcName,
147-
const configSTACK_DEPTH_TYPE uxStackDepth,
148-
void * const pvParameters,
149-
UBaseType_t uxPriority,
150-
StackType_t * const puxStackBuffer,
151-
StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
152-
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
153-
void MPU_vTaskPrioritySet( TaskHandle_t xTask,
154-
UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
155-
TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
156-
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
157-
void * pvParameter ) PRIVILEGED_FUNCTION;
139+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
140+
141+
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
142+
const char * const pcName,
143+
const configSTACK_DEPTH_TYPE uxStackDepth,
144+
void * const pvParameters,
145+
UBaseType_t uxPriority,
146+
TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL;
147+
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
148+
const char * const pcName,
149+
const configSTACK_DEPTH_TYPE uxStackDepth,
150+
void * const pvParameters,
151+
UBaseType_t uxPriority,
152+
StackType_t * const puxStackBuffer,
153+
StaticTask_t * const pxTaskBuffer ) FREERTOS_SYSTEM_CALL;
154+
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL;
155+
void MPU_vTaskPrioritySet( TaskHandle_t xTask,
156+
UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL;
157+
TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) FREERTOS_SYSTEM_CALL;
158+
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
159+
void * pvParameter ) FREERTOS_SYSTEM_CALL;
160+
void MPU_vTaskGetRunTimeStatistics( char * pcWriteBuffer,
161+
size_t uxBufferLength ) FREERTOS_SYSTEM_CALL;
162+
void MPU_vTaskListTasks( char * pcWriteBuffer,
163+
size_t uxBufferLength ) FREERTOS_SYSTEM_CALL;
164+
void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL;
165+
BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL;
166+
BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL;
167+
168+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
169+
170+
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
171+
const char * const pcName,
172+
const configSTACK_DEPTH_TYPE uxStackDepth,
173+
void * const pvParameters,
174+
UBaseType_t uxPriority,
175+
TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
176+
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
177+
const char * const pcName,
178+
const configSTACK_DEPTH_TYPE uxStackDepth,
179+
void * const pvParameters,
180+
UBaseType_t uxPriority,
181+
StackType_t * const puxStackBuffer,
182+
StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
183+
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
184+
void MPU_vTaskPrioritySet( TaskHandle_t xTask,
185+
UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
186+
TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
187+
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
188+
void * pvParameter ) PRIVILEGED_FUNCTION;
189+
190+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
191+
158192
char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
159193
BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
160194
TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
@@ -215,28 +249,58 @@ uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
215249
/* Privileged only wrappers for Queue APIs. These are needed so that
216250
* the application can use opaque handles maintained in mpu_wrappers.c
217251
* with all the APIs. */
218-
void MPU_vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
219-
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
220-
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
221-
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
222-
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
223-
const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
224-
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
225-
const UBaseType_t uxInitialCount,
226-
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
227-
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
228-
const UBaseType_t uxItemSize,
229-
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
230-
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
231-
const UBaseType_t uxItemSize,
232-
uint8_t * pucQueueStorage,
233-
StaticQueue_t * pxStaticQueue,
234-
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
235-
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
236-
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
237-
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
238-
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
239-
BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
252+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
253+
254+
void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
255+
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
256+
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
257+
StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
258+
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
259+
const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL;
260+
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
261+
const UBaseType_t uxInitialCount,
262+
StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
263+
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
264+
const UBaseType_t uxItemSize,
265+
const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
266+
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
267+
const UBaseType_t uxItemSize,
268+
uint8_t * pucQueueStorage,
269+
StaticQueue_t * pxStaticQueue,
270+
const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
271+
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL;
272+
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
273+
QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL;
274+
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
275+
BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL;
276+
277+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
278+
279+
void MPU_vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
280+
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
281+
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
282+
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
283+
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
284+
const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
285+
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
286+
const UBaseType_t uxInitialCount,
287+
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
288+
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
289+
const UBaseType_t uxItemSize,
290+
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
291+
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
292+
const UBaseType_t uxItemSize,
293+
uint8_t * pucQueueStorage,
294+
StaticQueue_t * pxStaticQueue,
295+
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
296+
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
297+
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
298+
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
299+
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
300+
BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
301+
302+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
303+
240304
BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
241305
uint8_t ** ppucQueueStorage,
242306
StaticQueue_t ** ppxStaticQueue ) PRIVILEGED_FUNCTION;
@@ -318,14 +382,25 @@ EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
318382
UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL;
319383
void MPU_vEventGroupSetNumber( void * xEventGroup,
320384
UBaseType_t uxEventGroupNumber ) FREERTOS_SYSTEM_CALL;
321-
#endif /* ( configUSE_TRACE_FACILITY == 1 )*/
385+
#endif /* #if ( configUSE_TRACE_FACILITY == 1 ) */
322386

323387
/* Privileged only wrappers for Event Group APIs. These are needed so that
324388
* the application can use opaque handles maintained in mpu_wrappers.c
325389
* with all the APIs. */
326-
EventGroupHandle_t MPU_xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
327-
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
328-
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
390+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
391+
392+
EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL;
393+
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL;
394+
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL;
395+
396+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
397+
398+
EventGroupHandle_t MPU_xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
399+
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
400+
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
401+
402+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
403+
329404
BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
330405
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
331406
BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
@@ -355,20 +430,42 @@ size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuff
355430
/* Privileged only wrappers for Stream Buffer APIs. These are needed so that
356431
* the application can use opaque handles maintained in mpu_wrappers.c
357432
* with all the APIs. */
358-
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
359-
size_t xTriggerLevelBytes,
360-
BaseType_t xStreamBufferType,
361-
StreamBufferCallbackFunction_t pxSendCompletedCallback,
362-
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
363-
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
364-
size_t xTriggerLevelBytes,
365-
BaseType_t xStreamBufferType,
366-
uint8_t * const pucStreamBufferStorageArea,
367-
StaticStreamBuffer_t * const pxStaticStreamBuffer,
368-
StreamBufferCallbackFunction_t pxSendCompletedCallback,
369-
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
370-
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
371-
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
433+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
434+
435+
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
436+
size_t xTriggerLevelBytes,
437+
BaseType_t xStreamBufferType,
438+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
439+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
440+
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
441+
size_t xTriggerLevelBytes,
442+
BaseType_t xStreamBufferType,
443+
uint8_t * const pucStreamBufferStorageArea,
444+
StaticStreamBuffer_t * const pxStaticStreamBuffer,
445+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
446+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
447+
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
448+
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
449+
450+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
451+
452+
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
453+
size_t xTriggerLevelBytes,
454+
BaseType_t xStreamBufferType,
455+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
456+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
457+
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
458+
size_t xTriggerLevelBytes,
459+
BaseType_t xStreamBufferType,
460+
uint8_t * const pucStreamBufferStorageArea,
461+
StaticStreamBuffer_t * const pxStaticStreamBuffer,
462+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
463+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
464+
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
465+
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
466+
467+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
468+
372469
BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
373470
uint8_t * ppucStreamBufferStorageArea,
374471
StaticStreamBuffer_t * ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;

include/mpu_wrappers.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@
8585
/* Privileged only wrappers for Task APIs. These are needed so that
8686
* the application can use opaque handles maintained in mpu_wrappers.c
8787
* with all the APIs. */
88+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
89+
90+
/* These are not needed in v2 because they do not take a task
91+
* handle and therefore, no lookup is needed. Needed in v1 because
92+
* these are available as system calls in v1. */
93+
#define vTaskGetRunTimeStatistics MPU_vTaskGetRunTimeStatistics
94+
#define vTaskListTasks MPU_vTaskListTasks
95+
#define vTaskSuspendAll MPU_vTaskSuspendAll
96+
#define xTaskCatchUpTicks MPU_xTaskCatchUpTicks
97+
#define xTaskResumeAll MPU_xTaskResumeAll
98+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
99+
88100
#define xTaskCreate MPU_xTaskCreate
89101
#define xTaskCreateStatic MPU_xTaskCreateStatic
90102
#define vTaskDelete MPU_vTaskDelete
@@ -165,11 +177,14 @@
165177
#define xTimerGetPeriod MPU_xTimerGetPeriod
166178
#define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
167179

180+
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
181+
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
182+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
183+
168184
/* Privileged only wrappers for Timer APIs. These are needed so that
169185
* the application can use opaque handles maintained in mpu_wrappers.c
170186
* with all the APIs. */
171187
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
172-
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
173188
#define xTimerCreate MPU_xTimerCreate
174189
#define xTimerCreateStatic MPU_xTimerCreateStatic
175190
#define xTimerGetStaticBuffer MPU_xTimerGetStaticBuffer

0 commit comments

Comments
 (0)