mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
acknowledge requests after handling them
This commit is contained in:
parent
7b46bc9703
commit
3b26c0b262
|
@ -4,16 +4,36 @@
|
||||||
.section .iwram, "ax"
|
.section .iwram, "ax"
|
||||||
.align
|
.align
|
||||||
InterruptHandler:
|
InterruptHandler:
|
||||||
ldr r2, =0x04000200 @ interrupt enable register location
|
mov r2, #0x04000000 @ interrupt enable register location
|
||||||
|
add r2, #0x200
|
||||||
|
|
||||||
mov r1, #0
|
mov r1, #0
|
||||||
strh r1, [r2, #8]
|
strh r1, [r2, #8]
|
||||||
|
|
||||||
push {r2}
|
|
||||||
|
|
||||||
ldrh r1, [r2] @ load 16 bit interrupt enable to r1
|
ldrh r1, [r2] @ load 16 bit interrupt enable to r1
|
||||||
ldrh r3, [r2, #2] @ load 16 bit interrupt request to r3
|
ldrh r3, [r2, #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
|
||||||
|
|
||||||
|
@ change to system mode
|
||||||
|
mrs r1, cpsr
|
||||||
|
orr r1, r1, #0xD
|
||||||
|
msr cpsr_c, r1
|
||||||
|
|
||||||
|
@ call the rust interrupt handler with r0 set to the triggered interrupts
|
||||||
|
ldr r1, =__RUST_INTERRUPT_HANDLER
|
||||||
|
push {lr, r2}
|
||||||
|
mov lr, pc
|
||||||
|
bx r1
|
||||||
|
pop {lr, r2}
|
||||||
|
|
||||||
|
@ change back to interrupt mode
|
||||||
|
mrs r1, cpsr
|
||||||
|
bic r1, r1, #0xD
|
||||||
|
msr cpsr_c, r1
|
||||||
|
|
||||||
|
mov r1, #1
|
||||||
|
strh r1, [r2, #8]
|
||||||
|
|
||||||
strh r0, [r2, #2] @ store to interrupt request
|
strh r0, [r2, #2] @ store to interrupt request
|
||||||
|
|
||||||
ldr r2, =0x03007FF8 @ load bios interrupt request location
|
ldr r2, =0x03007FF8 @ load bios interrupt request location
|
||||||
|
@ -21,27 +41,5 @@ InterruptHandler:
|
||||||
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 system mode
|
|
||||||
mrs r2, cpsr
|
|
||||||
orr r2, r2, #0xD
|
|
||||||
msr cpsr_c, r2
|
|
||||||
|
|
||||||
@ call the rust interrupt handler with r0 set to the triggered interrupts
|
|
||||||
ldr r1, =__RUST_INTERRUPT_HANDLER
|
|
||||||
push {lr}
|
|
||||||
mov lr, pc
|
|
||||||
bx r1
|
|
||||||
pop {lr}
|
|
||||||
|
|
||||||
@ change back to interrupt mode
|
|
||||||
mrs r2, cpsr
|
|
||||||
bic r2, r2, #0xD
|
|
||||||
msr cpsr_c, r2
|
|
||||||
|
|
||||||
pop {r2}
|
|
||||||
|
|
||||||
mov r1, #1
|
|
||||||
strh r1, [r2, #8]
|
|
||||||
|
|
||||||
bx lr @ return to bios
|
bx lr @ return to bios
|
||||||
.pool
|
.pool
|
||||||
|
|
|
@ -139,12 +139,14 @@ static mut INTERRUPT_TABLE: [InterruptRoot; 14] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn __RUST_INTERRUPT_HANDLER(interrupt: u16) {
|
extern "C" fn __RUST_INTERRUPT_HANDLER(interrupt: u16) -> u16 {
|
||||||
for (i, root) in unsafe { INTERRUPT_TABLE.iter().enumerate() } {
|
for (i, root) in unsafe { INTERRUPT_TABLE.iter().enumerate() } {
|
||||||
if (1 << i) & interrupt != 0 {
|
if (1 << i) & interrupt != 0 {
|
||||||
root.trigger_interrupts();
|
root.trigger_interrupts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InterruptClosureBounded<'a> {
|
pub struct InterruptClosureBounded<'a> {
|
||||||
|
|
Loading…
Reference in a new issue