Francisco Paez / freertos-cm3

Dependents:   mbed_lpc1768_freertos_lib

Committer:
fep
Date:
Wed May 31 02:36:43 2017 +0000
Revision:
0:5ff20db10a96
FreeRTOS v9.0.0 for ARM Cortex-M3 based boards.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fep 0:5ff20db10a96 1 /*
fep 0:5ff20db10a96 2 FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
fep 0:5ff20db10a96 3 All rights reserved
fep 0:5ff20db10a96 4
fep 0:5ff20db10a96 5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
fep 0:5ff20db10a96 6
fep 0:5ff20db10a96 7 This file is part of the FreeRTOS distribution.
fep 0:5ff20db10a96 8
fep 0:5ff20db10a96 9 FreeRTOS is free software; you can redistribute it and/or modify it under
fep 0:5ff20db10a96 10 the terms of the GNU General Public License (version 2) as published by the
fep 0:5ff20db10a96 11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
fep 0:5ff20db10a96 12
fep 0:5ff20db10a96 13 ***************************************************************************
fep 0:5ff20db10a96 14 >>! NOTE: The modification to the GPL is included to allow you to !<<
fep 0:5ff20db10a96 15 >>! distribute a combined work that includes FreeRTOS without being !<<
fep 0:5ff20db10a96 16 >>! obliged to provide the source code for proprietary components !<<
fep 0:5ff20db10a96 17 >>! outside of the FreeRTOS kernel. !<<
fep 0:5ff20db10a96 18 ***************************************************************************
fep 0:5ff20db10a96 19
fep 0:5ff20db10a96 20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
fep 0:5ff20db10a96 21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
fep 0:5ff20db10a96 22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
fep 0:5ff20db10a96 23 link: http://www.freertos.org/a00114.html
fep 0:5ff20db10a96 24
fep 0:5ff20db10a96 25 ***************************************************************************
fep 0:5ff20db10a96 26 * *
fep 0:5ff20db10a96 27 * FreeRTOS provides completely free yet professionally developed, *
fep 0:5ff20db10a96 28 * robust, strictly quality controlled, supported, and cross *
fep 0:5ff20db10a96 29 * platform software that is more than just the market leader, it *
fep 0:5ff20db10a96 30 * is the industry's de facto standard. *
fep 0:5ff20db10a96 31 * *
fep 0:5ff20db10a96 32 * Help yourself get started quickly while simultaneously helping *
fep 0:5ff20db10a96 33 * to support the FreeRTOS project by purchasing a FreeRTOS *
fep 0:5ff20db10a96 34 * tutorial book, reference manual, or both: *
fep 0:5ff20db10a96 35 * http://www.FreeRTOS.org/Documentation *
fep 0:5ff20db10a96 36 * *
fep 0:5ff20db10a96 37 ***************************************************************************
fep 0:5ff20db10a96 38
fep 0:5ff20db10a96 39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
fep 0:5ff20db10a96 40 the FAQ page "My application does not run, what could be wrong?". Have you
fep 0:5ff20db10a96 41 defined configASSERT()?
fep 0:5ff20db10a96 42
fep 0:5ff20db10a96 43 http://www.FreeRTOS.org/support - In return for receiving this top quality
fep 0:5ff20db10a96 44 embedded software for free we request you assist our global community by
fep 0:5ff20db10a96 45 participating in the support forum.
fep 0:5ff20db10a96 46
fep 0:5ff20db10a96 47 http://www.FreeRTOS.org/training - Investing in training allows your team to
fep 0:5ff20db10a96 48 be as productive as possible as early as possible. Now you can receive
fep 0:5ff20db10a96 49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
fep 0:5ff20db10a96 50 Ltd, and the world's leading authority on the world's leading RTOS.
fep 0:5ff20db10a96 51
fep 0:5ff20db10a96 52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
fep 0:5ff20db10a96 53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
fep 0:5ff20db10a96 54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
fep 0:5ff20db10a96 55
fep 0:5ff20db10a96 56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
fep 0:5ff20db10a96 57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
fep 0:5ff20db10a96 58
fep 0:5ff20db10a96 59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
fep 0:5ff20db10a96 60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
fep 0:5ff20db10a96 61 licenses offer ticketed support, indemnification and commercial middleware.
fep 0:5ff20db10a96 62
fep 0:5ff20db10a96 63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
fep 0:5ff20db10a96 64 engineered and independently SIL3 certified version for use in safety and
fep 0:5ff20db10a96 65 mission critical applications that require provable dependability.
fep 0:5ff20db10a96 66
fep 0:5ff20db10a96 67 1 tab == 4 spaces!
fep 0:5ff20db10a96 68 */
fep 0:5ff20db10a96 69
fep 0:5ff20db10a96 70 #ifndef STACK_MACROS_H
fep 0:5ff20db10a96 71 #define STACK_MACROS_H
fep 0:5ff20db10a96 72
fep 0:5ff20db10a96 73 /*
fep 0:5ff20db10a96 74 * Call the stack overflow hook function if the stack of the task being swapped
fep 0:5ff20db10a96 75 * out is currently overflowed, or looks like it might have overflowed in the
fep 0:5ff20db10a96 76 * past.
fep 0:5ff20db10a96 77 *
fep 0:5ff20db10a96 78 * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check
fep 0:5ff20db10a96 79 * the current stack state only - comparing the current top of stack value to
fep 0:5ff20db10a96 80 * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1
fep 0:5ff20db10a96 81 * will also cause the last few stack bytes to be checked to ensure the value
fep 0:5ff20db10a96 82 * to which the bytes were set when the task was created have not been
fep 0:5ff20db10a96 83 * overwritten. Note this second test does not guarantee that an overflowed
fep 0:5ff20db10a96 84 * stack will always be recognised.
fep 0:5ff20db10a96 85 */
fep 0:5ff20db10a96 86
fep 0:5ff20db10a96 87 /*-----------------------------------------------------------*/
fep 0:5ff20db10a96 88
fep 0:5ff20db10a96 89 #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) )
fep 0:5ff20db10a96 90
fep 0:5ff20db10a96 91 /* Only the current stack state is to be checked. */
fep 0:5ff20db10a96 92 #define taskCHECK_FOR_STACK_OVERFLOW() \
fep 0:5ff20db10a96 93 { \
fep 0:5ff20db10a96 94 /* Is the currently saved stack pointer within the stack limit? */ \
fep 0:5ff20db10a96 95 if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \
fep 0:5ff20db10a96 96 { \
fep 0:5ff20db10a96 97 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
fep 0:5ff20db10a96 98 } \
fep 0:5ff20db10a96 99 }
fep 0:5ff20db10a96 100
fep 0:5ff20db10a96 101 #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
fep 0:5ff20db10a96 102 /*-----------------------------------------------------------*/
fep 0:5ff20db10a96 103
fep 0:5ff20db10a96 104 #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) )
fep 0:5ff20db10a96 105
fep 0:5ff20db10a96 106 /* Only the current stack state is to be checked. */
fep 0:5ff20db10a96 107 #define taskCHECK_FOR_STACK_OVERFLOW() \
fep 0:5ff20db10a96 108 { \
fep 0:5ff20db10a96 109 \
fep 0:5ff20db10a96 110 /* Is the currently saved stack pointer within the stack limit? */ \
fep 0:5ff20db10a96 111 if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \
fep 0:5ff20db10a96 112 { \
fep 0:5ff20db10a96 113 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
fep 0:5ff20db10a96 114 } \
fep 0:5ff20db10a96 115 }
fep 0:5ff20db10a96 116
fep 0:5ff20db10a96 117 #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
fep 0:5ff20db10a96 118 /*-----------------------------------------------------------*/
fep 0:5ff20db10a96 119
fep 0:5ff20db10a96 120 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )
fep 0:5ff20db10a96 121
fep 0:5ff20db10a96 122 #define taskCHECK_FOR_STACK_OVERFLOW() \
fep 0:5ff20db10a96 123 { \
fep 0:5ff20db10a96 124 const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
fep 0:5ff20db10a96 125 const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \
fep 0:5ff20db10a96 126 \
fep 0:5ff20db10a96 127 if( ( pulStack[ 0 ] != ulCheckValue ) || \
fep 0:5ff20db10a96 128 ( pulStack[ 1 ] != ulCheckValue ) || \
fep 0:5ff20db10a96 129 ( pulStack[ 2 ] != ulCheckValue ) || \
fep 0:5ff20db10a96 130 ( pulStack[ 3 ] != ulCheckValue ) ) \
fep 0:5ff20db10a96 131 { \
fep 0:5ff20db10a96 132 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
fep 0:5ff20db10a96 133 } \
fep 0:5ff20db10a96 134 }
fep 0:5ff20db10a96 135
fep 0:5ff20db10a96 136 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
fep 0:5ff20db10a96 137 /*-----------------------------------------------------------*/
fep 0:5ff20db10a96 138
fep 0:5ff20db10a96 139 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
fep 0:5ff20db10a96 140
fep 0:5ff20db10a96 141 #define taskCHECK_FOR_STACK_OVERFLOW() \
fep 0:5ff20db10a96 142 { \
fep 0:5ff20db10a96 143 int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
fep 0:5ff20db10a96 144 static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
fep 0:5ff20db10a96 145 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
fep 0:5ff20db10a96 146 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
fep 0:5ff20db10a96 147 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
fep 0:5ff20db10a96 148 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \
fep 0:5ff20db10a96 149 \
fep 0:5ff20db10a96 150 \
fep 0:5ff20db10a96 151 pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
fep 0:5ff20db10a96 152 \
fep 0:5ff20db10a96 153 /* Has the extremity of the task stack ever been written over? */ \
fep 0:5ff20db10a96 154 if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
fep 0:5ff20db10a96 155 { \
fep 0:5ff20db10a96 156 vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
fep 0:5ff20db10a96 157 } \
fep 0:5ff20db10a96 158 }
fep 0:5ff20db10a96 159
fep 0:5ff20db10a96 160 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
fep 0:5ff20db10a96 161 /*-----------------------------------------------------------*/
fep 0:5ff20db10a96 162
fep 0:5ff20db10a96 163 /* Remove stack overflow macro if not being used. */
fep 0:5ff20db10a96 164 #ifndef taskCHECK_FOR_STACK_OVERFLOW
fep 0:5ff20db10a96 165 #define taskCHECK_FOR_STACK_OVERFLOW()
fep 0:5ff20db10a96 166 #endif
fep 0:5ff20db10a96 167
fep 0:5ff20db10a96 168
fep 0:5ff20db10a96 169
fep 0:5ff20db10a96 170 #endif /* STACK_MACROS_H */
fep 0:5ff20db10a96 171
fep 0:5ff20db10a96 172