FreeRTOS Real Time Operating System, Modified from Kenji Arai's initial port. See freertos.org for full documentation.
Fork of FreeRTOS_on_mbed_v1 by
StackMacros.h
00001 /* 00002 FreeRTOS V6.0.3 - Copyright (C) 2010 Real Time Engineers Ltd. 00003 00004 *************************************************************************** 00005 * * 00006 * If you are: * 00007 * * 00008 * + New to FreeRTOS, * 00009 * + Wanting to learn FreeRTOS or multitasking in general quickly * 00010 * + Looking for basic training, * 00011 * + Wanting to improve your FreeRTOS skills and productivity * 00012 * * 00013 * then take a look at the FreeRTOS eBook * 00014 * * 00015 * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * 00016 * http://www.FreeRTOS.org/Documentation * 00017 * * 00018 * A pdf reference manual is also available. Both are usually delivered * 00019 * to your inbox within 20 minutes to two hours when purchased between 8am * 00020 * and 8pm GMT (although please allow up to 24 hours in case of * 00021 * exceptional circumstances). Thank you for your support! * 00022 * * 00023 *************************************************************************** 00024 00025 This file is part of the FreeRTOS distribution. 00026 00027 FreeRTOS is free software; you can redistribute it and/or modify it under 00028 the terms of the GNU General Public License (version 2) as published by the 00029 Free Software Foundation AND MODIFIED BY the FreeRTOS exception. 00030 ***NOTE*** The exception to the GPL is included to allow you to distribute 00031 a combined work that includes FreeRTOS without being obliged to provide the 00032 source code for proprietary components outside of the FreeRTOS kernel. 00033 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT 00034 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00035 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00036 more details. You should have received a copy of the GNU General Public 00037 License and the FreeRTOS license exception along with FreeRTOS; if not it 00038 can be viewed here: http://www.freertos.org/a00114.html and also obtained 00039 by writing to Richard Barry, contact details for whom are available on the 00040 FreeRTOS WEB site. 00041 00042 1 tab == 4 spaces! 00043 00044 http://www.FreeRTOS.org - Documentation, latest information, license and 00045 contact details. 00046 00047 http://www.SafeRTOS.com - A version that is certified for use in safety 00048 critical systems. 00049 00050 http://www.OpenRTOS.com - Commercial support, development, porting, 00051 licensing and training services. 00052 */ 00053 00054 #ifndef STACK_MACROS_H 00055 #define STACK_MACROS_H 00056 00057 /* 00058 * Call the stack overflow hook function if the stack of the task being swapped 00059 * out is currently overflowed, or looks like it might have overflowed in the 00060 * past. 00061 * 00062 * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 00063 * the current stack state only - comparing the current top of stack value to 00064 * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 00065 * will also cause the last few stack bytes to be checked to ensure the value 00066 * to which the bytes were set when the task was created have not been 00067 * overwritten. Note this second test does not guarantee that an overflowed 00068 * stack will always be recognised. 00069 */ 00070 00071 /*-----------------------------------------------------------*/ 00072 00073 #if( configCHECK_FOR_STACK_OVERFLOW == 0 ) 00074 00075 /* FreeRTOSConfig.h is not set to check for stack overflows. */ 00076 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() 00077 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() 00078 00079 #endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ 00080 /*-----------------------------------------------------------*/ 00081 00082 #if( configCHECK_FOR_STACK_OVERFLOW == 1 ) 00083 00084 /* FreeRTOSConfig.h is only set to use the first method of 00085 overflow checking. */ 00086 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() 00087 00088 #endif 00089 /*-----------------------------------------------------------*/ 00090 00091 #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) 00092 /* Only the current stack state is to be checked. */ 00093 // Modified by Kenji Arai / JH1PJL, October 31st,2010 00094 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ 00095 { \ 00096 extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \ 00097 \ 00098 /* Is the currently saved stack pointer within the stack limit? */ \ 00099 if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 00100 { \ 00101 vApplicationStackOverflowHook( ( xTaskHandle *) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00102 } \ 00103 } 00104 #endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ 00105 /*-----------------------------------------------------------*/ 00106 00107 #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) 00108 // Modified by Kenji Arai / JH1PJL, October 31st,2010 00109 /* Only the current stack state is to be checked. */ 00110 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ 00111 { \ 00112 extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \ 00113 \ 00114 /* Is the currently saved stack pointer within the stack limit? */ \ 00115 if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 00116 { \ 00117 vApplicationStackOverflowHook( ( xTaskHandle *) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00118 } \ 00119 } 00120 00121 #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 00122 /*-----------------------------------------------------------*/ 00123 00124 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 00125 // Modified by Kenji Arai / JH1PJL, October 31st,2010 00126 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ 00127 { \ 00128 extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \ 00129 static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00130 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00131 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00132 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00133 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 00134 \ 00135 \ 00136 /* Has the extremity of the task stack ever been written over? */ \ 00137 if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 00138 { \ 00139 vApplicationStackOverflowHook( ( xTaskHandle *) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00140 } \ 00141 } 00142 00143 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 00144 /*-----------------------------------------------------------*/ 00145 00146 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 00147 // Modified by Kenji Arai / JH1PJL, October 31st,2010 00148 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ 00149 { \ 00150 extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \ 00151 char *pcEndOfStack = ( char * ) pxCurrentTCB->pxEndOfStack; \ 00152 static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00153 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00154 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00155 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00156 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 00157 \ 00158 \ 00159 pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 00160 \ 00161 /* Has the extremity of the task stack ever been written over? */ \ 00162 if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 00163 { \ 00164 vApplicationStackOverflowHook( ( xTaskHandle *) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00165 } \ 00166 } 00167 00168 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 00169 /*-----------------------------------------------------------*/ 00170 00171 #endif /* STACK_MACROS_H */ 00172
Generated on Fri Jul 15 2022 10:21:25 by
1.7.2
