1996-06-06 19:36:06 +04:00
|
|
|
/* $NetBSD: dcm.c,v 1.28 1996/06/06 15:36:10 thorpej Exp $ */
|
1994-10-26 10:22:45 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1996-02-24 03:54:53 +03:00
|
|
|
* Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
* Copyright (c) 1988 University of Utah.
|
1994-05-23 09:58:16 +04:00
|
|
|
* Copyright (c) 1982, 1986, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
1994-05-23 09:58:16 +04:00
|
|
|
* from Utah: $Hdr: dcm.c 1.29 92/01/21$
|
|
|
|
*
|
1994-10-26 10:22:45 +03:00
|
|
|
* @(#)dcm.c 8.4 (Berkeley) 1/12/94
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* Timeouts
|
|
|
|
* Test console support.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dcm.h"
|
|
|
|
#if NDCM > 0
|
|
|
|
/*
|
|
|
|
* 98642/MUX
|
|
|
|
*/
|
1994-02-10 16:59:25 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
#include <machine/autoconf.h>
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <machine/cpu.h>
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
#include <dev/cons.h>
|
|
|
|
|
1994-02-10 16:59:25 +03:00
|
|
|
#include <hp300/dev/device.h>
|
|
|
|
#include <hp300/dev/dcmreg.h>
|
|
|
|
#include <hp300/hp300/isr.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifndef DEFAULT_BAUD_RATE
|
|
|
|
#define DEFAULT_BAUD_RATE 9600
|
|
|
|
#endif
|
|
|
|
|
1996-02-14 05:43:54 +03:00
|
|
|
int dcmmatch(), dcmparam();
|
1995-12-02 21:18:50 +03:00
|
|
|
void dcmattach(), dcmstart();
|
1993-05-13 17:56:20 +04:00
|
|
|
struct driver dcmdriver = {
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmmatch, dcmattach, "dcm",
|
1993-05-13 17:56:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct speedtab dcmspeedtab[] = {
|
|
|
|
0, BR_0,
|
|
|
|
50, BR_50,
|
|
|
|
75, BR_75,
|
|
|
|
110, BR_110,
|
|
|
|
134, BR_134,
|
|
|
|
150, BR_150,
|
|
|
|
300, BR_300,
|
|
|
|
600, BR_600,
|
|
|
|
1200, BR_1200,
|
|
|
|
1800, BR_1800,
|
|
|
|
2400, BR_2400,
|
|
|
|
4800, BR_4800,
|
|
|
|
9600, BR_9600,
|
|
|
|
19200, BR_19200,
|
|
|
|
38400, BR_38400,
|
|
|
|
-1, -1
|
|
|
|
};
|
|
|
|
|
|
|
|
/* u-sec per character based on baudrate (assumes 1 start/8 data/1 stop bit) */
|
|
|
|
#define DCM_USPERCH(s) (10000000 / (s))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Per board interrupt scheme. 16.7ms is the polling interrupt rate
|
|
|
|
* (16.7ms is about 550 baud, 38.4k is 72 chars in 16.7ms).
|
|
|
|
*/
|
|
|
|
#define DIS_TIMER 0
|
|
|
|
#define DIS_PERCHAR 1
|
|
|
|
#define DIS_RESET 2
|
|
|
|
|
|
|
|
int dcmistype = -1; /* -1 == dynamic, 0 == timer, 1 == perchar */
|
|
|
|
int dcminterval = 5; /* interval (secs) between checks */
|
|
|
|
struct dcmischeme {
|
|
|
|
int dis_perchar; /* non-zero if interrupting per char */
|
|
|
|
long dis_time; /* last time examined */
|
|
|
|
int dis_intr; /* recv interrupts during last interval */
|
|
|
|
int dis_char; /* characters read during last interval */
|
1995-12-02 21:18:50 +03:00
|
|
|
};
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
1995-12-31 03:27:16 +03:00
|
|
|
* Stuff for DCM console support. This could probably be done a little
|
|
|
|
* better.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1995-12-31 03:27:16 +03:00
|
|
|
static struct dcmdevice *dcm_cn = NULL; /* pointer to hardware */
|
|
|
|
static int dcm_lastcnpri = CN_DEAD; /* XXX last priority */
|
|
|
|
static int dcmconsinit; /* has been initialized */
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
int dcmdefaultrate = DEFAULT_BAUD_RATE;
|
|
|
|
int dcmconbrdbusy = 0;
|
|
|
|
int dcmmajor;
|
|
|
|
|
|
|
|
#ifdef KGDB
|
|
|
|
/*
|
|
|
|
* Kernel GDB support
|
|
|
|
*/
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <machine/remote-sl.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
extern dev_t kgdb_dev;
|
|
|
|
extern int kgdb_rate;
|
|
|
|
extern int kgdb_debug_init;
|
|
|
|
#endif
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
/* #define DCMSTATS */
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
int dcmdebug = 0x0;
|
|
|
|
#define DDB_SIOERR 0x01
|
|
|
|
#define DDB_PARAM 0x02
|
|
|
|
#define DDB_INPUT 0x04
|
|
|
|
#define DDB_OUTPUT 0x08
|
|
|
|
#define DDB_INTR 0x10
|
|
|
|
#define DDB_IOCTL 0x20
|
|
|
|
#define DDB_INTSCHM 0x40
|
|
|
|
#define DDB_MODEM 0x80
|
|
|
|
#define DDB_OPENCLOSE 0x100
|
|
|
|
#endif
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
#define DCMRBSIZE 94
|
|
|
|
#define DCMXBSIZE 24
|
|
|
|
|
|
|
|
struct dcmstats {
|
|
|
|
long xints; /* # of xmit ints */
|
|
|
|
long xchars; /* # of xmit chars */
|
|
|
|
long xempty; /* times outq is empty in dcmstart */
|
|
|
|
long xrestarts; /* times completed while xmitting */
|
|
|
|
long rints; /* # of recv ints */
|
|
|
|
long rchars; /* # of recv chars */
|
|
|
|
long xsilo[DCMXBSIZE+2]; /* times this many chars xmit on one int */
|
|
|
|
long rsilo[DCMRBSIZE+2]; /* times this many chars read on one int */
|
1995-12-02 21:18:50 +03:00
|
|
|
};
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
#define DCMUNIT(x) minor(x)
|
|
|
|
#define DCMBOARD(x) (((x) >> 2) & 0x3f)
|
|
|
|
#define DCMPORT(x) ((x) & 3)
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Conversion from "HP DCE" to almost-normal DCE: on the 638 8-port mux,
|
|
|
|
* the distribution panel uses "HP DCE" conventions. If requested via
|
|
|
|
* the device flags, we swap the inputs to something closer to normal DCE,
|
|
|
|
* allowing a straight-through cable to a DTE or a reversed cable
|
|
|
|
* to a DCE (reversing 2-3, 4-5, 8-20 and leaving 6 unconnected;
|
|
|
|
* this gets "DCD" on pin 20 and "CTS" on 4, but doesn't connect
|
|
|
|
* DSR or make RTS work, though). The following gives the full
|
|
|
|
* details of a cable from this mux panel to a modem:
|
|
|
|
*
|
|
|
|
* HP modem
|
|
|
|
* name pin pin name
|
|
|
|
* HP inputs:
|
|
|
|
* "Rx" 2 3 Tx
|
|
|
|
* CTS 4 5 CTS (only needed for CCTS_OFLOW)
|
|
|
|
* DCD 20 8 DCD
|
|
|
|
* "DSR" 9 6 DSR (unneeded)
|
|
|
|
* RI 22 22 RI (unneeded)
|
|
|
|
*
|
|
|
|
* HP outputs:
|
|
|
|
* "Tx" 3 2 Rx
|
|
|
|
* "DTR" 6 not connected
|
|
|
|
* "RTS" 8 20 DTR
|
|
|
|
* "SR" 23 4 RTS (often not needed)
|
|
|
|
*/
|
|
|
|
#define hp2dce_in(ibits) (iconv[(ibits) & 0xf])
|
|
|
|
static char iconv[16] = {
|
|
|
|
0, MI_DM, MI_CTS, MI_CTS|MI_DM,
|
|
|
|
MI_CD, MI_CD|MI_DM, MI_CD|MI_CTS, MI_CD|MI_CTS|MI_DM,
|
|
|
|
MI_RI, MI_RI|MI_DM, MI_RI|MI_CTS, MI_RI|MI_CTS|MI_DM,
|
|
|
|
MI_RI|MI_CD, MI_RI|MI_CD|MI_DM, MI_RI|MI_CD|MI_CTS,
|
|
|
|
MI_RI|MI_CD|MI_CTS|MI_DM
|
|
|
|
};
|
|
|
|
|
1995-12-29 20:21:29 +03:00
|
|
|
/*
|
|
|
|
* Note that 8-port boards appear as 2 4-port boards at consecutive
|
|
|
|
* select codes.
|
|
|
|
*/
|
|
|
|
#define NDCMPORT 4
|
1995-12-02 21:18:50 +03:00
|
|
|
|
|
|
|
struct dcm_softc {
|
|
|
|
struct hp_device *sc_hd; /* device info */
|
|
|
|
struct dcmdevice *sc_dcm; /* pointer to hardware */
|
|
|
|
struct tty *sc_tty[NDCMPORT]; /* our tty instances */
|
|
|
|
struct modemreg *sc_modem[NDCMPORT]; /* modem control */
|
|
|
|
char sc_mcndlast[NDCMPORT]; /* XXX last modem status for port */
|
|
|
|
short sc_softCAR; /* mask of ports with soft-carrier */
|
|
|
|
struct dcmischeme sc_scheme; /* interrupt scheme for board */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mask of soft-carrier bits in config flags.
|
|
|
|
*/
|
|
|
|
#define DCM_SOFTCAR 0x0000000f
|
|
|
|
|
|
|
|
int sc_flags; /* misc. configuration info */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bits for sc_flags
|
|
|
|
*/
|
|
|
|
#define DCM_ACTIVE 0x00000001 /* indicates board is alive */
|
1996-02-24 03:54:53 +03:00
|
|
|
#define DCM_ISCONSOLE 0x00000002 /* indicates board is console */
|
1995-12-02 21:18:50 +03:00
|
|
|
#define DCM_STDDCE 0x00000010 /* re-map DCE to standard */
|
|
|
|
#define DCM_FLAGMASK (DCM_STDDCE) /* mask of valid bits in config flags */
|
|
|
|
|
|
|
|
#ifdef DCMSTATS
|
|
|
|
struct dcmstats sc_stats; /* metrics gathering */
|
|
|
|
#endif
|
|
|
|
} dcm_softc[NDCM];
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
void dcminit __P((struct dcmdevice *, int, int));
|
1996-02-14 05:43:54 +03:00
|
|
|
int dcmintr __P((void *));
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
int
|
|
|
|
dcmmatch(hd)
|
1993-05-13 17:56:20 +04:00
|
|
|
register struct hp_device *hd;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
int i, timo = 0;
|
1996-02-24 03:54:53 +03:00
|
|
|
int s, brd, mbits;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
dcm = (struct dcmdevice *)hd->hp_addr;
|
|
|
|
if ((dcm->dcm_rsid & 0x1f) != DCMID)
|
|
|
|
return (0);
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
brd = hd->hp_unit;
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_hd = hd;
|
|
|
|
hd->hp_ipl = DCMIPL(dcm->dcm_ic);
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Empirically derived self-test magic
|
|
|
|
*/
|
|
|
|
s = spltty();
|
|
|
|
dcm->dcm_rsid = DCMRS;
|
|
|
|
DELAY(50000); /* 5000 is not long enough */
|
|
|
|
dcm->dcm_rsid = 0;
|
|
|
|
dcm->dcm_ic = IC_IE;
|
|
|
|
dcm->dcm_cr = CR_SELFT;
|
|
|
|
while ((dcm->dcm_ic & IC_IR) == 0)
|
|
|
|
if (++timo == 20000)
|
|
|
|
return (0);
|
1996-05-17 19:08:13 +04:00
|
|
|
DELAY(50000); /* XXX why is this needed ???? */
|
1993-05-13 17:56:20 +04:00
|
|
|
while ((dcm->dcm_iir & IIR_SELFT) == 0)
|
|
|
|
if (++timo == 400000)
|
|
|
|
return (0);
|
1996-05-17 19:08:13 +04:00
|
|
|
DELAY(50000); /* XXX why is this needed ???? */
|
1993-05-13 17:56:20 +04:00
|
|
|
if (dcm->dcm_stcon != ST_OK) {
|
1996-02-24 03:54:53 +03:00
|
|
|
if (hd->hp_args->hw_sc != conscode)
|
1993-05-13 17:56:20 +04:00
|
|
|
printf("dcm%d: self test failed: %x\n",
|
|
|
|
brd, dcm->dcm_stcon);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
dcm->dcm_ic = IC_ID;
|
|
|
|
splx(s);
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dcmattach(hd)
|
|
|
|
register struct hp_device *hd;
|
|
|
|
{
|
|
|
|
struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
int i, timo = 0;
|
1996-02-24 03:54:53 +03:00
|
|
|
int s, brd, mbits;
|
1995-12-02 21:18:50 +03:00
|
|
|
|
|
|
|
dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr;
|
|
|
|
|
|
|
|
brd = hd->hp_unit;
|
1996-02-24 03:54:53 +03:00
|
|
|
if (hd->hp_args->hw_sc == conscode) {
|
|
|
|
sc->sc_flags |= DCM_ISCONSOLE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We didn't know which unit this would be during
|
|
|
|
* the console probe, so we have to fixup cn_dev here.
|
|
|
|
* Note that we always assume port 1 on the board.
|
|
|
|
*/
|
|
|
|
cn_tab->cn_dev = makedev(dcmmajor, (brd << 2) | DCMCONSPORT);
|
|
|
|
}
|
1995-12-02 21:18:50 +03:00
|
|
|
|
|
|
|
/* Extract configuration info from flags. */
|
|
|
|
sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR);
|
|
|
|
sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK);
|
|
|
|
|
|
|
|
/* Mark our unit as configured. */
|
|
|
|
sc->sc_flags |= DCM_ACTIVE;
|
|
|
|
|
|
|
|
/* Establish the interrupt handler. */
|
1996-02-14 05:43:54 +03:00
|
|
|
isrlink(dcmintr, sc, hd->hp_ipl, ISRPRI_TTY);
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if (dcmistype == DIS_TIMER)
|
|
|
|
dcmsetischeme(brd, DIS_RESET|DIS_TIMER);
|
|
|
|
else
|
|
|
|
dcmsetischeme(brd, DIS_RESET|DIS_PERCHAR);
|
|
|
|
|
|
|
|
/* load pointers to modem control */
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_modem[0] = &dcm->dcm_modem0;
|
|
|
|
sc->sc_modem[1] = &dcm->dcm_modem1;
|
|
|
|
sc->sc_modem[2] = &dcm->dcm_modem2;
|
|
|
|
sc->sc_modem[3] = &dcm->dcm_modem3;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/* set DCD (modem) and CTS (flow control) on all ports */
|
1995-12-02 21:18:50 +03:00
|
|
|
if (sc->sc_flags & DCM_STDDCE)
|
1993-05-13 17:56:20 +04:00
|
|
|
mbits = hp2dce_in(MI_CD|MI_CTS);
|
|
|
|
else
|
|
|
|
mbits = MI_CD|MI_CTS;
|
1995-12-02 21:18:50 +03:00
|
|
|
|
|
|
|
for (i = 0; i < NDCMPORT; i++)
|
|
|
|
sc->sc_modem[i]->mdmmsk = mbits;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
dcm->dcm_ic = IC_IE; /* turn all interrupts on */
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1996-02-24 03:54:53 +03:00
|
|
|
* Need to reset baud rate, etc. of next print so reset dcmconsinit.
|
1993-05-13 17:56:20 +04:00
|
|
|
* Also make sure console is always "hardwired"
|
|
|
|
*/
|
1996-02-24 03:54:53 +03:00
|
|
|
if (sc->sc_flags & DCM_ISCONSOLE) {
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmconsinit = 0;
|
1996-02-24 03:54:53 +03:00
|
|
|
sc->sc_softCAR |= (1 << DCMCONSPORT);
|
|
|
|
printf(": console on port %d\n", DCMCONSPORT);
|
1995-12-02 21:18:50 +03:00
|
|
|
} else
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
#ifdef KGDB
|
|
|
|
if (major(kgdb_dev) == dcmmajor &&
|
|
|
|
DCMBOARD(DCMUNIT(kgdb_dev)) == brd) {
|
1996-02-24 03:54:53 +03:00
|
|
|
if (dcmconsole == DCMUNIT(kgdb_dev)) /* XXX fixme */
|
1995-12-02 21:18:50 +03:00
|
|
|
kgdb_dev = NODEV; /* can't debug over console port */
|
|
|
|
#ifndef KGDB_CHEAT
|
|
|
|
/*
|
|
|
|
* The following could potentially be replaced
|
|
|
|
* by the corresponding code in dcmcnprobe.
|
|
|
|
*/
|
|
|
|
else {
|
1995-12-31 03:27:16 +03:00
|
|
|
dcminit(dcm, DCMPORT(DCMUNIT(kgdb_dev)),
|
|
|
|
kgdb_rate);
|
1995-12-02 21:18:50 +03:00
|
|
|
if (kgdb_debug_init) {
|
|
|
|
printf("%s port %d: ", sc->sc_hd->hp_xname,
|
|
|
|
DCMPORT(DCMUNIT(kgdb_dev)));
|
|
|
|
kgdb_connect(1);
|
|
|
|
} else
|
|
|
|
printf("%s port %d: kgdb enabled\n",
|
|
|
|
sc->sc_hd->hp_xname,
|
|
|
|
DCMPORT(DCMUNIT(kgdb_dev)));
|
|
|
|
}
|
|
|
|
/* end could be replaced */
|
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-12-02 21:18:50 +03:00
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmopen(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc;
|
|
|
|
struct tty *tp;
|
|
|
|
int unit, brd, port;
|
1995-10-04 09:39:06 +03:00
|
|
|
int error = 0, mbits, s;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
unit = DCMUNIT(dev);
|
|
|
|
brd = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
if ((brd >= NDCM) || (port >= NDCMPORT))
|
1993-05-13 17:56:20 +04:00
|
|
|
return (ENXIO);
|
1995-12-02 21:18:50 +03:00
|
|
|
|
|
|
|
sc = &dcm_softc[brd];
|
|
|
|
if ((sc->sc_flags & DCM_ACTIVE) == 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
1996-06-06 19:36:06 +04:00
|
|
|
if (sc->sc_tty[port] == NULL) {
|
1995-12-02 21:18:50 +03:00
|
|
|
tp = sc->sc_tty[port] = ttymalloc();
|
1996-06-06 19:36:06 +04:00
|
|
|
tty_attach(tp);
|
|
|
|
} else
|
1995-12-02 21:18:50 +03:00
|
|
|
tp = sc->sc_tty[port];
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_oproc = dcmstart;
|
|
|
|
tp->t_param = dcmparam;
|
|
|
|
tp->t_dev = dev;
|
1995-10-04 09:39:06 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
1995-10-04 09:39:06 +03:00
|
|
|
/*
|
|
|
|
* Sanity clause: reset the card on first open.
|
|
|
|
* The card might be left in an inconsistent state
|
|
|
|
* if the card memory is read inadvertently.
|
|
|
|
*/
|
1995-12-31 03:27:16 +03:00
|
|
|
dcminit(sc->sc_dcm, port, dcmdefaultrate);
|
1995-10-04 09:39:06 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
ttychars(tp);
|
1995-10-04 09:39:06 +03:00
|
|
|
tp->t_iflag = TTYDEF_IFLAG;
|
|
|
|
tp->t_oflag = TTYDEF_OFLAG;
|
|
|
|
tp->t_cflag = TTYDEF_CFLAG;
|
|
|
|
tp->t_lflag = TTYDEF_LFLAG;
|
|
|
|
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) dcmparam(tp, &tp->t_termios);
|
|
|
|
ttsetwater(tp);
|
1995-10-04 09:39:06 +03:00
|
|
|
} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
return (EBUSY);
|
1995-10-04 09:39:06 +03:00
|
|
|
else
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
/* Set modem control state. */
|
1993-05-13 17:56:20 +04:00
|
|
|
mbits = MO_ON;
|
1995-12-02 21:18:50 +03:00
|
|
|
if (sc->sc_flags & DCM_STDDCE)
|
1993-05-13 17:56:20 +04:00
|
|
|
mbits |= MO_SR; /* pin 23, could be used as RTS */
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) dcmmctl(dev, mbits, DMSET); /* enable port */
|
1995-10-04 09:39:06 +03:00
|
|
|
|
|
|
|
/* Set soft-carrier if so configured. */
|
1995-12-02 21:18:50 +03:00
|
|
|
if ((sc->sc_softCAR & (1 << port)) ||
|
1993-05-13 17:56:20 +04:00
|
|
|
(dcmmctl(dev, MO_OFF, DMGET) & MI_CD))
|
|
|
|
tp->t_state |= TS_CARR_ON;
|
1995-10-04 09:39:06 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_MODEM)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s: dcmopen port %d softcarr %c\n",
|
|
|
|
sc->sc_hd->hp_xname, port,
|
|
|
|
(tp->t_state & TS_CARR_ON) ? '1' : '0');
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1995-10-04 09:39:06 +03:00
|
|
|
|
|
|
|
/* Wait for carrier if necessary. */
|
|
|
|
if ((flag & O_NONBLOCK) == 0)
|
|
|
|
while ((tp->t_cflag & CLOCAL) == 0 &&
|
|
|
|
(tp->t_state & TS_CARR_ON) == 0) {
|
|
|
|
tp->t_state |= TS_WOPEN;
|
|
|
|
error = ttysleep(tp, (caddr_t)&tp->t_rawq,
|
|
|
|
TTIPRI | PCATCH, ttopen, 0);
|
|
|
|
if (error) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_OPENCLOSE)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmopen: st %x fl %x\n",
|
|
|
|
sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
if (error == 0)
|
|
|
|
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
1995-10-04 09:39:06 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmclose(dev, flag, mode, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flag, mode;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
int s, unit, board, port;
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
struct tty *tp;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
unit = DCMUNIT(dev);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
tp = sc->sc_tty[port];
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
(*linesw[tp->t_line].l_close)(tp, flag);
|
1995-10-04 09:39:06 +03:00
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
if (tp->t_cflag & HUPCL || tp->t_state & TS_WOPEN ||
|
|
|
|
(tp->t_state & TS_ISOPEN) == 0)
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) dcmmctl(dev, MO_OFF, DMSET);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_OPENCLOSE)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmclose: st %x fl %x\n",
|
|
|
|
sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1995-10-04 09:39:06 +03:00
|
|
|
splx(s);
|
1993-05-13 17:56:20 +04:00
|
|
|
ttyclose(tp);
|
1994-02-06 04:08:36 +03:00
|
|
|
#if 0
|
1996-06-06 19:36:06 +04:00
|
|
|
tty_detach(tp);
|
1993-07-12 15:36:53 +04:00
|
|
|
ttyfree(tp);
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_tty[port] == NULL;
|
1994-02-06 04:08:36 +03:00
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmread(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-05-23 09:58:16 +04:00
|
|
|
int flag;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
int unit, board, port;
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
register struct tty *tp;
|
|
|
|
|
|
|
|
unit = DCMUNIT(dev);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
tp = sc->sc_tty[port];
|
1994-05-23 09:58:16 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmwrite(dev, uio, flag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
1994-05-23 09:58:16 +04:00
|
|
|
int flag;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
int unit, board, port;
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
register struct tty *tp;
|
|
|
|
|
|
|
|
unit = DCMUNIT(dev);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
tp = sc->sc_tty[port];
|
1994-05-23 09:58:16 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
|
|
|
|
}
|
1995-04-19 23:15:47 +04:00
|
|
|
|
|
|
|
struct tty *
|
|
|
|
dcmtty(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
int unit, board, port;
|
|
|
|
struct dcm_softc *sc;
|
1995-04-19 23:15:47 +04:00
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
unit = DCMUNIT(dev);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
|
|
|
|
return (sc->sc_tty[port]);
|
1995-04-19 23:15:47 +04:00
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1996-02-14 05:43:54 +03:00
|
|
|
dcmintr(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1996-02-14 05:43:54 +03:00
|
|
|
struct dcm_softc *sc = arg;
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcmdevice *dcm = sc->sc_dcm;
|
|
|
|
struct dcmischeme *dis = &sc->sc_scheme;
|
1996-02-14 05:43:54 +03:00
|
|
|
int brd = sc->sc_hd->hp_unit;
|
1995-12-02 21:18:50 +03:00
|
|
|
int code, i;
|
1993-05-13 17:56:20 +04:00
|
|
|
int pcnd[4], mcode, mcnd[4];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do all guarded register accesses right off to minimize
|
|
|
|
* block out of hardware.
|
|
|
|
*/
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
if ((dcm->dcm_ic & IC_IR) == 0) {
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
pcnd[i] = dcm->dcm_icrtab[i].dcm_data;
|
|
|
|
dcm->dcm_icrtab[i].dcm_data = 0;
|
1995-12-02 21:18:50 +03:00
|
|
|
code = sc->sc_modem[i]->mdmin;
|
|
|
|
if (sc->sc_flags & DCM_STDDCE)
|
1993-05-13 17:56:20 +04:00
|
|
|
code = hp2dce_in(code);
|
|
|
|
mcnd[i] = code;
|
|
|
|
}
|
|
|
|
code = dcm->dcm_iir & IIR_MASK;
|
|
|
|
dcm->dcm_iir = 0; /* XXX doc claims read clears interrupt?! */
|
|
|
|
mcode = dcm->dcm_modemintr;
|
|
|
|
dcm->dcm_modemintr = 0;
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_INTR) {
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s: dcmintr: iir %x pc %x/%x/%x/%x ",
|
|
|
|
sc->sc_hd->hp_xname, code, pcnd[0], pcnd[1],
|
|
|
|
pcnd[2], pcnd[3]);
|
1993-05-13 17:56:20 +04:00
|
|
|
printf("miir %x mc %x/%x/%x/%x\n",
|
|
|
|
mcode, mcnd[0], mcnd[1], mcnd[2], mcnd[3]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (code & IIR_TIMEO)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmrint(sc);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (code & IIR_PORT0)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmpint(sc, 0, pcnd[0]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (code & IIR_PORT1)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmpint(sc, 1, pcnd[1]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (code & IIR_PORT2)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmpint(sc, 2, pcnd[2]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (code & IIR_PORT3)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmpint(sc, 3, pcnd[3]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (code & IIR_MODM) {
|
|
|
|
if (mcode == 0 || mcode & 0x1) /* mcode==0 -> 98642 board */
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmmint(sc, 0, mcnd[0]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (mcode & 0x2)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmmint(sc, 1, mcnd[1]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (mcode & 0x4)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmmint(sc, 2, mcnd[2]);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (mcode & 0x8)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmmint(sc, 3, mcnd[3]);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Chalk up a receiver interrupt if the timer running or one of
|
|
|
|
* the ports reports a special character interrupt.
|
|
|
|
*/
|
|
|
|
if ((code & IIR_TIMEO) ||
|
|
|
|
((pcnd[0]|pcnd[1]|pcnd[2]|pcnd[3]) & IT_SPEC))
|
|
|
|
dis->dis_intr++;
|
|
|
|
/*
|
|
|
|
* See if it is time to check/change the interrupt rate.
|
|
|
|
*/
|
|
|
|
if (dcmistype < 0 &&
|
|
|
|
(i = time.tv_sec - dis->dis_time) >= dcminterval) {
|
|
|
|
/*
|
|
|
|
* If currently per-character and averaged over 70 interrupts
|
|
|
|
* per-second (66 is threshold of 600 baud) in last interval,
|
|
|
|
* switch to timer mode.
|
|
|
|
*
|
|
|
|
* XXX decay counts ala load average to avoid spikes?
|
|
|
|
*/
|
|
|
|
if (dis->dis_perchar && dis->dis_intr > 70 * i)
|
|
|
|
dcmsetischeme(brd, DIS_TIMER);
|
|
|
|
/*
|
|
|
|
* If currently using timer and had more interrupts than
|
|
|
|
* received characters in the last interval, switch back
|
|
|
|
* to per-character. Note that after changing to per-char
|
|
|
|
* we must process any characters already in the queue
|
|
|
|
* since they may have arrived before the bitmap was setup.
|
|
|
|
*
|
|
|
|
* XXX decay counts?
|
|
|
|
*/
|
|
|
|
else if (!dis->dis_perchar && dis->dis_intr > dis->dis_char) {
|
|
|
|
dcmsetischeme(brd, DIS_PERCHAR);
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmrint(sc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
dis->dis_intr = dis->dis_char = 0;
|
|
|
|
dis->dis_time = time.tv_sec;
|
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Port interrupt. Can be two things:
|
|
|
|
* First, it might be a special character (exception interrupt);
|
|
|
|
* Second, it may be a buffer empty (transmit interrupt);
|
|
|
|
*/
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmpint(sc, port, code)
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
int port, code;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
if (code & IT_SPEC)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmreadbuf(sc, port);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (code & IT_TX)
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmxint(sc, port);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmrint(sc)
|
|
|
|
struct dcm_softc *sc;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
int port;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
for (port = 0; port < NDCMPORT; port++)
|
|
|
|
dcmreadbuf(sc, port);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmreadbuf(sc, port)
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
int port;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcmdevice *dcm = sc->sc_dcm;
|
|
|
|
struct tty *tp = sc->sc_tty[port];
|
|
|
|
struct dcmpreg *pp = dcm_preg(dcm, port);
|
|
|
|
struct dcmrfifo *fifo;
|
|
|
|
int c, stat;
|
|
|
|
u_int head;
|
1993-05-13 17:56:20 +04:00
|
|
|
int nch = 0;
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcmstats *dsp = &sc->sc_stats;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
dsp->rints++;
|
|
|
|
#endif
|
|
|
|
if ((tp->t_state & TS_ISOPEN) == 0) {
|
|
|
|
#ifdef KGDB
|
1995-12-02 21:18:50 +03:00
|
|
|
if ((makedev(dcmmajor, minor(tp->t_dev)) == kgdb_dev) &&
|
1993-05-13 17:56:20 +04:00
|
|
|
(head = pp->r_head & RX_MASK) != (pp->r_tail & RX_MASK) &&
|
1994-05-23 09:58:16 +04:00
|
|
|
dcm->dcm_rfifos[3-port][head>>1].data_char == FRAME_START) {
|
1993-05-13 17:56:20 +04:00
|
|
|
pp->r_head = (head + 2) & RX_MASK;
|
|
|
|
kgdb_connect(0); /* trap into kgdb */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif /* KGDB */
|
|
|
|
pp->r_head = pp->r_tail & RX_MASK;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
head = pp->r_head & RX_MASK;
|
|
|
|
fifo = &dcm->dcm_rfifos[3-port][head>>1];
|
|
|
|
/*
|
|
|
|
* XXX upper bound on how many chars we will take in one swallow?
|
|
|
|
*/
|
|
|
|
while (head != (pp->r_tail & RX_MASK)) {
|
|
|
|
/*
|
|
|
|
* Get character/status and update head pointer as fast
|
|
|
|
* as possible to make room for more characters.
|
|
|
|
*/
|
|
|
|
c = fifo->data_char;
|
|
|
|
stat = fifo->data_stat;
|
|
|
|
head = (head + 2) & RX_MASK;
|
|
|
|
pp->r_head = head;
|
|
|
|
fifo = head ? fifo+1 : &dcm->dcm_rfifos[3-port][0];
|
|
|
|
nch++;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_INPUT)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmreadbuf: c%x('%c') s%x f%x h%x t%x\n",
|
|
|
|
sc->sc_hd->hp_xname, port,
|
|
|
|
c&0xFF, c, stat&0xFF,
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_flags, head, pp->r_tail);
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Check for and handle errors
|
|
|
|
*/
|
|
|
|
if (stat & RD_MASK) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & (DDB_INPUT|DDB_SIOERR))
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmreadbuf: err: c%x('%c') s%x\n",
|
|
|
|
sc->sc_hd->hp_xname, port,
|
|
|
|
stat, c&0xFF, c);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
if (stat & (RD_BD | RD_FE))
|
|
|
|
c |= TTY_FE;
|
|
|
|
else if (stat & RD_PE)
|
|
|
|
c |= TTY_PE;
|
|
|
|
else if (stat & RD_OVF)
|
|
|
|
log(LOG_WARNING,
|
1995-12-02 21:18:50 +03:00
|
|
|
"%s port %d: silo overflow\n",
|
|
|
|
sc->sc_hd->hp_xname, port);
|
1993-05-13 17:56:20 +04:00
|
|
|
else if (stat & RD_OE)
|
|
|
|
log(LOG_WARNING,
|
1995-12-02 21:18:50 +03:00
|
|
|
"%s port %d: uart overflow\n",
|
|
|
|
sc->sc_hd->hp_xname, port);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
(*linesw[tp->t_line].l_rint)(c, tp);
|
|
|
|
}
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_scheme.dis_char += nch;
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
dsp->rchars += nch;
|
|
|
|
if (nch <= DCMRBSIZE)
|
|
|
|
dsp->rsilo[nch]++;
|
|
|
|
else
|
|
|
|
dsp->rsilo[DCMRBSIZE+1]++;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmxint(sc, port)
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
int port;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct tty *tp = sc->sc_tty[port];
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
tp->t_state &= ~TS_BUSY;
|
|
|
|
if (tp->t_state & TS_FLUSH)
|
|
|
|
tp->t_state &= ~TS_FLUSH;
|
|
|
|
(*linesw[tp->t_line].l_start)(tp);
|
|
|
|
}
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
dcmmint(sc, port, mcnd)
|
|
|
|
struct dcm_softc *sc;
|
|
|
|
int port, mcnd;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
int delta;
|
1995-12-02 21:18:50 +03:00
|
|
|
struct tty *tp;
|
|
|
|
struct dcmdevice *dcm = sc->sc_dcm;
|
|
|
|
|
|
|
|
tp = sc->sc_tty[port];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_MODEM)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmmint: mcnd %x mcndlast %x\n",
|
|
|
|
sc->sc_hd->hp_xname, port, mcnd, sc->sc_mcndlast[port]);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1995-12-02 21:18:50 +03:00
|
|
|
delta = mcnd ^ sc->sc_mcndlast[port];
|
|
|
|
sc->sc_mcndlast[port] = mcnd;
|
1993-05-13 17:56:20 +04:00
|
|
|
if ((delta & MI_CTS) && (tp->t_state & TS_ISOPEN) &&
|
|
|
|
(tp->t_flags & CCTS_OFLOW)) {
|
|
|
|
if (mcnd & MI_CTS) {
|
|
|
|
tp->t_state &= ~TS_TTSTOP;
|
|
|
|
ttstart(tp);
|
|
|
|
} else
|
|
|
|
tp->t_state |= TS_TTSTOP; /* inline dcmstop */
|
|
|
|
}
|
|
|
|
if (delta & MI_CD) {
|
|
|
|
if (mcnd & MI_CD)
|
|
|
|
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
|
1995-12-02 21:18:50 +03:00
|
|
|
else if ((sc->sc_softCAR & (1 << port)) == 0 &&
|
1993-05-13 17:56:20 +04:00
|
|
|
(*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_modem[port]->mdmout = MO_OFF;
|
1993-05-13 17:56:20 +04:00
|
|
|
SEM_LOCK(dcm);
|
1995-12-02 21:18:50 +03:00
|
|
|
dcm->dcm_modemchng |= (1 << port);
|
1993-05-13 17:56:20 +04:00
|
|
|
dcm->dcm_cr |= CR_MODM;
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
DELAY(10); /* time to change lines */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1994-02-10 16:59:25 +03:00
|
|
|
dcmioctl(dev, cmd, data, flag, p)
|
1993-05-13 17:56:20 +04:00
|
|
|
dev_t dev;
|
1994-02-10 16:59:25 +03:00
|
|
|
int cmd;
|
1993-05-13 17:56:20 +04:00
|
|
|
caddr_t data;
|
1994-02-10 16:59:25 +03:00
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc;
|
|
|
|
struct tty *tp;
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
int board, port, unit = DCMUNIT(dev);
|
1993-05-13 17:56:20 +04:00
|
|
|
int error, s;
|
1995-12-02 21:18:50 +03:00
|
|
|
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
dcm = sc->sc_dcm;
|
|
|
|
tp = sc->sc_tty[port];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_IOCTL)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n",
|
|
|
|
sc->sc_hd->hp_xname, port, cmd, *data, flag);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
1994-02-10 16:59:25 +03:00
|
|
|
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error >= 0)
|
|
|
|
return (error);
|
1994-02-10 16:59:25 +03:00
|
|
|
error = ttioctl(tp, cmd, data, flag, p);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error >= 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case TIOCSBRK:
|
|
|
|
/*
|
|
|
|
* Wait for transmitter buffer to empty
|
|
|
|
*/
|
|
|
|
s = spltty();
|
|
|
|
while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
|
|
|
|
DELAY(DCM_USPERCH(tp->t_ospeed));
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cmdtab[port].dcm_data |= CT_BRK;
|
|
|
|
dcm->dcm_cr |= (1 << port); /* start break */
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
splx(s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCCBRK:
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cmdtab[port].dcm_data |= CT_BRK;
|
|
|
|
dcm->dcm_cr |= (1 << port); /* end break */
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCSDTR:
|
|
|
|
(void) dcmmctl(dev, MO_ON, DMBIS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCCDTR:
|
|
|
|
(void) dcmmctl(dev, MO_ON, DMBIC);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMSET:
|
|
|
|
(void) dcmmctl(dev, *(int *)data, DMSET);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIS:
|
|
|
|
(void) dcmmctl(dev, *(int *)data, DMBIS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIC:
|
|
|
|
(void) dcmmctl(dev, *(int *)data, DMBIC);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMGET:
|
|
|
|
*(int *)data = dcmmctl(dev, 0, DMGET);
|
|
|
|
break;
|
|
|
|
|
1995-10-04 09:39:06 +03:00
|
|
|
case TIOCGFLAGS: {
|
|
|
|
int bits = 0;
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
if ((sc->sc_softCAR & (1 << port)))
|
1995-10-04 09:39:06 +03:00
|
|
|
bits |= TIOCFLAG_SOFTCAR;
|
|
|
|
|
|
|
|
if (tp->t_cflag & CLOCAL)
|
|
|
|
bits |= TIOCFLAG_CLOCAL;
|
|
|
|
|
|
|
|
*(int *)data = bits;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TIOCSFLAGS: {
|
|
|
|
int userbits;
|
|
|
|
|
|
|
|
error = suser(p->p_ucred, &p->p_acflag);
|
|
|
|
if (error)
|
|
|
|
return (EPERM);
|
|
|
|
|
|
|
|
userbits = *(int *)data;
|
|
|
|
|
|
|
|
if ((userbits & TIOCFLAG_SOFTCAR) ||
|
1996-02-24 03:54:53 +03:00
|
|
|
((sc->sc_flags & DCM_ISCONSOLE) &&
|
|
|
|
(port == DCMCONSPORT)))
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_softCAR |= (1 << port);
|
1995-10-04 09:39:06 +03:00
|
|
|
|
|
|
|
if (userbits & TIOCFLAG_CLOCAL)
|
|
|
|
tp->t_cflag |= CLOCAL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
default:
|
|
|
|
return (ENOTTY);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmparam(tp, t)
|
|
|
|
register struct tty *tp;
|
|
|
|
register struct termios *t;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc;
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
int unit, board, port, mode, cflag = t->c_cflag;
|
1993-05-13 17:56:20 +04:00
|
|
|
int ospeed = ttspeedtab(t->c_ospeed, dcmspeedtab);
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
unit = DCMUNIT(tp->t_dev);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
dcm = sc->sc_dcm;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/* check requested parameters */
|
|
|
|
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
|
|
|
|
return (EINVAL);
|
|
|
|
/* and copy to tty */
|
|
|
|
tp->t_ispeed = t->c_ispeed;
|
|
|
|
tp->t_ospeed = t->c_ospeed;
|
|
|
|
tp->t_cflag = cflag;
|
|
|
|
if (ospeed == 0) {
|
1995-12-02 21:18:50 +03:00
|
|
|
(void) dcmmctl(DCMUNIT(tp->t_dev), MO_OFF, DMSET);
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
mode = 0;
|
|
|
|
switch (cflag&CSIZE) {
|
|
|
|
case CS5:
|
|
|
|
mode = LC_5BITS; break;
|
|
|
|
case CS6:
|
|
|
|
mode = LC_6BITS; break;
|
|
|
|
case CS7:
|
|
|
|
mode = LC_7BITS; break;
|
|
|
|
case CS8:
|
|
|
|
mode = LC_8BITS; break;
|
|
|
|
}
|
|
|
|
if (cflag&PARENB) {
|
|
|
|
if (cflag&PARODD)
|
|
|
|
mode |= LC_PODD;
|
|
|
|
else
|
|
|
|
mode |= LC_PEVEN;
|
|
|
|
}
|
|
|
|
if (cflag&CSTOPB)
|
|
|
|
mode |= LC_2STOP;
|
|
|
|
else
|
|
|
|
mode |= LC_1STOP;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_PARAM)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmparam: cflag %x mode %x speed %d uperch %d\n",
|
|
|
|
sc->sc_hd->hp_xname, port, cflag, mode, tp->t_ospeed,
|
1993-05-13 17:56:20 +04:00
|
|
|
DCM_USPERCH(tp->t_ospeed));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for transmitter buffer to empty.
|
|
|
|
*/
|
|
|
|
while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
|
|
|
|
DELAY(DCM_USPERCH(tp->t_ospeed));
|
|
|
|
/*
|
|
|
|
* Make changes known to hardware.
|
|
|
|
*/
|
|
|
|
dcm->dcm_data[port].dcm_baud = ospeed;
|
|
|
|
dcm->dcm_data[port].dcm_conf = mode;
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
|
|
|
|
dcm->dcm_cr |= (1 << port);
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
/*
|
|
|
|
* Delay for config change to take place. Weighted by baud.
|
|
|
|
* XXX why do we do this?
|
|
|
|
*/
|
|
|
|
DELAY(16 * DCM_USPERCH(tp->t_ospeed));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1993-08-29 17:46:31 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmstart(tp)
|
|
|
|
register struct tty *tp;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc;
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
struct dcmpreg *pp;
|
|
|
|
struct dcmtfifo *fifo;
|
|
|
|
char *bp;
|
|
|
|
u_int head, tail, next;
|
|
|
|
int unit, board, port, nch;
|
1993-05-13 17:56:20 +04:00
|
|
|
char buf[16];
|
|
|
|
int s;
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcmstats *dsp = &sc->sc_stats;
|
1993-05-13 17:56:20 +04:00
|
|
|
int tch = 0;
|
|
|
|
#endif
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
unit = DCMUNIT(tp->t_dev);
|
|
|
|
board = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
|
|
|
|
sc = &dcm_softc[board];
|
|
|
|
dcm = sc->sc_dcm;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
s = spltty();
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
dsp->xints++;
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_OUTPUT)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmstart: state %x flags %x outcc %d\n",
|
|
|
|
sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags,
|
1993-07-12 15:36:53 +04:00
|
|
|
tp->t_outq.c_cc);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
|
|
|
|
goto out;
|
1993-07-12 15:36:53 +04:00
|
|
|
if (tp->t_outq.c_cc <= tp->t_lowat) {
|
1993-05-13 17:56:20 +04:00
|
|
|
if (tp->t_state&TS_ASLEEP) {
|
|
|
|
tp->t_state &= ~TS_ASLEEP;
|
1993-07-12 15:36:53 +04:00
|
|
|
wakeup((caddr_t)&tp->t_outq);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1993-05-18 22:18:40 +04:00
|
|
|
selwakeup(&tp->t_wsel);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1993-07-12 15:36:53 +04:00
|
|
|
if (tp->t_outq.c_cc == 0) {
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
dsp->xempty++;
|
|
|
|
#endif
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
pp = dcm_preg(dcm, port);
|
|
|
|
tail = pp->t_tail & TX_MASK;
|
|
|
|
next = (tail + 1) & TX_MASK;
|
|
|
|
head = pp->t_head & TX_MASK;
|
|
|
|
if (head == next)
|
|
|
|
goto out;
|
|
|
|
fifo = &dcm->dcm_tfifos[3-port][tail];
|
|
|
|
again:
|
|
|
|
nch = q_to_b(&tp->t_outq, buf, (head - next) & TX_MASK);
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
tch += nch;
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_OUTPUT)
|
|
|
|
printf("\thead %x tail %x nch %d\n", head, tail, nch);
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Loop transmitting all the characters we can.
|
|
|
|
*/
|
|
|
|
for (bp = buf; --nch >= 0; bp++) {
|
|
|
|
fifo->data_char = *bp;
|
|
|
|
pp->t_tail = next;
|
|
|
|
/*
|
|
|
|
* If this is the first character,
|
|
|
|
* get the hardware moving right now.
|
|
|
|
*/
|
|
|
|
if (bp == buf) {
|
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
|
|
|
|
dcm->dcm_cr |= (1 << port);
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
}
|
|
|
|
tail = next;
|
|
|
|
fifo = tail ? fifo+1 : &dcm->dcm_tfifos[3-port][0];
|
|
|
|
next = (next + 1) & TX_MASK;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Head changed while we were loading the buffer,
|
|
|
|
* go back and load some more if we can.
|
|
|
|
*/
|
1993-07-12 15:36:53 +04:00
|
|
|
if (tp->t_outq.c_cc && head != (pp->t_head & TX_MASK)) {
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
dsp->xrestarts++;
|
|
|
|
#endif
|
|
|
|
head = pp->t_head & TX_MASK;
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kick it one last time in case it finished while we were
|
|
|
|
* loading the last bunch.
|
|
|
|
*/
|
|
|
|
if (bp > &buf[1]) {
|
|
|
|
tp->t_state |= TS_BUSY;
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
|
|
|
|
dcm->dcm_cr |= (1 << port);
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_INTR)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmstart(%d): head %x tail %x outqcc %d\n",
|
|
|
|
sc->sc_hd->hp_xname, port, head, tail, tp->t_outq.c_cc);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
out:
|
1994-05-23 09:58:16 +04:00
|
|
|
#ifdef DCMSTATS
|
1993-05-13 17:56:20 +04:00
|
|
|
dsp->xchars += tch;
|
|
|
|
if (tch <= DCMXBSIZE)
|
|
|
|
dsp->xsilo[tch]++;
|
|
|
|
else
|
|
|
|
dsp->xsilo[DCMXBSIZE+1]++;
|
|
|
|
#endif
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop output on a line.
|
|
|
|
*/
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmstop(tp, flag)
|
|
|
|
register struct tty *tp;
|
1994-05-23 09:58:16 +04:00
|
|
|
int flag;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
if (tp->t_state & TS_BUSY) {
|
|
|
|
/* XXX is there some way to safely stop transmission? */
|
|
|
|
if ((tp->t_state&TS_TTSTOP) == 0)
|
|
|
|
tp->t_state |= TS_FLUSH;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Modem control
|
|
|
|
*/
|
|
|
|
dcmmctl(dev, bits, how)
|
|
|
|
dev_t dev;
|
|
|
|
int bits, how;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc;
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
int s, unit, brd, port, hit = 0;
|
|
|
|
|
|
|
|
unit = DCMUNIT(dev);
|
|
|
|
brd = DCMBOARD(unit);
|
|
|
|
port = DCMPORT(unit);
|
|
|
|
sc = &dcm_softc[brd];
|
|
|
|
dcm = sc->sc_dcm;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_MODEM)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s port %d: dcmmctl: bits 0x%x how %x\n",
|
|
|
|
sc->sc_hd->hp_xname, port, bits, how);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
switch (how) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case DMSET:
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_modem[port]->mdmout = bits;
|
1993-05-13 17:56:20 +04:00
|
|
|
hit++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMBIS:
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_modem[port]->mdmout |= bits;
|
1993-05-13 17:56:20 +04:00
|
|
|
hit++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMBIC:
|
1995-12-02 21:18:50 +03:00
|
|
|
sc->sc_modem[port]->mdmout &= ~bits;
|
1993-05-13 17:56:20 +04:00
|
|
|
hit++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DMGET:
|
1995-12-02 21:18:50 +03:00
|
|
|
bits = sc->sc_modem[port]->mdmin;
|
|
|
|
if (sc->sc_flags & DCM_STDDCE)
|
1993-05-13 17:56:20 +04:00
|
|
|
bits = hp2dce_in(bits);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (hit) {
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_modemchng |= 1<<(unit & 3);
|
|
|
|
dcm->dcm_cr |= CR_MODM;
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
DELAY(10); /* delay until done */
|
|
|
|
(void) splx(s);
|
|
|
|
}
|
|
|
|
return (bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set board to either interrupt per-character or at a fixed interval.
|
|
|
|
*/
|
|
|
|
dcmsetischeme(brd, flags)
|
|
|
|
int brd, flags;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcm_softc *sc = &dcm_softc[brd];
|
|
|
|
struct dcmdevice *dcm = sc->sc_dcm;
|
|
|
|
struct dcmischeme *dis = &sc->sc_scheme;
|
|
|
|
int i;
|
1993-05-13 17:56:20 +04:00
|
|
|
u_char mask;
|
|
|
|
int perchar = flags & DIS_PERCHAR;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (dcmdebug & DDB_INTSCHM)
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s: dcmsetischeme(%d): cur %d, ints %d, chars %d\n",
|
|
|
|
sc->sc_hd->hp_xname, perchar, dis->dis_perchar,
|
1993-05-13 17:56:20 +04:00
|
|
|
dis->dis_intr, dis->dis_char);
|
|
|
|
if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) {
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("%s: dcmsetischeme: redundent request %d\n",
|
|
|
|
sc->sc_hd->hp_xname, perchar);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* If perchar is non-zero, we enable interrupts on all characters
|
|
|
|
* otherwise we disable perchar interrupts and use periodic
|
|
|
|
* polling interrupts.
|
|
|
|
*/
|
|
|
|
dis->dis_perchar = perchar;
|
|
|
|
mask = perchar ? 0xf : 0x0;
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
dcm->dcm_bmap[i].data_data = mask;
|
|
|
|
/*
|
|
|
|
* Don't slow down tandem mode, interrupt on flow control
|
|
|
|
* chars for any port on the board.
|
|
|
|
*/
|
|
|
|
if (!perchar) {
|
1995-12-02 21:18:50 +03:00
|
|
|
register struct tty *tp;
|
1993-05-13 17:56:20 +04:00
|
|
|
int c;
|
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
for (i = 0; i < NDCMPORT; i++) {
|
|
|
|
tp = sc->sc_tty[i];
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if ((c = tp->t_cc[VSTART]) != _POSIX_VDISABLE)
|
|
|
|
dcm->dcm_bmap[c].data_data |= (1 << i);
|
|
|
|
if ((c = tp->t_cc[VSTOP]) != _POSIX_VDISABLE)
|
|
|
|
dcm->dcm_bmap[c].data_data |= (1 << i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Board starts with timer disabled so if first call is to
|
|
|
|
* set perchar mode then we don't want to toggle the timer.
|
|
|
|
*/
|
|
|
|
if (flags == (DIS_RESET|DIS_PERCHAR))
|
|
|
|
return;
|
|
|
|
/*
|
|
|
|
* Toggle card 16.7ms interrupts (we first make sure that card
|
|
|
|
* has cleared the bit so it will see the toggle).
|
|
|
|
*/
|
|
|
|
while (dcm->dcm_cr & CR_TIMER)
|
|
|
|
;
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cr |= CR_TIMER;
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
}
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
void
|
|
|
|
dcminit(dcm, port, rate)
|
|
|
|
struct dcmdevice *dcm;
|
|
|
|
int port, rate;
|
|
|
|
{
|
|
|
|
int s, mode;
|
|
|
|
|
|
|
|
mode = LC_8BITS | LC_1STOP;
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for transmitter buffer to empty.
|
|
|
|
*/
|
|
|
|
while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
|
|
|
|
DELAY(DCM_USPERCH(rate));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make changes known to hardware.
|
|
|
|
*/
|
|
|
|
dcm->dcm_data[port].dcm_baud = ttspeedtab(rate, dcmspeedtab);
|
|
|
|
dcm->dcm_data[port].dcm_conf = mode;
|
|
|
|
SEM_LOCK(dcm);
|
|
|
|
dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
|
|
|
|
dcm->dcm_cr |= (1 << port);
|
|
|
|
SEM_UNLOCK(dcm);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delay for config change to take place. Weighted by baud.
|
|
|
|
* XXX why do we do this?
|
|
|
|
*/
|
|
|
|
DELAY(16 * DCM_USPERCH(rate));
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Following are all routines needed for DCM to act as console
|
|
|
|
*/
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
int
|
|
|
|
dcm_console_scan(scode, va, arg)
|
|
|
|
int scode;
|
|
|
|
caddr_t va;
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1996-02-24 03:54:53 +03:00
|
|
|
struct dcmdevice *dcm = (struct dcmdevice *)va;
|
|
|
|
struct consdev *cp = arg;
|
|
|
|
u_char *dioiidev;
|
1996-02-27 02:40:29 +03:00
|
|
|
int force = 0, pri;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-12-02 21:18:50 +03:00
|
|
|
switch (dcm->dcm_rsid) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case DCMID:
|
1996-02-27 02:40:29 +03:00
|
|
|
pri = CN_NORMAL;
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
case DCMID|DCMCON:
|
1996-02-27 02:40:29 +03:00
|
|
|
pri = CN_REMOTE;
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
default:
|
1996-02-24 03:54:53 +03:00
|
|
|
return (0);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
#ifdef CONSCODE
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1996-02-24 03:54:53 +03:00
|
|
|
* Raise our priority, if appropriate.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1996-02-24 03:54:53 +03:00
|
|
|
if (scode == CONSCODE) {
|
1996-02-27 02:40:29 +03:00
|
|
|
pri = CN_REMOTE;
|
1996-02-24 03:54:53 +03:00
|
|
|
force = conforced = 1;
|
|
|
|
}
|
|
|
|
#endif
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1996-03-03 19:48:52 +03:00
|
|
|
/* Only raise priority. */
|
|
|
|
if (pri > cp->cn_pri)
|
|
|
|
cp->cn_pri = pri;
|
|
|
|
|
1995-12-31 03:27:16 +03:00
|
|
|
/*
|
|
|
|
* If our priority is higher than the currently-remembered
|
1996-02-24 03:54:53 +03:00
|
|
|
* console, stash our priority, for the benefit of dcmcninit().
|
1995-12-31 03:27:16 +03:00
|
|
|
*/
|
1996-03-03 19:48:52 +03:00
|
|
|
if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) || force) {
|
|
|
|
cn_tab = cp;
|
1996-02-24 03:54:53 +03:00
|
|
|
if (scode >= 132) {
|
|
|
|
dioiidev = (u_char *)va;
|
|
|
|
return ((dioiidev[0x101] + 1) * 0x100000);
|
|
|
|
}
|
|
|
|
return (DIOCSIZE);
|
1995-12-31 03:27:16 +03:00
|
|
|
}
|
1996-02-24 03:54:53 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dcmcnprobe(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* locate the major number */
|
|
|
|
for (dcmmajor = 0; dcmmajor < nchrdev; dcmmajor++)
|
|
|
|
if (cdevsw[dcmmajor].d_open == dcmopen)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* initialize required fields */
|
|
|
|
cp->cn_dev = makedev(dcmmajor, 0); /* XXX */
|
|
|
|
cp->cn_pri = CN_DEAD;
|
|
|
|
|
|
|
|
/* Abort early if console already forced. */
|
|
|
|
if (conforced)
|
|
|
|
return;
|
|
|
|
|
|
|
|
console_scan(dcm_console_scan, cp);
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
#ifdef KGDB_CHEAT
|
1996-02-24 03:54:53 +03:00
|
|
|
/* XXX this needs to be fixed. */
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* This doesn't currently work, at least not with ite consoles;
|
|
|
|
* the console hasn't been initialized yet.
|
|
|
|
*/
|
1995-12-02 21:18:50 +03:00
|
|
|
if (major(kgdb_dev) == dcmmajor &&
|
|
|
|
DCMBOARD(DCMUNIT(kgdb_dev)) == DCMBOARD(unit)) {
|
1995-12-31 03:27:16 +03:00
|
|
|
dcminit(dcm_cn, DCMPORT(DCMUNIT(kgdb_dev)), kgdb_rate);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (kgdb_debug_init) {
|
|
|
|
/*
|
|
|
|
* We assume that console is ready for us...
|
|
|
|
* this assumes that a dca or ite console
|
|
|
|
* has been selected already and will init
|
|
|
|
* on the first putc.
|
|
|
|
*/
|
1995-12-02 21:18:50 +03:00
|
|
|
printf("dcm%d: ", DCMUNIT(kgdb_dev));
|
1993-05-13 17:56:20 +04:00
|
|
|
kgdb_connect(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
/* ARGSUSED */
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmcninit(cp)
|
|
|
|
struct consdev *cp;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
dcm_cn = (struct dcmdevice *)conaddr;
|
|
|
|
dcminit(dcm_cn, DCMCONSPORT, dcmdefaultrate);
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmconsinit = 1;
|
|
|
|
}
|
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
/* ARGSUSED */
|
1995-04-19 23:15:47 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmcngetc(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcmrfifo *fifo;
|
|
|
|
struct dcmpreg *pp;
|
|
|
|
u_int head;
|
1996-02-24 03:54:53 +03:00
|
|
|
int s, c, stat;
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
pp = dcm_preg(dcm_cn, DCMCONSPORT);
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
s = splhigh();
|
|
|
|
head = pp->r_head & RX_MASK;
|
1996-02-24 03:54:53 +03:00
|
|
|
fifo = &dcm_cn->dcm_rfifos[3-DCMCONSPORT][head>>1];
|
1993-05-13 17:56:20 +04:00
|
|
|
while (head == (pp->r_tail & RX_MASK))
|
|
|
|
;
|
|
|
|
/*
|
|
|
|
* If board interrupts are enabled, just let our received char
|
|
|
|
* interrupt through in case some other port on the board was
|
|
|
|
* busy. Otherwise we must clear the interrupt.
|
|
|
|
*/
|
1995-12-31 03:27:16 +03:00
|
|
|
SEM_LOCK(dcm_cn);
|
|
|
|
if ((dcm_cn->dcm_ic & IC_IE) == 0)
|
|
|
|
stat = dcm_cn->dcm_iir;
|
|
|
|
SEM_UNLOCK(dcm_cn);
|
1993-05-13 17:56:20 +04:00
|
|
|
c = fifo->data_char;
|
|
|
|
stat = fifo->data_stat;
|
|
|
|
pp->r_head = (head + 2) & RX_MASK;
|
|
|
|
splx(s);
|
|
|
|
return (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Console kernel output character routine.
|
|
|
|
*/
|
1996-02-24 03:54:53 +03:00
|
|
|
/* ARGSUSED */
|
1995-04-10 05:01:40 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmcnputc(dev, c)
|
|
|
|
dev_t dev;
|
|
|
|
int c;
|
|
|
|
{
|
1995-12-02 21:18:50 +03:00
|
|
|
struct dcmpreg *pp;
|
1993-05-13 17:56:20 +04:00
|
|
|
unsigned tail;
|
1996-02-24 03:54:53 +03:00
|
|
|
int s, unit, stat;
|
1995-12-31 03:27:16 +03:00
|
|
|
|
1996-02-24 03:54:53 +03:00
|
|
|
pp = dcm_preg(dcm_cn, DCMCONSPORT);
|
1995-12-02 21:18:50 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
s = splhigh();
|
|
|
|
#ifdef KGDB
|
|
|
|
if (dev != kgdb_dev)
|
|
|
|
#endif
|
|
|
|
if (dcmconsinit == 0) {
|
1996-02-24 03:54:53 +03:00
|
|
|
dcminit(dcm_cn, DCMCONSPORT, dcmdefaultrate);
|
1993-05-13 17:56:20 +04:00
|
|
|
dcmconsinit = 1;
|
|
|
|
}
|
|
|
|
tail = pp->t_tail & TX_MASK;
|
|
|
|
while (tail != (pp->t_head & TX_MASK))
|
|
|
|
;
|
1996-02-24 03:54:53 +03:00
|
|
|
dcm_cn->dcm_tfifos[3-DCMCONSPORT][tail].data_char = c;
|
1993-05-13 17:56:20 +04:00
|
|
|
pp->t_tail = tail = (tail + 1) & TX_MASK;
|
1995-12-31 03:27:16 +03:00
|
|
|
SEM_LOCK(dcm_cn);
|
1996-02-24 03:54:53 +03:00
|
|
|
dcm_cn->dcm_cmdtab[DCMCONSPORT].dcm_data |= CT_TX;
|
|
|
|
dcm_cn->dcm_cr |= (1 << DCMCONSPORT);
|
1995-12-31 03:27:16 +03:00
|
|
|
SEM_UNLOCK(dcm_cn);
|
1993-05-13 17:56:20 +04:00
|
|
|
while (tail != (pp->t_head & TX_MASK))
|
|
|
|
;
|
|
|
|
/*
|
|
|
|
* If board interrupts are enabled, just let our completion
|
|
|
|
* interrupt through in case some other port on the board
|
|
|
|
* was busy. Otherwise we must clear the interrupt.
|
|
|
|
*/
|
1995-12-31 03:27:16 +03:00
|
|
|
if ((dcm_cn->dcm_ic & IC_IE) == 0) {
|
|
|
|
SEM_LOCK(dcm_cn);
|
|
|
|
stat = dcm_cn->dcm_iir;
|
|
|
|
SEM_UNLOCK(dcm_cn);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
1995-12-31 03:27:16 +03:00
|
|
|
#endif /* NDCM > 0 */
|