Labor04
mpu_wrappers.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Kernel V10.0.0
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software. If you wish to use our Amazon
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * http://www.FreeRTOS.org
24  * http://aws.amazon.com/freertos
25  *
26  * 1 tab == 4 spaces!
27  */
28 
29 #ifndef MPU_WRAPPERS_H
30 #define MPU_WRAPPERS_H
31 
32 /* This file redefines API functions to be called through a wrapper macro, but
33 only for ports that are using the MPU. */
34 #ifdef portUSING_MPU_WRAPPERS
35 
36 /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
37 included from queue.c or task.c to prevent it from having an effect within
38 those files. */
39 #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
40 
41 /*
42  * Map standard (non MPU) API functions to equivalents that start
43  * "MPU_". This will cause the application code to call the MPU_
44  * version, which wraps the non-MPU version with privilege promoting
45  * then demoting code, so the kernel code always runs will full
46  * privileges.
47  */
48 
49 /* Map standard tasks.h API functions to the MPU equivalents. */
50 #define xTaskCreate MPU_xTaskCreate
51 #define xTaskCreateStatic MPU_xTaskCreateStatic
52 #define xTaskCreateRestricted MPU_xTaskCreateRestricted
53 #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
54 #define vTaskDelete MPU_vTaskDelete
55 #define vTaskDelay MPU_vTaskDelay
56 #define vTaskDelayUntil MPU_vTaskDelayUntil
57 #define xTaskAbortDelay MPU_xTaskAbortDelay
58 #define uxTaskPriorityGet MPU_uxTaskPriorityGet
59 #define eTaskGetState MPU_eTaskGetState
60 #define vTaskGetInfo MPU_vTaskGetInfo
61 #define vTaskPrioritySet MPU_vTaskPrioritySet
62 #define vTaskSuspend MPU_vTaskSuspend
63 #define vTaskResume MPU_vTaskResume
64 #define vTaskSuspendAll MPU_vTaskSuspendAll
65 #define xTaskResumeAll MPU_xTaskResumeAll
66 #define xTaskGetTickCount MPU_xTaskGetTickCount
67 #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
68 #define pcTaskGetName MPU_pcTaskGetName
69 #define xTaskGetHandle MPU_xTaskGetHandle
70 #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
71 #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
72 #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
73 #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
74 #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
75 #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
76 #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
77 #define uxTaskGetSystemState MPU_uxTaskGetSystemState
78 #define vTaskList MPU_vTaskList
79 #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
80 #define xTaskGenericNotify MPU_xTaskGenericNotify
81 #define xTaskNotifyWait MPU_xTaskNotifyWait
82 #define ulTaskNotifyTake MPU_ulTaskNotifyTake
83 #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear
84 
85 #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
86 #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
87 #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
88 #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
89 
90 /* Map standard queue.h API functions to the MPU equivalents. */
91 #define xQueueGenericSend MPU_xQueueGenericSend
92 #define xQueueReceive MPU_xQueueReceive
93 #define xQueuePeek MPU_xQueuePeek
94 #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake
95 #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
96 #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
97 #define vQueueDelete MPU_vQueueDelete
98 #define xQueueCreateMutex MPU_xQueueCreateMutex
99 #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
100 #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
101 #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
102 #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
103 #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
104 #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
105 #define xQueueGenericCreate MPU_xQueueGenericCreate
106 #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
107 #define xQueueCreateSet MPU_xQueueCreateSet
108 #define xQueueAddToSet MPU_xQueueAddToSet
109 #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
110 #define xQueueSelectFromSet MPU_xQueueSelectFromSet
111 #define xQueueGenericReset MPU_xQueueGenericReset
112 
113 #if( configQUEUE_REGISTRY_SIZE > 0 )
114 #define vQueueAddToRegistry MPU_vQueueAddToRegistry
115 #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
116 #define pcQueueGetName MPU_pcQueueGetName
117 #endif
118 
119 /* Map standard timer.h API functions to the MPU equivalents. */
120 #define xTimerCreate MPU_xTimerCreate
121 #define xTimerCreateStatic MPU_xTimerCreateStatic
122 #define pvTimerGetTimerID MPU_pvTimerGetTimerID
123 #define vTimerSetTimerID MPU_vTimerSetTimerID
124 #define xTimerIsTimerActive MPU_xTimerIsTimerActive
125 #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
126 #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall
127 #define pcTimerGetName MPU_pcTimerGetName
128 #define xTimerGetPeriod MPU_xTimerGetPeriod
129 #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
130 #define xTimerGenericCommand MPU_xTimerGenericCommand
131 
132 /* Map standard event_group.h API functions to the MPU equivalents. */
133 #define xEventGroupCreate MPU_xEventGroupCreate
134 #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
135 #define xEventGroupWaitBits MPU_xEventGroupWaitBits
136 #define xEventGroupClearBits MPU_xEventGroupClearBits
137 #define xEventGroupSetBits MPU_xEventGroupSetBits
138 #define xEventGroupSync MPU_xEventGroupSync
139 #define vEventGroupDelete MPU_vEventGroupDelete
140 
141 /* Map standard message/stream_buffer.h API functions to the MPU
142 equivalents. */
143 #define xStreamBufferSend MPU_xStreamBufferSend
144 #define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR
145 #define xStreamBufferReceive MPU_xStreamBufferReceive
146 #define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR
147 #define vStreamBufferDelete MPU_vStreamBufferDelete
148 #define xStreamBufferIsFull MPU_xStreamBufferIsFull
149 #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty
150 #define xStreamBufferReset MPU_xStreamBufferReset
151 #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable
152 #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable
153 #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel
154 #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate
155 #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
156 
157 
158 /* Remove the privileged function macro, but keep the PRIVILEGED_DATA
159 macro so applications can place data in privileged access sections
160 (useful when using statically allocated objects). */
161 #define PRIVILEGED_FUNCTION
162 #define PRIVILEGED_DATA __attribute__((section("privileged_data")))
163 
164 #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
165 
166 /* Ensure API functions go in the privileged execution section. */
167 #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))
168 #define PRIVILEGED_DATA __attribute__((section("privileged_data")))
169 
170 #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
171 
172 #else /* portUSING_MPU_WRAPPERS */
173 
174 #define PRIVILEGED_FUNCTION
175 #define PRIVILEGED_DATA
176 #define portUSING_MPU_WRAPPERS 0
177 
178 #endif /* portUSING_MPU_WRAPPERS */
179 
180 
181 #endif /* MPU_WRAPPERS_H */
182