Skip to content

Commit c1641e7

Browse files
committed
Reformat except.S
Tidy up formatting, and make all 3 toolchain versions more consistent, for ease of diffing and transferring changes between them.
1 parent 5e76548 commit c1641e7

File tree

3 files changed

+351
-353
lines changed

3 files changed

+351
-353
lines changed

platform/source/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S

Lines changed: 120 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -22,141 +22,141 @@
2222
; * -----------------------------------------------------------------------------
2323
; */
2424
#ifndef MBED_FAULT_HANDLER_DISABLED
25-
25+
2626
#ifndef DOMAIN_NS
2727
#define DOMAIN_NS 1
2828
#endif
29-
30-
FAULT_TYPE_HARD_FAULT EQU 0x10
31-
FAULT_TYPE_MEMMANAGE_FAULT EQU 0x20
32-
FAULT_TYPE_BUS_FAULT EQU 0x30
33-
FAULT_TYPE_USAGE_FAULT EQU 0x40
3429

35-
PRESERVE8
36-
THUMB
30+
FAULT_TYPE_HARD_FAULT EQU 0x10
31+
FAULT_TYPE_MEMMANAGE_FAULT EQU 0x20
32+
FAULT_TYPE_BUS_FAULT EQU 0x30
33+
FAULT_TYPE_USAGE_FAULT EQU 0x40
34+
35+
PRESERVE8
36+
THUMB
3737

38-
AREA |.text|, CODE, READONLY
38+
AREA |.text|, CODE, READONLY
3939

4040
HardFault_Handler\
41-
PROC
42-
EXPORT HardFault_Handler
43-
LDR R3,=FAULT_TYPE_HARD_FAULT
44-
B Fault_Handler
45-
ENDP
41+
PROC
42+
EXPORT HardFault_Handler
43+
LDR R3,=FAULT_TYPE_HARD_FAULT
44+
B Fault_Handler
45+
ENDP
4646

4747
MemManage_Handler\
48-
PROC
49-
EXPORT MemManage_Handler
50-
LDR R3,=FAULT_TYPE_MEMMANAGE_FAULT
51-
B Fault_Handler
52-
ENDP
53-
48+
PROC
49+
EXPORT MemManage_Handler
50+
LDR R3,=FAULT_TYPE_MEMMANAGE_FAULT
51+
B Fault_Handler
52+
ENDP
53+
5454
BusFault_Handler\
55-
PROC
56-
EXPORT BusFault_Handler
57-
LDR R3,=FAULT_TYPE_BUS_FAULT
58-
B Fault_Handler
59-
ENDP
55+
PROC
56+
EXPORT BusFault_Handler
57+
LDR R3,=FAULT_TYPE_BUS_FAULT
58+
B Fault_Handler
59+
ENDP
6060

6161
UsageFault_Handler\
62-
PROC
63-
EXPORT UsageFault_Handler
64-
LDR R3,=FAULT_TYPE_USAGE_FAULT
65-
B Fault_Handler
66-
ENDP
67-
68-
Fault_Handler PROC
69-
EXPORT Fault_Handler
62+
PROC
63+
EXPORT UsageFault_Handler
64+
LDR R3,=FAULT_TYPE_USAGE_FAULT
65+
B Fault_Handler
66+
ENDP
67+
68+
Fault_Handler\
69+
PROC
70+
EXPORT Fault_Handler
7071
#if (DOMAIN_NS == 1)
71-
IMPORT mbed_fault_handler
72-
IMPORT mbed_fault_context
73-
74-
MRS R0,MSP
75-
LDR R1,=0x4
76-
MOV R2,LR
77-
TST R2,R1 ; Check EXC_RETURN for bit 2
78-
BEQ Fault_Handler_Continue
79-
MRS R0,PSP
72+
IMPORT mbed_fault_context
73+
IMPORT mbed_fault_handler
74+
75+
MRS R0,MSP
76+
LDR R1,=0x4
77+
MOV R2,LR
78+
TST R2,R1 ; Check EXC_RETURN for bit 2
79+
BEQ Fault_Handler_Continue
80+
MRS R0,PSP
8081

8182
Fault_Handler_Continue
82-
MOV R12,R3
83-
LDR R3,=mbed_fault_context
84-
LDR R1,[R3]
85-
LDR R2,[R0] ; Capture R0
86-
STR R2,[R1]
87-
ADDS R1,#4
88-
LDR R2,[R0,#4] ; Capture R1
89-
STR R2,[R1]
90-
ADDS R1,#4
91-
LDR R2,[R0,#8] ; Capture R2
92-
STR R2,[R1]
93-
ADDS R1,#4
94-
LDR R2,[R0,#12] ; Capture R3
95-
STR R2,[R1]
96-
ADDS R1,#4
97-
STMIA R1!,{R4-R7} ; Capture R4..R7
98-
MOV R7,R8 ; Capture R8
99-
STR R7,[R1]
100-
ADDS R1,#4
101-
MOV R7,R9 ; Capture R9
102-
STR R7,[R1]
103-
ADDS R1,#4
104-
MOV R7,R10 ; Capture R10
105-
STR R7,[R1]
106-
ADDS R1,#4
107-
MOV R7,R11 ; Capture R11
108-
STR R7,[R1]
109-
ADDS R1,#4
110-
LDR R2,[R0,#16] ; Capture R12
111-
STR R2,[R1]
112-
ADDS R1,#8 ; Add 8 here to capture LR next, we will capture SP later
113-
LDR R2,[R0,#20] ; Capture LR
114-
STR R2,[R1]
115-
ADDS R1,#4
116-
LDR R2,[R0,#24] ; Capture PC
117-
STR R2,[R1]
118-
ADDS R1,#4
119-
LDR R2,[R0,#28] ; Capture xPSR
120-
STR R2,[R1]
121-
ADDS R1,#4
122-
; Adjust stack pointer to its original value and capture it
123-
MOV R3,R0
124-
ADDS R3,#0x20 ; Add 0x20 to get the SP value prior to exception
125-
LDR R6,=0x200
126-
TST R2,R6 ; Check for if STK was aligned by checking bit-9 in xPSR value
127-
BEQ Fault_Handler_Continue1
128-
ADDS R3,#0x4
83+
MOV R12,R3
84+
LDR R3,=mbed_fault_context
85+
LDR R1,[R3]
86+
LDR R2,[R0] ; Capture R0
87+
STR R2,[R1]
88+
ADDS R1,#4
89+
LDR R2,[R0,#4] ; Capture R1
90+
STR R2,[R1]
91+
ADDS R1,#4
92+
LDR R2,[R0,#8] ; Capture R2
93+
STR R2,[R1]
94+
ADDS R1,#4
95+
LDR R2,[R0,#12] ; Capture R3
96+
STR R2,[R1]
97+
ADDS R1,#4
98+
STMIA R1!,{R4-R7} ; Capture R4..R7
99+
MOV R7,R8 ; Capture R8
100+
STR R7,[R1]
101+
ADDS R1,#4
102+
MOV R7,R9 ; Capture R9
103+
STR R7,[R1]
104+
ADDS R1,#4
105+
MOV R7,R10 ; Capture R10
106+
STR R7,[R1]
107+
ADDS R1,#4
108+
MOV R7,R11 ; Capture R11
109+
STR R7,[R1]
110+
ADDS R1,#4
111+
LDR R2,[R0,#16] ; Capture R12
112+
STR R2,[R1]
113+
ADDS R1,#8 ; Add 8 here to capture LR next, we will capture SP later
114+
LDR R2,[R0,#20] ; Capture LR
115+
STR R2,[R1]
116+
ADDS R1,#4
117+
LDR R2,[R0,#24] ; Capture PC
118+
STR R2,[R1]
119+
ADDS R1,#4
120+
LDR R2,[R0,#28] ; Capture xPSR
121+
STR R2,[R1]
122+
ADDS R1,#4
123+
; Adjust stack pointer to its original value and capture it
124+
MOV R3,R0
125+
ADDS R3,#0x20 ; Add 0x20 to get the SP value prior to exception
126+
LDR R6,=0x200
127+
TST R2,R6 ; Check for if STK was aligned by checking bit-9 in xPSR value
128+
BEQ Fault_Handler_Continue1
129+
ADDS R3,#0x4
129130

130131
Fault_Handler_Continue1
131-
MOV R5,LR
132-
LDR R6,=0x10 ; Check for bit-4 to see if FP context was saved
133-
TST R5,R6
134-
BNE Fault_Handler_Continue2
135-
ADDS R3,#0x48 ; 16 FP regs + FPCSR + 1 Reserved
136-
137-
Fault_Handler_Continue2
138-
MOV R4,R1
139-
SUBS R4,#0x10 ; Set the location of SP in ctx
140-
STR R3,[R4] ; Capture the adjusted SP
141-
MRS R2,PSP ; Get PSP
142-
STR R2,[R1]
143-
ADDS R1,#4
144-
MRS R2,MSP ; Get MSP
145-
STR R2,[R1]
146-
ADDS R1,#4
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-
MOV R0,R12
153-
LDR R3,=mbed_fault_context
154-
LDR R1,[R3]
155-
BL mbed_fault_handler
156-
#endif
157-
B . ; Just in case we come back here
158-
ENDP
159-
132+
MOV R5,LR
133+
LDR R6,=0x10 ; Check for bit-4 to see if FP context was saved
134+
TST R5,R6
135+
BNE Fault_Handler_Continue2
136+
ADDS R3,#0x48 ; 16 FP regs + FPCSR + 1 Reserved
137+
138+
Fault_Handler_Continue2
139+
MOV R4,R1
140+
SUBS R4,#0x10 ; Set the location of SP in ctx
141+
STR R3,[R4] ; Capture the adjusted SP
142+
MRS R2,PSP ; Get PSP
143+
STR R2,[R1]
144+
ADDS R1,#4
145+
MRS R2,MSP ; Get MSP
146+
STR R2,[R1]
147+
ADDS R1,#4
148+
MOV R2,LR ; Get current LR(EXC_RETURN)
149+
STR R2,[R1]
150+
ADDS R1,#4
151+
MRS R2,CONTROL ; Get CONTROL Reg
152+
STR R2,[R1]
153+
MOV R0,R12
154+
LDR R3,=mbed_fault_context
155+
LDR R1,[R3]
156+
BL mbed_fault_handler
160157
#endif
161-
162-
END
158+
B . ; Just in case we come back here
159+
ENDP
160+
#endif
161+
162+
END

0 commit comments

Comments
 (0)