Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/newsmips Use hb_intr_establish().



details:   https://anonhg.NetBSD.org/src/rev/24cd29a340c8
branches:  trunk
changeset: 479692:24cd29a340c8
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Sat Dec 18 06:54:05 1999 +0000

description:
Use hb_intr_establish().

diffstat:

 sys/arch/newsmips/dev/kb.c                 |  51 +++++++++++++++++++++--------
 sys/arch/newsmips/dev/kbms_if.c            |   3 +-
 sys/arch/newsmips/dev/ms.c                 |  21 ++++++++++-
 sys/arch/newsmips/newsmips/newsmips_trap.c |  22 +++++-------
 4 files changed, 65 insertions(+), 32 deletions(-)

diffs (256 lines):

diff -r 13eb16f39b2d -r 24cd29a340c8 sys/arch/newsmips/dev/kb.c
--- a/sys/arch/newsmips/dev/kb.c        Sat Dec 18 06:33:54 1999 +0000
+++ b/sys/arch/newsmips/dev/kb.c        Sat Dec 18 06:54:05 1999 +0000
@@ -1,4 +1,5 @@
-/*     $NetBSD: kb.c,v 1.3 1999/02/15 04:36:34 hubertf Exp $   */
+/*     $NetBSD: kb.c,v 1.4 1999/12/18 06:54:05 tsubai Exp $    */
+
 /*
  * Copyright (c) 1992, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -39,10 +40,6 @@
  *     @(#)kb.c        8.1 (Berkeley) 6/11/93
  */
 
-#include "kb.h"
-
-#if NKB > 0
-
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/ioctl.h>
@@ -50,8 +47,8 @@
 #include <sys/uio.h>
 #include <sys/device.h>
 
+#include <machine/autoconf.h>
 #include <machine/keyboard.h>
-#include <machine/autoconf.h>
 
 #include <newsmips/dev/kbreg.h>
 
@@ -61,6 +58,11 @@
 #include "../iop/iopvar.h"
 #endif
 
+struct kb_softc {
+       struct device sc_dev;
+       int sc_busy;
+};
+
 extern Key_table key_table[];
 extern Key_table default_table[];
 extern int country;
@@ -73,6 +75,7 @@
 static int     kbmatch __P((struct device *, struct cfdata *, void *));
 static void    kbattach __P((struct device *, struct device *, void *));
 
+static int kbintr __P((void *));
 extern int kbopen(dev_t, int, int, struct proc *);
 extern int kbclose(dev_t, int, int, struct proc *);
 #ifdef KBDEBUG
@@ -92,7 +95,7 @@
 static int kb_ctrl(int, void *);
 
 struct cfattach kb_ca = {
-       sizeof(struct device), kbmatch, kbattach
+       sizeof(struct kb_softc), kbmatch, kbattach
 };
 
 extern struct cfdriver kb_cd;
@@ -101,8 +104,6 @@
 extern Key_table *key_table_addr;
 #endif
 
-static int kb_busy;
-
 int
 kbmatch(parent, cf, aux)
        struct device *parent;
@@ -122,10 +123,24 @@
        struct device *parent, *self;
        void *aux;
 {
+       int intr = self->dv_cfdata->cf_level;
+
        kb_attach();
        init_key_table();
 
-       printf("\n");
+       if (intr == -1)
+               intr = 2;       /* XXX */
+
+       hb_intr_establish(intr, IPL_TTY, kbintr, self);
+       printf(" level %d\n", intr);
+}
+
+int
+kbintr(v)
+       void *v;
+{
+       kbm_rint(SCC_KEYBOARD);
+       return 1;
 }
 
 int
@@ -135,14 +150,19 @@
        struct proc *p;
 
 {
+       struct kb_softc *sc;
        int unit = minor(dev);
 
-       if (unit >= NKB)
+       if (unit >= kb_cd.cd_ndevs)
                return ENXIO;
-       if (kb_busy)
+       sc = kb_cd.cd_devs[unit];
+       if (sc == NULL)
+               return ENXIO;
+
+       if (sc->sc_busy)
                return EBUSY;
        /* need spl? */
-       kb_busy = 1;
+       sc->sc_busy = 1;
        return kb_open();
 }
 
@@ -152,8 +172,10 @@
        int flags, mode;
        struct proc *p;
 {
+       struct kb_softc *sc = kb_cd.cd_devs[minor(dev)];
+
        kb_close();
-       kb_busy = 0;
+       sc->sc_busy = 0;
        return 0;
 }
 
@@ -438,4 +460,3 @@
        return (0);
 }
 #endif /* IPC_MRX */
-#endif /* NKB > 0 */
diff -r 13eb16f39b2d -r 24cd29a340c8 sys/arch/newsmips/dev/kbms_if.c
--- a/sys/arch/newsmips/dev/kbms_if.c   Sat Dec 18 06:33:54 1999 +0000
+++ b/sys/arch/newsmips/dev/kbms_if.c   Sat Dec 18 06:54:05 1999 +0000
@@ -1,4 +1,5 @@
-/*     $NetBSD: kbms_if.c,v 1.3 1999/02/15 04:36:34 hubertf Exp $      */
+/*     $NetBSD: kbms_if.c,v 1.4 1999/12/18 06:54:05 tsubai Exp $       */
+
 /*
  * Copyright (c) 1992, 1993
  *     The Regents of the University of California.  All rights reserved.
diff -r 13eb16f39b2d -r 24cd29a340c8 sys/arch/newsmips/dev/ms.c
--- a/sys/arch/newsmips/dev/ms.c        Sat Dec 18 06:33:54 1999 +0000
+++ b/sys/arch/newsmips/dev/ms.c        Sat Dec 18 06:54:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ms.c,v 1.3 1998/12/26 00:53:49 tsubai Exp $    */
+/*     $NetBSD: ms.c,v 1.4 1999/12/18 06:54:05 tsubai Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -60,8 +60,8 @@
 #include <sys/file.h>
 #include <sys/device.h>
 
+#include <machine/autoconf.h>
 #include <machine/mouse.h>
-#include <machine/autoconf.h>
 
 #include <newsmips/dev/msreg.h>
 #include <newsmips/dev/scc.h>
@@ -93,6 +93,7 @@
 
 extern struct cfdriver ms_cd;
 
+static int ms_intr __P((void *));
 static void msq_init __P((int));
 static int msq_stat __P((int));
 static struct ms_event * msq_read __P((int));
@@ -140,7 +141,21 @@
        struct device *parent, *self;
        void *aux;
 {
-       printf("\n");
+       int intr = self->dv_cfdata->cf_level;
+
+       if (intr == -1)
+               intr = 2;       /* XXX */
+
+       hb_intr_establish(intr, IPL_TTY, ms_intr, self);
+       printf(" level %d\n", intr);
+}
+
+int
+ms_intr(v)
+       void *v;
+{
+       kbm_rint(SCC_MOUSE);
+       return 1;
 }
 
 /* queue structure operators */
diff -r 13eb16f39b2d -r 24cd29a340c8 sys/arch/newsmips/newsmips/newsmips_trap.c
--- a/sys/arch/newsmips/newsmips/newsmips_trap.c        Sat Dec 18 06:33:54 1999 +0000
+++ b/sys/arch/newsmips/newsmips/newsmips_trap.c        Sat Dec 18 06:54:05 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newsmips_trap.c,v 1.7 1999/12/17 03:21:10 tsubai Exp $ */
+/*     $NetBSD: newsmips_trap.c,v 1.8 1999/12/18 06:54:05 tsubai Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -64,8 +64,6 @@
 #include <newsmips/dev/scc.h>
 
 #include "sc.h"
-#include "kb.h"
-#include "ms.h"
 /*#include "lp.h"*/
 /*#include "fd.h"*/
 /*#include "sb.h"*/
@@ -78,7 +76,6 @@
 void news3400_errintr __P((u_int));
 
 int sc_intr __P((void));
-void kbm_rint __P((int));
 void hb_intr_dispatch __P((int));
 
 static int badaddr_flag;
@@ -100,10 +97,12 @@
                register int stat;
 
                stat = *(volatile u_char *)INTST0;
+               stat &= INTST0_TIMINT|INTST0_KBDINT|INTST0_MSINT;
+               *(volatile u_char *)INTCLR0 = stat;
+
                if (stat & INTST0_TIMINT) {     /* timer */
                        static int led_count = 0;
 
-                       *(volatile u_char *)INTCLR0 = INTCLR0_TIMINT;
                        cf.pc = pc;
                        cf.sr = statusReg;
                        hardclock(&cf);
@@ -112,15 +111,12 @@
                                led_count = 0;
                                *(volatile u_char *)DEBUG_PORT ^= DP_LED1;
                        }
+                       stat &= ~INTST0_TIMINT;
                }
-#if NKB > 0
-               if (stat & INTST0_KBDINT)       /* keyboard */
-                       kbm_rint(SCC_KEYBOARD);
-#endif
-#if NMS > 0
-               if (stat & INTST0_MSINT)        /* mouse */
-                       kbm_rint(SCC_MOUSE);
-#endif
+
+               if (stat)
+                       hb_intr_dispatch(2);
+
                /* keep clock interrupts enabled when we return */
                causeReg &= ~MIPS_INT_MASK_2;
        }



Home | Main Index | Thread Index | Old Index