You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aarch32-rt/src/arch_v4/interrupt.rs
+19-24Lines changed: 19 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -16,33 +16,28 @@ core::arch::global_asm!(
16
16
.global _asm_default_irq_handler
17
17
.type _asm_default_irq_handler, %function
18
18
_asm_default_irq_handler:
19
-
// make sure we jump back to the right place
20
-
sub lr, lr, 4
21
-
// save our LR
22
-
stmfd sp!, {{ lr }}
23
-
// The hardware has copied the interrupted task's CPSR to SPSR_irq
24
-
mrs lr, spsr
25
-
stmfd sp!, {{ lr }}
26
-
// switch to system mode so we can handle another interrupt
27
-
// (because if we interrupt irq mode we trash our own shadow registers)
28
-
msr cpsr_c, {sys_mode}
29
-
// save state to the system stack (adjusting SP for alignment)
30
-
"#,
31
-
crate::save_context!(),
19
+
sub lr, lr, 4 // make sure we jump back to the right place
20
+
push {{ lr }} // save adjusted LR to IRQ stack
21
+
mrs lr, spsr // The hardware has copied the interrupted task's CPSR to SPSR_irq - grab it and
22
+
push {{ lr }} // save it to IRQ stack using LR
23
+
msr cpsr_c, {sys_mode} // switch to system mode so we can handle another interrupt (because if we interrupt irq mode we trash our own shadow registers)
24
+
mov lr, sp // align SP down to eight byte boundary using LR
25
+
and lr, lr, 7 //
26
+
sub sp, lr // SP now aligned - only push 64-bit values from here
27
+
push {{ r0-r3, r12, lr }} // push alignment amount (in LR) and preserved registers
28
+
"#,
29
+
crate::save_fpu_context!(),
32
30
r#"
33
-
// call C handler (they may choose to re-enable interrupts)
34
-
bl _irq_handler
35
-
// restore from the system stack
31
+
bl _irq_handler // call C handler (they may choose to re-enable interrupts)
36
32
"#,
37
-
crate::restore_context!(),
33
+
crate::restore_fpu_context!(),
38
34
r#"
39
-
// switch back to IRQ mode (with IRQ masked)
40
-
msr cpsr_c, {irq_mode}
41
-
// load and restore SPSR
42
-
ldmia sp!, {{ lr }}
43
-
msr spsr, lr
44
-
// return
45
-
ldmfd sp!, {{ pc }}^
35
+
pop {{ r0-r3, r12, lr }} // restore alignment amount (in LR) and preserved registers
36
+
add sp, lr // restore SP alignment using LR
37
+
msr cpsr_c, {irq_mode} // switch back to IRQ mode (with IRQ masked)
38
+
pop {{ lr }} // load and restore SPSR using LR
39
+
msr spsr, lr //
40
+
ldmfd sp!, {{ pc }}^ // return from exception (^ => restore SPSR to CPSR)
0 commit comments