disable interrupts during the interrupt handler

This commit is contained in:
Corwin Kuiper 2021-06-23 19:06:24 +01:00
parent dacdf51dca
commit 2ff9644310

View file

@ -3,33 +3,43 @@
.global InterruptHandlerSimple .global InterruptHandlerSimple
.align .align
InterruptHandlerSimple: InterruptHandlerSimple:
ldr r2, =0x04000200 @ interrupt enable register location ldr r4, =0x04000200 @ interrupt enable register location
ldrh r1, [r2] @ load 16 bit interrupt enable to r1
ldrh r3, [r2, #2] @ load 16 bit interrupt request to r3 @ disable interrupts by setting bit 0 to 0
strh r2, [r4, #8]
ldrh r1, [r4] @ load 16 bit interrupt enable to r1
ldrh r3, [r4, #2] @ load 16 bit interrupt request to r3
and r0, r1, r3 @ interrupts both enabled and requested and r0, r1, r3 @ interrupts both enabled and requested
strh r0, [r2, #2] @ store to interrupt request strh r0, [r4, #2] @ store to interrupt request
ldr r2, =0x03007FF8 @ load bios interrupt request location ldr r2, =0x03007FF8 @ load bios interrupt request location
ldrh r1, [r2] @ load bios interrupt requests ldrh r1, [r2] @ load bios interrupt requests
orr r1, r1, r0 @ or with enabled and requested interrupts orr r1, r1, r0 @ or with enabled and requested interrupts
strh r1, [r2] @ acknowlege bios requests strh r1, [r2] @ acknowlege bios requests
@ change to user mode
mrs r2, cpsr mrs r2, cpsr
orr r2, r2, #0xD orr r2, r2, #0xD
msr cpsr_c, r2 msr cpsr_c, r2
@ call the rust interrupt handler with r0 set to the triggered interrupts
ldr r1, =__RUST_INTERRUPT_HANDLER ldr r1, =__RUST_INTERRUPT_HANDLER
push {lr} push {lr, r4}
adr lr, .IReturn adr lr, .IReturn
bx r1 bx r1
.IReturn: .IReturn:
pop {lr} pop {lr, r4}
@ change back to interuupt mode
mrs r2, cpsr mrs r2, cpsr
bic r2, r2, #0xD bic r2, r2, #0xD
orr r2, r2, #0x92 orr r2, r2, #0x92
msr cpsr_c, r2 msr cpsr_c, r2
@ reenable interrupts by setting bit 0 to 1
mov r0, #1
strh r0, [r4, #8]
bx lr @ return to bios bx lr @ return to bios
.pool .pool