diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-01 13:16:02 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-01 13:16:02 +0000 |
commit | dcd4dfc34c1b7b82d3fbd7d8ba730898955cd856 (patch) | |
tree | 56337d187f40603f54fbd94ff17e27a809f3e512 | |
parent | a92f45ce789448e8fc61a3f97344e33e58f74f8f (diff) |
Enable A/UX style interrupt routing on non-AV Centrises and Quadras, gives us
smarter spl levels and the clock drift is reduced; adapted from NetBSD.
-rw-r--r-- | sys/arch/mac68k/dev/if_sn_obio.c | 7 | ||||
-rw-r--r-- | sys/arch/mac68k/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/include/viareg.h | 3 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/intr.c | 24 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/locore.s | 25 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/machdep.c | 45 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/vectors.s | 6 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/via.c | 77 |
8 files changed, 107 insertions, 86 deletions
diff --git a/sys/arch/mac68k/dev/if_sn_obio.c b/sys/arch/mac68k/dev/if_sn_obio.c index f57d4dd6dc4..30e1fb0cce7 100644 --- a/sys/arch/mac68k/dev/if_sn_obio.c +++ b/sys/arch/mac68k/dev/if_sn_obio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn_obio.c,v 1.20 2004/11/26 21:21:24 miod Exp $ */ +/* $OpenBSD: if_sn_obio.c,v 1.21 2006/01/01 13:15:59 miod Exp $ */ /* $NetBSD: if_sn_obio.c,v 1.9 1997/04/22 20:56:15 scottr Exp $ */ /* @@ -181,7 +181,10 @@ sn_obio_attach(parent, self, aux) return; } - add_nubus_intr(sc->slotno, snintr, sc, sc->sc_dev.dv_xname); + if (mac68k_machine.aux_interrupts) + intr_establish(snintr, sc, 3, sc->sc_dev.dv_xname); + else + add_nubus_intr(sc->slotno, snintr, sc, sc->sc_dev.dv_xname); } static int diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h index cf1b4d4d85c..aeabbaaafd7 100644 --- a/sys/arch/mac68k/include/cpu.h +++ b/sys/arch/mac68k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.34 2005/08/01 11:54:24 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.35 2006/01/01 13:16:01 miod Exp $ */ /* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */ /* @@ -244,6 +244,10 @@ struct mac68k_machine_S { int scsi96; /* Has NCR 53C96 */ int scsi96_2; /* Has 2nd 53C96 */ int sonic; /* Has SONIC e-net */ + + int via1_ipl; + int via2_ipl; + int aux_interrupts; }; /* What kind of model is this */ diff --git a/sys/arch/mac68k/include/viareg.h b/sys/arch/mac68k/include/viareg.h index 27ec412fe65..899e11619e8 100644 --- a/sys/arch/mac68k/include/viareg.h +++ b/sys/arch/mac68k/include/viareg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: viareg.h,v 1.16 2005/09/27 07:15:19 martin Exp $ */ +/* $OpenBSD: viareg.h,v 1.17 2006/01/01 13:16:01 miod Exp $ */ /* $NetBSD: viareg.h,v 1.6 1997/02/28 07:41:41 scottr Exp $ */ /*- @@ -56,6 +56,7 @@ #define DB1I_Par_Err 0x80 #define DB1O_vSndEnb 0x80 #define DB1O_Par_Enb 0x40 +#define DB1O_AuxIntEnb 0x40 /* 0 = enabled, 1 = disabled */ #define DB1O_vFDesk2 0x20 #define DB1O_vFDesk1 0x10 #define DB1I_vFDBInt 0x08 diff --git a/sys/arch/mac68k/mac68k/intr.c b/sys/arch/mac68k/mac68k/intr.c index 091ec3a81ae..b779cf7bf8f 100644 --- a/sys/arch/mac68k/mac68k/intr.c +++ b/sys/arch/mac68k/mac68k/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.5 2005/12/03 21:37:14 brad Exp $ */ +/* $OpenBSD: intr.c,v 1.6 2006/01/01 13:16:01 miod Exp $ */ /* $NetBSD: intr.c,v 1.2 1998/08/25 04:03:56 scottr Exp $ */ /*- @@ -86,14 +86,22 @@ intr_init() /* Standard spl(9) interrupt priorities */ mac68k_ttyipl = (PSL_S | PSL_IPL1); mac68k_bioipl = (PSL_S | PSL_IPL2); - mac68k_netipl = (PSL_S | PSL_IPL2); - mac68k_impipl = (PSL_S | PSL_IPL2); - mac68k_clockipl = (PSL_S | PSL_IPL2); - mac68k_statclockipl = (PSL_S | PSL_IPL2); - - if (current_mac_model->class == MACH_CLASSAV) - mac68k_bioipl = mac68k_netipl = (PSL_S | PSL_IPL4); + if (mac68k_machine.aux_interrupts) { + mac68k_netipl = (PSL_S | PSL_IPL3); + mac68k_impipl = (PSL_S | PSL_IPL6); + mac68k_clockipl = (PSL_S | PSL_IPL6); + mac68k_statclockipl = (PSL_S | PSL_IPL6); + } else { + mac68k_netipl = (PSL_S | PSL_IPL2); + mac68k_impipl = (PSL_S | PSL_IPL2); + mac68k_clockipl = (PSL_S | PSL_IPL2); + mac68k_statclockipl = (PSL_S | PSL_IPL2); + + if (current_mac_model->class == MACH_CLASSAV) + mac68k_bioipl = mac68k_netipl = (PSL_S | PSL_IPL4); + } + intr_computeipl(); } diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s index a3b9d83136b..3972f2fb50d 100644 --- a/sys/arch/mac68k/mac68k/locore.s +++ b/sys/arch/mac68k/mac68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.47 2006/01/01 13:14:44 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.48 2006/01/01 13:16:01 miod Exp $ */ /* $NetBSD: locore.s,v 1.103 1998/07/09 06:02:50 scottr Exp $ */ /* @@ -861,29 +861,6 @@ ENTRY_NOPROFILE(spurintr) addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS jra _ASM_LABEL(rei) -ENTRY_NOPROFILE(lev1intr) - clrl sp@- - moveml #0xFFFF,sp@- - movl sp, sp@- - jbsr _C_LABEL(via1_intr) - addql #4,sp - moveml sp@+,#0xFFFF - addql #4,sp - addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS - jra _ASM_LABEL(rei) - -ENTRY_NOPROFILE(lev2intr) - clrl sp@- - moveml #0xFFFF,sp@- - movl sp, sp@- - movl _C_LABEL(real_via2_intr),a2 - jbsr a2@ - addql #4,sp - moveml sp@+,#0xFFFF - addql #4,sp - addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS - jra _ASM_LABEL(rei) - ENTRY_NOPROFILE(intrhand) /* levels 3 through 6 */ INTERRUPT_SAVEREG movw sp@(22),sp@- | push exception vector info diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index 51a60179283..0710c332cf5 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.122 2005/12/17 07:31:26 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.123 2006/01/01 13:16:01 miod Exp $ */ /* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ /* @@ -2222,7 +2222,6 @@ void setmachdep(void); void setmachdep() { - int setup_mrg_vectors = 0; struct cpu_model_info *cpui; /* @@ -2236,23 +2235,26 @@ setmachdep() cpui = &(cpu_models[mac68k_machine.cpu_model_index]); current_mac_model = cpui; + mac68k_machine.via1_ipl = 1; + mac68k_machine.via2_ipl = 2; + mac68k_machine.aux_interrupts = 0; + /* * Set up any machine specific stuff that we have to before * ANYTHING else happens */ switch (cpui->class) { /* Base this on class of machine... */ case MACH_CLASSII: - VIA2 = 1; + VIA2 = VIA2OFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; mac68k_machine.zs_chip = 0; via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ - setup_mrg_vectors = 1; break; case MACH_CLASSPB: - VIA2 = 1; + VIA2 = VIA2OFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2270,7 +2272,7 @@ setmachdep() * like the VIA2 functions might be on the MSC at the RBV * locations. The rest is copied from the Powerbooks. */ - VIA2 = 0x13; + VIA2 = RBVOFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2282,10 +2284,26 @@ setmachdep() break; case MACH_CLASSQ: case MACH_CLASSQ2: + VIA2 = VIA2OFF; + IOBase = 0x50f00000; + Via1Base = (volatile u_char *)IOBase; mac68k_machine.sonic = 1; + mac68k_machine.scsi96 = 1; + mac68k_machine.zs_chip = 0; + via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ + via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ + + /* Enable A/UX interrupt scheme */ + mac68k_machine.aux_interrupts = 1; + via_reg(VIA1, vBufB) &= (0xff ^ DB1O_AuxIntEnb); + via_reg(VIA1, vDirB) |= DB1O_AuxIntEnb; + mac68k_machine.via1_ipl = 6; + mac68k_machine.via2_ipl = 2; + + break; case MACH_CLASSAV: case MACH_CLASSP580: - VIA2 = 1; + VIA2 = VIA2OFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi96 = 1; @@ -2294,7 +2312,7 @@ setmachdep() via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ break; case MACH_CLASSIIci: - VIA2 = 0x13; + VIA2 = RBVOFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2303,7 +2321,7 @@ setmachdep() via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ break; case MACH_CLASSIIsi: - VIA2 = 0x13; + VIA2 = RBVOFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2312,7 +2330,7 @@ setmachdep() via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ break; case MACH_CLASSIIvx: - VIA2 = 0x13; + VIA2 = RBVOFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2321,7 +2339,7 @@ setmachdep() via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ break; case MACH_CLASSLC: - VIA2 = 0x13; + VIA2 = RBVOFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2330,7 +2348,7 @@ setmachdep() via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ break; case MACH_CLASSIIfx: - VIA2 = 0xd; + VIA2 = OSSOFF; IOBase = 0x50f00000; Via1Base = (volatile u_char *)IOBase; mac68k_machine.scsi80 = 1; @@ -2348,8 +2366,7 @@ setmachdep() * used later when we re-map the vectors from MacOS Address * Space to BSD Address Space. */ - if ((mac68k_machine.serial_console & 0x03) == 0 || setup_mrg_vectors) - mrg_MacOSROMVectors = cpui->rom_vectors; + mrg_MacOSROMVectors = cpui->rom_vectors; } /* diff --git a/sys/arch/mac68k/mac68k/vectors.s b/sys/arch/mac68k/mac68k/vectors.s index 08594c8cd43..8f282772233 100644 --- a/sys/arch/mac68k/mac68k/vectors.s +++ b/sys/arch/mac68k/mac68k/vectors.s @@ -1,4 +1,4 @@ -/* $OpenBSD: vectors.s,v 1.7 2004/11/25 18:32:11 miod Exp $ */ +/* $OpenBSD: vectors.s,v 1.8 2006/01/01 13:16:01 miod Exp $ */ | $NetBSD: vectors.s,v 1.10 1998/08/12 06:58:42 scottr Exp $ | Copyright (c) 1988 University of Utah @@ -73,8 +73,8 @@ GLOBAL(vectab) VECTOR(badtrap) /* 22: unassigned, reserved */ VECTOR(badtrap) /* 23: unassigned, reserved */ VECTOR(spurintr) /* 24: spurious interrupt */ - VECTOR(lev1intr) /* 25: level 1 interrupt autovector */ - VECTOR(lev2intr) /* 26: level 2 interrupt autovector */ + VECTOR(intrhand) /* 25: level 1 interrupt autovector */ + VECTOR(intrhand) /* 26: level 2 interrupt autovector */ VECTOR(intrhand) /* 27: level 3 interrupt autovector */ VECTOR(intrhand) /* 28: level 4 interrupt autovector */ VECTOR(intrhand) /* 29: level 5 interrupt autovector */ diff --git a/sys/arch/mac68k/mac68k/via.c b/sys/arch/mac68k/mac68k/via.c index cfabb18c7f3..4a523f5f802 100644 --- a/sys/arch/mac68k/mac68k/via.c +++ b/sys/arch/mac68k/mac68k/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.22 2005/02/06 19:51:35 martin Exp $ */ +/* $OpenBSD: via.c,v 1.23 2006/01/01 13:16:01 miod Exp $ */ /* $NetBSD: via.c,v 1.62 1997/09/10 04:38:48 scottr Exp $ */ /*- @@ -55,17 +55,15 @@ int mrg_pmintr(void *); int rtclock_intr(void *); void profclock(void *); -void via1_intr(struct frame *); -void via2_intr(struct frame *); -void rbv_intr(struct frame *); -void oss_intr(struct frame *); +int via1_intr(void *); +int via2_intr(void *); +int rbv_intr(void *); +int oss_intr(void *); int via2_nubus_intr(void *); int rbv_nubus_intr(void *); static int slot_ignore(void *); -void (*real_via2_intr)(struct frame *); - int VIA2 = VIA2OFF; /* default for II, IIx, IIcx, SE/30. */ struct intrhand via1intrs[7]; @@ -98,6 +96,8 @@ via_init() /* turn off timer latch */ via_reg(VIA1, vACR) &= 0x3f; + intr_establish(via1_intr, NULL, mac68k_machine.via1_ipl, "via1"); + /* register default VIA1 interrupts */ via1_register_irq(2, mrg_adbintr, NULL, "adb"); via1_register_irq(4, mrg_pmintr, NULL, "pm"); @@ -153,9 +153,11 @@ via_init() break; } - real_via2_intr = via2_intr; + intr_establish(via2_intr, NULL, mac68k_machine.via2_ipl, + "via2"); } else if (current_mac_model->class == MACH_CLASSIIfx) { /* OSS */ - real_via2_intr = oss_intr; + intr_establish(oss_intr, NULL, mac68k_machine.via2_ipl, + "via2"); } else { /* RBV */ if (current_mac_model->class == MACH_CLASSIIci) { /* @@ -163,7 +165,8 @@ via_init() */ via2_reg(rBufB) |= DB2O_CEnable; } - real_via2_intr = rbv_intr; + intr_establish(rbv_intr, NULL, mac68k_machine.via2_ipl, + "via2"); nubus_intr.vh_ipl = 1; nubus_intr.vh_fn = rbv_nubus_intr; @@ -186,8 +189,8 @@ via_set_modem(int onoff) via_reg(VIA1, vBufA) &= ~DA1O_vSync; } -void -via1_intr(struct frame *fp) +int +via1_intr(void *arg) { struct intrhand *ih; u_int8_t intbits, bitnum; @@ -197,7 +200,7 @@ via1_intr(struct frame *fp) intbits &= via_reg(VIA1, vIER); /* only care about enabled */ if (intbits == 0) - return; + return (0); /* * Unflag interrupts here. If we do it after each interrupt, @@ -215,10 +218,12 @@ via1_intr(struct frame *fp) if (intbits < mask) break; } + + return (1); } -void -via2_intr(struct frame *fp) +int +via2_intr(void *arg) { struct via2hand *v2h; via2hand_t *anchor; @@ -230,7 +235,7 @@ via2_intr(struct frame *fp) intbits &= via2_reg(vIER); /* only care about enabled */ if (intbits == 0) - return; + return (0); via2_reg(vIFR) = intbits; @@ -238,24 +243,26 @@ via2_intr(struct frame *fp) mask = 1; for (bitnum = 0, anchor = via2intrs; ; bitnum++, anchor++) { if ((intbits & mask) != 0) { - handled = 0; - SLIST_FOREACH(v2h, anchor, v2h_link) { - struct intrhand *ih = &v2h->v2h_ih; - rc = (*ih->ih_fn)(ih->ih_arg); - if (rc != 0) { - ih->ih_count.ec_count++; - handled |= rc; + handled = 0; + SLIST_FOREACH(v2h, anchor, v2h_link) { + struct intrhand *ih = &v2h->v2h_ih; + rc = (*ih->ih_fn)(ih->ih_arg); + if (rc != 0) { + ih->ih_count.ec_count++; + handled |= rc; + } } } + mask <<= 1; + if (intbits < mask) + break; } - mask <<= 1; - if (intbits < mask) - break; - } + + return (1); } -void -rbv_intr(struct frame *fp) +int +rbv_intr(void *arg) { struct via2hand *v2h; via2hand_t *anchor; @@ -267,7 +274,7 @@ rbv_intr(struct frame *fp) intbits &= via2_reg(vIER + rIER); if (intbits == 0) - return; + return (0); via2_reg(rIFR) = intbits; @@ -289,6 +296,8 @@ rbv_intr(struct frame *fp) if (intbits < mask) break; } + + return (1); } static int nubus_intr_mask = 0; @@ -343,8 +352,8 @@ enable_nubus_intr() via2_reg(rIER) = 0x80 | V2IF_SLOTINT; } -void -oss_intr(struct frame *fp) +int +oss_intr(void *arg) { struct intrhand *ih; u_int8_t intbits, bitnum; @@ -353,7 +362,7 @@ oss_intr(struct frame *fp) intbits = via2_reg(vIFR + rIFR); if (intbits == 0) - return; + return (0); intbits &= 0x7f; mask = 1; @@ -369,6 +378,8 @@ oss_intr(struct frame *fp) if (intbits < mask) break; } + + return (1); } /*ARGSUSED*/ |