www.freertos.org
Dependents: Nucleo freertos_test FreeRTOS_test freertos_bluetooth ... more
StackMacros.h
00001 /* 00002 FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. 00003 All rights reserved 00004 00005 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 00006 00007 *************************************************************************** 00008 * * 00009 * FreeRTOS provides completely free yet professionally developed, * 00010 * robust, strictly quality controlled, supported, and cross * 00011 * platform software that has become a de facto standard. * 00012 * * 00013 * Help yourself get started quickly and support the FreeRTOS * 00014 * project by purchasing a FreeRTOS tutorial book, reference * 00015 * manual, or both from: http://www.FreeRTOS.org/Documentation * 00016 * * 00017 * Thank you! * 00018 * * 00019 *************************************************************************** 00020 00021 This file is part of the FreeRTOS distribution. 00022 00023 FreeRTOS is free software; you can redistribute it and/or modify it under 00024 the terms of the GNU General Public License (version 2) as published by the 00025 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. 00026 00027 >>! NOTE: The modification to the GPL is included to allow you to distribute 00028 >>! a combined work that includes FreeRTOS without being obliged to provide 00029 >>! the source code for proprietary components outside of the FreeRTOS 00030 >>! kernel. 00031 00032 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 00033 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00034 FOR A PARTICULAR PURPOSE. Full license text is available from the following 00035 link: http://www.freertos.org/a00114.html 00036 00037 1 tab == 4 spaces! 00038 00039 *************************************************************************** 00040 * * 00041 * Having a problem? Start by reading the FAQ "My application does * 00042 * not run, what could be wrong?" * 00043 * * 00044 * http://www.FreeRTOS.org/FAQHelp.html * 00045 * * 00046 *************************************************************************** 00047 00048 http://www.FreeRTOS.org - Documentation, books, training, latest versions, 00049 license and Real Time Engineers Ltd. contact details. 00050 00051 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 00052 including FreeRTOS+Trace - an indispensable productivity tool, a DOS 00053 compatible FAT file system, and our tiny thread aware UDP/IP stack. 00054 00055 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High 00056 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS 00057 licenses offer ticketed support, indemnification and middleware. 00058 00059 http://www.SafeRTOS.com - High Integrity Systems also provide a safety 00060 engineered and independently SIL3 certified version for use in safety and 00061 mission critical applications that require provable dependability. 00062 00063 1 tab == 4 spaces! 00064 */ 00065 00066 #ifndef STACK_MACROS_H 00067 #define STACK_MACROS_H 00068 00069 /* 00070 * Call the stack overflow hook function if the stack of the task being swapped 00071 * out is currently overflowed, or looks like it might have overflowed in the 00072 * past. 00073 * 00074 * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 00075 * the current stack state only - comparing the current top of stack value to 00076 * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 00077 * will also cause the last few stack bytes to be checked to ensure the value 00078 * to which the bytes were set when the task was created have not been 00079 * overwritten. Note this second test does not guarantee that an overflowed 00080 * stack will always be recognised. 00081 */ 00082 00083 /*-----------------------------------------------------------*/ 00084 00085 #if( configCHECK_FOR_STACK_OVERFLOW == 0 ) 00086 00087 /* FreeRTOSConfig.h is not set to check for stack overflows. */ 00088 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() 00089 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() 00090 00091 #endif /* configCHECK_FOR_STACK_OVERFLOW == 0 */ 00092 /*-----------------------------------------------------------*/ 00093 00094 #if( configCHECK_FOR_STACK_OVERFLOW == 1 ) 00095 00096 /* FreeRTOSConfig.h is only set to use the first method of 00097 overflow checking. */ 00098 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() 00099 00100 #endif 00101 /*-----------------------------------------------------------*/ 00102 00103 #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) 00104 00105 /* Only the current stack state is to be checked. */ 00106 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ 00107 { \ 00108 /* Is the currently saved stack pointer within the stack limit? */ \ 00109 if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 00110 { \ 00111 vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00112 } \ 00113 } 00114 00115 #endif /* configCHECK_FOR_STACK_OVERFLOW > 0 */ 00116 /*-----------------------------------------------------------*/ 00117 00118 #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) 00119 00120 /* Only the current stack state is to be checked. */ 00121 #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ 00122 { \ 00123 \ 00124 /* Is the currently saved stack pointer within the stack limit? */ \ 00125 if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 00126 { \ 00127 vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00128 } \ 00129 } 00130 00131 #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 00132 /*-----------------------------------------------------------*/ 00133 00134 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 00135 00136 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ 00137 { \ 00138 static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00139 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00140 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00141 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00142 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 00143 \ 00144 \ 00145 /* Has the extremity of the task stack ever been written over? */ \ 00146 if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 00147 { \ 00148 vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00149 } \ 00150 } 00151 00152 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 00153 /*-----------------------------------------------------------*/ 00154 00155 #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 00156 00157 #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ 00158 { \ 00159 char *pcEndOfStack = ( char * ) pxCurrentTCB->pxEndOfStack; \ 00160 static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00161 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00162 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00163 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 00164 tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 00165 \ 00166 \ 00167 pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 00168 \ 00169 /* Has the extremity of the task stack ever been written over? */ \ 00170 if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 00171 { \ 00172 vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 00173 } \ 00174 } 00175 00176 #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 00177 /*-----------------------------------------------------------*/ 00178 00179 #endif /* STACK_MACROS_H */ 00180
Generated on Tue Jul 12 2022 11:36:40 by
![doxygen](doxygen.png)