Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips/tx totaly rewritten.



details:   https://anonhg.NetBSD.org/src/rev/1d7bdd1889e8
branches:  trunk
changeset: 479906:1d7bdd1889e8
user:      uch <uch%NetBSD.org@localhost>
date:      Sun Dec 26 17:05:28 1999 +0000

description:
totaly rewritten.

diffstat:

 sys/arch/hpcmips/tx/tx39icureg.h |   35 +-
 sys/arch/hpcmips/tx/txcom.c      |  806 ++++++++++++++++++++++++++++----------
 2 files changed, 624 insertions(+), 217 deletions(-)

diffs (truncated from 1179 to 300 lines):

diff -r ffb849399ae9 -r 1d7bdd1889e8 sys/arch/hpcmips/tx/tx39icureg.h
--- a/sys/arch/hpcmips/tx/tx39icureg.h  Sun Dec 26 13:02:24 1999 +0000
+++ b/sys/arch/hpcmips/tx/tx39icureg.h  Sun Dec 26 17:05:28 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tx39icureg.h,v 1.1 1999/11/20 19:56:34 uch Exp $ */
+/*     $NetBSD: tx39icureg.h,v 1.2 1999/12/26 17:05:28 uch Exp $ */
 
 /*
  * Copyright (c) 1999, by UCHIYAMA Yasushi
@@ -154,6 +154,7 @@
 #define TX39_INTRSTATUS2_UARTAEMPTYINT         0x01000000
 #define TX39_INTRSTATUS2_UARTADMAFULLINT       0x00800000
 #define TX39_INTRSTATUS2_UARTADMAHALFINT       0x00400000
+
 #define TX39_INTRSTATUS2_UARTBRXINT            0x00200000
 #define TX39_INTRSTATUS2_UARTBRXOVERRUNINT     0x00100000
 #define TX39_INTRSTATUS2_UARTBFRAMEERRINT      0x00080000
@@ -164,6 +165,38 @@
 #define TX39_INTRSTATUS2_UARTBEMPTYINT         0x00004000
 #define TX39_INTRSTATUS2_UARTBDMAFULLINT       0x00002000
 #define TX39_INTRSTATUS2_UARTBDMAHALFINT       0x00001000
+
+#define        TX39_INTRSTATUS2_UARTRXINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBRXINT : \
+        TX39_INTRSTATUS2_UARTARXINT)
+#define TX39_INTRSTATUS2_UARTRXOVERRUNINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBRXOVERRUNINT : \
+        TX39_INTRSTATUS2_UARTARXOVERRUNINT)
+#define TX39_INTRSTATUS2_UARTFRAMEERRINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBFRAMEERRINT : \
+        TX39_INTRSTATUS2_UARTAFRAMEERRINT)
+#define TX39_INTRSTATUS2_UARTBREAKINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBBREAKINT : \
+       TX39_INTRSTATUS2_UARTABREAKINT)
+#define TX39_INTRSTATUS2_UARTPARITYERRINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBPARITYERRINT : \
+        TX39_INTRSTATUS2_UARTAPARITYERRINT)
+#define TX39_INTRSTATUS2_UARTTXINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBTXINT : \
+       TX39_INTRSTATUS2_UARTATXINT)
+#define TX39_INTRSTATUS2_UARTTXOVERRUNINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBTXOVERRUNINT : \
+       TX39_INTRSTATUS2_UARTATXOVERRUNINT)
+#define TX39_INTRSTATUS2_UARTEMPTYINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBEMPTYINT : \
+       TX39_INTRSTATUS2_UARTEMPTYINT)
+#define TX39_INTRSTATUS2_UARTDMAFULLINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBDMAFULLINT : \
+       TX39_INTRSTATUS2_UARTADMAFULLINT)
+#define TX39_INTRSTATUS2_UARTDMAHALFINT(x) \
+       ((x) ? TX39_INTRSTATUS2_UARTBDMAHALFINT : \
+       TX39_INTRSTATUS2_UARTADMAHALFINT)
+
 #ifdef TX391X
 #define TX39_INTRSTATUS2_MBUSTXBUFAVAILINT     0x00000800
 #define TX39_INTRSTATUS2_MBUSTXERRINT          0x00000400
diff -r ffb849399ae9 -r 1d7bdd1889e8 sys/arch/hpcmips/tx/txcom.c
--- a/sys/arch/hpcmips/tx/txcom.c       Sun Dec 26 13:02:24 1999 +0000
+++ b/sys/arch/hpcmips/tx/txcom.c       Sun Dec 26 17:05:28 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: txcom.c,v 1.2 1999/12/23 16:57:14 uch Exp $ */
+/*     $NetBSD: txcom.c,v 1.3 1999/12/26 17:05:28 uch Exp $ */
 
 /*
  * Copyright (c) 1999, by UCHIYAMA Yasushi
@@ -30,7 +30,9 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/kernel.h>
 #include <sys/device.h>
+#include <sys/malloc.h>
 
 #include <sys/proc.h> /* tsleep/wakeup */
 
@@ -61,67 +63,78 @@
 #define        DPRINTF(arg)
 #endif
 
-#define MAXBUF 16
-struct txcom_buf {
-       int b_cnt;
-       int b_in;
-       int b_out;
-       char b_buf[MAXBUF];
-};
+#define TXCOM_HW_CONSOLE       0x40
+#define        TXCOM_RING_SIZE         256 /* must be a power of two! */
+#define TXCOM_RING_MASK                (TXCOM_RING_SIZE - 1)
 
-#define TXCOM_HW_CONSOLE 0x40
-struct txcom_softc {
-       struct  device sc_dev;
-       struct tty *sc_tty;
+struct txcom_chip {
        tx_chipset_tag_t sc_tc;
        int sc_slot;    /* UARTA or UARTB */
        int sc_cflag;   
        int sc_speed;
-       struct txcom_buf *sc_rxbuf;
-       struct txcom_buf *sc_txbuf;
-       char **sc_msg;
+       int sc_swflags;
        int sc_hwflags;
-       u_int8_t *sc_tba;               /* transmit buffer address */
-       int sc_tbc, sc_heldtbc;         /* transmit byte count */
-       u_int8_t sc_rbuf; /* XXX */
+};
+
+struct txcom_softc {
+       struct  device          sc_dev;
+       struct tty              *sc_tty;
+       struct txcom_chip       *sc_chip;
 
+       u_int8_t        *sc_tba;        /* transmit buffer address */
+       int             sc_tbc;         /* transmit byte count */
+       int             sc_heldtbc;
+       u_int8_t        *sc_rbuf;       /* receive buffer address */
+       int             sc_rbput;       /* receive byte count */
+       int             sc_rbget;
 };
-volatile int   com_softrxintr_scheduled;
 
 extern struct cfdriver txcom_cd;
 
 int    txcom_match     __P((struct device*, struct cfdata*, void*));
 void   txcom_attach    __P((struct device*, struct device*, void*));
-int    txcom_txintr    __P((void*));
-int    txcom_a_rxintr  __P((void*));
-int    txcom_b_rxintr  __P((void*));
+
+int    txcom_txintr            __P((void*));
+int    txcom_rxintr            __P((void*));
 int    txcom_overrun_intr      __P((void*));
+int    txcom_frameerr_intr     __P((void*));
+int    txcom_parityerr_intr    __P((void*));
+int    txcom_break_intr        __P((void*));
+
 void   txcom_rxsoft    __P((void*));
+void   txcom_txsoft    __P((void*));
+ 
+void   txcom_shutdown  __P((struct txcom_softc*));
+void   txcom_break     __P((struct txcom_softc*, int));
+void   txcom_modem     __P((struct txcom_softc*, int));
+void   txcomstart      __P((struct tty*));
+int    txcomparam      __P((struct tty*, struct termios*));
 
+int    txcom_enable            __P((struct txcom_chip*));
+void   txcom_disable           __P((struct txcom_chip*));
+void   txcom_setmode           __P((struct txcom_chip*));
+void   txcom_setbaudrate       __P((struct txcom_chip*));
 int    txcom_cngetc            __P((dev_t));
 void   txcom_cnputc            __P((dev_t, int));
-void   txcom_cnpollc   __P((dev_t, int));
+void   txcom_cnpollc           __P((dev_t, int));
 
-void   txcomstart __P((struct tty*));
-int    txcomparam __P((struct tty*, struct termios*));
+__inline int   __txcom_txbufready __P((struct txcom_chip*, int));
+__inline const char *__txcom_slotname __P((int));
+
 cdev_decl(txcom);
 
+struct consdev txcomcons = {
+       NULL, NULL, txcom_cngetc, txcom_cnputc, txcom_cnpollc, 
+       NODEV, CN_NORMAL
+};
+
 /* Serial console */
-static struct consdev txcomcons = {
-       NULL, NULL, txcom_cngetc, txcom_cnputc, 
-       txcom_cnpollc, NODEV, CN_NORMAL
-};
-static struct txcom_softc cn_sc;
+struct txcom_chip txcom_chip;
 
 struct cfattach txcom_ca = {
        sizeof(struct txcom_softc), txcom_match, txcom_attach
 };
 
-int    txcom_enable __P((struct txcom_softc*));
-void   txcom_disable __P((struct txcom_softc*));
-void   txcom_setmode __P((struct txcom_softc*));
-void   txcom_setbaudrate __P((struct txcom_softc*));
-
 int
 txcom_match(parent, cf, aux)
        struct device *parent;
@@ -142,28 +155,40 @@
        struct txcom_softc *sc = (void*)self;
        tx_chipset_tag_t tc;
        struct tty *tp;
-
-       printf("\n");
+       struct txcom_chip *chip;
+       int slot;
 
        /* Check this slot used as serial console */
-       if (ua->ua_slot == cn_sc.sc_slot &&
-           (cn_sc.sc_hwflags & TXCOM_HW_CONSOLE)) {
-               memcpy(&cn_sc, self, sizeof(struct device));
-               memcpy(self, &cn_sc, sizeof(struct txcom_softc));
+       if (ua->ua_slot == txcom_chip.sc_slot &&
+           (txcom_chip.sc_hwflags & TXCOM_HW_CONSOLE)) {
+               sc->sc_chip = &txcom_chip;
+       } else {
+               if (!(sc->sc_chip = malloc(sizeof(struct txcom_chip),
+                                          M_DEVBUF, M_WAITOK))) {
+                       printf(": can't allocate chip\n");
+                       return;
+               }
+               memset(sc->sc_chip, 0, sizeof(struct txcom_chip));
        }
 
-       tc = sc->sc_tc = ua->ua_tc;
-       sc->sc_slot = ua->ua_slot;
+       chip = sc->sc_chip;
+       tc = chip->sc_tc = ua->ua_tc;
+       slot = chip->sc_slot = ua->ua_slot;
+       
+       if (!(sc->sc_rbuf = malloc(TXCOM_RING_SIZE, M_DEVBUF, M_WAITOK))) {
+               printf(": can't allocate buffer.\n");
+               return;
+       }
+       memset(sc->sc_rbuf, 0, TXCOM_RING_SIZE);
 
        tp = ttymalloc();
        tp->t_oproc = txcomstart;
        tp->t_param = txcomparam;
        tp->t_hwiflow = NULL;
        sc->sc_tty = tp;
-       cn_sc.sc_tty = tp; 
        tty_attach(tp);
 
-       if (ISSET(sc->sc_hwflags, TXCOM_HW_CONSOLE)) {
+       if (ISSET(chip->sc_hwflags, TXCOM_HW_CONSOLE)) {
                int maj;
                /* locate the major number */
                for (maj = 0; maj < nchrdev; maj++)
@@ -172,83 +197,95 @@
 
                cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);
 
-               printf("%s: console\n", sc->sc_dev.dv_xname);
+               printf(": console");
        }
 
+       printf("\n");
 
        /* 
         * Enable interrupt
         */
-       switch (sc->sc_slot) {
-       case TX39_UARTA:
-               tx_intr_establish(tc, MAKEINTR(2, 
-                                              TX39_INTRSTATUS2_UARTARXINT),
-                                 IST_EDGE, IPL_TTY,
-                                 txcom_a_rxintr, sc);
-               tx_intr_establish(
-                       tc, MAKEINTR(2, TX39_INTRSTATUS2_UARTARXOVERRUNINT),
-                       IST_EDGE, IPL_TTY, txcom_overrun_intr, sc);
-               break;
-       case TX39_UARTB:
-               tx_intr_establish(tc, MAKEINTR(2, 
-                                              TX39_INTRSTATUS2_UARTBRXINT),
-                                 IST_EDGE, IPL_TTY,
-                                 txcom_b_rxintr, sc);
-               tx_intr_establish(
-                       tc, MAKEINTR(2, TX39_INTRSTATUS2_UARTBRXOVERRUNINT),
-                       IST_EDGE, IPL_TTY, txcom_overrun_intr, sc);
-               break;
-       }
+#define TXCOMINTR(i, s) MAKEINTR(2, TX39_INTRSTATUS2_UART##i##INT(s))
+       
+       tx_intr_establish(tc, TXCOMINTR(RX, slot), IST_EDGE, IPL_TTY, 
+                         txcom_rxintr, sc);
+       tx_intr_establish(tc, TXCOMINTR(TX, slot), IST_EDGE, IPL_TTY,
+                         txcom_txintr, sc);
+       tx_intr_establish(tc, TXCOMINTR(RXOVERRUN, slot), IST_EDGE, IPL_TTY,
+                         txcom_overrun_intr, sc);
+       tx_intr_establish(tc, TXCOMINTR(TXOVERRUN, slot), IST_EDGE, IPL_TTY,
+                         txcom_overrun_intr, sc);
+       tx_intr_establish(tc, TXCOMINTR(FRAMEERR, slot), IST_EDGE, IPL_TTY,
+                         txcom_frameerr_intr, sc);
+       tx_intr_establish(tc, TXCOMINTR(PARITYERR, slot), IST_EDGE, IPL_TTY,
+                         txcom_parityerr_intr, sc);
+       tx_intr_establish(tc, TXCOMINTR(BREAK, slot), IST_EDGE, IPL_TTY,
+                         txcom_break_intr, sc);
 }
 
 int
-txcom_enable(sc)
-       struct txcom_softc *sc;
+txcom_enable(chip)
+       struct txcom_chip *chip;
+{
+       tx_chipset_tag_t tc;
+       
+       txreg_t reg;
+       int slot, ofs, timeout;



Home | Main Index | Thread Index | Old Index