1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** ThreadX Component */
17 /** */
18 /** Thread */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define TX_SOURCE_CODE
24
25
26 /* Include necessary system files. */
27
28 #include "tx_api.h"
29 #if defined(TX_MISRA_ENABLE) || defined(TX_ENABLE_STACK_CHECKING) || defined(TX_PORT_THREAD_STACK_ERROR_HANDLING)
30 #include "tx_thread.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _tx_thread_stack_error_handler PORTABLE C */
38 /* 6.1.9 */
39 /* AUTHOR */
40 /* */
41 /* William E. Lamie, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function processes stack errors detected during run-time. The */
46 /* processing currently consists of a spin loop. */
47 /* */
48 /* INPUT */
49 /* */
50 /* thread_ptr Thread control block pointer */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* None */
55 /* */
56 /* CALLS */
57 /* */
58 /* None */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* ThreadX internal code */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
69 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
70 /* update misra support, */
71 /* resulting in version 6.1 */
72 /* 10-16-2020 William E. Lamie Modified comment(s), */
73 /* fixed link issue, */
74 /* resulting in version 6.1.1 */
75 /* 06-02-2021 William E. Lamie Modified comment(s), */
76 /* fixed link issue, added */
77 /* conditional compilation */
78 /* for ARMv8-M (Cortex M23/33) */
79 /* resulting in version 6.1.7 */
80 /* 10-15-2021 Yuxin Zhou Modified comment(s), improved */
81 /* stack check error handling, */
82 /* resulting in version 6.1.9 */
83 /* */
84 /**************************************************************************/
_tx_thread_stack_error_handler(TX_THREAD * thread_ptr)85 VOID _tx_thread_stack_error_handler(TX_THREAD *thread_ptr)
86 {
87
88 TX_INTERRUPT_SAVE_AREA
89
90 #if defined(TX_ENABLE_STACK_CHECKING) || defined(TX_PORT_THREAD_STACK_ERROR_HANDLING)
91
92 /* Disable interrupts. */
93 TX_DISABLE
94
95 /* Determine if the application has registered an error handler. */
96 if (_tx_thread_application_stack_error_handler != TX_NULL)
97 {
98
99 /* Yes, an error handler is present, simply call the application error handler. */
100 (_tx_thread_application_stack_error_handler)(thread_ptr);
101 }
102
103 /* Restore interrupts. */
104 TX_RESTORE
105
106 #else
107
108 /* Access input argument just for the sake of lint, MISRA, etc. */
109 if (thread_ptr != TX_NULL)
110 {
111
112 /* Disable interrupts. */
113 TX_DISABLE
114
115 /* Restore interrupts. */
116 TX_RESTORE
117 }
118 #endif
119 }
120 #endif
121