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