aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxetc/interruptcallback.s
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
commit9f4891f95070c66ea9f1aba99d72724d4ab24e5a (patch)
tree723e3ef2118a3d1a9e6dafa811ed1b8b1bc9196e /libpsn00b/psxetc/interruptcallback.s
parent6762c39551ded059450d17d8bb0cb80642c8aaab (diff)
downloadpsn00bsdk-9f4891f95070c66ea9f1aba99d72724d4ab24e5a.tar.gz
Revised makefiles, added strtok(), command line arguments, SetHeapSize(), moved ISR and callback system to psxetc, moved debug font to psxgpu, fixed CD-ROM library crashing on PSIO, fixed interrupt callback setup to fix crashing on ResetGraph()
Diffstat (limited to 'libpsn00b/psxetc/interruptcallback.s')
-rw-r--r--libpsn00b/psxetc/interruptcallback.s48
1 files changed, 48 insertions, 0 deletions
diff --git a/libpsn00b/psxetc/interruptcallback.s b/libpsn00b/psxetc/interruptcallback.s
new file mode 100644
index 0000000..8e912d8
--- /dev/null
+++ b/libpsn00b/psxetc/interruptcallback.s
@@ -0,0 +1,48 @@
+.set noreorder
+
+.include "hwregs_a.h"
+
+.section .text
+
+.global InterruptCallback
+.type InterruptCallback, @function
+InterruptCallback:
+
+ # a0 - Interrupt number
+ # a1 - Callback function
+
+ lui $a2, IOBASE
+
+ beqz $a1, .Ldisable_irq
+ nop
+
+ lw $v0, IMASK($a2) # Enable interrupt mask
+ li $v1, 1
+ sll $v1, $a0
+ or $v0, $v1
+
+ b .Lcont
+ sw $v0, IMASK($a2)
+
+.Ldisable_irq:
+
+.set noat
+ lw $v0, IMASK($a2) # Disable interrupt mask
+ li $v1, 1
+ sll $v1, $a0
+ addiu $at, $0 , -1
+ xor $v1, $at
+.set at
+ and $v0, $v1
+ sw $v0, IMASK($a2)
+
+.Lcont:
+
+ la $a2, _irq_func_table # Get address to IRQ function table
+
+ sll $v1, $a0, 2 # Compute the slot
+ addu $v1, $a2, $v1
+ lw $v0, 0($v1) # Get old handler address
+
+ jr $ra # Return and set new IRQ handler
+ sw $a1, 0($v1)