|
53 | 53 | #define portSTACK_LIMIT_PADDING 0 |
54 | 54 | #endif |
55 | 55 |
|
| 56 | +#ifndef portSTRIP_ADDRESS_TAG |
| 57 | + #define portSTRIP_ADDRESS_TAG( pxPointer ) ( pxPointer ) |
| 58 | +#endif |
| 59 | + |
56 | 60 | /* Stack overflow check is not straight forward to implement for MPU ports |
57 | 61 | * because of the following reasons: |
58 | 62 | * 1. The context is stored in TCB and as a result, pxTopOfStack member points |
|
67 | 71 | #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) ) |
68 | 72 |
|
69 | 73 | /* Only the current stack state is to be checked. */ |
70 | | - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
71 | | - do \ |
72 | | - { \ |
73 | | - /* Is the currently saved stack pointer within the stack limit? */ \ |
| 74 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 75 | + do \ |
| 76 | + { \ |
| 77 | + /* Is the currently saved stack pointer within the stack limit? */ \ |
74 | 78 | if( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \ |
75 | | - { \ |
76 | | - char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
77 | | - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ |
78 | | - } \ |
| 79 | + { \ |
| 80 | + char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
| 81 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ |
| 82 | + } \ |
79 | 83 | } while( 0 ) |
80 | 84 |
|
81 | 85 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ |
|
84 | 88 | #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) ) |
85 | 89 |
|
86 | 90 | /* Only the current stack state is to be checked. */ |
87 | | - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
88 | | - do \ |
89 | | - { \ |
90 | | - /* Is the currently saved stack pointer within the stack limit? */ \ |
| 91 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 92 | + do \ |
| 93 | + { \ |
| 94 | + /* Is the currently saved stack pointer within the stack limit? */ \ |
91 | 95 | if( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \ |
92 | | - { \ |
93 | | - char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
94 | | - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ |
95 | | - } \ |
| 96 | + { \ |
| 97 | + char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
| 98 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ |
| 99 | + } \ |
96 | 100 | } while( 0 ) |
97 | 101 |
|
98 | 102 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ |
99 | 103 | /*-----------------------------------------------------------*/ |
100 | 104 |
|
101 | 105 | #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) && ( portUSING_MPU_WRAPPERS != 1 ) ) |
102 | 106 |
|
103 | | - #define taskCHECK_FOR_STACK_OVERFLOW() \ |
104 | | - do \ |
105 | | - { \ |
106 | | - const uint32_t * const pulStack = ( uint32_t * ) portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxStack ); \ |
107 | | - const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \ |
108 | | - \ |
109 | | - if( ( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) <= ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxStack ) + portSTACK_LIMIT_PADDING ) || \ |
110 | | - ( pulStack[ 0 ] != ulCheckValue ) || \ |
111 | | - ( pulStack[ 1 ] != ulCheckValue ) || \ |
112 | | - ( pulStack[ 2 ] != ulCheckValue ) || \ |
113 | | - ( pulStack[ 3 ] != ulCheckValue ) ) \ |
114 | | - { \ |
115 | | - char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
116 | | - vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ |
117 | | - } \ |
| 107 | + #define taskCHECK_FOR_STACK_OVERFLOW() \ |
| 108 | + do \ |
| 109 | + { \ |
| 110 | + const uint32_t * const pulStack = ( uint32_t * ) portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxStack ); \ |
| 111 | + const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \ |
| 112 | + \ |
| 113 | + if( ( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) || \ |
| 114 | + ( pulStack[ 0 ] != ulCheckValue ) || \ |
| 115 | + ( pulStack[ 1 ] != ulCheckValue ) || \ |
| 116 | + ( pulStack[ 2 ] != ulCheckValue ) || \ |
| 117 | + ( pulStack[ 3 ] != ulCheckValue ) ) \ |
| 118 | + { \ |
| 119 | + char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
| 120 | + vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \ |
| 121 | + } \ |
118 | 122 | } while( 0 ) |
119 | 123 |
|
120 | 124 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ |
|
134 | 138 | \ |
135 | 139 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ |
136 | 140 | \ |
137 | | - if( ( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \ |
| 141 | + if( ( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \ |
138 | 142 | ( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) ) \ |
139 | 143 | { \ |
140 | 144 | char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \ |
|
0 commit comments