Skip to content

Commit a9b0501

Browse files
Merge pull request #143 from rust-embedded/possible-fix-arch_v4-interrupt-handler
possible fix for pre ARMv7 ASM interrupt handler
2 parents 27fc08c + 6cf3b41 commit a9b0501

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

aarch32-rt/src/arch_v4/interrupt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ core::arch::global_asm!(
2121
mrs lr, spsr // The hardware has copied the interrupted task's CPSR to SPSR_irq - grab it and
2222
push {{ lr }} // save it to IRQ stack using LR
2323
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+
push {{ lr }} // Save LR of system mode before using it for stack alignment
2425
mov lr, sp // align SP down to eight byte boundary using LR
2526
and lr, lr, 7 //
2627
sub sp, lr // SP now aligned - only push 64-bit values from here
@@ -34,6 +35,7 @@ core::arch::global_asm!(
3435
r#"
3536
pop {{ r0-r3, r12, lr }} // restore alignment amount (in LR) and preserved registers
3637
add sp, lr // restore SP alignment using LR
38+
pop {{ lr }} // Restore the actual link register of system mode.
3739
msr cpsr_c, {irq_mode} // switch back to IRQ mode (with IRQ masked)
3840
pop {{ lr }} // load and restore SPSR using LR
3941
msr spsr, lr //

0 commit comments

Comments
 (0)