mpu_wrappers.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #ifndef MPU_WRAPPERS_H
  29. #define MPU_WRAPPERS_H
  30. /* This file redefines API functions to be called through a wrapper macro, but
  31. only for ports that are using the MPU. */
  32. #ifdef portUSING_MPU_WRAPPERS
  33. /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
  34. included from queue.c or task.c to prevent it from having an effect within
  35. those files. */
  36. #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  37. /*
  38. * Map standard (non MPU) API functions to equivalents that start
  39. * "MPU_". This will cause the application code to call the MPU_
  40. * version, which wraps the non-MPU version with privilege promoting
  41. * then demoting code, so the kernel code always runs will full
  42. * privileges.
  43. */
  44. /* Map standard tasks.h API functions to the MPU equivalents. */
  45. #define xTaskCreate MPU_xTaskCreate
  46. #define xTaskCreateStatic MPU_xTaskCreateStatic
  47. #define xTaskCreateRestricted MPU_xTaskCreateRestricted
  48. #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
  49. #define vTaskDelete MPU_vTaskDelete
  50. #define vTaskDelay MPU_vTaskDelay
  51. #define vTaskDelayUntil MPU_vTaskDelayUntil
  52. #define xTaskAbortDelay MPU_xTaskAbortDelay
  53. #define uxTaskPriorityGet MPU_uxTaskPriorityGet
  54. #define eTaskGetState MPU_eTaskGetState
  55. #define vTaskGetInfo MPU_vTaskGetInfo
  56. #define vTaskPrioritySet MPU_vTaskPrioritySet
  57. #define vTaskSuspend MPU_vTaskSuspend
  58. #define vTaskResume MPU_vTaskResume
  59. #define vTaskSuspendAll MPU_vTaskSuspendAll
  60. #define xTaskResumeAll MPU_xTaskResumeAll
  61. #define xTaskGetTickCount MPU_xTaskGetTickCount
  62. #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
  63. #define pcTaskGetName MPU_pcTaskGetName
  64. #define xTaskGetHandle MPU_xTaskGetHandle
  65. #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
  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 xTaskGenericNotify MPU_xTaskGenericNotify
  76. #define xTaskNotifyWait MPU_xTaskNotifyWait
  77. #define ulTaskNotifyTake MPU_ulTaskNotifyTake
  78. #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear
  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 xTimerGetPeriod MPU_xTimerGetPeriod
  120. #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
  121. #define xTimerGenericCommand MPU_xTimerGenericCommand
  122. /* Map standard event_group.h API functions to the MPU equivalents. */
  123. #define xEventGroupCreate MPU_xEventGroupCreate
  124. #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
  125. #define xEventGroupWaitBits MPU_xEventGroupWaitBits
  126. #define xEventGroupClearBits MPU_xEventGroupClearBits
  127. #define xEventGroupSetBits MPU_xEventGroupSetBits
  128. #define xEventGroupSync MPU_xEventGroupSync
  129. #define vEventGroupDelete MPU_vEventGroupDelete
  130. /* Map standard message/stream_buffer.h API functions to the MPU
  131. equivalents. */
  132. #define xStreamBufferSend MPU_xStreamBufferSend
  133. #define xStreamBufferSendFromISR MPU_xStreamBufferSendFromISR
  134. #define xStreamBufferReceive MPU_xStreamBufferReceive
  135. #define xStreamBufferReceiveFromISR MPU_xStreamBufferReceiveFromISR
  136. #define vStreamBufferDelete MPU_vStreamBufferDelete
  137. #define xStreamBufferIsFull MPU_xStreamBufferIsFull
  138. #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty
  139. #define xStreamBufferReset MPU_xStreamBufferReset
  140. #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable
  141. #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable
  142. #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel
  143. #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate
  144. #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
  145. /* Remove the privileged function macro, but keep the PRIVILEGED_DATA
  146. macro so applications can place data in privileged access sections
  147. (useful when using statically allocated objects). */
  148. #define PRIVILEGED_FUNCTION
  149. #define PRIVILEGED_DATA __attribute__((section("privileged_data")))
  150. #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
  151. /* Ensure API functions go in the privileged execution section. */
  152. #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))
  153. #define PRIVILEGED_DATA __attribute__((section("privileged_data")))
  154. #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
  155. #else /* portUSING_MPU_WRAPPERS */
  156. #define PRIVILEGED_FUNCTION
  157. #define PRIVILEGED_DATA
  158. #define portUSING_MPU_WRAPPERS 0
  159. #endif /* portUSING_MPU_WRAPPERS */
  160. #endif /* MPU_WRAPPERS_H */