|
66 | 66 | */
|
67 | 67 | #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
|
68 | 68 |
|
| 69 | + #if ( configNUMBER_OF_CORES == 1 ) |
| 70 | + |
69 | 71 | /* Only the current stack state is to be checked. */
|
70 |
| - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 72 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
71 | 73 | do \
|
72 | 74 | { \
|
73 | 75 | /* Is the currently saved stack pointer within the stack limit? */ \
|
|
78 | 80 | } \
|
79 | 81 | } while( 0 )
|
80 | 82 |
|
| 83 | + #else /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 84 | + |
| 85 | +/* Only the current stack state is to be checked. */ |
| 86 | + #define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \ |
| 87 | + do \ |
| 88 | + { \ |
| 89 | + TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \ |
| 90 | + \ |
| 91 | + /* Is the currently saved stack pointer within the stack limit? */ \ |
| 92 | + if( pxTCB->pxTopOfStack <= pxTCB->pxStack + portSTACK_LIMIT_PADDING ) \ |
| 93 | + { \ |
| 94 | + char * pcOverflowTaskName = pxTCB->pcTaskName; \ |
| 95 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \ |
| 96 | + } \ |
| 97 | + } while( 0 ) |
| 98 | + |
| 99 | + #endif /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 100 | + |
81 | 101 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
|
82 | 102 | /*-----------------------------------------------------------*/
|
83 | 103 |
|
84 | 104 | #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
|
85 | 105 |
|
| 106 | + #if ( configNUMBER_OF_CORES == 1 ) |
| 107 | + |
86 | 108 | /* Only the current stack state is to be checked. */
|
87 |
| - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 109 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
88 | 110 | do \
|
89 | 111 | { \
|
90 | 112 | /* Is the currently saved stack pointer within the stack limit? */ \
|
|
95 | 117 | } \
|
96 | 118 | } while( 0 )
|
97 | 119 |
|
| 120 | + #else /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 121 | + |
| 122 | +/* Only the current stack state is to be checked. */ |
| 123 | + #define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \ |
| 124 | + do \ |
| 125 | + { \ |
| 126 | + TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \ |
| 127 | + \ |
| 128 | + /* Is the currently saved stack pointer within the stack limit? */ \ |
| 129 | + if( pxTCB->pxTopOfStack >= pxTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \ |
| 130 | + { \ |
| 131 | + char * pcOverflowTaskName = pxTCB->pcTaskName; \ |
| 132 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \ |
| 133 | + } \ |
| 134 | + } while( 0 ) |
| 135 | + |
| 136 | + #endif /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 137 | + |
98 | 138 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
|
99 | 139 | /*-----------------------------------------------------------*/
|
100 | 140 |
|
101 | 141 | #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
|
102 | 142 |
|
103 |
| - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 143 | + #if ( configNUMBER_OF_CORES == 1 ) |
| 144 | + |
| 145 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
104 | 146 | do \
|
105 | 147 | { \
|
106 | 148 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
|
|
117 | 159 | } \
|
118 | 160 | } while( 0 )
|
119 | 161 |
|
| 162 | + #else /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 163 | + |
| 164 | + #define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \ |
| 165 | + do \ |
| 166 | + { \ |
| 167 | + TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \ |
| 168 | + const uint32_t * const pulStack = ( uint32_t * ) pxTCB->pxStack; \ |
| 169 | + const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \ |
| 170 | + \ |
| 171 | + if( ( pxTCB->pxTopOfStack <= pxTCB->pxStack + portSTACK_LIMIT_PADDING ) || \ |
| 172 | + ( pulStack[ 0 ] != ulCheckValue ) || \ |
| 173 | + ( pulStack[ 1 ] != ulCheckValue ) || \ |
| 174 | + ( pulStack[ 2 ] != ulCheckValue ) || \ |
| 175 | + ( pulStack[ 3 ] != ulCheckValue ) ) \ |
| 176 | + { \ |
| 177 | + char * pcOverflowTaskName = pxTCB->pcTaskName; \ |
| 178 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \ |
| 179 | + } \ |
| 180 | + } while( 0 ) |
| 181 | + |
| 182 | + #endif /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 183 | + |
120 | 184 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
|
121 | 185 | /*-----------------------------------------------------------*/
|
122 | 186 |
|
123 | 187 | #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) )
|
124 | 188 |
|
125 |
| - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 189 | + #if ( configNUMBER_OF_CORES == 1 ) |
| 190 | + |
| 191 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
126 | 192 | do \
|
127 | 193 | { \
|
128 | 194 | int8_t * pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
|
|
142 | 208 | } \
|
143 | 209 | } while( 0 )
|
144 | 210 |
|
| 211 | + #else /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 212 | + |
| 213 | + #define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) \ |
| 214 | + do \ |
| 215 | + { \ |
| 216 | + TCB_t * pxTCB = pxCurrentTCBs[ xCoreID ]; \ |
| 217 | + int8_t * pcEndOfStack = ( int8_t * ) pxTCB->pxEndOfStack; \ |
| 218 | + static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ |
| 219 | + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ |
| 220 | + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ |
| 221 | + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ |
| 222 | + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ |
| 223 | + \ |
| 224 | + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ |
| 225 | + \ |
| 226 | + if( ( pxTCB->pxTopOfStack >= pxTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \ |
| 227 | + ( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) ) \ |
| 228 | + { \ |
| 229 | + char * pcOverflowTaskName = pxTCB->pcTaskName; \ |
| 230 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxTCB, pcOverflowTaskName ); \ |
| 231 | + } \ |
| 232 | + } while( 0 ) |
| 233 | + |
| 234 | + #endif /* if ( configNUMBER_OF_CORES == 1 ) */ |
| 235 | + |
145 | 236 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
|
146 | 237 | /*-----------------------------------------------------------*/
|
147 | 238 |
|
148 | 239 | /* Remove stack overflow macro if not being used. */
|
149 | 240 | #ifndef taskCHECK_FOR_STACK_OVERFLOW
|
150 |
| - #define taskCHECK_FOR_STACK_OVERFLOW() |
| 241 | + #if ( configNUMBER_OF_CORES == 1 ) |
| 242 | + #define taskCHECK_FOR_STACK_OVERFLOW() |
| 243 | + #else |
| 244 | + #define taskCHECK_FOR_STACK_OVERFLOW( xCoreID ) |
| 245 | + #endif |
151 | 246 | #endif
|
152 | 247 |
|
153 | 248 |
|
|
0 commit comments