X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2F32x%2F32x.c;h=323b0b65a669aa01b8ebd097bdc3cfe7a8b55e4b;hb=e05b81fc5b3f640496795ced5d893ece4cc51c2d;hp=c75e3fe1512ac49a0373f01aabc456e49d424b91;hpb=83ff19ec52ff47992b5d6ceda3900b914eda2123;p=picodrive.git diff --git a/pico/32x/32x.c b/pico/32x/32x.c index c75e3fe..323b0b6 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -4,10 +4,19 @@ struct Pico32x Pico32x; SH2 sh2s[2]; -static void sh2_irq_cb(int id, int level) +static int REGPARM(2) sh2_irq_cb(SH2 *sh2, int level) { - // diagnostic for now - elprintf(EL_32X, "%csh2 ack %d @ %08x", id ? 's' : 'm', level, sh2_pc(id)); + if (sh2->pending_irl > sh2->pending_int_irq) { + elprintf(EL_32X, "%csh2 ack/irl %d @ %08x", + sh2->is_slave ? 's' : 'm', level, sh2->pc); + return 64 + sh2->pending_irl / 2; + } else { + elprintf(EL_32X, "%csh2 ack/int %d/%d @ %08x", + sh2->is_slave ? 's' : 'm', level, sh2->pending_int_vector, sh2->pc); + sh2->pending_int_irq = 0; // auto-clear + sh2->pending_level = sh2->pending_irl; + return sh2->pending_int_vector; + } } void p32x_update_irls(void) @@ -38,6 +47,7 @@ void Pico32xStartup(void) { elprintf(EL_STATUS|EL_32X, "32X startup"); + // TODO: OOM handling PicoAHW |= PAHW_32X; sh2_init(&msh2, 0); msh2.irq_callback = sh2_irq_cb; @@ -121,6 +131,8 @@ void PicoUnload32x(void) if (Pico32xMem != NULL) free(Pico32xMem); Pico32xMem = NULL; + sh2_finish(&msh2); + sh2_finish(&ssh2); PicoAHW &= ~PAHW_32X; }