2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
1995-11-28 02:07:36 +00:00
|
|
|
* Device driver for Specialix range (SI/XIO) of serial line multiplexors.
|
1995-08-09 13:13:47 +00:00
|
|
|
*
|
1998-03-23 16:27:43 +00:00
|
|
|
* Copyright (C) 1990, 1992, 1998 Specialix International,
|
1995-08-09 13:13:47 +00:00
|
|
|
* Copyright (C) 1993, Andy Rutter <andy@acronym.co.uk>
|
2000-01-24 07:24:02 +00:00
|
|
|
* Copyright (C) 2000, Peter Wemm <peter@netplex.com.au>
|
1995-08-09 13:13:47 +00:00
|
|
|
*
|
|
|
|
* Originally derived from: SunOS 4.x version
|
|
|
|
* Ported from BSDI version to FreeBSD by Peter Wemm.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* notices, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notices, 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 Andy Rutter of
|
|
|
|
* Advanced Methods and Tools Ltd. based on original information
|
|
|
|
* from Specialix International.
|
|
|
|
* 4. Neither the name of Advanced Methods and Tools, nor Specialix
|
|
|
|
* International may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY ``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 AUTHORS BE LIABLE.
|
|
|
|
*
|
|
|
|
*/
|
2003-08-24 18:03:45 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
#ifndef lint
|
1998-03-23 16:27:43 +00:00
|
|
|
static const char si_copyright1[] = "@(#) Copyright (C) Specialix International, 1990,1992,1998",
|
|
|
|
si_copyright2[] = "@(#) Copyright (C) Andy Rutter 1993",
|
2000-01-24 07:24:02 +00:00
|
|
|
si_copyright3[] = "@(#) Copyright (C) Peter Wemm 2000";
|
1995-08-09 13:13:47 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
1997-12-16 17:40:42 +00:00
|
|
|
#include "opt_compat.h"
|
1998-01-31 07:23:16 +00:00
|
|
|
#include "opt_debug_si.h"
|
2007-01-18 13:33:36 +00:00
|
|
|
#include "opt_eisa.h"
|
1997-12-16 17:40:42 +00:00
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2004-10-02 16:56:08 +00:00
|
|
|
#include <sys/serial.h>
|
1995-08-09 13:13:47 +00:00
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/conf.h>
|
1997-03-23 03:37:54 +00:00
|
|
|
#include <sys/fcntl.h>
|
1995-08-09 13:13:47 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
2006-11-06 13:42:10 +00:00
|
|
|
#include <sys/priv.h>
|
1996-05-08 04:48:25 +00:00
|
|
|
#include <sys/sysctl.h>
|
2000-01-23 22:51:49 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <machine/resource.h>
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
|
1995-12-06 23:52:35 +00:00
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/pmap.h>
|
1995-12-06 23:52:35 +00:00
|
|
|
|
1996-01-09 03:01:45 +00:00
|
|
|
#include <machine/stdarg.h>
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
#include <dev/si/sireg.h>
|
2000-01-24 07:24:02 +00:00
|
|
|
#include <dev/si/sivar.h>
|
2000-01-23 22:51:49 +00:00
|
|
|
#include <dev/si/si.h>
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
|
|
|
* This device driver is designed to interface the Specialix International
|
1998-03-23 16:27:43 +00:00
|
|
|
* SI, XIO and SX range of serial multiplexor cards to FreeBSD on an ISA,
|
|
|
|
* EISA or PCI bus machine.
|
1995-08-09 13:13:47 +00:00
|
|
|
*
|
1998-03-23 16:27:43 +00:00
|
|
|
* The controller is interfaced to the host via dual port RAM
|
|
|
|
* and an interrupt.
|
1998-02-15 14:42:33 +00:00
|
|
|
*
|
1998-03-23 16:27:43 +00:00
|
|
|
* The code for the Host 1 (very old ISA cards) has not been tested.
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
#undef POLL /* turn on poller to scan for lost interrupts */
|
2008-06-06 03:21:59 +00:00
|
|
|
#if 0
|
1996-08-12 17:12:07 +00:00
|
|
|
#define REALPOLL /* on each poll, scan for work regardless */
|
2008-06-06 03:21:59 +00:00
|
|
|
#endif
|
1996-08-12 17:12:07 +00:00
|
|
|
#define POLLHZ (hz/10) /* 10 times per second */
|
1995-11-28 02:07:36 +00:00
|
|
|
#define SI_I_HIGH_WATER (TTYHOG - 2 * SI_BUFFERSIZE)
|
1998-03-23 16:27:43 +00:00
|
|
|
#define INT_COUNT 25000 /* max of 125 ints per second */
|
|
|
|
#define JET_INT_COUNT 100 /* max of 100 ints per second */
|
1996-05-05 17:09:04 +00:00
|
|
|
#define RXINT_COUNT 1 /* one rxint per 10 milliseconds */
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
static void si_command(struct si_port *, int, int);
|
2004-06-16 09:47:26 +00:00
|
|
|
static int si_Sioctl(struct cdev *, u_long, caddr_t, int, struct thread *);
|
2008-09-08 11:41:20 +00:00
|
|
|
/* static void si_stop(struct tty *, int); */
|
|
|
|
#if 0
|
1997-04-20 15:36:12 +00:00
|
|
|
static timeout_t si_lstart;
|
2008-09-08 11:41:20 +00:00
|
|
|
#endif
|
1995-09-13 08:45:28 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
static tsw_outwakeup_t si_start;
|
|
|
|
static tsw_ioctl_t siioctl;
|
|
|
|
static tsw_close_t siclose;
|
|
|
|
static tsw_modem_t simodem;
|
|
|
|
static tsw_open_t siopen;
|
|
|
|
static tsw_param_t siparam;
|
1995-12-08 11:19:42 +00:00
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
static void si_modem_state(struct si_port *pp, struct tty *tp, int hi_ip);
|
|
|
|
static char * si_modulename(int host_type, int uart_type);
|
1998-03-23 16:27:43 +00:00
|
|
|
|
2004-10-02 16:56:08 +00:00
|
|
|
static struct cdevsw si_Scdevsw = {
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_version = D_VERSION,
|
2004-10-02 16:56:08 +00:00
|
|
|
.d_ioctl = si_Sioctl,
|
2003-03-03 12:15:54 +00:00
|
|
|
.d_name = "si",
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_flags = D_TTY | D_NEEDGIANT,
|
1998-08-23 08:26:42 +00:00
|
|
|
};
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1995-09-22 20:00:12 +00:00
|
|
|
static int si_Nports;
|
|
|
|
static int si_Nmodules;
|
2008-09-08 11:41:20 +00:00
|
|
|
static int si_debug;
|
1995-09-22 20:00:12 +00:00
|
|
|
|
1998-03-23 16:27:43 +00:00
|
|
|
SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RW, &si_debug, 0, "");
|
2002-07-27 08:17:29 +00:00
|
|
|
TUNABLE_INT("machdep.si_debug", &si_debug);
|
1998-03-23 16:27:43 +00:00
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
static int si_numunits;
|
|
|
|
|
2000-01-24 07:24:02 +00:00
|
|
|
devclass_t si_devclass;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
struct si_speedtab {
|
|
|
|
int sp_speed; /* Speed. */
|
|
|
|
int sp_code; /* Code. */
|
|
|
|
};
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
#ifndef B2000 /* not standard, but the hardware knows it. */
|
1995-08-09 13:13:47 +00:00
|
|
|
# define B2000 2000
|
|
|
|
#endif
|
2008-09-08 11:41:20 +00:00
|
|
|
static struct si_speedtab bdrates[] = {
|
1999-08-27 08:32:54 +00:00
|
|
|
{ B75, CLK75, }, /* 0x0 */
|
|
|
|
{ B110, CLK110, }, /* 0x1 */
|
|
|
|
{ B150, CLK150, }, /* 0x3 */
|
|
|
|
{ B300, CLK300, }, /* 0x4 */
|
|
|
|
{ B600, CLK600, }, /* 0x5 */
|
|
|
|
{ B1200, CLK1200, }, /* 0x6 */
|
|
|
|
{ B2000, CLK2000, }, /* 0x7 */
|
|
|
|
{ B2400, CLK2400, }, /* 0x8 */
|
|
|
|
{ B4800, CLK4800, }, /* 0x9 */
|
|
|
|
{ B9600, CLK9600, }, /* 0xb */
|
|
|
|
{ B19200, CLK19200, }, /* 0xc */
|
|
|
|
{ B38400, CLK38400, }, /* 0x2 (out of order!) */
|
|
|
|
{ B57600, CLK57600, }, /* 0xd */
|
|
|
|
{ B115200, CLK110, }, /* 0x1 (dupe!, 110 baud on "si") */
|
|
|
|
{ -1, -1 },
|
1995-08-09 13:13:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef POLL
|
1996-05-08 04:48:25 +00:00
|
|
|
static int si_pollrate; /* in addition to irq */
|
2000-01-23 22:51:49 +00:00
|
|
|
static int si_realpoll = 0; /* poll HW on timer */
|
1996-05-05 17:09:04 +00:00
|
|
|
|
1996-06-16 13:32:16 +00:00
|
|
|
SYSCTL_INT(_machdep, OID_AUTO, si_pollrate, CTLFLAG_RW, &si_pollrate, 0, "");
|
1996-08-12 17:12:07 +00:00
|
|
|
SYSCTL_INT(_machdep, OID_AUTO, si_realpoll, CTLFLAG_RW, &si_realpoll, 0, "");
|
1999-08-27 08:32:54 +00:00
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
static int init_finished = 0;
|
2000-01-23 22:51:49 +00:00
|
|
|
static void si_poll(void *);
|
1995-08-09 13:13:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Array of adapter types and the corresponding RAM size. The order of
|
|
|
|
* entries here MUST match the ordinal of the adapter type.
|
|
|
|
*/
|
2004-10-02 16:56:08 +00:00
|
|
|
static const char *si_type[] = {
|
1995-08-09 13:13:47 +00:00
|
|
|
"EMPTY",
|
|
|
|
"SIHOST",
|
1998-03-23 16:27:43 +00:00
|
|
|
"SIMCA", /* FreeBSD does not support Microchannel */
|
1995-08-09 13:13:47 +00:00
|
|
|
"SIHOST2",
|
|
|
|
"SIEISA",
|
1998-02-15 14:42:33 +00:00
|
|
|
"SIPCI",
|
|
|
|
"SXPCI",
|
|
|
|
"SXISA",
|
1995-08-09 13:13:47 +00:00
|
|
|
};
|
|
|
|
|
2008-06-06 03:21:59 +00:00
|
|
|
#ifdef SI_DEBUG
|
|
|
|
static char *
|
|
|
|
si_cmdname(int cmd)
|
|
|
|
{
|
|
|
|
static char buf[32];
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case IDLE_OPEN: return("IDLE_OPEN");
|
|
|
|
case LOPEN: return("LOPEN");
|
|
|
|
case MOPEN: return("MOPEN");
|
|
|
|
case MPEND: return("MPEND");
|
|
|
|
case CONFIG: return("CONFIG");
|
|
|
|
case CLOSE: return("CLOSE");
|
|
|
|
case SBREAK: return("SBREAK");
|
|
|
|
case EBREAK: return("EBREAK");
|
|
|
|
case IDLE_CLOSE: return("IDLE_CLOSE");
|
|
|
|
case IDLE_BREAK: return("IDLE_BREAK");
|
|
|
|
case FCLOSE: return("FCLOSE");
|
|
|
|
case RESUME: return("RESUME");
|
|
|
|
case WFLUSH: return("WFLUSH");
|
|
|
|
case RFLUSH: return("RFLUSH");
|
|
|
|
default:
|
|
|
|
sprintf(buf, "?cmd:0x%x?", cmd);
|
|
|
|
return (buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
/*
|
|
|
|
* We have to make an 8 bit version of bcopy, since some cards can't
|
|
|
|
* deal with 32 bit I/O
|
|
|
|
*/
|
|
|
|
static void __inline
|
|
|
|
si_bcopy(const void *src, void *dst, size_t len)
|
|
|
|
{
|
2004-07-28 06:21:53 +00:00
|
|
|
u_char *d;
|
|
|
|
const u_char *s;
|
|
|
|
|
|
|
|
d = dst;
|
|
|
|
s = src;
|
2000-01-23 22:51:49 +00:00
|
|
|
while (len--)
|
2004-07-28 06:21:53 +00:00
|
|
|
*d++ = *s++;
|
2000-01-23 22:51:49 +00:00
|
|
|
}
|
|
|
|
static void __inline
|
|
|
|
si_vbcopy(const volatile void *src, void *dst, size_t len)
|
|
|
|
{
|
2004-07-28 06:21:53 +00:00
|
|
|
u_char *d;
|
|
|
|
const volatile u_char *s;
|
|
|
|
|
|
|
|
d = dst;
|
|
|
|
s = src;
|
2000-01-23 22:51:49 +00:00
|
|
|
while (len--)
|
2004-07-28 06:21:53 +00:00
|
|
|
*d++ = *s++;
|
2000-01-23 22:51:49 +00:00
|
|
|
}
|
|
|
|
static void __inline
|
|
|
|
si_bcopyv(const void *src, volatile void *dst, size_t len)
|
|
|
|
{
|
2004-07-28 06:21:53 +00:00
|
|
|
volatile u_char *d;
|
|
|
|
const u_char *s;
|
|
|
|
|
|
|
|
d = dst;
|
|
|
|
s = src;
|
2000-01-23 22:51:49 +00:00
|
|
|
while (len--)
|
2004-07-28 06:21:53 +00:00
|
|
|
*d++ = *s++;
|
2000-01-23 22:51:49 +00:00
|
|
|
}
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
static int
|
|
|
|
si_speedtab(int speed, struct si_speedtab *table)
|
|
|
|
{
|
|
|
|
for ( ; table->sp_speed != -1; table++)
|
|
|
|
if (table->sp_speed == speed)
|
|
|
|
return (table->sp_code);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct ttydevsw si_tty_class = {
|
|
|
|
.tsw_flags = TF_INITLOCK|TF_CALLOUT,
|
|
|
|
.tsw_open = siopen,
|
|
|
|
.tsw_close = siclose,
|
|
|
|
.tsw_outwakeup = si_start,
|
|
|
|
/* .tsw_stop = si_stop */
|
|
|
|
.tsw_ioctl = siioctl,
|
|
|
|
.tsw_param = siparam,
|
|
|
|
.tsw_modem = simodem,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
|
|
|
* Attach the device. Initialize the card.
|
|
|
|
*/
|
2000-01-24 07:24:02 +00:00
|
|
|
int
|
2000-01-23 22:51:49 +00:00
|
|
|
siattach(device_t dev)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
2000-01-23 22:51:49 +00:00
|
|
|
int unit;
|
|
|
|
struct si_softc *sc;
|
1995-08-09 13:13:47 +00:00
|
|
|
struct si_port *pp;
|
2004-10-02 16:56:08 +00:00
|
|
|
struct tty *tp;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile struct si_channel *ccbp;
|
|
|
|
volatile struct si_reg *regp;
|
|
|
|
volatile caddr_t maddr;
|
|
|
|
struct si_module *modp;
|
|
|
|
int nmodule, nport, x, y;
|
1995-11-09 21:53:48 +00:00
|
|
|
int uart_type;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
sc = device_get_softc(dev);
|
|
|
|
unit = device_get_unit(dev);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2000-01-24 07:24:02 +00:00
|
|
|
sc->sc_typename = si_type[sc->sc_type];
|
|
|
|
if (si_numunits < unit + 1)
|
|
|
|
si_numunits = unit + 1;
|
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
DPRINT((0, DBG_AUTOBOOT, "si%d: siattach\n", unit));
|
|
|
|
|
|
|
|
#ifdef POLL
|
|
|
|
if (si_pollrate == 0) {
|
|
|
|
si_pollrate = POLLHZ; /* in addition to irq */
|
|
|
|
#ifdef REALPOLL
|
|
|
|
si_realpoll = 1; /* scan always */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1998-02-15 14:42:33 +00:00
|
|
|
DPRINT((0, DBG_AUTOBOOT, "si%d: type: %s paddr: %x maddr: %x\n", unit,
|
|
|
|
sc->sc_typename, sc->sc_paddr, sc->sc_maddr));
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
sc->sc_ports = NULL; /* mark as uninitialised */
|
|
|
|
|
|
|
|
maddr = sc->sc_maddr;
|
|
|
|
|
1998-03-23 16:27:43 +00:00
|
|
|
/* Stop the CPU first so it won't stomp around while we load */
|
|
|
|
|
|
|
|
switch (sc->sc_type) {
|
2007-01-18 13:33:36 +00:00
|
|
|
#ifdef DEV_EISA
|
1998-03-23 16:27:43 +00:00
|
|
|
case SIEISA:
|
2000-01-23 22:51:49 +00:00
|
|
|
outb(sc->sc_iobase + 2, sc->sc_irq << 4);
|
2007-01-18 13:33:36 +00:00
|
|
|
#endif
|
1998-03-23 16:27:43 +00:00
|
|
|
break;
|
|
|
|
case SIPCI:
|
|
|
|
*(maddr+SIPCIRESET) = 0;
|
|
|
|
break;
|
|
|
|
case SIJETPCI: /* fall through to JET ISA */
|
|
|
|
case SIJETISA:
|
|
|
|
*(maddr+SIJETCONFIG) = 0;
|
|
|
|
break;
|
|
|
|
case SIHOST2:
|
|
|
|
*(maddr+SIPLRESET) = 0;
|
|
|
|
break;
|
|
|
|
case SIHOST:
|
|
|
|
*(maddr+SIRESET) = 0;
|
|
|
|
break;
|
|
|
|
default: /* this should never happen */
|
|
|
|
printf("si%d: unsupported configuration\n", unit);
|
2000-01-23 22:51:49 +00:00
|
|
|
return EINVAL;
|
1998-03-23 16:27:43 +00:00
|
|
|
break;
|
1998-02-15 14:42:33 +00:00
|
|
|
}
|
1998-03-23 16:27:43 +00:00
|
|
|
|
|
|
|
/* OK, now lets download the download code */
|
|
|
|
|
1998-06-13 19:36:22 +00:00
|
|
|
if (SI_ISJET(sc->sc_type)) {
|
1998-03-23 16:27:43 +00:00
|
|
|
DPRINT((0, DBG_DOWNLOAD, "si%d: jet_download: nbytes %d\n",
|
2000-01-23 22:51:49 +00:00
|
|
|
unit, si3_t225_dsize));
|
1998-03-23 16:27:43 +00:00
|
|
|
si_bcopy(si3_t225_download, maddr + si3_t225_downloadaddr,
|
|
|
|
si3_t225_dsize);
|
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
|
|
|
"si%d: jet_bootstrap: nbytes %d -> %x\n",
|
2000-01-23 22:51:49 +00:00
|
|
|
unit, si3_t225_bsize, si3_t225_bootloadaddr));
|
1998-03-23 16:27:43 +00:00
|
|
|
si_bcopy(si3_t225_bootstrap, maddr + si3_t225_bootloadaddr,
|
|
|
|
si3_t225_bsize);
|
|
|
|
} else {
|
1998-02-15 14:42:33 +00:00
|
|
|
DPRINT((0, DBG_DOWNLOAD, "si%d: si_download: nbytes %d\n",
|
2000-01-23 22:51:49 +00:00
|
|
|
unit, si2_z280_dsize));
|
1998-03-23 16:27:43 +00:00
|
|
|
si_bcopy(si2_z280_download, maddr + si2_z280_downloadaddr,
|
|
|
|
si2_z280_dsize);
|
1998-02-15 14:42:33 +00:00
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1998-03-23 16:27:43 +00:00
|
|
|
/* Now start the CPU */
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
switch (sc->sc_type) {
|
2007-01-18 13:33:36 +00:00
|
|
|
#ifdef DEV_EISA
|
1998-03-23 16:27:43 +00:00
|
|
|
case SIEISA:
|
|
|
|
/* modify the download code to tell it that it's on an EISA */
|
|
|
|
*(maddr + 0x42) = 1;
|
2000-01-23 22:51:49 +00:00
|
|
|
outb(sc->sc_iobase + 2, (sc->sc_irq << 4) | 4);
|
|
|
|
(void)inb(sc->sc_iobase + 3); /* reset interrupt */
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
2007-01-18 13:33:36 +00:00
|
|
|
#endif
|
1998-02-15 14:42:33 +00:00
|
|
|
case SIPCI:
|
1998-03-23 16:27:43 +00:00
|
|
|
/* modify the download code to tell it that it's on a PCI */
|
1998-02-15 14:42:33 +00:00
|
|
|
*(maddr+0x42) = 1;
|
|
|
|
*(maddr+SIPCIRESET) = 1;
|
|
|
|
*(maddr+SIPCIINTCL) = 0;
|
|
|
|
break;
|
|
|
|
case SIJETPCI:
|
|
|
|
*(maddr+SIJETRESET) = 0;
|
|
|
|
*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN;
|
|
|
|
break;
|
|
|
|
case SIJETISA:
|
|
|
|
*(maddr+SIJETRESET) = 0;
|
1998-03-23 16:27:43 +00:00
|
|
|
switch (sc->sc_irq) {
|
2000-01-23 22:51:49 +00:00
|
|
|
case 9:
|
1998-03-23 16:27:43 +00:00
|
|
|
*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0x90;
|
|
|
|
break;
|
2000-01-23 22:51:49 +00:00
|
|
|
case 10:
|
1998-03-23 16:27:43 +00:00
|
|
|
*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xa0;
|
|
|
|
break;
|
2000-01-23 22:51:49 +00:00
|
|
|
case 11:
|
1998-03-23 16:27:43 +00:00
|
|
|
*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xb0;
|
|
|
|
break;
|
2000-01-23 22:51:49 +00:00
|
|
|
case 12:
|
1998-03-23 16:27:43 +00:00
|
|
|
*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xc0;
|
|
|
|
break;
|
2000-01-23 22:51:49 +00:00
|
|
|
case 15:
|
1998-03-23 16:27:43 +00:00
|
|
|
*(maddr+SIJETCONFIG) = SIJETBUSEN|SIJETIRQEN|0xf0;
|
|
|
|
break;
|
|
|
|
}
|
1998-02-15 14:42:33 +00:00
|
|
|
break;
|
1995-08-09 13:13:47 +00:00
|
|
|
case SIHOST:
|
|
|
|
*(maddr+SIRESET_CL) = 0;
|
|
|
|
*(maddr+SIINTCL_CL) = 0;
|
|
|
|
break;
|
|
|
|
case SIHOST2:
|
|
|
|
*(maddr+SIPLRESET) = 0x10;
|
|
|
|
switch (sc->sc_irq) {
|
2000-01-23 22:51:49 +00:00
|
|
|
case 11:
|
1995-08-09 13:13:47 +00:00
|
|
|
*(maddr+SIPLIRQ11) = 0x10;
|
|
|
|
break;
|
2000-01-23 22:51:49 +00:00
|
|
|
case 12:
|
1995-08-09 13:13:47 +00:00
|
|
|
*(maddr+SIPLIRQ12) = 0x10;
|
|
|
|
break;
|
2000-01-23 22:51:49 +00:00
|
|
|
case 15:
|
1995-08-09 13:13:47 +00:00
|
|
|
*(maddr+SIPLIRQ15) = 0x10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*(maddr+SIPLIRQCLR) = 0x10;
|
|
|
|
break;
|
1998-03-23 16:27:43 +00:00
|
|
|
default: /* this should _REALLY_ never happen */
|
|
|
|
printf("si%d: Uh, it was supported a second ago...\n", unit);
|
2000-01-23 22:51:49 +00:00
|
|
|
return EINVAL;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DELAY(1000000); /* wait around for a second */
|
|
|
|
|
|
|
|
regp = (struct si_reg *)maddr;
|
|
|
|
y = 0;
|
|
|
|
/* wait max of 5 sec for init OK */
|
|
|
|
while (regp->initstat == 0 && y++ < 10) {
|
|
|
|
DELAY(500000);
|
|
|
|
}
|
|
|
|
switch (regp->initstat) {
|
|
|
|
case 0:
|
|
|
|
printf("si%d: startup timeout - aborting\n", unit);
|
1995-11-09 21:53:48 +00:00
|
|
|
sc->sc_type = SIEMPTY;
|
2000-01-23 22:51:49 +00:00
|
|
|
return EINVAL;
|
1995-08-09 13:13:47 +00:00
|
|
|
case 1:
|
1998-06-13 19:36:22 +00:00
|
|
|
if (SI_ISJET(sc->sc_type)) {
|
1998-03-23 16:27:43 +00:00
|
|
|
/* set throttle to 100 times per second */
|
|
|
|
regp->int_count = JET_INT_COUNT;
|
|
|
|
/* rx_intr_count is a NOP in Jet */
|
|
|
|
} else {
|
|
|
|
/* set throttle to 125 times per second */
|
|
|
|
regp->int_count = INT_COUNT;
|
|
|
|
/* rx intr max of 25 times per second */
|
|
|
|
regp->rx_int_count = RXINT_COUNT;
|
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
regp->int_pending = 0; /* no intr pending */
|
|
|
|
regp->int_scounter = 0; /* reset counter */
|
|
|
|
break;
|
|
|
|
case 0xff:
|
|
|
|
/*
|
|
|
|
* No modules found, so give up on this one.
|
|
|
|
*/
|
|
|
|
printf("si%d: %s - no ports found\n", unit,
|
|
|
|
si_type[sc->sc_type]);
|
|
|
|
return 0;
|
|
|
|
default:
|
1998-03-23 16:27:43 +00:00
|
|
|
printf("si%d: download code version error - initstat %x\n",
|
1995-08-09 13:13:47 +00:00
|
|
|
unit, regp->initstat);
|
2000-01-23 22:51:49 +00:00
|
|
|
return EINVAL;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First time around the ports just count them in order
|
|
|
|
* to allocate some memory.
|
|
|
|
*/
|
|
|
|
nport = 0;
|
|
|
|
modp = (struct si_module *)(maddr + 0x80);
|
|
|
|
for (;;) {
|
1995-11-09 21:53:48 +00:00
|
|
|
DPRINT((0, DBG_DOWNLOAD, "si%d: ccb addr 0x%x\n", unit, modp));
|
1998-03-23 16:27:43 +00:00
|
|
|
switch (modp->sm_type) {
|
|
|
|
case TA4:
|
1995-08-09 13:13:47 +00:00
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
1998-03-23 16:27:43 +00:00
|
|
|
"si%d: Found old TA4 module, 4 ports\n",
|
|
|
|
unit));
|
|
|
|
x = 4;
|
|
|
|
break;
|
|
|
|
case TA8:
|
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
|
|
|
"si%d: Found old TA8 module, 8 ports\n",
|
|
|
|
unit));
|
|
|
|
x = 8;
|
|
|
|
break;
|
|
|
|
case TA4_ASIC:
|
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
|
|
|
"si%d: Found ASIC TA4 module, 4 ports\n",
|
|
|
|
unit));
|
|
|
|
x = 4;
|
|
|
|
break;
|
|
|
|
case TA8_ASIC:
|
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
|
|
|
"si%d: Found ASIC TA8 module, 8 ports\n",
|
|
|
|
unit));
|
|
|
|
x = 8;
|
|
|
|
break;
|
|
|
|
case MTA:
|
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
|
|
|
"si%d: Found CD1400 module, 8 ports\n",
|
|
|
|
unit));
|
|
|
|
x = 8;
|
|
|
|
break;
|
|
|
|
case SXDC:
|
|
|
|
DPRINT((0, DBG_DOWNLOAD,
|
|
|
|
"si%d: Found SXDC module, 8 ports\n",
|
|
|
|
unit));
|
|
|
|
x = 8;
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("si%d: unknown module type %d\n",
|
|
|
|
unit, modp->sm_type);
|
1998-03-23 16:27:43 +00:00
|
|
|
goto try_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this was limited in firmware and is also a driver issue */
|
|
|
|
if ((nport + x) > SI_MAXPORTPERCARD) {
|
|
|
|
printf("si%d: extra ports ignored\n", unit);
|
|
|
|
goto try_next;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
1998-03-23 16:27:43 +00:00
|
|
|
|
|
|
|
nport += x;
|
|
|
|
si_Nports += x;
|
|
|
|
si_Nmodules++;
|
|
|
|
|
|
|
|
try_next:
|
1995-08-09 13:13:47 +00:00
|
|
|
if (modp->sm_next == 0)
|
|
|
|
break;
|
|
|
|
modp = (struct si_module *)
|
|
|
|
(maddr + (unsigned)(modp->sm_next & 0x7fff));
|
|
|
|
}
|
|
|
|
sc->sc_ports = (struct si_port *)malloc(sizeof(struct si_port) * nport,
|
2000-12-08 21:51:06 +00:00
|
|
|
M_DEVBUF, M_NOWAIT | M_ZERO);
|
1995-08-09 13:13:47 +00:00
|
|
|
if (sc->sc_ports == 0) {
|
|
|
|
printf("si%d: fail to malloc memory for port structs\n",
|
|
|
|
unit);
|
2000-01-23 22:51:49 +00:00
|
|
|
return EINVAL;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
sc->sc_nport = nport;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan round the ports again, this time initialising.
|
|
|
|
*/
|
|
|
|
pp = sc->sc_ports;
|
|
|
|
nmodule = 0;
|
|
|
|
modp = (struct si_module *)(maddr + 0x80);
|
1998-03-23 16:27:43 +00:00
|
|
|
uart_type = 1000; /* arbitary, > uchar_max */
|
1995-08-09 13:13:47 +00:00
|
|
|
for (;;) {
|
1998-03-23 16:27:43 +00:00
|
|
|
switch (modp->sm_type) {
|
|
|
|
case TA4:
|
|
|
|
nport = 4;
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
1998-03-23 16:27:43 +00:00
|
|
|
case TA8:
|
|
|
|
nport = 8;
|
|
|
|
break;
|
|
|
|
case TA4_ASIC:
|
|
|
|
nport = 4;
|
|
|
|
break;
|
|
|
|
case TA8_ASIC:
|
|
|
|
nport = 8;
|
|
|
|
break;
|
|
|
|
case MTA:
|
|
|
|
nport = 8;
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
1998-03-23 16:27:43 +00:00
|
|
|
case SXDC:
|
|
|
|
nport = 8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto try_next2;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
1998-03-23 16:27:43 +00:00
|
|
|
nmodule++;
|
|
|
|
ccbp = (struct si_channel *)((char *)modp + 0x100);
|
|
|
|
if (uart_type == 1000)
|
|
|
|
uart_type = ccbp->type;
|
|
|
|
else if (uart_type != ccbp->type)
|
|
|
|
printf("si%d: Warning: module %d mismatch! (%d%s != %d%s)\n",
|
|
|
|
unit, nmodule,
|
|
|
|
ccbp->type, si_modulename(sc->sc_type, ccbp->type),
|
|
|
|
uart_type, si_modulename(sc->sc_type, uart_type));
|
|
|
|
|
|
|
|
for (x = 0; x < nport; x++, pp++, ccbp++) {
|
|
|
|
pp->sp_ccb = ccbp; /* save the address */
|
|
|
|
pp->sp_pend = IDLE_CLOSE;
|
|
|
|
pp->sp_state = 0; /* internal flag */
|
2004-10-02 16:56:08 +00:00
|
|
|
#ifdef SI_DEBUG
|
2006-01-06 19:56:12 +00:00
|
|
|
sprintf(pp->sp_name, "si%r%r", unit,
|
|
|
|
(int)(pp - sc->sc_ports));
|
2004-10-02 16:56:08 +00:00
|
|
|
#endif
|
2008-09-08 11:41:20 +00:00
|
|
|
tp = pp->sp_tty = tty_alloc(&si_tty_class, pp, &Giant);
|
|
|
|
tty_makedev(tp, NULL, "A%r%r", unit, (int)(pp - sc->sc_ports));
|
1998-03-23 16:27:43 +00:00
|
|
|
}
|
|
|
|
try_next2:
|
1995-08-09 13:13:47 +00:00
|
|
|
if (modp->sm_next == 0) {
|
1998-03-23 16:27:43 +00:00
|
|
|
printf("si%d: card: %s, ports: %d, modules: %d, type: %d%s\n",
|
1995-08-09 13:13:47 +00:00
|
|
|
unit,
|
|
|
|
sc->sc_typename,
|
|
|
|
sc->sc_nport,
|
1995-11-09 21:53:48 +00:00
|
|
|
nmodule,
|
1998-03-23 16:27:43 +00:00
|
|
|
uart_type,
|
|
|
|
si_modulename(sc->sc_type, uart_type));
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
modp = (struct si_module *)
|
|
|
|
(maddr + (unsigned)(modp->sm_next & 0x7fff));
|
|
|
|
}
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
|
2006-01-06 19:56:12 +00:00
|
|
|
if (unit == 0)
|
|
|
|
make_dev(&si_Scdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
|
|
|
|
"si_control");
|
2000-01-23 22:51:49 +00:00
|
|
|
return (0);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
2008-09-08 11:41:20 +00:00
|
|
|
siopen(struct tty *tp)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((0, DBG_ENTRY|DBG_OPEN, "siopen()\n"));
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
#ifdef POLL
|
|
|
|
/*
|
|
|
|
* We've now got a device, so start the poller.
|
|
|
|
*/
|
|
|
|
if (init_finished == 0) {
|
1996-05-05 17:09:04 +00:00
|
|
|
timeout(si_poll, (caddr_t)0L, si_pollrate);
|
1995-08-09 13:13:47 +00:00
|
|
|
init_finished = 1;
|
|
|
|
}
|
|
|
|
#endif
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((0, DBG_EXIT|DBG_OPEN, "siopen() finished\n"));
|
2004-10-02 16:56:08 +00:00
|
|
|
return(0);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-02 16:56:08 +00:00
|
|
|
siclose(struct tty *tp)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
2000-01-23 22:51:49 +00:00
|
|
|
struct si_port *pp;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((0, DBG_ENTRY|DBG_CLOSE, "siclose()\n"));
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
2008-09-08 11:41:20 +00:00
|
|
|
pp = tty_softc(tp);
|
2008-06-06 03:21:59 +00:00
|
|
|
(void) si_command(pp, FCLOSE, SI_WAIT);
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((0, DBG_EXIT|DBG_CLOSE, "siclose() finished\n"));
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
static int
|
|
|
|
siioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
struct si_port *pp;
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((0, DBG_ENTRY|DBG_IOCTL, "siioctl(0x%lx,0x%x)\n", cmd, data));
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
2008-09-08 11:41:20 +00:00
|
|
|
pp = tty_softc(tp);
|
|
|
|
switch (cmd) {
|
|
|
|
case TIOCSBRK:
|
1996-06-21 21:35:01 +00:00
|
|
|
si_command(pp, SBREAK, SI_WAIT);
|
2008-09-08 11:41:20 +00:00
|
|
|
return (0);
|
|
|
|
case TIOCCBRK:
|
1996-06-21 21:35:01 +00:00
|
|
|
si_command(pp, EBREAK, SI_WAIT);
|
2008-09-08 11:41:20 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (ENOIOCTL); /* Let the common tty ioctl handler do it */
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-10-02 16:56:08 +00:00
|
|
|
* Handle the Specialix ioctls on the control dev.
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
si_Sioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
struct si_softc *xsc;
|
2000-01-23 22:51:49 +00:00
|
|
|
struct si_port *xpp;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile struct si_reg *regp;
|
|
|
|
struct si_tcsi *dp;
|
1995-08-13 15:18:05 +00:00
|
|
|
struct si_pstat *sps;
|
1995-10-28 15:39:31 +00:00
|
|
|
int *ip, error = 0;
|
1995-08-09 13:13:47 +00:00
|
|
|
int oldspl;
|
|
|
|
int card, port;
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((0, DBG_ENTRY|DBG_IOCTL, "si_Sioctl(%s,0x%lx,0x%x)\n",
|
|
|
|
devtoname(dev), cmd, data));
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-08-13 15:18:05 +00:00
|
|
|
#if 1
|
|
|
|
DPRINT((0, DBG_IOCTL, "TCSI_PORT=%x\n", TCSI_PORT));
|
|
|
|
DPRINT((0, DBG_IOCTL, "TCSI_CCB=%x\n", TCSI_CCB));
|
|
|
|
#endif
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
oldspl = spltty(); /* better safe than sorry */
|
|
|
|
|
|
|
|
ip = (int *)data;
|
|
|
|
|
2006-11-06 13:42:10 +00:00
|
|
|
#define SUCHECK if ((error = priv_check(td, PRIV_DRIVER))) goto out
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TCSIPORTS:
|
|
|
|
*ip = si_Nports;
|
|
|
|
goto out;
|
|
|
|
case TCSIMODULES:
|
|
|
|
*ip = si_Nmodules;
|
|
|
|
goto out;
|
|
|
|
case TCSISDBG_ALL:
|
|
|
|
SUCHECK;
|
|
|
|
si_debug = *ip;
|
|
|
|
goto out;
|
|
|
|
case TCSIGDBG_ALL:
|
|
|
|
*ip = si_debug;
|
|
|
|
goto out;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Check that a controller for this port exists
|
|
|
|
*/
|
1995-08-13 15:18:05 +00:00
|
|
|
|
|
|
|
/* may also be a struct si_pstat, a superset of si_tcsi */
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
dp = (struct si_tcsi *)data;
|
1995-08-13 15:18:05 +00:00
|
|
|
sps = (struct si_pstat *)data;
|
1995-08-09 13:13:47 +00:00
|
|
|
card = dp->tc_card;
|
2000-01-23 22:51:49 +00:00
|
|
|
xsc = devclass_get_softc(si_devclass, card); /* check.. */
|
|
|
|
if (xsc == NULL || xsc->sc_type == SIEMPTY) {
|
1995-08-09 13:13:47 +00:00
|
|
|
error = ENOENT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* And check that a port exists
|
|
|
|
*/
|
|
|
|
port = dp->tc_port;
|
|
|
|
if (port < 0 || port >= xsc->sc_nport) {
|
|
|
|
error = ENOENT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
xpp = xsc->sc_ports + port;
|
|
|
|
regp = (struct si_reg *)xsc->sc_maddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TCSIDEBUG:
|
|
|
|
#ifdef SI_DEBUG
|
|
|
|
SUCHECK;
|
|
|
|
if (xpp->sp_debug)
|
|
|
|
xpp->sp_debug = 0;
|
|
|
|
else {
|
|
|
|
xpp->sp_debug = DBG_ALL;
|
|
|
|
DPRINT((xpp, DBG_IOCTL, "debug toggled %s\n",
|
|
|
|
(xpp->sp_debug&DBG_ALL)?"ON":"OFF"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#else
|
|
|
|
error = ENODEV;
|
|
|
|
goto out;
|
|
|
|
#endif
|
|
|
|
case TCSISDBG_LEVEL:
|
|
|
|
case TCSIGDBG_LEVEL:
|
|
|
|
#ifdef SI_DEBUG
|
|
|
|
if (cmd == TCSIGDBG_LEVEL) {
|
|
|
|
dp->tc_dbglvl = xpp->sp_debug;
|
|
|
|
} else {
|
|
|
|
SUCHECK;
|
|
|
|
xpp->sp_debug = dp->tc_dbglvl;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#else
|
|
|
|
error = ENODEV;
|
|
|
|
goto out;
|
|
|
|
#endif
|
|
|
|
case TCSIGRXIT:
|
|
|
|
dp->tc_int = regp->rx_int_count;
|
|
|
|
break;
|
|
|
|
case TCSIRXIT:
|
|
|
|
SUCHECK;
|
|
|
|
regp->rx_int_count = dp->tc_int;
|
|
|
|
break;
|
|
|
|
case TCSIGIT:
|
|
|
|
dp->tc_int = regp->int_count;
|
|
|
|
break;
|
|
|
|
case TCSIIT:
|
|
|
|
SUCHECK;
|
|
|
|
regp->int_count = dp->tc_int;
|
|
|
|
break;
|
1995-08-13 15:18:05 +00:00
|
|
|
case TCSISTATE:
|
|
|
|
dp->tc_int = xpp->sp_ccb->hi_ip;
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
1995-08-13 15:18:05 +00:00
|
|
|
/* these next three use a different structure */
|
|
|
|
case TCSI_PORT:
|
1995-08-09 13:13:47 +00:00
|
|
|
SUCHECK;
|
1998-03-23 16:27:43 +00:00
|
|
|
si_bcopy(xpp, &sps->tc_siport, sizeof(sps->tc_siport));
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
1995-08-13 15:18:05 +00:00
|
|
|
case TCSI_CCB:
|
|
|
|
SUCHECK;
|
1999-08-27 08:32:54 +00:00
|
|
|
si_vbcopy(xpp->sp_ccb, &sps->tc_ccb, sizeof(sps->tc_ccb));
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
splx(oldspl);
|
|
|
|
return(error); /* success */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* siparam() : Configure line params
|
|
|
|
* called at spltty();
|
|
|
|
* this may sleep, does not flush, nor wait for drain, nor block writes
|
|
|
|
* caller must arrange this if it's important..
|
|
|
|
*/
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
2000-01-23 22:51:49 +00:00
|
|
|
siparam(struct tty *tp, struct termios *t)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
2008-09-08 11:41:20 +00:00
|
|
|
struct si_port *pp = tty_softc(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile struct si_channel *ccbp;
|
|
|
|
int oldspl, cflag, iflag, oflag, lflag;
|
|
|
|
int error = 0; /* shutup gcc */
|
|
|
|
int ispeed = 0; /* shutup gcc */
|
|
|
|
int ospeed = 0; /* shutup gcc */
|
1995-08-22 00:48:17 +00:00
|
|
|
BYTE val;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
DPRINT((pp, DBG_ENTRY|DBG_PARAM, "siparam(%x,%x)\n", tp, t));
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
cflag = t->c_cflag;
|
|
|
|
iflag = t->c_iflag;
|
|
|
|
oflag = t->c_oflag;
|
|
|
|
lflag = t->c_lflag;
|
1995-08-13 15:18:05 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "OFLAG 0x%x CFLAG 0x%x IFLAG 0x%x LFLAG 0x%x\n",
|
|
|
|
oflag, cflag, iflag, lflag));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1998-03-23 16:27:43 +00:00
|
|
|
/* XXX - if Jet host and SXDC module, use extended baud rates */
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/* if not hung up.. */
|
|
|
|
if (t->c_ospeed != 0) {
|
|
|
|
/* translate baud rate to firmware values */
|
2008-09-08 11:41:20 +00:00
|
|
|
ospeed = si_speedtab(t->c_ospeed, bdrates);
|
1995-08-09 13:13:47 +00:00
|
|
|
ispeed = t->c_ispeed ?
|
2008-09-08 11:41:20 +00:00
|
|
|
si_speedtab(t->c_ispeed, bdrates) : ospeed;
|
1995-08-09 13:13:47 +00:00
|
|
|
/* enforce legit baud rate */
|
|
|
|
if (ospeed < 0 || ispeed < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldspl = spltty();
|
|
|
|
|
|
|
|
ccbp = pp->sp_ccb;
|
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/* ========== set hi_break ========== */
|
|
|
|
val = 0;
|
|
|
|
if (iflag & IGNBRK) /* Breaks */
|
|
|
|
val |= BR_IGN;
|
|
|
|
if (iflag & BRKINT) /* Interrupt on break? */
|
|
|
|
val |= BR_INT;
|
|
|
|
if (iflag & PARMRK) /* Parity mark? */
|
|
|
|
val |= BR_PARMRK;
|
|
|
|
if (iflag & IGNPAR) /* Ignore chars with parity errors? */
|
|
|
|
val |= BR_PARIGN;
|
|
|
|
ccbp->hi_break = val;
|
|
|
|
|
|
|
|
/* ========== set hi_csr ========== */
|
1995-08-09 13:13:47 +00:00
|
|
|
/* if not hung up.. */
|
|
|
|
if (t->c_ospeed != 0) {
|
|
|
|
/* Set I/O speeds */
|
1995-08-22 00:48:17 +00:00
|
|
|
val = (ispeed << 4) | ospeed;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
1995-08-22 00:48:17 +00:00
|
|
|
ccbp->hi_csr = val;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/* ========== set hi_mr2 ========== */
|
|
|
|
val = 0;
|
2008-09-08 11:41:20 +00:00
|
|
|
if (cflag & CSTOPB) /* Stop bits */
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR2_2_STOP;
|
1995-08-09 13:13:47 +00:00
|
|
|
else
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR2_1_STOP;
|
2008-09-08 11:41:20 +00:00
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/*
|
|
|
|
* Enable H/W RTS/CTS handshaking. The default TA/MTA is
|
|
|
|
* a DCE, hence the reverse sense of RTS and CTS
|
|
|
|
*/
|
|
|
|
/* Output Flow - RTS must be raised before data can be sent */
|
|
|
|
if (cflag & CCTS_OFLOW)
|
|
|
|
val |= MR2_RTSCONT;
|
|
|
|
|
1996-06-21 21:35:01 +00:00
|
|
|
ccbp->hi_mr2 = val;
|
1995-08-22 00:48:17 +00:00
|
|
|
|
|
|
|
/* ========== set hi_mr1 ========== */
|
|
|
|
val = 0;
|
1995-08-09 13:13:47 +00:00
|
|
|
if (!(cflag & PARENB)) /* Parity */
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_NONE;
|
1995-08-09 13:13:47 +00:00
|
|
|
else
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_WITH;
|
1995-08-09 13:13:47 +00:00
|
|
|
if (cflag & PARODD)
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_ODD;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
if ((cflag & CS8) == CS8) /* 8 data bits? */
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_8_BITS;
|
2008-09-08 11:41:20 +00:00
|
|
|
else if ((cflag & CS7) == CS7) /* 7 data bits? */
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_7_BITS;
|
2008-09-08 11:41:20 +00:00
|
|
|
else if ((cflag & CS6) == CS6) /* 6 data bits? */
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_6_BITS;
|
2008-09-08 11:41:20 +00:00
|
|
|
else /* Must be 5 */
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= MR1_5_BITS;
|
2008-09-08 11:41:20 +00:00
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/*
|
|
|
|
* Enable H/W RTS/CTS handshaking. The default TA/MTA is
|
|
|
|
* a DCE, hence the reverse sense of RTS and CTS
|
|
|
|
*/
|
|
|
|
/* Input Flow - CTS is raised when port is ready to receive data */
|
|
|
|
if (cflag & CRTS_IFLOW)
|
|
|
|
val |= MR1_CTSCONT;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
ccbp->hi_mr1 = val;
|
|
|
|
|
|
|
|
/* ========== set hi_mask ========== */
|
|
|
|
val = 0xff;
|
|
|
|
if ((cflag & CS8) == CS8) { /* 8 data bits? */
|
|
|
|
val &= 0xFF;
|
|
|
|
} else if ((cflag & CS7) == CS7) { /* 7 data bits? */
|
|
|
|
val &= 0x7F;
|
|
|
|
} else if ((cflag & CS6) == CS6) { /* 6 data bits? */
|
|
|
|
val &= 0x3F;
|
|
|
|
} else { /* Must be 5 */
|
|
|
|
val &= 0x1F;
|
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
if (iflag & ISTRIP)
|
1995-08-22 00:48:17 +00:00
|
|
|
val &= 0x7F;
|
|
|
|
|
|
|
|
ccbp->hi_mask = val;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/* ========== set hi_prtcl ========== */
|
2000-01-25 16:45:54 +00:00
|
|
|
val = SP_DCEN; /* Monitor DCD always, or TIOCMGET misses it */
|
1995-08-13 15:18:05 +00:00
|
|
|
if (iflag & IXANY)
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= SP_TANY;
|
1995-08-09 13:13:47 +00:00
|
|
|
if (iflag & IXON)
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= SP_TXEN;
|
1995-08-09 13:13:47 +00:00
|
|
|
if (iflag & IXOFF)
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= SP_RXEN;
|
1995-08-09 13:13:47 +00:00
|
|
|
if (iflag & INPCK)
|
1995-08-22 00:48:17 +00:00
|
|
|
val |= SP_PAEN;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
ccbp->hi_prtcl = val;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/* ========== set hi_{rx|tx}{on|off} ========== */
|
|
|
|
/* XXX: the card TOTALLY shields us from the flow control... */
|
|
|
|
ccbp->hi_txon = t->c_cc[VSTART];
|
|
|
|
ccbp->hi_txoff = t->c_cc[VSTOP];
|
|
|
|
|
|
|
|
ccbp->hi_rxon = t->c_cc[VSTART];
|
|
|
|
ccbp->hi_rxoff = t->c_cc[VSTOP];
|
|
|
|
|
|
|
|
/* ========== send settings to the card ========== */
|
1995-08-09 13:13:47 +00:00
|
|
|
/* potential sleep here */
|
|
|
|
if (ccbp->hi_stat == IDLE_CLOSE) /* Not yet open */
|
|
|
|
si_command(pp, LOPEN, SI_WAIT); /* open it */
|
|
|
|
else
|
|
|
|
si_command(pp, CONFIG, SI_WAIT); /* change params */
|
|
|
|
|
1995-08-22 00:48:17 +00:00
|
|
|
/* ========== set DTR etc ========== */
|
1995-08-09 13:13:47 +00:00
|
|
|
/* Hangup if ospeed == 0 */
|
|
|
|
if (t->c_ospeed == 0) {
|
2004-10-02 16:56:08 +00:00
|
|
|
(void) simodem(tp, 0, SER_DTR | SER_RTS);
|
1995-08-09 13:13:47 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If the previous speed was 0, may need to re-enable
|
1998-03-23 16:27:43 +00:00
|
|
|
* the modem signals
|
|
|
|
*/
|
2004-10-02 16:56:08 +00:00
|
|
|
(void) simodem(tp, SER_DTR | SER_RTS, 0);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "siparam, complete: MR1 %x MR2 %x HI_MASK %x PRTCL %x HI_BREAK %x HI_CSR %x\n",
|
|
|
|
ccbp->hi_mr1, ccbp->hi_mr2, ccbp->hi_mask, ccbp->hi_prtcl, ccbp->hi_break, ccbp->hi_csr));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
splx(oldspl);
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set/Get state of modem control lines.
|
|
|
|
* Due to DCE-like behaviour of the adapter, some signals need translation:
|
|
|
|
* TIOCM_DTR DSR
|
|
|
|
* TIOCM_RTS CTS
|
|
|
|
*/
|
|
|
|
static int
|
2004-10-02 16:56:08 +00:00
|
|
|
simodem(struct tty *tp, int sigon, int sigoff)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
2004-10-02 16:56:08 +00:00
|
|
|
struct si_port *pp;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile struct si_channel *ccbp;
|
|
|
|
int x;
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
pp = tty_softc(tp);
|
2004-10-02 16:56:08 +00:00
|
|
|
DPRINT((pp, DBG_ENTRY|DBG_MODEM, "simodem(%x,%x)\n", sigon, sigoff));
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
ccbp = pp->sp_ccb; /* Find channel address */
|
2004-10-02 16:56:08 +00:00
|
|
|
if (sigon == 0 && sigoff == 0) {
|
1995-08-09 13:13:47 +00:00
|
|
|
x = ccbp->hi_ip;
|
2004-10-02 16:56:08 +00:00
|
|
|
/*
|
|
|
|
* XXX: not sure this is correct, should it be CTS&DSR ?
|
|
|
|
* XXX: or do we (just) miss CTS & DSR ?
|
|
|
|
*/
|
|
|
|
if (x & IP_DCD) sigon |= SER_DCD;
|
|
|
|
if (x & IP_DTR) sigon |= SER_DTR;
|
|
|
|
if (x & IP_RTS) sigon |= SER_RTS;
|
|
|
|
if (x & IP_RI) sigon |= SER_RI;
|
|
|
|
return (sigon);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
2004-10-02 16:56:08 +00:00
|
|
|
|
|
|
|
x = ccbp->hi_op;
|
|
|
|
if (sigon & SER_DTR)
|
|
|
|
x |= OP_DSR;
|
|
|
|
if (sigoff & SER_DTR)
|
|
|
|
x &= ~OP_DSR;
|
|
|
|
if (sigon & SER_RTS)
|
|
|
|
x |= OP_CTS;
|
|
|
|
if (sigoff & SER_RTS)
|
|
|
|
x &= ~OP_CTS;
|
|
|
|
ccbp->hi_op = x;
|
1995-08-09 13:13:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle change of modem state
|
|
|
|
*/
|
|
|
|
static void
|
2000-01-23 22:51:49 +00:00
|
|
|
si_modem_state(struct si_port *pp, struct tty *tp, int hi_ip)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
/* if a modem dev */
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
if (hi_ip & IP_DCD) {
|
1999-08-27 08:32:54 +00:00
|
|
|
if (!(pp->sp_last_hi_ip & IP_DCD)) {
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_INTR, "modem carr on%d\n"));
|
|
|
|
(void)ttydisc_modem(tp, 1);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pp->sp_last_hi_ip & IP_DCD) {
|
|
|
|
DPRINT((pp, DBG_INTR, "modem carr off\n"));
|
2008-09-08 11:41:20 +00:00
|
|
|
#if 0 /* XXX mpsafetty ttyld_modem used to tell us to shutdown the port or not */
|
|
|
|
if (ttydisc_modem(tp, 0))
|
2004-10-02 16:56:08 +00:00
|
|
|
(void) simodem(tp, 0, SER_DTR | SER_RTS);
|
2008-09-08 11:41:20 +00:00
|
|
|
#else
|
|
|
|
ttydisc_modem(tp, 0);
|
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pp->sp_last_hi_ip = hi_ip;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Poller to catch missed interrupts.
|
1995-11-09 21:53:48 +00:00
|
|
|
*
|
1995-11-28 02:07:36 +00:00
|
|
|
* Note that the SYSV Specialix drivers poll at 100 times per second to get
|
|
|
|
* better response. We could really use a "periodic" version timeout(). :-)
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
#ifdef POLL
|
1995-09-13 08:45:28 +00:00
|
|
|
static void
|
1995-08-09 13:13:47 +00:00
|
|
|
si_poll(void *nothing)
|
|
|
|
{
|
2000-01-23 22:51:49 +00:00
|
|
|
struct si_softc *sc;
|
|
|
|
int i;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile struct si_reg *regp;
|
2000-01-23 22:51:49 +00:00
|
|
|
struct si_port *pp;
|
1995-11-09 21:53:48 +00:00
|
|
|
int lost, oldspl, port;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
DPRINT((0, DBG_POLL, "si_poll()\n"));
|
1995-10-21 09:10:49 +00:00
|
|
|
oldspl = spltty();
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
lost = 0;
|
2000-01-23 22:51:49 +00:00
|
|
|
for (i = 0; i < si_numunits; i++) {
|
|
|
|
sc = devclass_get_softc(si_devclass, i);
|
|
|
|
if (sc == NULL || sc->sc_type == SIEMPTY)
|
1995-08-09 13:13:47 +00:00
|
|
|
continue;
|
|
|
|
regp = (struct si_reg *)sc->sc_maddr;
|
1998-03-23 16:27:43 +00:00
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
|
|
|
* See if there has been a pending interrupt for 2 seconds
|
1998-02-15 14:42:33 +00:00
|
|
|
* or so. The test (int_scounter >= 200) won't correspond
|
1995-08-09 13:13:47 +00:00
|
|
|
* to 2 seconds if int_count gets changed.
|
|
|
|
*/
|
|
|
|
if (regp->int_pending != 0) {
|
|
|
|
if (regp->int_scounter >= 200 &&
|
|
|
|
regp->initstat == 1) {
|
1995-11-09 21:53:48 +00:00
|
|
|
printf("si%d: lost intr\n", i);
|
1995-08-09 13:13:47 +00:00
|
|
|
lost++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
regp->int_scounter = 0;
|
|
|
|
}
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
/*
|
|
|
|
* gripe about no input flow control..
|
|
|
|
*/
|
|
|
|
pp = sc->sc_ports;
|
|
|
|
for (port = 0; port < sc->sc_nport; pp++, port++) {
|
|
|
|
if (pp->sp_delta_overflows > 0) {
|
|
|
|
printf("si%d: %d tty level buffer overflows\n",
|
|
|
|
i, pp->sp_delta_overflows);
|
|
|
|
pp->sp_delta_overflows = 0;
|
|
|
|
}
|
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
1996-08-12 17:12:07 +00:00
|
|
|
if (lost || si_realpoll)
|
2000-01-23 22:51:49 +00:00
|
|
|
si_intr(NULL); /* call intr with fake vector */
|
1995-08-09 13:13:47 +00:00
|
|
|
splx(oldspl);
|
|
|
|
|
1996-05-05 17:09:04 +00:00
|
|
|
timeout(si_poll, (caddr_t)0L, si_pollrate);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
#endif /* ifdef POLL */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The interrupt handler polls ALL ports on ALL adapters each time
|
|
|
|
* it is called.
|
|
|
|
*/
|
|
|
|
|
1995-11-28 02:07:36 +00:00
|
|
|
static BYTE si_rxbuf[SI_BUFFERSIZE]; /* input staging area */
|
1998-03-23 16:27:43 +00:00
|
|
|
static BYTE si_txbuf[SI_BUFFERSIZE]; /* output staging area */
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2000-01-24 07:24:02 +00:00
|
|
|
void
|
2000-01-23 22:51:49 +00:00
|
|
|
si_intr(void *arg)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
2000-01-23 22:51:49 +00:00
|
|
|
struct si_softc *sc;
|
|
|
|
struct si_port *pp;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile struct si_channel *ccbp;
|
2000-01-23 22:51:49 +00:00
|
|
|
struct tty *tp;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile caddr_t maddr;
|
1995-10-28 15:39:31 +00:00
|
|
|
BYTE op, ip;
|
1995-11-09 21:53:48 +00:00
|
|
|
int x, card, port, n, i, isopen;
|
1995-08-09 13:13:47 +00:00
|
|
|
volatile BYTE *z;
|
|
|
|
BYTE c;
|
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
sc = arg;
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
2000-01-23 22:51:49 +00:00
|
|
|
|
|
|
|
DPRINT((0, arg == NULL ? DBG_POLL:DBG_INTR, "si_intr\n"));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When we get an int we poll all the channels and do ALL pending
|
|
|
|
* work, not just the first one we find. This allows all cards to
|
|
|
|
* share the same vector.
|
1998-03-23 16:27:43 +00:00
|
|
|
*
|
|
|
|
* XXX - But if we're sharing the vector with something that's NOT
|
|
|
|
* a SI/XIO/SX card, we may be making more work for ourselves.
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
2000-01-23 22:51:49 +00:00
|
|
|
for (card = 0; card < si_numunits; card++) {
|
|
|
|
sc = devclass_get_softc(si_devclass, card);
|
|
|
|
if (sc == NULL || sc->sc_type == SIEMPTY)
|
1995-08-09 13:13:47 +00:00
|
|
|
continue;
|
1995-11-09 21:53:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First, clear the interrupt
|
|
|
|
*/
|
1995-08-09 13:13:47 +00:00
|
|
|
switch(sc->sc_type) {
|
1998-03-23 16:27:43 +00:00
|
|
|
case SIHOST:
|
1995-08-09 13:13:47 +00:00
|
|
|
maddr = sc->sc_maddr;
|
|
|
|
((volatile struct si_reg *)maddr)->int_pending = 0;
|
|
|
|
/* flag nothing pending */
|
|
|
|
*(maddr+SIINTCL) = 0x00; /* Set IRQ clear */
|
|
|
|
*(maddr+SIINTCL_CL) = 0x00; /* Clear IRQ clear */
|
|
|
|
break;
|
|
|
|
case SIHOST2:
|
|
|
|
maddr = sc->sc_maddr;
|
|
|
|
((volatile struct si_reg *)maddr)->int_pending = 0;
|
|
|
|
*(maddr+SIPLIRQCLR) = 0x00;
|
|
|
|
*(maddr+SIPLIRQCLR) = 0x10;
|
|
|
|
break;
|
1998-02-15 14:42:33 +00:00
|
|
|
case SIPCI:
|
|
|
|
maddr = sc->sc_maddr;
|
|
|
|
((volatile struct si_reg *)maddr)->int_pending = 0;
|
|
|
|
*(maddr+SIPCIINTCL) = 0x0;
|
|
|
|
break;
|
1998-03-23 16:27:43 +00:00
|
|
|
case SIJETPCI: /* fall through to JETISA case */
|
1998-02-15 14:42:33 +00:00
|
|
|
case SIJETISA:
|
|
|
|
maddr = sc->sc_maddr;
|
|
|
|
((volatile struct si_reg *)maddr)->int_pending = 0;
|
|
|
|
*(maddr+SIJETINTCL) = 0x0;
|
|
|
|
break;
|
2007-01-18 13:33:36 +00:00
|
|
|
#ifdef DEV_EISA
|
1998-03-23 16:27:43 +00:00
|
|
|
case SIEISA:
|
1995-08-09 13:13:47 +00:00
|
|
|
maddr = sc->sc_maddr;
|
|
|
|
((volatile struct si_reg *)maddr)->int_pending = 0;
|
2000-01-23 22:51:49 +00:00
|
|
|
(void)inb(sc->sc_iobase + 3);
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
2007-01-18 13:33:36 +00:00
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
case SIEMPTY:
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
((volatile struct si_reg *)maddr)->int_scounter = 0;
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
/*
|
|
|
|
* check each port
|
|
|
|
*/
|
1999-08-27 08:32:54 +00:00
|
|
|
for (pp = sc->sc_ports, port = 0; port < sc->sc_nport;
|
1998-03-23 16:27:43 +00:00
|
|
|
pp++, port++) {
|
1995-08-09 13:13:47 +00:00
|
|
|
ccbp = pp->sp_ccb;
|
|
|
|
tp = pp->sp_tty;
|
2008-09-08 11:41:20 +00:00
|
|
|
tty_lock(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* See if a command has completed ?
|
|
|
|
*/
|
|
|
|
if (ccbp->hi_stat != pp->sp_pend) {
|
|
|
|
DPRINT((pp, DBG_INTR,
|
2008-06-06 03:21:59 +00:00
|
|
|
"si_intr hi_stat = %s, pend = %s\n",
|
|
|
|
si_cmdname(ccbp->hi_stat),
|
|
|
|
si_cmdname(pp->sp_pend)));
|
1995-08-09 13:13:47 +00:00
|
|
|
switch(pp->sp_pend) {
|
|
|
|
case LOPEN:
|
|
|
|
case MPEND:
|
|
|
|
case MOPEN:
|
2008-06-06 03:21:59 +00:00
|
|
|
case FCLOSE:
|
1995-08-09 13:13:47 +00:00
|
|
|
case CONFIG:
|
1996-06-21 21:35:01 +00:00
|
|
|
case SBREAK:
|
|
|
|
case EBREAK:
|
2008-06-06 03:21:59 +00:00
|
|
|
/* sleeping in si_command */
|
|
|
|
DPRINT((pp, DBG_INTR, "do wakeup\n"));
|
1995-08-09 13:13:47 +00:00
|
|
|
wakeup(&pp->sp_state);
|
|
|
|
break;
|
|
|
|
}
|
2008-06-06 03:21:59 +00:00
|
|
|
pp->sp_pend = ccbp->hi_stat;
|
1998-03-23 16:27:43 +00:00
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Continue on if it's closed
|
|
|
|
*/
|
2008-09-08 11:41:20 +00:00
|
|
|
if (ccbp->hi_stat == IDLE_CLOSE) {
|
|
|
|
tty_unlock(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
continue;
|
2008-09-08 11:41:20 +00:00
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do modem state change if not a local device
|
|
|
|
*/
|
|
|
|
si_modem_state(pp, tp, ccbp->hi_ip);
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
/*
|
1998-03-23 16:27:43 +00:00
|
|
|
* Check to see if we should 'receive' characters.
|
1995-11-09 21:53:48 +00:00
|
|
|
*/
|
2008-09-08 11:41:20 +00:00
|
|
|
isopen = tty_opened(tp);
|
1995-11-09 21:53:48 +00:00
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
1996-06-21 21:35:01 +00:00
|
|
|
* Do input break processing
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
if (ccbp->hi_state & ST_BREAK) {
|
2008-06-06 03:21:59 +00:00
|
|
|
if (isopen)
|
2008-09-08 11:41:20 +00:00
|
|
|
ttydisc_rint(tp, 0, TRE_BREAK);
|
1995-08-09 13:13:47 +00:00
|
|
|
ccbp->hi_state &= ~ST_BREAK; /* A Bit iffy this */
|
|
|
|
DPRINT((pp, DBG_INTR, "si_intr break\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1995-11-09 21:53:48 +00:00
|
|
|
* Do RX stuff - if not open then dump any characters.
|
|
|
|
* XXX: This is VERY messy and needs to be cleaned up.
|
|
|
|
*
|
|
|
|
* XXX: can we leave data in the host adapter buffer
|
|
|
|
* when the clists are full? That may be dangerous
|
|
|
|
* if the user cannot get an interrupt signal through.
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-06 03:21:59 +00:00
|
|
|
more_rx:
|
1995-11-09 21:53:48 +00:00
|
|
|
|
|
|
|
if (!isopen) {
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_INTR, "intr1: not open\n"));
|
1995-08-09 13:13:47 +00:00
|
|
|
ccbp->hi_rxopos = ccbp->hi_rxipos;
|
1995-11-09 21:53:48 +00:00
|
|
|
goto end_rx;
|
|
|
|
}
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
#if 0 /* XXXMPSAFETTY */
|
1995-11-09 21:53:48 +00:00
|
|
|
/*
|
1996-05-05 17:35:19 +00:00
|
|
|
* If the tty input buffers are blocked, stop emptying
|
|
|
|
* the incoming buffers and let the auto flow control
|
|
|
|
* assert..
|
1995-11-09 21:53:48 +00:00
|
|
|
*/
|
2008-06-06 03:21:59 +00:00
|
|
|
if (tp->t_state & TS_TBLOCK)
|
1995-11-09 21:53:48 +00:00
|
|
|
goto end_rx;
|
2008-09-08 11:41:20 +00:00
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1996-05-05 17:35:19 +00:00
|
|
|
/*
|
|
|
|
* Process read characters if not skipped above
|
|
|
|
*/
|
1995-11-09 21:53:48 +00:00
|
|
|
op = ccbp->hi_rxopos;
|
|
|
|
ip = ccbp->hi_rxipos;
|
1996-05-05 17:35:19 +00:00
|
|
|
c = ip - op;
|
2008-06-06 03:21:59 +00:00
|
|
|
if (c == 0)
|
1996-05-05 17:35:19 +00:00
|
|
|
goto end_rx;
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
n = c & 0xff;
|
1996-05-05 17:35:19 +00:00
|
|
|
if (n > 250)
|
|
|
|
n = 250;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
DPRINT((pp, DBG_INTR, "n = %d, op = %d, ip = %d\n",
|
1995-08-09 13:13:47 +00:00
|
|
|
n, op, ip));
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
/*
|
|
|
|
* Suck characters out of host card buffer into the
|
|
|
|
* "input staging buffer" - so that we dont leave the
|
|
|
|
* host card in limbo while we're possibly echoing
|
|
|
|
* characters and possibly flushing input inside the
|
|
|
|
* ldisc l_rint() routine.
|
|
|
|
*/
|
1995-11-28 02:07:36 +00:00
|
|
|
if (n <= SI_BUFFERSIZE - op) {
|
1995-11-09 21:53:48 +00:00
|
|
|
|
|
|
|
z = ccbp->hi_rxbuf + op;
|
1999-08-27 08:32:54 +00:00
|
|
|
si_vbcopy(z, si_rxbuf, n);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
op += n;
|
|
|
|
} else {
|
1995-11-28 02:07:36 +00:00
|
|
|
x = SI_BUFFERSIZE - op;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
z = ccbp->hi_rxbuf + op;
|
1999-08-27 08:32:54 +00:00
|
|
|
si_vbcopy(z, si_rxbuf, x);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
z = ccbp->hi_rxbuf;
|
1999-08-27 08:32:54 +00:00
|
|
|
si_vbcopy(z, si_rxbuf + x, n - x);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
op += n;
|
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
/* clear collected characters from buffer */
|
|
|
|
ccbp->hi_rxopos = op;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
/*
|
|
|
|
* at this point...
|
|
|
|
* n = number of chars placed in si_rxbuf
|
|
|
|
*/
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
if (0 && ttydisc_can_bypass(tp)) {
|
|
|
|
|
|
|
|
i = ttydisc_rint_bypass(tp, (char *)si_rxbuf, n);
|
|
|
|
if (i < n)
|
|
|
|
pp->sp_delta_overflows += (n - i);
|
|
|
|
|
1995-11-09 21:53:48 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* It'd be nice to not have to go through the
|
|
|
|
* function call overhead for each char here.
|
|
|
|
* It'd be nice to block input it, saving a
|
|
|
|
* loop here and the call/return overhead.
|
|
|
|
*/
|
|
|
|
for(x = 0; x < n; x++) {
|
|
|
|
i = si_rxbuf[x];
|
2008-09-08 11:41:20 +00:00
|
|
|
if (ttydisc_rint(tp, i, 0) == -1)
|
1995-11-09 21:53:48 +00:00
|
|
|
pp->sp_delta_overflows++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto more_rx; /* try for more until RXbuf is empty */
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-06-06 03:21:59 +00:00
|
|
|
end_rx:
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
ttydisc_rint_done(tp);
|
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
|
|
|
* Do TX stuff
|
|
|
|
*/
|
2008-09-08 11:41:20 +00:00
|
|
|
si_start(tp);
|
|
|
|
tty_unlock(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
} /* end of for (all ports on this controller) */
|
|
|
|
} /* end of for (all controllers) */
|
|
|
|
|
2000-01-23 22:51:49 +00:00
|
|
|
DPRINT((0, arg == NULL ? DBG_POLL:DBG_INTR, "end si_intr\n"));
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Nudge the transmitter...
|
1995-11-09 21:53:48 +00:00
|
|
|
*
|
|
|
|
* XXX: I inherited some funny code here. It implies the host card only
|
|
|
|
* interrupts when the transmit buffer reaches the low-water-mark, and does
|
|
|
|
* not interrupt when it's actually hits empty. In some cases, we have
|
|
|
|
* processes waiting for complete drain, and we need to simulate an interrupt
|
|
|
|
* about when we think the buffer is going to be empty (and retry if not).
|
|
|
|
* I really am not certain about this... I *need* the hardware manuals.
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
static void
|
2000-01-23 22:51:49 +00:00
|
|
|
si_start(struct tty *tp)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
struct si_port *pp;
|
|
|
|
volatile struct si_channel *ccbp;
|
2008-09-08 11:41:20 +00:00
|
|
|
BYTE ipos, count;
|
|
|
|
#if 0
|
1995-08-09 13:13:47 +00:00
|
|
|
int nchar;
|
2008-09-08 11:41:20 +00:00
|
|
|
#endif
|
|
|
|
int oldspl, n, amount;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
oldspl = spltty();
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
pp = tty_softc(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
DPRINT((pp, DBG_ENTRY|DBG_START,
|
2008-09-08 11:41:20 +00:00
|
|
|
"si_start(%x) sp_state %x\n",
|
|
|
|
tp, pp->sp_state));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
ccbp = pp->sp_ccb;
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
while ((count = (int)ccbp->hi_txipos - (int)ccbp->hi_txopos) < 255) {
|
|
|
|
DPRINT((pp, DBG_START, "txbuf pend count %d\n", (BYTE)count));
|
1995-08-09 13:13:47 +00:00
|
|
|
ipos = (unsigned int)ccbp->hi_txipos;
|
2008-09-08 11:41:20 +00:00
|
|
|
if ((int)ccbp->hi_txopos <= ipos)
|
|
|
|
amount = SI_BUFFERSIZE - ipos;
|
|
|
|
else
|
|
|
|
amount = 255 - count;
|
|
|
|
DPRINT((pp, DBG_START, "spaceleft amount %d\n", amount));
|
|
|
|
if (amount == 0)
|
|
|
|
break;
|
|
|
|
n = ttydisc_getc(tp, si_txbuf, amount);
|
|
|
|
DPRINT((pp, DBG_START, "getc n=%d\n", n));
|
|
|
|
if (n == 0)
|
|
|
|
break;
|
|
|
|
si_bcopyv(si_txbuf, &ccbp->hi_txbuf[ipos], n);
|
1995-08-09 13:13:47 +00:00
|
|
|
ccbp->hi_txipos += n;
|
|
|
|
}
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* See if there are any characters still to come. If so, we can
|
|
|
|
* depend on si_start being called again.
|
|
|
|
*
|
|
|
|
* XXX the manual is vague on this. It implies we get an interrupt
|
|
|
|
* when the transmit queue reaches the 25% low water mark, but NOT
|
|
|
|
* when it hits empty.
|
|
|
|
*/
|
|
|
|
nchar = ttyoutq_getsize(&tp->t_outq) - ttyoutq_bytesleft(&tp->t_outq);
|
|
|
|
DPRINT((pp, DBG_START, "count %d, nchar %d\n",
|
|
|
|
(BYTE)count, nchar));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
if (count != 0 && nchar == 0) {
|
1995-08-09 13:13:47 +00:00
|
|
|
int time;
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
/* XXX lame. Ticks per character. used to be a table. */
|
|
|
|
time = (tp->t_termios.c_ospeed + 9) / 10;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
1998-03-21 05:17:29 +00:00
|
|
|
if (time > 0) {
|
|
|
|
if (time < nchar)
|
|
|
|
time = nchar / time;
|
|
|
|
else
|
|
|
|
time = 2;
|
|
|
|
} else {
|
|
|
|
DPRINT((pp, DBG_START,
|
|
|
|
"bad char time value! %d\n", time));
|
|
|
|
time = hz/10;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
2008-06-06 03:21:59 +00:00
|
|
|
if ((pp->sp_state & SS_LSTART) != 0)
|
1997-09-21 21:41:49 +00:00
|
|
|
untimeout(si_lstart, (caddr_t)pp, pp->lstart_ch);
|
1995-08-09 13:13:47 +00:00
|
|
|
DPRINT((pp, DBG_START, "arming lstart, time=%d\n", time));
|
2008-06-06 03:21:59 +00:00
|
|
|
pp->sp_state |= SS_LSTART;
|
1997-09-21 21:41:49 +00:00
|
|
|
pp->lstart_ch = timeout(si_lstart, (caddr_t)pp, time);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
2008-09-08 11:41:20 +00:00
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
splx(oldspl);
|
|
|
|
DPRINT((pp, DBG_EXIT|DBG_START, "leave si_start()\n"));
|
|
|
|
}
|
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
#if 0
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
|
|
|
* Note: called at splsoftclock from the timeout code
|
|
|
|
* This has to deal with two things... cause wakeups while waiting for
|
|
|
|
* tty drains on last process exit, and call l_start at about the right
|
|
|
|
* time for protocols like ppp.
|
|
|
|
*/
|
|
|
|
static void
|
1997-04-20 15:36:12 +00:00
|
|
|
si_lstart(void *arg)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
2000-01-23 22:51:49 +00:00
|
|
|
struct si_port *pp = arg;
|
|
|
|
struct tty *tp;
|
1995-08-09 13:13:47 +00:00
|
|
|
int oldspl;
|
|
|
|
|
|
|
|
DPRINT((pp, DBG_ENTRY|DBG_LSTART, "si_lstart(%x) sp_state %x\n",
|
|
|
|
pp, pp->sp_state));
|
|
|
|
|
|
|
|
oldspl = spltty();
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
|
|
|
pp->sp_state &= ~SS_LSTART;
|
2004-10-02 16:56:08 +00:00
|
|
|
tp = pp->sp_tty;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
si_start(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
splx(oldspl);
|
|
|
|
}
|
2008-09-08 11:41:20 +00:00
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-09-08 11:41:20 +00:00
|
|
|
#if 0 /* XXX mpsafetty */
|
1995-08-09 13:13:47 +00:00
|
|
|
/*
|
|
|
|
* Stop output on a line. called at spltty();
|
|
|
|
*/
|
2002-10-16 08:48:39 +00:00
|
|
|
static void
|
2000-01-23 22:51:49 +00:00
|
|
|
si_stop(struct tty *tp, int rw)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
volatile struct si_channel *ccbp;
|
|
|
|
struct si_port *pp;
|
|
|
|
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
2008-09-08 11:41:20 +00:00
|
|
|
pp = tty_softc(tp);
|
1995-08-09 13:13:47 +00:00
|
|
|
ccbp = pp->sp_ccb;
|
|
|
|
|
2004-10-02 16:56:08 +00:00
|
|
|
DPRINT((pp, DBG_ENTRY|DBG_STOP, "si_stop(%x,%x)\n", tp, rw));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/* XXX: must check (rw & FWRITE | FREAD) etc flushing... */
|
|
|
|
if (rw & FWRITE) {
|
|
|
|
/* what level are we meant to be flushing anyway? */
|
|
|
|
if (tp->t_state & TS_BUSY) {
|
2004-10-02 16:56:08 +00:00
|
|
|
si_command(pp, WFLUSH, SI_NOWAIT);
|
1995-08-09 13:13:47 +00:00
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
ttwwakeup(tp); /* Bruce???? */
|
|
|
|
}
|
|
|
|
}
|
1995-11-09 21:53:48 +00:00
|
|
|
#if 1 /* XXX: this doesn't work right yet.. */
|
|
|
|
/* XXX: this may have been failing because we used to call l_rint()
|
|
|
|
* while we were looping based on these two counters. Now, we collect
|
|
|
|
* the data and then loop stuffing it into l_rint(), making this
|
|
|
|
* useless. Should we cause this to blow away the staging buffer?
|
|
|
|
*/
|
1995-08-09 13:13:47 +00:00
|
|
|
if (rw & FREAD) {
|
|
|
|
ccbp->hi_rxopos = ccbp->hi_rxipos;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2008-09-08 11:41:20 +00:00
|
|
|
#endif
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/*
|
1998-03-23 16:27:43 +00:00
|
|
|
* Issue a command to the host card CPU.
|
2008-09-08 11:41:20 +00:00
|
|
|
*
|
|
|
|
* XXX This is all just so WRONG!. Ed says we're not supposed to sleep
|
|
|
|
* here anyway. We sort of get away with it for now by using Giant.
|
|
|
|
* Something better will have to be done.
|
|
|
|
* Linux does a busy spin here waiting for the 8-bit cpu to notice the
|
|
|
|
* posted command and respond to it. I'm not sure I like that either.
|
1995-08-09 13:13:47 +00:00
|
|
|
*/
|
|
|
|
static void
|
2000-01-23 22:51:49 +00:00
|
|
|
si_command(struct si_port *pp, int cmd, int waitflag)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
|
|
|
int oldspl;
|
|
|
|
volatile struct si_channel *ccbp = pp->sp_ccb;
|
|
|
|
int x;
|
2008-09-08 11:41:20 +00:00
|
|
|
int err;
|
1995-08-09 13:13:47 +00:00
|
|
|
|
2008-06-06 03:21:59 +00:00
|
|
|
DPRINT((pp, DBG_ENTRY|DBG_PARAM, "si_command(%x,%s,%d): hi_stat %s, sp_pend: %s\n",
|
|
|
|
pp, si_cmdname(cmd), waitflag, si_cmdname(ccbp->hi_stat),
|
|
|
|
si_cmdname(pp->sp_pend)));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
oldspl = spltty(); /* Keep others out */
|
2008-06-06 03:21:59 +00:00
|
|
|
mtx_assert(&Giant, MA_OWNED);
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/* wait until it's finished what it was doing.. */
|
1996-06-21 21:35:01 +00:00
|
|
|
/* XXX: sits in IDLE_BREAK until something disturbs it or break
|
|
|
|
* is turned off. */
|
1995-08-09 13:13:47 +00:00
|
|
|
while((x = ccbp->hi_stat) != IDLE_OPEN &&
|
|
|
|
x != IDLE_CLOSE &&
|
1996-06-21 21:35:01 +00:00
|
|
|
x != IDLE_BREAK &&
|
1995-08-09 13:13:47 +00:00
|
|
|
x != cmd) {
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd1 old cmd pending (going to tsleep): hi_stat (%s)\n", si_cmdname(ccbp->hi_stat)));
|
|
|
|
err = tsleep(&pp->sp_state, (PSOCK+1)|PCATCH, "sicmd1", hz/4);
|
|
|
|
if (err) {
|
2008-06-06 03:21:59 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd1 timeout: hi_stat (%s)\n",
|
|
|
|
si_cmdname(ccbp->hi_stat)));
|
|
|
|
/* This is very very bad. The card has crashed. */
|
|
|
|
/* XXX the driver breaks at this point */
|
2008-09-08 11:41:20 +00:00
|
|
|
if (err == ETIMEDOUT)
|
2009-02-07 02:14:27 +00:00
|
|
|
DPRINT(("%s: tsleep1 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
1995-08-09 13:13:47 +00:00
|
|
|
splx(oldspl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1996-06-21 21:35:01 +00:00
|
|
|
/* it should now be in IDLE_{OPEN|CLOSE|BREAK}, or "cmd" */
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd1 now in: hi_stat (%s) sp_pend (%s)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
/* if there was a pending command, cause a state-change wakeup */
|
1996-06-21 21:35:01 +00:00
|
|
|
switch(pp->sp_pend) {
|
|
|
|
case LOPEN:
|
|
|
|
case MPEND:
|
|
|
|
case MOPEN:
|
2008-06-06 03:21:59 +00:00
|
|
|
case FCLOSE:
|
1996-06-21 21:35:01 +00:00
|
|
|
case CONFIG:
|
|
|
|
case SBREAK:
|
|
|
|
case EBREAK:
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "si_command: sp_pend %s, doing wakeup\n", si_cmdname(pp->sp_pend)));
|
1996-06-21 21:35:01 +00:00
|
|
|
wakeup(&pp->sp_state);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pp->sp_pend = cmd; /* New command pending */
|
|
|
|
ccbp->hi_stat = cmd; /* Post it */
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd now posted: hi_stat (%s) sp_pend (%s)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
1995-08-09 13:13:47 +00:00
|
|
|
|
|
|
|
if (waitflag) {
|
2008-06-06 03:21:59 +00:00
|
|
|
while((x = ccbp->hi_stat) != IDLE_OPEN &&
|
|
|
|
x != IDLE_CLOSE &&
|
|
|
|
x != IDLE_BREAK) {
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd2 now waiting: hi_stat (%s) sp_pend (%s) (going to tsleep)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
|
|
|
err = tsleep(&pp->sp_state, (PSOCK+1)|PCATCH, "sicmd2", hz);
|
|
|
|
if (err) {
|
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd2 tsleep error: hi_stat (%s) sp_pend (%s)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
|
|
|
if (err == ETIMEDOUT) {
|
2009-02-07 02:14:27 +00:00
|
|
|
DPRINT(("%s: tsleep2 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
2008-09-08 11:41:20 +00:00
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
break;
|
2008-09-08 11:41:20 +00:00
|
|
|
}
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-08 11:41:20 +00:00
|
|
|
DPRINT((pp, DBG_PARAM, "sicmd2 finished: hi_stat (%s) sp_pend (%s)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)));
|
1995-08-09 13:13:47 +00:00
|
|
|
splx(oldspl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SI_DEBUG
|
1996-01-09 03:01:45 +00:00
|
|
|
|
2000-01-24 07:24:02 +00:00
|
|
|
void
|
1996-01-09 03:01:45 +00:00
|
|
|
si_dprintf(struct si_port *pp, int flags, const char *fmt, ...)
|
1995-08-09 13:13:47 +00:00
|
|
|
{
|
1996-01-09 03:01:45 +00:00
|
|
|
va_list ap;
|
1996-01-25 07:21:50 +00:00
|
|
|
|
1995-08-09 13:13:47 +00:00
|
|
|
if ((pp == NULL && (si_debug&flags)) ||
|
|
|
|
(pp != NULL && ((pp->sp_debug&flags) || (si_debug&flags)))) {
|
1998-03-23 16:27:43 +00:00
|
|
|
if (pp != NULL)
|
2004-10-02 16:56:08 +00:00
|
|
|
printf("%s: ", pp->sp_name);
|
1996-01-25 07:21:50 +00:00
|
|
|
va_start(ap, fmt);
|
|
|
|
vprintf(fmt, ap);
|
1996-01-09 03:01:45 +00:00
|
|
|
va_end(ap);
|
1995-08-09 13:13:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-04 17:33:45 +00:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
1998-03-23 16:27:43 +00:00
|
|
|
static char *
|
2000-01-23 22:51:49 +00:00
|
|
|
si_modulename(int host_type, int uart_type)
|
1998-03-23 16:27:43 +00:00
|
|
|
{
|
|
|
|
switch (host_type) {
|
|
|
|
/* Z280 based cards */
|
2007-01-18 13:33:36 +00:00
|
|
|
#ifdef DEV_EISA
|
1999-08-27 08:32:54 +00:00
|
|
|
case SIEISA:
|
2007-01-18 13:33:36 +00:00
|
|
|
#endif
|
1999-08-27 08:32:54 +00:00
|
|
|
case SIHOST2:
|
1998-03-23 16:27:43 +00:00
|
|
|
case SIHOST:
|
|
|
|
case SIPCI:
|
|
|
|
switch (uart_type) {
|
|
|
|
case 0:
|
|
|
|
return(" (XIO)");
|
|
|
|
case 1:
|
|
|
|
return(" (SI)");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* T225 based hosts */
|
|
|
|
case SIJETPCI:
|
|
|
|
case SIJETISA:
|
|
|
|
switch (uart_type) {
|
|
|
|
case 0:
|
|
|
|
return(" (SI)");
|
|
|
|
case 40:
|
|
|
|
return(" (XIO)");
|
1998-06-10 12:49:54 +00:00
|
|
|
case 72:
|
|
|
|
return(" (SXDC)");
|
1998-03-23 16:27:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return("");
|
|
|
|
}
|