portable.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. /*-----------------------------------------------------------
  29. * Portable layer API. Each function must be defined for each port.
  30. *----------------------------------------------------------*/
  31. #ifndef PORTABLE_H
  32. #define PORTABLE_H
  33. /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
  34. pre-processor definition was used to ensure the pre-processor found the correct
  35. portmacro.h file for the port being used. That scheme was deprecated in favour
  36. of setting the compiler's include path such that it found the correct
  37. portmacro.h file - removing the need for the constant and allowing the
  38. portmacro.h file to be located anywhere in relation to the port being used.
  39. Purely for reasons of backward compatibility the old method is still valid, but
  40. to make it clear that new projects should not use it, support for the port
  41. specific constants has been moved into the deprecated_definitions.h header
  42. file. */
  43. #include "deprecated_definitions.h"
  44. /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
  45. did not result in a portmacro.h header file being included - and it should be
  46. included here. In this case the path to the correct portmacro.h header file
  47. must be set in the compiler's include path. */
  48. #ifndef portENTER_CRITICAL
  49. #include "portmacro.h"
  50. #endif
  51. #if portBYTE_ALIGNMENT == 32
  52. #define portBYTE_ALIGNMENT_MASK ( 0x001f )
  53. #endif
  54. #if portBYTE_ALIGNMENT == 16
  55. #define portBYTE_ALIGNMENT_MASK ( 0x000f )
  56. #endif
  57. #if portBYTE_ALIGNMENT == 8
  58. #define portBYTE_ALIGNMENT_MASK ( 0x0007 )
  59. #endif
  60. #if portBYTE_ALIGNMENT == 4
  61. #define portBYTE_ALIGNMENT_MASK ( 0x0003 )
  62. #endif
  63. #if portBYTE_ALIGNMENT == 2
  64. #define portBYTE_ALIGNMENT_MASK ( 0x0001 )
  65. #endif
  66. #if portBYTE_ALIGNMENT == 1
  67. #define portBYTE_ALIGNMENT_MASK ( 0x0000 )
  68. #endif
  69. #ifndef portBYTE_ALIGNMENT_MASK
  70. #error "Invalid portBYTE_ALIGNMENT definition"
  71. #endif
  72. #ifndef portNUM_CONFIGURABLE_REGIONS
  73. #define portNUM_CONFIGURABLE_REGIONS 1
  74. #endif
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif
  78. #include "mpu_wrappers.h"
  79. /*
  80. * Setup the stack of a new task so it is ready to be placed under the
  81. * scheduler control. The registers have to be placed on the stack in
  82. * the order that the port expects to find them.
  83. *
  84. */
  85. #if( portUSING_MPU_WRAPPERS == 1 )
  86. StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
  87. #else
  88. StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
  89. #endif
  90. /* Used by heap_5.c. */
  91. typedef struct HeapRegion
  92. {
  93. uint8_t *pucStartAddress;
  94. size_t xSizeInBytes;
  95. } HeapRegion_t;
  96. /*
  97. * Used to define multiple heap regions for use by heap_5.c. This function
  98. * must be called before any calls to pvPortMalloc() - not creating a task,
  99. * queue, semaphore, mutex, software timer, event group, etc. will result in
  100. * pvPortMalloc being called.
  101. *
  102. * pxHeapRegions passes in an array of HeapRegion_t structures - each of which
  103. * defines a region of memory that can be used as the heap. The array is
  104. * terminated by a HeapRegions_t structure that has a size of 0. The region
  105. * with the lowest start address must appear first in the array.
  106. */
  107. void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
  108. /*
  109. * Map to the memory management routines required for the port.
  110. */
  111. void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
  112. void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
  113. void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
  114. size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
  115. size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
  116. /*
  117. * Setup the hardware ready for the scheduler to take control. This generally
  118. * sets up a tick interrupt and sets timers for the correct tick frequency.
  119. */
  120. BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
  121. /*
  122. * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
  123. * the hardware is left in its original condition after the scheduler stops
  124. * executing.
  125. */
  126. void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
  127. /*
  128. * The structures and methods of manipulating the MPU are contained within the
  129. * port layer.
  130. *
  131. * Fills the xMPUSettings structure with the memory region information
  132. * contained in xRegions.
  133. */
  134. #if( portUSING_MPU_WRAPPERS == 1 )
  135. struct xMEMORY_REGION;
  136. void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
  137. #endif
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif /* PORTABLE_H */