Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/atari - establish zs interrupts via common intr_est...



details:   https://anonhg.NetBSD.org/src/rev/24b83a491dd9
branches:  trunk
changeset: 753775:24b83a491dd9
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Apr 09 17:38:43 2010 +0000

description:
- establish zs interrupts via common intr_establish() function rather than
  hardcording them in locore.s and vector.s
- also make interrupt handlers take per unit softc and put a softint cookie
  into softc (though atari machines have only one zs)
- tweak some structures as per MI z8530sc driver

Tested on TT030 using sl(4) on zs.

diffstat:

 sys/arch/atari/atari/locore.s  |   19 +--
 sys/arch/atari/atari/vectors.s |   37 +----
 sys/arch/atari/dev/zs.c        |  255 ++++++++++++++++++++++------------------
 sys/arch/atari/dev/zsvar.h     |    9 +-
 4 files changed, 152 insertions(+), 168 deletions(-)

diffs (truncated from 572 to 300 lines):

diff -r a1fc60988d13 -r 24b83a491dd9 sys/arch/atari/atari/locore.s
--- a/sys/arch/atari/atari/locore.s     Fri Apr 09 17:06:31 2010 +0000
+++ b/sys/arch/atari/atari/locore.s     Fri Apr 09 17:38:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.104 2009/12/02 15:53:34 tsutsui Exp $     */
+/*     $NetBSD: locore.s,v 1.105 2010/04/09 17:38:43 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1980, 1990 The Regents of the University of California.
@@ -756,23 +756,6 @@
        jra     _ASM_LABEL(rei)
 #endif /* NNCRSCSI > 0 */
 
-#if NZS > 0
-       /* SCC Interrupt --- modem2/serial2 --- */
-ASENTRY_NOPROFILE(sccint)
-       addql   #1,_C_LABEL(idepth)
-       addql   #1,_C_LABEL(intrcnt)+32 |  add another SCC interrupt
-
-       moveml  %d0-%d1/%a0-%a1,%sp@-   |  Save scratch registers
-       movw    %sp@(16),%sp@-          |  push previous SR value
-       clrw    %sp@-                   |     padded to longword
-       jbsr    _C_LABEL(zshard)        |  handle interrupt
-       addql   #4,%sp                  |  pop SR
-       moveml  %sp@+,%d0-%d1/%a0-%a1
-       addql   #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
-       subql   #1,_C_LABEL(idepth)
-       jra     _ASM_LABEL(rei)
-#endif /* NZS > 0 */
-
 #ifdef _ATARIHW_
        /* Level 1 (Software) interrupt handler */
 ENTRY_NOPROFILE(lev1intr)
diff -r a1fc60988d13 -r 24b83a491dd9 sys/arch/atari/atari/vectors.s
--- a/sys/arch/atari/atari/vectors.s    Fri Apr 09 17:06:31 2010 +0000
+++ b/sys/arch/atari/atari/vectors.s    Fri Apr 09 17:38:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vectors.s,v 1.21 2005/12/11 12:16:54 christos Exp $    */
+/*     $NetBSD: vectors.s,v 1.22 2010/04/09 17:38:43 tsutsui Exp $     */
 
 /*
  * Copyright (c) 1990 Regents of the University of California.
@@ -212,44 +212,25 @@
        VECTOR(badmfpint)       |  95:
 #endif /* NNCRSCSI > 0 */
 
-#if NZS > 0
        /*
         * Interrupts from the 8530 SCC
         */
-       ASVECTOR(sccint)        |  96: SCC Tx empty channel B
+       VECTOR(badtrap)         |  96: SCC Tx empty channel B
        VECTOR(badtrap)         |  97: Not used
-       ASVECTOR(sccint)        |  98: SCC Ext./Status Channel B
+       VECTOR(badtrap)         |  98: SCC Ext./Status Channel B
        VECTOR(badtrap)         |  99: Not used
-       ASVECTOR(sccint)        | 100: SCC Rx Channel B
+       VECTOR(badtrap)         | 100: SCC Rx Channel B
        VECTOR(badtrap)         | 101: Not used
-       ASVECTOR(sccint)        | 102: SCC Special Rx cond.  Channel B
+       VECTOR(badtrap)         | 102: SCC Special Rx cond.  Channel B
        VECTOR(badtrap)         | 103: Not used
-       ASVECTOR(sccint)        | 104: SCC Tx empty channel A
+       VECTOR(badtrap)         | 104: SCC Tx empty channel A
        VECTOR(badtrap)         | 105: Not used
-       ASVECTOR(sccint)        | 106: SCC Ext./Status Channel A
+       VECTOR(badtrap)         | 106: SCC Ext./Status Channel A
        VECTOR(badtrap)         | 107: Not used
-       ASVECTOR(sccint)        | 108: SCC Rx Channel A
+       VECTOR(badtrap)         | 108: SCC Rx Channel A
        VECTOR(badtrap)         | 109: Not used
-       ASVECTOR(sccint)        | 110: SCC Special Rx cond.  Channel A
+       VECTOR(badtrap)         | 110: SCC Special Rx cond.  Channel A
        VECTOR(badtrap)         | 111: Not used
-#else
-       VECTOR(badtrap)         |  96: Not used
-       VECTOR(badtrap)         |  97: Not used
-       VECTOR(badtrap)         |  98: Not used
-       VECTOR(badtrap)         |  99: Not used
-       VECTOR(badtrap)         | 100: Not used
-       VECTOR(badtrap)         | 101: Not used
-       VECTOR(badtrap)         | 102: Not used
-       VECTOR(badtrap)         | 103: Not used
-       VECTOR(badtrap)         | 104: Not used
-       VECTOR(badtrap)         | 105: Not used
-       VECTOR(badtrap)         | 106: Not used
-       VECTOR(badtrap)         | 107: Not used
-       VECTOR(badtrap)         | 108: Not used
-       VECTOR(badtrap)         | 109: Not used
-       VECTOR(badtrap)         | 110: Not used
-       VECTOR(badtrap)         | 111: Not used
-#endif /* NZS > 0 */
 
 #define BADTRAP16      VECTOR(badtrap) ; VECTOR(badtrap) ; \
                        VECTOR(badtrap) ; VECTOR(badtrap) ; \
diff -r a1fc60988d13 -r 24b83a491dd9 sys/arch/atari/dev/zs.c
--- a/sys/arch/atari/dev/zs.c   Fri Apr 09 17:06:31 2010 +0000
+++ b/sys/arch/atari/dev/zs.c   Fri Apr 09 17:38:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.71 2010/04/09 17:06:31 tsutsui Exp $  */
+/*     $NetBSD: zs.c,v 1.72 2010/04/09 17:38:43 tsutsui Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.71 2010/04/09 17:06:31 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.72 2010/04/09 17:38:43 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -123,11 +123,12 @@
  */
 struct zs_softc {
        device_t sc_dev;                /* base device */
-       struct zsdevice *sc_zs;         /* chip registers */
-       struct zs_chanstate sc_cs[2];   /* chan A and B software state */
+       struct zs_chanstate *sc_cs[2];  /* chan A and B software state */
+
+       struct zs_chanstate sc_cs_store[2];
+       void *sc_sicookie;              /* for callback */
 };
 
-static void    *zs_softint_cookie;     /* for callback */
 /*
  * Define the registers for a closed port
  */
@@ -242,14 +243,12 @@
 };
 
 /* Interrupt handlers. */
-int            zshard(long);
-static int     zssoft(long);
+static int     zshard(void *);
+static int     zssoft(void *);
 static int     zsrint(struct zs_chanstate *, struct zschan *);
 static int     zsxint(struct zs_chanstate *, struct zschan *);
 static int     zssint(struct zs_chanstate *, struct zschan *);
 
-static struct zs_chanstate *zslist;
-
 /* Routines called from other code. */
 static void    zsstart(struct tty *);
 
@@ -279,36 +278,45 @@
 zsattach(device_t parent, device_t self, void *aux)
 {
        struct zs_softc *sc;
+       struct zsdevice *zs;
+       struct zschan *zc;
        struct zs_chanstate *cs;
-       struct zsdevice *addr;
-       uint8_t tmp;
+       int channel;
+
+       sc = device_private(self);
+       sc->sc_dev = self;
 
-       addr      = (struct zsdevice *)AD_SCC;
-       sc        = device_private(self);
-       sc->sc_dev = self;
-       sc->sc_zs = addr;
-       cs        = sc->sc_cs;
+       printf(": serial2 on channel a and modem2 on channel b\n");
+
+       zs = (struct zsdevice *)AD_SCC;
+
+       for (channel = 0; channel < 2; channel++) {
+               cs = &sc->sc_cs_store[channel];
+               sc->sc_cs[channel] = cs;
 
-       /*
-        * Get the command register into a known state.
-        */
-       tmp = addr->zs_chan[ZS_CHAN_A].zc_csr;
-       tmp = addr->zs_chan[ZS_CHAN_A].zc_csr;
-       tmp = addr->zs_chan[ZS_CHAN_B].zc_csr;
-       tmp = addr->zs_chan[ZS_CHAN_B].zc_csr;
+               cs->cs_unit = channel;
+               cs->cs_zc = zc =
+                   (channel == 0) ?  &zs->zs_chan_a : &zs->zs_chan_b;
+               /*
+                * Get the command register into a known state.
+                */
+               (void)zc->zc_csr;
+               (void)zc->zc_csr;
 
-       /*
-        * Do a hardware reset.
-        */
-       ZS_WRITE(&addr->zs_chan[ZS_CHAN_A], 9, ZSWR9_HARD_RESET);
-       delay(50000);   /*enough ? */
-       ZS_WRITE(&addr->zs_chan[ZS_CHAN_A], 9, 0);
+               /*
+                * Do a hardware reset.
+                */
+               if (channel == 0) {
+                       ZS_WRITE(zc, 9, ZSWR9_HARD_RESET);
+                       delay(50000);   /* enough ? */
+                       ZS_WRITE(zc, 9, 0);
+               }
 
-       /*
-        * Initialize both channels
-        */
-       zs_loadchannelregs(&addr->zs_chan[ZS_CHAN_A], zs_init_regs);
-       zs_loadchannelregs(&addr->zs_chan[ZS_CHAN_B], zs_init_regs);
+               /*
+                * Initialize channel
+                */
+               zs_loadchannelregs(zc, zs_init_regs);
+       }
 
        if (machineid & ATARI_TT) {
                /*
@@ -336,21 +344,33 @@
                zs_frequencies = zs_freqs_generic;
        }
 
-       /* link into interrupt list with order (A,B) (B=A+1) */
-       cs[0].cs_next = &cs[1];
-       cs[1].cs_next = zslist;
-       zslist        = cs;
+       if (intr_establish(36, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Rx chan B)\n");
+       if (intr_establish(32, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Tx empty chan B)\n");
+       if (intr_establish(34, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Ext./Status chan B)\n");
+       if (intr_establish(38, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Special Rx cond. chan B)\n");
+       if (intr_establish(44, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Rx chan A)\n");
+       if (intr_establish(40, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Tx empty chan A)\n");
+       if (intr_establish(42, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Ext./Status chan A)\n");
+       if (intr_establish(46, USER_VEC, 0, (hw_ifun_t)zshard, sc) == NULL)
+               aprint_error_dev(self,
+                   "Can't establish interrupt (Special Rx cond. chan A)\n");
 
-       cs->cs_unit  = 0;
-       cs->cs_zc    = &addr->zs_chan[ZS_CHAN_A];
-       cs++;
-       cs->cs_unit  = 1;
-       cs->cs_zc    = &addr->zs_chan[ZS_CHAN_B];
-
-       zs_softint_cookie = softint_establish(SOFTINT_SERIAL,
-           (void (*)(void *))zssoft, 0);
-
-       printf(": serial2 on channel a and modem2 on channel b\n");
+       sc->sc_sicookie = softint_establish(SOFTINT_SERIAL,
+           (void (*)(void *))zssoft, sc);
 }
 
 /*
@@ -369,7 +389,7 @@
        sc = device_lookup_private(&zs_cd, zs);
        if (sc == NULL)
                return ENXIO;
-       cs = &sc->sc_cs[unit & 1];
+       cs = sc->sc_cs[unit & 1];
 
        /*
         * When port A (ser02) is selected on the TT, make sure
@@ -462,7 +482,7 @@
        int unit = ZS_UNIT(dev);
 
        sc = device_lookup_private(&zs_cd, unit >> 1);
-       cs = &sc->sc_cs[unit & 1];
+       cs = sc->sc_cs[unit & 1];
        tp = cs->cs_ttyp;
 
        tp->t_linesw->l_close(tp, flags);
@@ -492,7 +512,7 @@
 
        unit = ZS_UNIT(dev);
        sc   = device_lookup_private(&zs_cd, unit >> 1);
-       cs   = &sc->sc_cs[unit & 1];
+       cs   = sc->sc_cs[unit & 1];
        tp   = cs->cs_ttyp;
 
        return (*tp->t_linesw->l_read)(tp, uio, flags);
@@ -508,7 +528,7 @@
 
        unit = ZS_UNIT(dev);
        sc   = device_lookup_private(&zs_cd, unit >> 1);
-       cs   = &sc->sc_cs[unit & 1];
+       cs   = sc->sc_cs[unit & 1];
        tp   = cs->cs_ttyp;
 



Home | Main Index | Thread Index | Old Index