mpu_wrappers.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * FreeRTOS Kernel V10.2.1
  3. * Copyright (C) 2019 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. * http://www.FreeRTOS.org
  23. * http://aws.amazon.com/freertos
  24. *
  25. * 1 tab == 4 spaces!
  26. */
  27. #ifndef MPU_WRAPPERS_H
  28. #define MPU_WRAPPERS_H
  29. /* This file redefines API functions to be called through a wrapper macro, but
  30. only for ports that are using the MPU. */
  31. #ifdef portUSING_MPU_WRAPPERS
  32. /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
  33. included from queue.c or task.c to prevent it from having an effect within
  34. those files. */
  35. #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  36. /*
  37. * Map standard (non MPU) API functions to equivalents that start
  38. * "MPU_". This will cause the application code to call the MPU_
  39. * version, which wraps the non-MPU version with privilege promoting
  40. * then demoting code, so the kernel code always runs will full
  41. * privileges.
  42. */
  43. /* Map standard tasks.h API functions to the MPU equivalents. */
  44. #define xTaskCreate MPU_xTaskCreate
  45. #define xTaskCreateStatic MPU_xTaskCreateStatic
  46. #define xTaskCreateRestricted MPU_xTaskCreateRestricted
  47. #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
  48. #define vTaskDelete MPU_vTaskDelete
  49. #define vTaskDelay MPU_vTaskDelay
  50. #define vTaskDelayUntil MPU_vTaskDelayUntil
  51. #define xTaskAbortDelay MPU_xTaskAbortDelay
  52. #define uxTaskPriorityGet MPU_uxTaskPriorityGet
  53. #define eTaskGetState MPU_eTaskGetState
  54. #define vTaskGetInfo MPU_vTaskGetInfo
  55. #define vTaskPrioritySet MPU_vTaskPrioritySet
  56. #define vTaskSuspend MPU_vTaskSuspend
  57. #define vTaskResume MPU_vTaskResume
  58. #define vTaskSuspendAll MPU_vTaskSuspendAll
  59. #define xTaskResumeAll MPU_xTaskResumeAll
  60. #define xTaskGetTickCount MPU_xTaskGetTickCount
  61. #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
  62. #define pcTaskGetName MPU_pcTaskGetName
  63. #define xTaskGetHandle MPU_xTaskGetHandle
  64. #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
  65. #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2
  66. #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
  67. #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
  68. #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
  69. #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
  70. #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
  71. #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
  72. #define uxTaskGetSystemState MPU_uxTaskGetSystemState
  73. #define vTaskList MPU_vTaskList
  74. #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
  75. #define xTaskGetIdleRunTimeCounter MPU_xTaskGetIdleRunTimeCounter
  76. #define xTaskGenericNotify MPU_xTaskGenericNotify
  77. #define xTaskNotifyWait MPU_xTaskNotifyWait
  78. #define ulTaskNotifyTake MPU_ulTaskNotifyTake
  79. #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear
  80. #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
  81. #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
  82. #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
  83. #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
  84. /* Map standard queue.h API functions to the MPU equivalents. */
  85. #define xQueueGenericSend MPU_xQueueGenericSend
  86. #define xQueueReceive MPU_xQueueReceive
  87. #define xQueuePeek MPU_xQueuePeek
  88. #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake
  89. #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
  90. #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
  91. #define vQueueDelete MPU_vQueueDelete
  92. #define xQueueCreateMutex MPU_xQueueCreateMutex
  93. #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
  94. #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
  95. #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
  96. #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
  97. #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
  98. #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
  99. #define xQueueGenericCreate MPU_xQueueGenericCreate
  100. #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
  101. #define xQueueCreateSet MPU_xQueueCreateSet
  102. #define xQueueAddToSet MPU_xQueueAddToSet
  103. #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
  104. #define xQueueSelectFromSet MPU_xQueueSelectFromSet
  105. #define xQueueGenericReset MPU_xQueueGenericReset
  106. #if( configQUEUE_REGISTRY_SIZE > 0 )
  107. #define vQueueAddToRegistry MPU_vQueueAddToRegistry
  108. #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
  109. #define pcQueueGetName MPU_pcQueueGetName
  110. #endif
  111. /* Map standard timer.h API functions to the MPU equivalents. */
  112. #define xTimerCreate MPU_xTimerCreate
  113. #define xTimerCreateStatic MPU_xTimerCreateStatic
  114. #define pvTimerGetTimerID MPU_pvTimerGetTimerID
  115. #define vTimerSetTimerID MPU_vTimerSetTimerID
  116. #define xTimerIsTimerActive MPU_xTimerIsTimerActive
  117. #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
  118. #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall
  119. #define pcTimerGetName MPU_pcTimerGetName
  120. #define vTimerSetReloadMode MPU_vTimerSetReloadMode
  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 */