New version of com driver. Uses a different queueing mechanism and a split

hardware/software interrupt mechanism for improved performance.  Many odd
protocols bugs also fixed.
This commit is contained in:
mycroft 1997-04-04 20:56:34 +00:00
parent 925f3b37f7
commit 9448a01404
8 changed files with 2373 additions and 1653 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: comvar.h,v 1.7 1996/11/13 19:41:37 cgd Exp $ */
/* $NetBSD: comvar.h,v 1.8 1997/04/04 20:56:40 mycroft Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -30,22 +30,87 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
struct commulti_attach_args {
int ca_slave; /* slave number */
bus_space_tag_t ca_iot;
bus_space_handle_t ca_ioh;
int ca_iobase;
int ca_noien;
};
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
int comintr __P((void *));
/* For other ports that use 'com' as console (alpha). */
extern int comconsaddr;
extern int comconsattached;
extern bus_space_tag_t comconstag;
extern bus_space_handle_t comconsbah;
extern bus_space_handle_t comconsioh;
extern tcflag_t comconscflag;
void cominit __P((bus_space_tag_t, bus_space_handle_t, int));
/* Hardware flag masks */
#define COM_HW_NOIEN 0x01
#define COM_HW_FIFO 0x02
#define COM_HW_HAYESP 0x04
#define COM_HW_CONSOLE 0x40
/* Buffer size for character buffer */
#define RXBUFSIZE 2048 /* More than enough.. */
#define RXBUFMASK (RXBUFSIZE-1) /* Only iff previous is a power of 2 */
#define RXHIWAT (RXBUFSIZE >> 2)
struct com_softc {
struct device sc_dev;
void *sc_ih;
void *sc_si;
struct tty *sc_tty;
int sc_overflows;
int sc_floods;
int sc_errors;
int sc_iobase;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_space_handle_t sc_hayespioh;
u_char sc_hwflags;
u_char sc_swflags;
int sc_fifolen;
u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr, sc_mcr_active, sc_lcr,
sc_ier, sc_fifo, sc_dlbl, sc_dlbh;
u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
int sc_r_hiwat;
volatile u_int sc_rbget;
volatile u_int sc_rbput;
volatile u_int sc_rbavail;
u_char sc_rbuf[RXBUFSIZE];
u_char sc_lbuf[RXBUFSIZE];
u_char *sc_tba;
int sc_tbc,
sc_heldtbc;
volatile u_char sc_rx_blocked,
sc_tx_busy,
sc_tx_done,
sc_tx_stopped,
sc_st_check,
sc_rx_ready;
volatile u_char sc_heldchange;
};
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
int comintr __P((void *));
void com_attach_subr __P((struct com_softc *));
void cominit __P((bus_space_tag_t, bus_space_handle_t, int));
#ifndef __GENERIC_SOFT_INTERRUPTS
#ifdef alpha
#define IPL_SERIAL IPL_TTY
#define splserial() spltty()
#define IPL_SOFTSERIAL IPL_TTY
#define splsoftserial() spltty()
#endif
#endif
#ifndef __BROKEN_INDIRECT_CONFIG
#define __CGD_INDIRECT_CONFIG
#endif

File diff suppressed because it is too large Load Diff

154
sys/dev/isa/com_isa.c Normal file
View File

@ -0,0 +1,154 @@
/* $NetBSD: com_isa.c,v 1.1 1997/04/04 20:56:37 mycroft Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996
* Charles M. Hannum. All rights reserved.
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)com.c 7.5 (Berkeley) 5/16/91
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/tty.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/types.h>
#include <sys/device.h>
#include <machine/intr.h>
#include <machine/bus.h>
#include <dev/isa/isavar.h>
#include <dev/isa/comreg.h>
#include <dev/isa/comvar.h>
#ifndef __CGD_INDIRECT_CONFIG
int com_isa_probe __P((struct device *, void *, void *));
#else
int com_isa_probe __P((struct device *, struct cfdata *, void *));
#endif
void com_isa_attach __P((struct device *, struct device *, void *));
void com_isa_cleanup __P((void *));
struct cfattach com_isa_ca = {
sizeof(struct com_softc), com_isa_probe, com_isa_attach
};
int
com_isa_probe(parent, match, aux)
struct device *parent;
#ifndef __CGD_INDIRECT_CONFIG
void *match;
#else
struct cfdata *match;
#endif
void *aux;
{
bus_space_tag_t iot;
bus_space_handle_t ioh;
int iobase;
int rv = 1;
struct isa_attach_args *ia = aux;
iot = ia->ia_iot;
iobase = ia->ia_iobase;
/* if it's in use as console, it's there. */
if (iobase != comconsaddr || comconsattached) {
if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
return 0;
}
rv = comprobe1(iot, ioh, iobase);
bus_space_unmap(iot, ioh, COM_NPORTS);
}
if (rv) {
ia->ia_iosize = COM_NPORTS;
ia->ia_msize = 0;
}
return (rv);
}
void
com_isa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct com_softc *sc = (void *)self;
int iobase, irq;
bus_space_tag_t iot;
struct isa_attach_args *ia = aux;
/*
* We're living on an isa.
*/
iobase = sc->sc_iobase = ia->ia_iobase;
iot = sc->sc_iot = ia->ia_iot;
if (iobase != comconsaddr) {
if (bus_space_map(iot, iobase, COM_NPORTS, 0, &sc->sc_ioh))
panic("comattach: io mapping failed");
} else
sc->sc_ioh = comconsioh;
irq = ia->ia_irq;
com_attach_subr(sc);
if (irq != IRQUNK) {
sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
IST_EDGE, IPL_SERIAL, comintr, sc);
}
/*
* Shutdown hook for buggy BIOSs that don't recognize the UART
* without a disabled FIFO.
*/
if (shutdownhook_establish(com_isa_cleanup, sc) == NULL)
panic("comisa: could not establish shutdown hook");
}
void
com_isa_cleanup(arg)
void *arg;
{
struct com_softc *sc = arg;
if (ISSET(sc->sc_hwflags, COM_HW_FIFO))
bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_fifo, 0);
}

113
sys/dev/isa/com_multi.c Normal file
View File

@ -0,0 +1,113 @@
/* $NetBSD: com_multi.c,v 1.1 1997/04/04 20:56:37 mycroft Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996
* Charles M. Hannum. All rights reserved.
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)com.c 7.5 (Berkeley) 5/16/91
*/
/*
* COM driver, uses National Semiconductor NS16450/NS16550AF UART
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/tty.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/types.h>
#include <sys/device.h>
#include <machine/intr.h>
#include <machine/bus.h>
#include <dev/isa/isavar.h>
#include <dev/isa/comreg.h>
#include <dev/isa/comvar.h>
#include <dev/isa/com_multi.h>
int com_multi_probe __P((struct device *, void *, void *));
void com_multi_attach __P((struct device *, struct device *, void *));
struct cfattach com_multi_ca = {
sizeof(struct com_softc), com_multi_probe, com_multi_attach
};
int
com_multi_probe(parent, match, aux)
struct device *parent;
void *match, *aux;
{
int iobase;
struct cfdata *cf = match;
struct commulti_attach_args *ca = aux;
if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave)
return (0);
iobase = ca->ca_iobase;
/* if it's in use as console, it's there. */
if (iobase == comconsaddr && !comconsattached)
return 1;
return comprobe1(ca->ca_iot, ca->ca_ioh, iobase);
}
void
com_multi_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct com_softc *sc = (void *)self;
struct commulti_attach_args *ca = aux;
/*
* We're living on a commulti.
*/
sc->sc_iot = ca->ca_iot;
sc->sc_ioh = ca->ca_ioh;
sc->sc_iobase = ca->ca_iobase;
if (ca->ca_noien)
sc->sc_hwflags |= COM_HW_NOIEN;
com_attach_subr(sc);
}

40
sys/dev/isa/com_multi.h Normal file
View File

@ -0,0 +1,40 @@
/* $NetBSD: com_multi.h,v 1.1 1997/04/04 20:56:38 mycroft Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christopher G. Demetriou
* for the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
struct commulti_attach_args {
int ca_slave; /* slave number */
bus_space_tag_t ca_iot;
bus_space_handle_t ca_ioh;
int ca_iobase;
int ca_noien;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: comvar.h,v 1.7 1996/11/13 19:41:37 cgd Exp $ */
/* $NetBSD: comvar.h,v 1.8 1997/04/04 20:56:40 mycroft Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -30,22 +30,87 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
struct commulti_attach_args {
int ca_slave; /* slave number */
bus_space_tag_t ca_iot;
bus_space_handle_t ca_ioh;
int ca_iobase;
int ca_noien;
};
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
int comintr __P((void *));
/* For other ports that use 'com' as console (alpha). */
extern int comconsaddr;
extern int comconsattached;
extern bus_space_tag_t comconstag;
extern bus_space_handle_t comconsbah;
extern bus_space_handle_t comconsioh;
extern tcflag_t comconscflag;
void cominit __P((bus_space_tag_t, bus_space_handle_t, int));
/* Hardware flag masks */
#define COM_HW_NOIEN 0x01
#define COM_HW_FIFO 0x02
#define COM_HW_HAYESP 0x04
#define COM_HW_CONSOLE 0x40
/* Buffer size for character buffer */
#define RXBUFSIZE 2048 /* More than enough.. */
#define RXBUFMASK (RXBUFSIZE-1) /* Only iff previous is a power of 2 */
#define RXHIWAT (RXBUFSIZE >> 2)
struct com_softc {
struct device sc_dev;
void *sc_ih;
void *sc_si;
struct tty *sc_tty;
int sc_overflows;
int sc_floods;
int sc_errors;
int sc_iobase;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_space_handle_t sc_hayespioh;
u_char sc_hwflags;
u_char sc_swflags;
int sc_fifolen;
u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr, sc_mcr_active, sc_lcr,
sc_ier, sc_fifo, sc_dlbl, sc_dlbh;
u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
int sc_r_hiwat;
volatile u_int sc_rbget;
volatile u_int sc_rbput;
volatile u_int sc_rbavail;
u_char sc_rbuf[RXBUFSIZE];
u_char sc_lbuf[RXBUFSIZE];
u_char *sc_tba;
int sc_tbc,
sc_heldtbc;
volatile u_char sc_rx_blocked,
sc_tx_busy,
sc_tx_done,
sc_tx_stopped,
sc_st_check,
sc_rx_ready;
volatile u_char sc_heldchange;
};
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
int comintr __P((void *));
void com_attach_subr __P((struct com_softc *));
void cominit __P((bus_space_tag_t, bus_space_handle_t, int));
#ifndef __GENERIC_SOFT_INTERRUPTS
#ifdef alpha
#define IPL_SERIAL IPL_TTY
#define splserial() spltty()
#define IPL_SOFTSERIAL IPL_TTY
#define splsoftserial() spltty()
#endif
#endif
#ifndef __BROKEN_INDIRECT_CONFIG
#define __CGD_INDIRECT_CONFIG
#endif

View File

@ -1,4 +1,4 @@
# $NetBSD: files.isa,v 1.27 1997/03/15 18:11:37 is Exp $
# $NetBSD: files.isa,v 1.28 1997/04/04 20:56:41 mycroft Exp $
#
# Config.new file and device description for machine-independent ISA code.
# Included by ports that need it. Requires that the SCSI files be
@ -45,9 +45,13 @@ file dev/isa/rtfps.c rtfps
# 8250/16[45]50-based "com" ports
device com: tty
file dev/isa/com.c com needs-flag
attach com at isa with com_isa
attach com at commulti with com_commulti
file dev/isa/com.c com & (com_isa | com_commulti) needs-flag
file dev/isa/com_isa.c com_isa
attach com at commulti with com_multi
file dev/isa/com_multi.c com_multi
# Cyclades Cyclom-8/16/32
attach cy at isa with cy_isa
@ -143,6 +147,7 @@ attach el at isa
file dev/isa/if_el.c el
# 3Com 3C509 Ethernet controller
# device declaration in sys/conf/files
attach ep at isa with ep_isa: elink
file dev/isa/if_ep_isa.c ep_isa