File tree Expand file tree Collapse file tree 5 files changed +44
-7
lines changed
rtos/TARGET_CORTEX/TARGET_CORTEX_M Expand file tree Collapse file tree 5 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -144,13 +144,18 @@ Fault_Handler_Continue2
144
144
MRS R2 , MSP ; Get MSP
145
145
STR R2 ,[ R1 ]
146
146
ADDS R1 , # 4
147
- LDR R3 , =mbed_fault_handler ; Load address of mbedFaultHandler
147
+ MOV R2 , LR ; Get current LR(EXC_RETURN)
148
+ STR R2 ,[ R1 ]
149
+ ADDS R1 , # 4
150
+ MRS R2 , CONTROL ; Get CONTROL Reg
151
+ STR R2 ,[ R1 ]
152
+ LDR R3 , =mbed_fault_handler ; Load address of mbedFaultHandler
148
153
MOV R0 , R12
149
154
LDR R1 , =mbed_fault_context
150
155
LDR R2 , =osRtxInfo
151
156
BLX R3
152
157
#endif
153
- B . ; Just in case we come back here
158
+ B . ; Just in case we come back here
154
159
ENDP
155
160
156
161
#endif
Original file line number Diff line number Diff line change @@ -176,7 +176,12 @@ Fault_Handler_Continue2:
176
176
MRS R2 , MSP // Get MSP
177
177
STR R2 ,[ R1 ]
178
178
ADDS R1 , # 4
179
- LDR R3 , =mbed_fault_handler // Load address of mbedFaultHandler
179
+ MOV R2 , LR // Get current LR(EXC_RETURN)
180
+ STR R2 ,[ R1 ]
181
+ ADDS R1 , # 4
182
+ MRS R2 , CONTROL // Get CONTROL Reg
183
+ STR R2 ,[ R1 ]
184
+ LDR R3 , =mbed_fault_handler // Load address of mbedFaultHandler
180
185
MOV R0 , R12
181
186
LDR R1 , =mbed_fault_context
182
187
LDR R2 , =osRtxInfo
Original file line number Diff line number Diff line change @@ -139,13 +139,18 @@ Fault_Handler_Continue2
139
139
MRS R2 , MSP ; Get MSP
140
140
STR R2 ,[ R1 ]
141
141
ADDS R1 , # 4
142
- LDR R3 , =mbed_fault_handler ; Load address of mbedFaultHandler
142
+ MOV R2 , LR ; Get current LR(EXC_RETURN)
143
+ STR R2 ,[ R1 ]
144
+ ADDS R1 , # 4
145
+ MRS R2 , CONTROL ; Get CONTROL Reg
146
+ STR R2 ,[ R1 ]
147
+ LDR R3 , =mbed_fault_handler ; Load address of mbedFaultHandler
143
148
MOV R0 , R12
144
149
LDR R1 , =mbed_fault_context
145
150
LDR R2 , =osRtxInfo
146
151
BLX R3
147
152
#endif
148
- B . ; Just in case we come back here
149
- #endif ; #if (MBED_FAULT_HANDLER_SUPPORT == 1)
153
+ B . ; Just in case we come back here
154
+ #endif ; #if (MBED_FAULT_HANDLER_SUPPORT == 1)
150
155
151
156
END
Original file line number Diff line number Diff line change @@ -143,7 +143,27 @@ void print_context_info()
143
143
fault_print_str ("\nBFAR : %" ,(uint32_t * )& SCB -> BFAR );
144
144
}
145
145
#endif
146
-
146
+ //Print Mode
147
+ if (mbed_fault_context .EXC_RETURN & 0x8 ) {
148
+ fault_print_str ("\nMode : Thread" , NULL );
149
+ //Print Priv level in Thread mode - We capture CONTROL reg which reflects the privilege.
150
+ //Note that the CONTROL register captured still reflects the privilege status of the
151
+ //thread mode eventhough we are in Handler mode by the time we capture it.
152
+ if (mbed_fault_context .CONTROL & 0x1 ) {
153
+ fault_print_str ("\nPriv : User" , NULL );
154
+ } else {
155
+ fault_print_str ("\nPriv : Privileged" , NULL );
156
+ }
157
+ } else {
158
+ fault_print_str ("\nMode : Handler" , NULL );
159
+ fault_print_str ("\nPriv : Privileged" , NULL );
160
+ }
161
+ //Print Return Stack
162
+ if (mbed_fault_context .EXC_RETURN & 0x4 ) {
163
+ fault_print_str ("\nStack: PSP" , NULL );
164
+ } else {
165
+ fault_print_str ("\nStack: MSP" , NULL );
166
+ }
147
167
}
148
168
149
169
/* Prints thread info from a list */
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ typedef struct {
37
37
uint32_t xPSR ;
38
38
uint32_t PSP ;
39
39
uint32_t MSP ;
40
+ uint32_t EXC_RETURN ;
41
+ uint32_t CONTROL ;
40
42
} mbed_fault_context_t ;
41
43
42
44
//Fault type definitions
You can’t perform that action at this time.
0 commit comments