mpu_wrappers.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. #ifndef MPU_WRAPPERS_H
  27. #define MPU_WRAPPERS_H
  28. /* This file redefines API functions to be called through a wrapper macro, but
  29. * only for ports that are using the MPU. */
  30. #ifdef portUSING_MPU_WRAPPERS
  31. /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
  32. * included from queue.c or task.c to prevent it from having an effect within
  33. * those files. */
  34. #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  35. /*
  36. * Map standard (non MPU) API functions to equivalents that start
  37. * "MPU_". This will cause the application code to call the MPU_
  38. * version, which wraps the non-MPU version with privilege promoting
  39. * then demoting code, so the kernel code always runs will full
  40. * privileges.
  41. */
  42. /* Map standard tasks.h API functions to the MPU equivalents. */
  43. #define xTaskCreate MPU_xTaskCreate
  44. #define xTaskCreateStatic MPU_xTaskCreateStatic
  45. #define vTaskDelete MPU_vTaskDelete
  46. #define vTaskDelay MPU_vTaskDelay
  47. #define xTaskDelayUntil MPU_xTaskDelayUntil
  48. #define xTaskAbortDelay MPU_xTaskAbortDelay
  49. #define uxTaskPriorityGet MPU_uxTaskPriorityGet
  50. #define eTaskGetState MPU_eTaskGetState
  51. #define vTaskGetInfo MPU_vTaskGetInfo
  52. #define vTaskPrioritySet MPU_vTaskPrioritySet
  53. #define vTaskSuspend MPU_vTaskSuspend
  54. #define vTaskResume MPU_vTaskResume
  55. #define vTaskSuspendAll MPU_vTaskSuspendAll
  56. #define xTaskResumeAll MPU_xTaskResumeAll
  57. #define xTaskGetTickCount MPU_xTaskGetTickCount
  58. #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
  59. #define pcTaskGetName MPU_pcTaskGetName
  60. #define xTaskGetHandle MPU_xTaskGetHandle
  61. #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
  62. #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2
  63. #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
  64. #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
  65. #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
  66. #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
  67. #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
  68. #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
  69. #define uxTaskGetSystemState MPU_uxTaskGetSystemState
  70. #define vTaskList MPU_vTaskList
  71. #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
  72. #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter
  73. #define xTaskGenericNotify MPU_xTaskGenericNotify
  74. #define xTaskGenericNotifyWait MPU_xTaskGenericNotifyWait
  75. #define ulTaskGenericNotifyTake MPU_ulTaskGenericNotifyTake
  76. #define xTaskGenericNotifyStateClear MPU_xTaskGenericNotifyStateClear
  77. #define ulTaskGenericNotifyValueClear MPU_ulTaskGenericNotifyValueClear
  78. #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks
  79. #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
  80. #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
  81. #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
  82. #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
  83. /* Map standard queue.h API functions to the MPU equivalents. */
  84. #define xQueueGenericSend MPU_xQueueGenericSend
  85. #define xQueueReceive MPU_xQueueReceive
  86. #define xQueuePeek MPU_xQueuePeek
  87. #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake
  88. #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
  89. #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
  90. #define vQueueDelete MPU_vQueueDelete
  91. #define xQueueCreateMutex MPU_xQueueCreateMutex
  92. #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
  93. #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
  94. #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
  95. #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
  96. #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
  97. #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
  98. #define xQueueGenericCreate MPU_xQueueGenericCreate
  99. #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
  100. #define xQueueCreateSet MPU_xQueueCreateSet
  101. #define xQueueAddToSet MPU_xQueueAddToSet
  102. #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
  103. #define xQueueSelectFromSet MPU_xQueueSelectFromSet
  104. #define xQueueGenericReset MPU_xQueueGenericReset
  105. #if ( configQUEUE_REGISTRY_SIZE > 0 )
  106. #define vQueueAddToRegistry MPU_vQueueAddToRegistry
  107. #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
  108. #define pcQueueGetName MPU_pcQueueGetName
  109. #endif
  110. /* Map standard timer.h API functions to the MPU equivalents. */
  111. #define xTimerCreate MPU_xTimerCreate
  112. #define xTimerCreateStatic MPU_xTimerCreateStatic
  113. #define pvTimerGetTimerID MPU_pvTimerGetTimerID
  114. #define vTimerSetTimerID MPU_vTimerSetTimerID
  115. #define xTimerIsTimerActive MPU_xTimerIsTimerActive
  116. #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
  117. #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall
  118. #define pcTimerGetName MPU_pcTimerGetName
  119. #define vTimerSetReloadMode MPU_vTimerSetReloadMode
  120. #define uxTimerGetReloadMode MPU_uxTimerGetReloadMode
  121. #define xTimerGetPeriod MPU_xTimerGetPeriod
  122. #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
  123. #define xTimerGenericCommand MPU_xTimerGenericCommand
  124. /* Map standard event_group.h API functions to the MPU equivalents. */
  125. #define xEventGroupCreate MPU_xEventGroupCreate
  126. #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
  127. #define xEventGroupWaitBits MPU_xEventGroupWaitBits
  128. #define xEventGroupClearBits MPU_xEventGroupClearBits
  129. #define xEventGroupSetBits MPU_xEventGroupSetBits
  130. #define xEventGroupSync MPU_xEventGroupSync
  131. #define vEventGroupDelete MPU_vEventGroupDelete
  132. /* Map standard message/stream_buffer.h API functions to the MPU
  133. * equivalents. */
  134. #define xStreamBufferSend MPU_xStreamBufferSend
  135. #define xStreamBufferReceive MPU_xStreamBufferReceive
  136. #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes
  137. #define vStreamBufferDelete MPU_vStreamBufferDelete
  138. #define xStreamBufferIsFull MPU_xStreamBufferIsFull
  139. #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty
  140. #define xStreamBufferReset MPU_xStreamBufferReset
  141. #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable
  142. #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable
  143. #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel
  144. #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate
  145. #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
  146. /* Remove the privileged function macro, but keep the PRIVILEGED_DATA
  147. * macro so applications can place data in privileged access sections
  148. * (useful when using statically allocated objects). */
  149. #define PRIVILEGED_FUNCTION
  150. #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
  151. #define FREERTOS_SYSTEM_CALL
  152. #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
  153. /* Ensure API functions go in the privileged execution section. */
  154. #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) )
  155. #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
  156. #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) )
  157. #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
  158. #else /* portUSING_MPU_WRAPPERS */
  159. #define PRIVILEGED_FUNCTION
  160. #define PRIVILEGED_DATA
  161. #define FREERTOS_SYSTEM_CALL
  162. #define portUSING_MPU_WRAPPERS 0
  163. #endif /* portUSING_MPU_WRAPPERS */
  164. #endif /* MPU_WRAPPERS_H */