portable.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
  3. All rights reserved
  4. VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
  5. This file is part of the FreeRTOS distribution.
  6. FreeRTOS is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License (version 2) as published by the
  8. Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
  9. ***************************************************************************
  10. >>! NOTE: The modification to the GPL is included to allow you to !<<
  11. >>! distribute a combined work that includes FreeRTOS without being !<<
  12. >>! obliged to provide the source code for proprietary components !<<
  13. >>! outside of the FreeRTOS kernel. !<<
  14. ***************************************************************************
  15. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
  16. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. FOR A PARTICULAR PURPOSE. Full license text is available on the following
  18. link: http://www.freertos.org/a00114.html
  19. ***************************************************************************
  20. * *
  21. * FreeRTOS provides completely free yet professionally developed, *
  22. * robust, strictly quality controlled, supported, and cross *
  23. * platform software that is more than just the market leader, it *
  24. * is the industry's de facto standard. *
  25. * *
  26. * Help yourself get started quickly while simultaneously helping *
  27. * to support the FreeRTOS project by purchasing a FreeRTOS *
  28. * tutorial book, reference manual, or both: *
  29. * http://www.FreeRTOS.org/Documentation *
  30. * *
  31. ***************************************************************************
  32. http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
  33. the FAQ page "My application does not run, what could be wrong?". Have you
  34. defined configASSERT()?
  35. http://www.FreeRTOS.org/support - In return for receiving this top quality
  36. embedded software for free we request you assist our global community by
  37. participating in the support forum.
  38. http://www.FreeRTOS.org/training - Investing in training allows your team to
  39. be as productive as possible as early as possible. Now you can receive
  40. FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
  41. Ltd, and the world's leading authority on the world's leading RTOS.
  42. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
  43. including FreeRTOS+Trace - an indispensable productivity tool, a DOS
  44. compatible FAT file system, and our tiny thread aware UDP/IP stack.
  45. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
  46. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
  47. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
  48. Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
  49. licenses offer ticketed support, indemnification and commercial middleware.
  50. http://www.SafeRTOS.com - High Integrity Systems also provide a safety
  51. engineered and independently SIL3 certified version for use in safety and
  52. mission critical applications that require provable dependability.
  53. 1 tab == 4 spaces!
  54. */
  55. /*-----------------------------------------------------------
  56. * Portable layer API. Each function must be defined for each port.
  57. *----------------------------------------------------------*/
  58. #ifndef PORTABLE_H
  59. #define PORTABLE_H
  60. /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
  61. pre-processor definition was used to ensure the pre-processor found the correct
  62. portmacro.h file for the port being used. That scheme was deprecated in favour
  63. of setting the compiler's include path such that it found the correct
  64. portmacro.h file - removing the need for the constant and allowing the
  65. portmacro.h file to be located anywhere in relation to the port being used.
  66. Purely for reasons of backward compatibility the old method is still valid, but
  67. to make it clear that new projects should not use it, support for the port
  68. specific constants has been moved into the deprecated_definitions.h header
  69. file. */
  70. #include "deprecated_definitions.h"
  71. /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
  72. did not result in a portmacro.h header file being included - and it should be
  73. included here. In this case the path to the correct portmacro.h header file
  74. must be set in the compiler's include path. */
  75. #ifndef portENTER_CRITICAL
  76. #include "portmacro.h"
  77. #endif
  78. #if portBYTE_ALIGNMENT == 32
  79. #define portBYTE_ALIGNMENT_MASK ( 0x001f )
  80. #endif
  81. #if portBYTE_ALIGNMENT == 16
  82. #define portBYTE_ALIGNMENT_MASK ( 0x000f )
  83. #endif
  84. #if portBYTE_ALIGNMENT == 8
  85. #define portBYTE_ALIGNMENT_MASK ( 0x0007 )
  86. #endif
  87. #if portBYTE_ALIGNMENT == 4
  88. #define portBYTE_ALIGNMENT_MASK ( 0x0003 )
  89. #endif
  90. #if portBYTE_ALIGNMENT == 2
  91. #define portBYTE_ALIGNMENT_MASK ( 0x0001 )
  92. #endif
  93. #if portBYTE_ALIGNMENT == 1
  94. #define portBYTE_ALIGNMENT_MASK ( 0x0000 )
  95. #endif
  96. #ifndef portBYTE_ALIGNMENT_MASK
  97. #error "Invalid portBYTE_ALIGNMENT definition"
  98. #endif
  99. #ifndef portNUM_CONFIGURABLE_REGIONS
  100. #define portNUM_CONFIGURABLE_REGIONS 1
  101. #endif
  102. #ifdef __cplusplus
  103. extern "C" {
  104. #endif
  105. #include "mpu_wrappers.h"
  106. /*
  107. * Setup the stack of a new task so it is ready to be placed under the
  108. * scheduler control. The registers have to be placed on the stack in
  109. * the order that the port expects to find them.
  110. *
  111. */
  112. #if( portUSING_MPU_WRAPPERS == 1 )
  113. StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
  114. #else
  115. StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
  116. #endif
  117. /* Used by heap_5.c. */
  118. typedef struct HeapRegion
  119. {
  120. uint8_t *pucStartAddress;
  121. size_t xSizeInBytes;
  122. } HeapRegion_t;
  123. /*
  124. * Used to define multiple heap regions for use by heap_5.c. This function
  125. * must be called before any calls to pvPortMalloc() - not creating a task,
  126. * queue, semaphore, mutex, software timer, event group, etc. will result in
  127. * pvPortMalloc being called.
  128. *
  129. * pxHeapRegions passes in an array of HeapRegion_t structures - each of which
  130. * defines a region of memory that can be used as the heap. The array is
  131. * terminated by a HeapRegions_t structure that has a size of 0. The region
  132. * with the lowest start address must appear first in the array.
  133. */
  134. void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
  135. /*
  136. * Map to the memory management routines required for the port.
  137. */
  138. void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
  139. void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
  140. void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
  141. size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
  142. size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
  143. /*
  144. * Setup the hardware ready for the scheduler to take control. This generally
  145. * sets up a tick interrupt and sets timers for the correct tick frequency.
  146. */
  147. BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
  148. /*
  149. * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
  150. * the hardware is left in its original condition after the scheduler stops
  151. * executing.
  152. */
  153. void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
  154. /*
  155. * The structures and methods of manipulating the MPU are contained within the
  156. * port layer.
  157. *
  158. * Fills the xMPUSettings structure with the memory region information
  159. * contained in xRegions.
  160. */
  161. #if( portUSING_MPU_WRAPPERS == 1 )
  162. struct xMEMORY_REGION;
  163. void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint16_t usStackDepth ) PRIVILEGED_FUNCTION;
  164. #endif
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif /* PORTABLE_H */