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