split toggling masks and interrupts themselves

This commit is contained in:
Connor Olding 2018-08-24 23:34:28 +02:00
parent c7a694595e
commit 2aa87bb878
5 changed files with 23 additions and 7 deletions

View file

@ -43,7 +43,7 @@ constant CP0_STATUS_IM4($1000) // Interrupt Mask 4 (External)
constant CP0_STATUS_IM5($2000) // Interrupt Mask 5 (External)
constant CP0_STATUS_IM6($4000) // Interrupt Mask 6 (External)
constant CP0_STATUS_IM7($8000) // Interrupt Mask 7 (External)
constant CP0_STATUS_IM_ALL($FF01) // enable all interrupts
constant CP0_STATUS_IM_ALL($FF00) // all interrupt masks
// note that these are all masks.
constant CP0_CAUSE_CODE($007C) // actually supposed to be called ExcCode

View file

@ -77,7 +77,7 @@ macro SP_BUSY_WAIT() {
-
lw t0, SP_STATUS(a0)
andi t0, 0x1C
sltu t0, r0, t0 // TODO: rewrite this
sltu t0, r0, t0
bnez t0,-
nop
}

View file

@ -1,4 +1,20 @@
macro EnableInt() {
// careful not to touch unrelated flags here
mfc0 t0, CP0_Status
addiu at, r0, CP0_STATUS_IE
or t0, at
mtc0 t0, CP0_Status
}
macro DisableInt() {
// careful not to touch unrelated flags here
mfc0 t0, CP0_Status
addiu at, r0, ~CP0_STATUS_IE
and t0, at
mtc0 t0, CP0_Status
}
macro SetIntMask() {
lli t0, MI_INTR_MASK_ALL_SET
lui a0, MI_BASE
sw t0, MI_INTR_MASK(a0)
@ -9,7 +25,7 @@ macro EnableInt() {
mtc0 t1, CP0_Status
}
macro DisableInt() {
macro ClearIntMask() {
lli t0, MI_INTR_MASK_ALL_CLR
lui a0, MI_BASE
sw t0, MI_INTR_MASK(a0)

View file

@ -40,7 +40,7 @@ Start:
// enable CPU interrupts.
mfc0 t1, CP0_Status
ori t1, t1, CP0_STATUS_IM_ALL
ori t1, t1, CP0_STATUS_IM_ALL | CP0_STATUS_IE
mtc0 t1, CP0_Status
// enable even more interrupts.
@ -440,7 +440,7 @@ K_MI_SP:
lui a1, SP_BASE
sw t0, SP_STATUS(a1)
// then check andi t1, SG1 | SG2 ?
// then check andi t1, SP_SG1 | SP_SG2 ?
lw t0, K_HISTORY(k0)
ori t0, 0x01

View file

@ -85,7 +85,7 @@ include "dlist.asm" // takes a0
nop
Start3D:
DisableInt()
ClearIntMask()
// stuff i'm borrowing from zelda:
lui a0, SP_BASE
@ -126,7 +126,7 @@ Start3D:
sw t0, SP_STATUS(a0)
nop
EnableInt()
SetIntMask()
MainLoop:
lui a0, K_BASE