Skip to content

Commit 18540a1

Browse files
ArcaneNibbledlech
authored andcommitted
pbio/platform/ev3/exceptionhandler.S: Remove SWI handler
This handler was copied from an existing project template. We do not use SWI opcodes in this firmware, so replace it with a panic handler.
1 parent 0c1271f commit 18540a1

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

lib/pbio/platform/ev3/exceptionhandler.S

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
.set MODE_SYS, 0x1F
1212
1313

14-
.equ I_F_BIT, 0xC0
15-
.equ MASK_SWI_NUM, 0xFF000000
14+
.equ I_F_BIT, 0xC0
1615
.equ MASK_SR_MODE, 0x1F
1716

1817
@ This will be placed at 0xffff0000 by the linker script
@@ -52,6 +51,12 @@ UnknownExceptionHandler:
5251
@ Save r0-r12, lr
5352
stmfd sp!, {r0-r12, lr}
5453
mov r7, #EV3_PANIC_UNKNOWN
54+
b CommonPanicHandler
55+
56+
SWIHandler:
57+
@ Save r0-r12, lr
58+
stmfd sp!, {r0-r12, lr}
59+
mov r7, #EV3_PANIC_SWI
5560
@ b CommonPanicHandler
5661
@ fall through
5762

@@ -87,25 +92,7 @@ FIQHandler:
8792
MOV lr, pc
8893
LDR pc, [r0]
8994
LDMFD r13!, {r0-r7, lr}
90-
SUBS pc, lr, #0x4
91-
92-
@******************************************************************************
93-
@* Function Definition of SWI Handler
94-
@******************************************************************************
95-
@
96-
@ The SWI Handler switches to system mode if the SWI number is 458752. If the
97-
@ SWI number is different, no mode switching will be done. No other SWI are
98-
@ handled here
99-
@
100-
SWIHandler:
101-
STMFD r13!, {r0-r1, r14} @ Save context in SVC stack
102-
LDR r0, [r14, #-4] @ R0 points to SWI instruction
103-
BIC r0, r0, #MASK_SWI_NUM @ Get the SWI number
104-
CMP r0, #458752
105-
MRSEQ r1, spsr @ Copy SPSR
106-
ORREQ r1, r1, #0x1F @ Change the mode to System
107-
MSREQ spsr_cf, r1 @ Restore SPSR
108-
LDMFD r13!, {r0-r1, pc}^ @ Restore registers from IRQ stack
95+
SUBS pc, lr, #0x4
10996

11097
@******************************************************************************
11198
@* Function Definition of IRQ Handler

lib/pbio/platform/ev3/exceptionhandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
#define EV3_PANIC_UNDEFINED_INSTR 1
66
#define EV3_PANIC_PREFETCH_ABORT 2
77
#define EV3_PANIC_DATA_ABORT 3
8+
#define EV3_PANIC_SWI 4
89

910
#endif // PBIO_EV3_EXCEPTIONHANDLER_H_

lib/pbio/platform/ev3/platform.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ static const char *const panic_types[] = {
419419
"Undefined Instruction",
420420
"Prefetch Abort",
421421
"Data Abort",
422+
"SWI opcode"
422423
};
423424

424425
typedef struct {

0 commit comments

Comments
 (0)