Skip to content

Commit 69510fe

Browse files
committed
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. 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 c0bfbb9 commit 69510fe

File tree

2 files changed

+169
-60
lines changed

2 files changed

+169
-60
lines changed

include/mpu_prototypes.h

Lines changed: 154 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,57 @@ 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_vTaskGetRunTimeStats( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL;
161+
void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL;
162+
void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL;
163+
BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL;
164+
BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL;
165+
166+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
167+
168+
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
169+
const char * const pcName,
170+
const configSTACK_DEPTH_TYPE uxStackDepth,
171+
void * const pvParameters,
172+
UBaseType_t uxPriority,
173+
TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
174+
TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
175+
const char * const pcName,
176+
const configSTACK_DEPTH_TYPE uxStackDepth,
177+
void * const pvParameters,
178+
UBaseType_t uxPriority,
179+
StackType_t * const puxStackBuffer,
180+
StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
181+
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
182+
void MPU_vTaskPrioritySet( TaskHandle_t xTask,
183+
UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
184+
TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
185+
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
186+
void * pvParameter ) PRIVILEGED_FUNCTION;
187+
188+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
189+
158190
char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
159191
BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
160192
TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
@@ -215,28 +247,58 @@ uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
215247
/* Privileged only wrappers for Queue APIs. These are needed so that
216248
* the application can use opaque handles maintained in mpu_wrappers.c
217249
* 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;
250+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
251+
252+
void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
253+
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
254+
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
255+
StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
256+
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
257+
const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL;
258+
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
259+
const UBaseType_t uxInitialCount,
260+
StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
261+
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
262+
const UBaseType_t uxItemSize,
263+
const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
264+
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
265+
const UBaseType_t uxItemSize,
266+
uint8_t * pucQueueStorage,
267+
StaticQueue_t * pxStaticQueue,
268+
const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
269+
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL;
270+
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
271+
QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL;
272+
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
273+
BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL;
274+
275+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
276+
277+
void MPU_vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
278+
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
279+
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
280+
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
281+
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
282+
const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
283+
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
284+
const UBaseType_t uxInitialCount,
285+
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
286+
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
287+
const UBaseType_t uxItemSize,
288+
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
289+
QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
290+
const UBaseType_t uxItemSize,
291+
uint8_t * pucQueueStorage,
292+
StaticQueue_t * pxStaticQueue,
293+
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
294+
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
295+
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
296+
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
297+
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
298+
BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
299+
300+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
301+
240302
BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
241303
uint8_t ** ppucQueueStorage,
242304
StaticQueue_t ** ppxStaticQueue ) PRIVILEGED_FUNCTION;
@@ -318,14 +380,25 @@ EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
318380
UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL;
319381
void MPU_vEventGroupSetNumber( void * xEventGroup,
320382
UBaseType_t uxEventGroupNumber ) FREERTOS_SYSTEM_CALL;
321-
#endif /* ( configUSE_TRACE_FACILITY == 1 )*/
383+
#endif /* #if ( configUSE_TRACE_FACILITY == 1 ) */
322384

323385
/* Privileged only wrappers for Event Group APIs. These are needed so that
324386
* the application can use opaque handles maintained in mpu_wrappers.c
325387
* 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;
388+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
389+
390+
EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL;
391+
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL;
392+
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL;
393+
394+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
395+
396+
EventGroupHandle_t MPU_xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
397+
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
398+
void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
399+
400+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
401+
329402
BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
330403
StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
331404
BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
@@ -355,20 +428,42 @@ size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuff
355428
/* Privileged only wrappers for Stream Buffer APIs. These are needed so that
356429
* the application can use opaque handles maintained in mpu_wrappers.c
357430
* 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;
431+
#if ( configUSE_MPU_WRAPPERS_V1 == 1 )
432+
433+
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
434+
size_t xTriggerLevelBytes,
435+
BaseType_t xStreamBufferType,
436+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
437+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
438+
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
439+
size_t xTriggerLevelBytes,
440+
BaseType_t xStreamBufferType,
441+
uint8_t * const pucStreamBufferStorageArea,
442+
StaticStreamBuffer_t * const pxStaticStreamBuffer,
443+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
444+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
445+
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
446+
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
447+
448+
#else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
449+
450+
StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
451+
size_t xTriggerLevelBytes,
452+
BaseType_t xStreamBufferType,
453+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
454+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
455+
StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
456+
size_t xTriggerLevelBytes,
457+
BaseType_t xStreamBufferType,
458+
uint8_t * const pucStreamBufferStorageArea,
459+
StaticStreamBuffer_t * const pxStaticStreamBuffer,
460+
StreamBufferCallbackFunction_t pxSendCompletedCallback,
461+
StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
462+
void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
463+
BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
464+
465+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
466+
372467
BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
373468
uint8_t * ppucStreamBufferStorageArea,
374469
StaticStreamBuffer_t * ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;

include/mpu_wrappers.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@
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+
/* These are not needed in v2 because they do not take a task
90+
* handle and therefore, no lookup is needed. Needed in v1 because
91+
* these are available as system calls in v1. */
92+
#define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
93+
#define vTaskList MPU_vTaskList
94+
#define vTaskSuspendAll MPU_vTaskSuspendAll
95+
#define xTaskCatchUpTicks MPU_xTaskCatchUpTicks
96+
#define xTaskResumeAll MPU_xTaskResumeAll
97+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
98+
8899
#define xTaskCreate MPU_xTaskCreate
89100
#define xTaskCreateStatic MPU_xTaskCreateStatic
90101
#define vTaskDelete MPU_vTaskDelete
@@ -165,11 +176,14 @@
165176
#define xTimerGetPeriod MPU_xTimerGetPeriod
166177
#define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
167178

179+
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
180+
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
181+
#endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
182+
168183
/* Privileged only wrappers for Timer APIs. These are needed so that
169184
* the application can use opaque handles maintained in mpu_wrappers.c
170185
* with all the APIs. */
171186
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
172-
#define xTimerGetReloadMode MPU_xTimerGetReloadMode
173187
#define xTimerCreate MPU_xTimerCreate
174188
#define xTimerCreateStatic MPU_xTimerCreateStatic
175189
#define xTimerGetStaticBuffer MPU_xTimerGetStaticBuffer

0 commit comments

Comments
 (0)