mpu_wrappers.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * FreeRTOS Kernel V10.4.4
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * SPDX-License-Identifier: MIT
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. * this software and associated documentation files (the "Software"), to deal in
  9. * the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. * the Software, and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  19. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  20. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * https://www.FreeRTOS.org
  25. * https://github.com/FreeRTOS
  26. *
  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. #if ( portUSING_MPU_WRAPPERS == 1 )
  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 vTaskDelete MPU_vTaskDelete
  48. #define vTaskDelay MPU_vTaskDelay
  49. #define xTaskDelayUntil MPU_xTaskDelayUntil
  50. #define xTaskAbortDelay MPU_xTaskAbortDelay
  51. #define uxTaskPriorityGet MPU_uxTaskPriorityGet
  52. #define eTaskGetState MPU_eTaskGetState
  53. #define vTaskGetInfo MPU_vTaskGetInfo
  54. #define vTaskPrioritySet MPU_vTaskPrioritySet
  55. #define vTaskSuspend MPU_vTaskSuspend
  56. #define vTaskResume MPU_vTaskResume
  57. #define vTaskSuspendAll MPU_vTaskSuspendAll
  58. #define xTaskResumeAll MPU_xTaskResumeAll
  59. #define xTaskGetTickCount MPU_xTaskGetTickCount
  60. #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
  61. #define pcTaskGetName MPU_pcTaskGetName
  62. #define xTaskGetHandle MPU_xTaskGetHandle
  63. #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
  64. #define uxTaskGetStackHighWaterMark2 MPU_uxTaskGetStackHighWaterMark2
  65. #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
  66. #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
  67. #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
  68. #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
  69. #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
  70. #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
  71. #define uxTaskGetSystemState MPU_uxTaskGetSystemState
  72. #define vTaskList MPU_vTaskList
  73. #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
  74. #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter
  75. #define xTaskGenericNotify MPU_xTaskGenericNotify
  76. #define xTaskGenericNotifyWait MPU_xTaskGenericNotifyWait
  77. #define ulTaskGenericNotifyTake MPU_ulTaskGenericNotifyTake
  78. #define xTaskGenericNotifyStateClear MPU_xTaskGenericNotifyStateClear
  79. #define ulTaskGenericNotifyValueClear MPU_ulTaskGenericNotifyValueClear
  80. #define xTaskCatchUpTicks MPU_xTaskCatchUpTicks
  81. #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
  82. #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
  83. #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
  84. #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
  85. /* Map standard queue.h API functions to the MPU equivalents. */
  86. #define xQueueGenericSend MPU_xQueueGenericSend
  87. #define xQueueReceive MPU_xQueueReceive
  88. #define xQueuePeek MPU_xQueuePeek
  89. #define xQueueSemaphoreTake MPU_xQueueSemaphoreTake
  90. #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
  91. #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
  92. #define vQueueDelete MPU_vQueueDelete
  93. #define xQueueCreateMutex MPU_xQueueCreateMutex
  94. #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
  95. #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
  96. #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
  97. #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
  98. #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
  99. #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
  100. #define xQueueGenericCreate MPU_xQueueGenericCreate
  101. #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
  102. #define xQueueCreateSet MPU_xQueueCreateSet
  103. #define xQueueAddToSet MPU_xQueueAddToSet
  104. #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
  105. #define xQueueSelectFromSet MPU_xQueueSelectFromSet
  106. #define xQueueGenericReset MPU_xQueueGenericReset
  107. #if ( configQUEUE_REGISTRY_SIZE > 0 )
  108. #define vQueueAddToRegistry MPU_vQueueAddToRegistry
  109. #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
  110. #define pcQueueGetName MPU_pcQueueGetName
  111. #endif
  112. /* Map standard timer.h API functions to the MPU equivalents. */
  113. #define xTimerCreate MPU_xTimerCreate
  114. #define xTimerCreateStatic MPU_xTimerCreateStatic
  115. #define pvTimerGetTimerID MPU_pvTimerGetTimerID
  116. #define vTimerSetTimerID MPU_vTimerSetTimerID
  117. #define xTimerIsTimerActive MPU_xTimerIsTimerActive
  118. #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
  119. #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall
  120. #define pcTimerGetName MPU_pcTimerGetName
  121. #define vTimerSetReloadMode MPU_vTimerSetReloadMode
  122. #define uxTimerGetReloadMode MPU_uxTimerGetReloadMode
  123. #define xTimerGetPeriod MPU_xTimerGetPeriod
  124. #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
  125. #define xTimerGenericCommand MPU_xTimerGenericCommand
  126. /* Map standard event_group.h API functions to the MPU equivalents. */
  127. #define xEventGroupCreate MPU_xEventGroupCreate
  128. #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
  129. #define xEventGroupWaitBits MPU_xEventGroupWaitBits
  130. #define xEventGroupClearBits MPU_xEventGroupClearBits
  131. #define xEventGroupSetBits MPU_xEventGroupSetBits
  132. #define xEventGroupSync MPU_xEventGroupSync
  133. #define vEventGroupDelete MPU_vEventGroupDelete
  134. /* Map standard message/stream_buffer.h API functions to the MPU
  135. * equivalents. */
  136. #define xStreamBufferSend MPU_xStreamBufferSend
  137. #define xStreamBufferReceive MPU_xStreamBufferReceive
  138. #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes
  139. #define vStreamBufferDelete MPU_vStreamBufferDelete
  140. #define xStreamBufferIsFull MPU_xStreamBufferIsFull
  141. #define xStreamBufferIsEmpty MPU_xStreamBufferIsEmpty
  142. #define xStreamBufferReset MPU_xStreamBufferReset
  143. #define xStreamBufferSpacesAvailable MPU_xStreamBufferSpacesAvailable
  144. #define xStreamBufferBytesAvailable MPU_xStreamBufferBytesAvailable
  145. #define xStreamBufferSetTriggerLevel MPU_xStreamBufferSetTriggerLevel
  146. #define xStreamBufferGenericCreate MPU_xStreamBufferGenericCreate
  147. #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
  148. /* Remove the privileged function macro, but keep the PRIVILEGED_DATA
  149. * macro so applications can place data in privileged access sections
  150. * (useful when using statically allocated objects). */
  151. #define PRIVILEGED_FUNCTION
  152. #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
  153. #define FREERTOS_SYSTEM_CALL
  154. #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
  155. /* Ensure API functions go in the privileged execution section. */
  156. #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) )
  157. #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
  158. #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) )
  159. #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
  160. #else /* portUSING_MPU_WRAPPERS */
  161. #define PRIVILEGED_FUNCTION
  162. #define PRIVILEGED_DATA
  163. #define FREERTOS_SYSTEM_CALL
  164. #endif /* portUSING_MPU_WRAPPERS */
  165. #endif /* MPU_WRAPPERS_H */