Skip to content

Commit 2c3ce96

Browse files
authored
Merge pull request #11272 from andrewc-arm/pr_mbed_fault_context01
mbed fault handler: fix mbed_fault_context parameter
2 parents 14021eb + 9edfad4 commit 2c3ce96

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

platform/source/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ Fault_Handler_Continue2
150150
MRS R2,CONTROL ; Get CONTROL Reg
151151
STR R2,[R1]
152152
MOV R0,R12
153-
LDR R1,=mbed_fault_context
153+
LDR R3,=mbed_fault_context
154+
LDR R1,[R3]
154155
BL mbed_fault_handler
155156
#endif
156157
B . ; Just in case we come back here

platform/source/TARGET_CORTEX_M/TOOLCHAIN_GCC/except.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ Fault_Handler_Continue2:
183183
MRS R2,CONTROL // Get CONTROL Reg
184184
STR R2,[R1]
185185
MOV R0,R12
186-
LDR R1,=mbed_fault_context
186+
LDR R3,=mbed_fault_context
187+
LDR R1,[R3]
187188
BL mbed_fault_handler
188189
#endif
189190
B . // Just in case we come back here

platform/source/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ Fault_Handler_Continue2
145145
MRS R2,CONTROL ; Get CONTROL Reg
146146
STR R2,[R1]
147147
MOV R0,R12
148-
LDR R1,=mbed_fault_context
148+
LDR R3,=mbed_fault_context
149+
LDR R1,[R3]
149150
BL mbed_fault_handler
150151
#endif
151152
B . ; Just in case we come back here

platform/source/TARGET_CORTEX_M/mbed_fault_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ void print_context_info(void);
3636
mbed_fault_context_t *const mbed_fault_context = (mbed_fault_context_t *)(FAULT_CONTEXT_LOCATION);
3737
#else
3838
mbed_fault_context_t fault_context;
39-
mbed_fault_context_t *const mbed_fault_context = (mbed_fault_context_t *) &fault_context;
39+
mbed_fault_context_t *const mbed_fault_context = &fault_context;
4040
#endif
4141

4242
//This is a handler function called from Fault handler to print the error information out.
4343
//This runs in fault context and uses special functions(defined in mbed_rtx_fault_handler.c) to print the information without using C-lib support.
44-
void mbed_fault_handler(uint32_t fault_type, void *mbed_fault_context_in)
44+
void mbed_fault_handler(uint32_t fault_type, const mbed_fault_context_t *mbed_fault_context_in)
4545
{
4646
mbed_error_status_t faultStatus = MBED_SUCCESS;
4747

platform/source/TARGET_CORTEX_M/mbed_fault_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef struct {
5757

5858
//This is a handler function called from Fault handler to print the error information out.
5959
//This runs in fault context and uses special functions(defined in mbed_fault_handler.c) to print the information without using C-lib support.
60-
void mbed_fault_handler(uint32_t fault_type, void *mbed_fault_context_in);
60+
void mbed_fault_handler(uint32_t fault_type, const mbed_fault_context_t *mbed_fault_context_in);
6161

6262
/**
6363
* Call this function to retrieve the fault context after a fatal exception which triggered a system reboot. The function retrieves the fault context stored in crash-report ram area which is preserved over reboot.

0 commit comments

Comments
 (0)