示例#1
0
int
ucomclose(dev_t dev, int flag, int mode, struct proc *p)
{
	struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
	struct tty *tp = sc->sc_tty;
	int s;

	if (!ISSET(tp->t_state, TS_ISOPEN))
		return (0);

	DPRINTF(("ucomclose: unit=%d\n", UCOMUNIT(dev)));
	ucom_lock(sc);

	(*LINESW(tp, l_close))(tp, flag);
	s = spltty();
	CLR(tp->t_state, TS_BUSY | TS_FLUSH);
	sc->sc_cua = 0;
	ttyclose(tp);
	ucom_cleanup(sc);
	splx(s);

	if (sc->sc_methods->ucom_close != NULL)
		sc->sc_methods->ucom_close(sc->sc_parent, sc->sc_portno);

	ucom_unlock(sc);

	return (0);
}
int
at91usart_close(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct at91usart_softc *sc = device_lookup_private(&at91usart_cd, COMUNIT(dev));
	struct tty *tp = sc->sc_tty;

	/* XXX This is for cons.c. */
	if (!ISSET(tp->t_state, TS_ISOPEN))
		return (0);

	(*tp->t_linesw->l_close)(tp, flag);
	ttyclose(tp);

	if (COM_ISALIVE(sc) == 0)
		return (0);

	if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
		/*
		 * Although we got a last close, the device may still be in
		 * use; e.g. if this was the dialout node, and there are still
		 * processes waiting for carrier on the non-dialout node.
		 */
		at91usart_shutdown(sc);
	}

	return (0);
}
示例#3
0
static int
dcons_detach(int port)
{
	struct	tty *tp;
	struct dcons_softc *dc;

	dc = &sc[port];

	tp = dc->dev->si_tty;

	if (tp->t_state & TS_ISOPEN) {
		printf("dcons: still opened\n");
		(*linesw[tp->t_line].l_close)(tp, 0);
		tp->t_gen++;
		ttyclose(tp);
		ttwakeup(tp);
		ttwwakeup(tp);
	}
	/* XXX
	 * must wait until all device are closed.
	 */
	tsleep((void *)dc, PWAIT, "dcodtc", hz/4);
	destroy_dev(dc->dev);

	return(0);
}
示例#4
0
int
imxuartclose(dev_t dev, int flag, int mode, struct proc *p)
{
	int unit = DEVUNIT(dev);
	struct imxuart_softc *sc = imxuart_cd.cd_devs[unit];
	bus_space_tag_t iot = sc->sc_iot;
	bus_space_handle_t ioh = sc->sc_ioh;
	struct tty *tp = sc->sc_tty;
	int s;

	/* XXX This is for cons.c. */
	if (!ISSET(tp->t_state, TS_ISOPEN))
		return 0;

	(*linesw[tp->t_line].l_close)(tp, flag, p);
	s = spltty();
	if (ISSET(tp->t_state, TS_WOPEN)) {
		/* tty device is waiting for carrier; drop dtr then re-raise */
		CLR(sc->sc_ucr3, IMXUART_CR3_DSR);
		bus_space_write_2(iot, ioh, IMXUART_UCR3, sc->sc_ucr3);
		timeout_add(&sc->sc_dtr_tmo, hz * 2);
	} else {
		/* no one else waiting; turn off the uart */
		imxuart_pwroff(sc);
	}
	CLR(tp->t_state, TS_BUSY | TS_FLUSH);

	sc->sc_cua = 0;
	splx(s);
	ttyclose(tp);

	return 0;
}
示例#5
0
/*
 * close routine. returns zero if successful, else error code
 */
int
mttyclose(dev_t dev, int flag, int mode, struct proc *p)
{
    struct mtty_softc *ms = mtty_cd.cd_devs[MAGMA_CARD(dev)];
    struct mtty_port *mp = &ms->ms_port[MAGMA_PORT(dev)];
    struct tty *tp = mp->mp_tty;
    int s;

    (*linesw[tp->t_line].l_close)(tp, flag, p);
    s = spltty();

    /* if HUPCL is set, and the tty is no longer open
     * shut down the port
     */
    if (ISSET(tp->t_cflag, HUPCL) || !ISSET(tp->t_state, TS_ISOPEN)) {
        /* XXX wait until FIFO is empty before turning off the channel
        	struct cd1400 *cd = mp->mp_cd1400;
        */

        /* drop DTR and RTS */
        (void)mtty_modem_control(mp, 0, DMSET);

        /* turn off the channel
        CD1400_WRITE_REG(cd, CD1400_CAR, mp->mp_channel);
        cd1400_write_ccr(cd, CD1400_CCR_CMDRESET);
        */
    }

    splx(s);
    ttyclose(tp);

    return (0);
}
示例#6
0
/*
 * Close a zs serial port.
 */
int
zsclose(dev_t dev, int flags, int mode, struct lwp *l)
{
	struct zs_chanstate *cs;
	struct tty *tp;
	struct zs_softc *sc;
	int unit = ZS_UNIT(dev);

	sc = device_lookup_private(&zs_cd, unit >> 1);
	cs = sc->sc_cs[unit & 1];
	tp = cs->cs_ttyp;

	tp->t_linesw->l_close(tp, flags);
	ttyclose(tp);

	if ((tp->t_state & TS_ISOPEN) == 0 && tp->t_wopen == 0) {
		/*
		 * Although we got a last close, the device may still be in
		 * use; e.g. if this was the dialout node, and there are still
		 * processes waiting for carrier on the non-dialout node.
		 */
		zs_shutdown(cs);
	}
	return 0;
}
示例#7
0
int
clmpccclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct clmpcc_softc	*sc =
		device_lookup_private(&clmpcc_cd, CLMPCCUNIT(dev));
	struct clmpcc_chan	*ch = &sc->sc_chans[CLMPCCCHAN(dev)];
	struct tty		*tp = ch->ch_tty;
	int s;

	if ( ISCLR(tp->t_state, TS_ISOPEN) )
		return 0;

	(*tp->t_linesw->l_close)(tp, flag);

	s = spltty();

	if ( ISCLR(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0 ) {
		/*
		 * Although we got a last close, the device may still be in
		 * use; e.g. if this was the dialout node, and there are still
		 * processes waiting for carrier on the non-dialout node.
		 */
		clmpcc_shutdown(ch);
	}

	ttyclose(tp);

	splx(s);

	return 0;
}
示例#8
0
文件: com.c 项目: lacombar/netbsd-alc
int
comclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct com_softc *sc = device_lookup_private(&xcom_cd, COMUNIT(dev));
	struct tty *tp = sc->sc_tty;
	int iobase = sc->sc_iobase;
	int s;

	/* XXX This is for cons.c. */
	if (!ISSET(tp->t_state, TS_ISOPEN))
		return 0;

	(*tp->t_linesw->l_close)(tp, flag);
	s = spltty();
	CLR(sc->sc_lcr, LCR_SBREAK);
	outb(pio(iobase , com_lcr), sc->sc_lcr);
	outb(pio(iobase , com_ier), 0);
	if (ISSET(tp->t_cflag, HUPCL) &&
	    !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) {
		/* XXX perhaps only clear DTR */
		outb(pio(iobase , com_mcr), 0);
	}
	CLR(tp->t_state, TS_BUSY | TS_FLUSH);
	if (--comsopen == 0)
		callout_stop(&com_poll_ch);
	splx(s);
	ttyclose(tp);
#ifdef notyet /* XXXX */
	if (unit != comconsole) {
		ttyfree(tp);
		sc->sc_tty = 0;
	}
#endif
	return 0;
}
示例#9
0
/*
 * Close a zs serial port.
 */
int
zsclose(dev_t dev, int flags, int mode, struct proc *p)
{
	struct zstty_softc *zst = zs_device_lookup(&zstty_cd, ZSUNIT(dev));
	struct zs_chanstate *cs = zst->zst_cs;
	struct tty *tp = zst->zst_tty;
	int s;

	/* XXX This is for cons.c. */
	if (!ISSET(tp->t_state, TS_ISOPEN))
		return 0;

	(*linesw[tp->t_line].l_close)(tp, flags, p);

	s = spltty();
	cs->cs_cua = 0;
	ttyclose(tp);
	splx(s);

	if (!ISSET(tp->t_state, TS_ISOPEN)) {
		/*
		 * Although we got a last close, the device may still be in
		 * use; e.g. if this was the dialout node, and there are still
		 * processes waiting for carrier on the non-dialout node.
		 */
		zs_shutdown(zst);
	}

	return (0);
}
示例#10
0
/*ARGSUSED*/
int
qvclose(dev_t dev, int flag, int mode, struct proc *p)
{
	register struct tty *tp;
	register unit;
	register struct qvdevice *qvaddr;
	int error;

	unit = minor(dev);
	tp = &qv_tty[unit];

	/*
	 * If this is the keyboard unit (0) shutdown the
	 * interface.
	 */
	qvaddr = (struct qvdevice *)tp->t_addr;
	if (QVCHAN(unit) == QVKEYBOARD )
		qvaddr->qv_csr &= ~QV_INT_ENABLE;

	/*
	 * If unit is not the mouse channel call the line disc.
	 * otherwise clear the state flag, and put the keyboard into down/up.
	 */
	if (QVCHAN(unit) != QVMOUSECHAN) {
		(*tp->t_linesw->l_close)(tp, flag);
		error = ttyclose(tp);
	} else {
		mouseon = 0;
		qv_init( qvaddr );
		error = 0;
	}
	tp->t_state = 0;
	return (error);
}
示例#11
0
int hypcnclose(int dev, int flag)
{
	struct tty	*tp = &hypcn_tty;
	spl_t s = spltty();
	simple_lock(&tp->t_lock);
	ttyclose(tp);
	simple_unlock(&tp->t_lock);
	splx(s);
	return 0;
}
示例#12
0
int
uart_close(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct uart_softc *sc = device_lookup_private(&uart_cd, minor(dev));
	struct tty *tp = sc->sc_tty;

	(*tp->t_linesw->l_close)(tp, flag);
	ttyclose(tp);
	return (0);
}
示例#13
0
int
biconsdevclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct tty *tp = &biconsdev_tty[0];

	(*tp->t_linesw->l_close)(tp, flag);
	ttyclose(tp);

	return (0);
}
int
arcbios_ttyclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	int unit = minor(dev);
	struct tty *tp = arcbios_tty[unit];

	callout_stop(&arcbios_tty_ch);
	(*tp->t_linesw->l_close)(tp, flag);
	ttyclose(tp);
	return (0);
}
示例#15
0
int 
kmclose(__unused dev_t dev, __unused int flag, __unused int mode,
	__unused struct proc *p)
{
	 
	struct tty *tp;

	tp = &cons;
	(*linesw[tp->t_line].l_close)(tp,flag);
	ttyclose(tp);
	return (0);
}
示例#16
0
int 
pconsclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct pconssoftc *sc = device_lookup_private(&pcons_cd, minor(dev));
	struct tty *tp = sc->of_tty;

	callout_stop(&sc->sc_poll_ch);
	sc->of_flags &= ~OFPOLL;
	(*tp->t_linesw->l_close)(tp, flag);
	ttyclose(tp);
	return 0;
}
示例#17
0
文件: km.c 项目: DINKIN/xnu
int kmclose(dev_t dev, int flag, __unused int mode, __unused proc_t p)
{
    int ret;
    struct tty *tp = km_tty[minor(dev)];

    tty_lock(tp);
    ret = (*linesw[tp->t_line].l_close) (tp, flag);
    ttyclose(tp);
    tty_unlock(tp);

    return (ret);
}
示例#18
0
int
ptsclose(dev_t dev, int flag, int mode, struct proc *p)
{
	struct pt_softc *pti = pt_softc[minor(dev)];
	struct tty *tp = pti->pt_tty;
	int error;

	error = (*linesw[tp->t_line].l_close)(tp, flag);
	error |= ttyclose(tp);
	ptcwakeup(tp, FREAD|FWRITE);
	return (error);
}
示例#19
0
文件: ite.c 项目: lacombar/netbsd-alc
int
iteclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct tty *tp;

	tp = getitesp(dev)->tp;

	KDASSERT(tp);
	tp->t_linesw->l_close(tp, flag);
	ttyclose(tp);
	ite_off(dev, 0);
	return (0);
}
示例#20
0
/*ARGSUSED*/
int
dlclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct dl_softc *sc = device_lookup_private(&dl_cd, minor(dev));
	struct tty *tp = sc->sc_tty;

	(*tp->t_linesw->l_close)(tp, flag);

	/* Make sure a BREAK state is not left enabled. */
	dlbrk(sc, 0);

	return (ttyclose(tp));
}
示例#21
0
文件: zs.c 项目: MarginC/kame
static int
zsttyclose(dev_t dev, int flags, int mode, struct thread *td)
{
	struct tty *tp;

	tp = dev->si_tty;

	if ((tp->t_state & TS_ISOPEN) == 0)
		return (0);

	(*linesw[tp->t_line].l_close)(tp, flags);
	ttyclose(tp);

	return (0);
}
示例#22
0
int
xencons_close(dev_t dev, int flag, int mode, struct lwp *l)
{
    struct xencons_softc *sc = device_lookup_private(&xencons_cd,
                               XENCONS_UNIT(dev));
    struct tty *tp = sc->sc_tty;

    if (tp == NULL)
        return (0);
    (*tp->t_linesw->l_close)(tp, flag);
    ttyclose(tp);
#ifdef notyet /* XXX */
    tty_free(tp);
#endif
    return (0);
}
示例#23
0
文件: com.c 项目: SylvestreG/bitrig
int
comclose(dev_t dev, int flag, int mode, struct proc *p)
{
	int unit = DEVUNIT(dev);
	struct com_softc *sc = com_cd.cd_devs[unit];
	bus_space_tag_t iot = sc->sc_iot;
	bus_space_handle_t ioh = sc->sc_ioh;
	struct tty *tp = sc->sc_tty;
	int s;

#ifdef COM_CONSOLE
	/* XXX This is for cons.c. */
	if (!ISSET(tp->t_state, TS_ISOPEN))
		return 0;
#endif

	if(sc->sc_swflags & COM_SW_DEAD)
		return 0;

	(*linesw[tp->t_line].l_close)(tp, flag, p);
	s = spltty();
	if (ISSET(tp->t_state, TS_WOPEN)) {
		/* tty device is waiting for carrier; drop dtr then re-raise */
		CLR(sc->sc_mcr, MCR_DTR | MCR_RTS);
		bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr);
		timeout_add_sec(&sc->sc_dtr_tmo, 2);
	} else {
		/* no one else waiting; turn off the uart */
		compwroff(sc);
	}
	CLR(tp->t_state, TS_BUSY | TS_FLUSH);
	sc->sc_cua = 0;
	splx(s);
	ttyclose(tp);

#ifdef COM_CONSOLE
#ifdef notyet /* XXXX */
	if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
		ttyfree(tp);
		sc->sc_tty = 0;
	}
#endif
#endif
	return 0;
}
示例#24
0
int
vconsclose(dev_t dev, int flag, int mode, struct proc *p)
{
	struct vcons_softc *sc;
	struct tty *tp;
	int unit = minor(dev);

	if (unit > vcons_cd.cd_ndevs)
		return (ENXIO);
	sc = vcons_cd.cd_devs[unit];
	if (sc == NULL)
		return (ENXIO);

	tp = sc->sc_tty;
	(*linesw[tp->t_line].l_close)(tp, flag, p);
	ttyclose(tp);
	return (0);
}
示例#25
0
int
dartclose(dev_t dev, int flag, int mode, struct proc *p)
{
	struct tty *tp;
	struct dart_info *dart;
	struct dartsoftc *sc;
	int port;

	sc = (struct dartsoftc *)dart_cd.cd_devs[0];
	port = DART_PORT(dev);
	dart = &sc->sc_dart[port];

	tp = dart->tty;
	(*linesw[tp->t_line].l_close)(tp, flag);
	ttyclose(tp);

	return (0);
}
示例#26
0
static int
ofw_dev_close(dev_t dev, int flag, int mode, struct thread *td)
{
	int	unit;
	struct	tty *tp;

	unit = minor(dev);
	tp = ofw_tp;

	if (unit != 0) {
		return (ENXIO);
	}

	(*linesw[tp->t_line].l_close)(tp, flag);
	ttyclose(tp);

	return (0);
}
示例#27
0
static int
dcons_close(dev_t dev, int flag, int mode, struct THREAD *td)
{
	int	unit;
	struct	tty *tp;

	unit = minor(dev);
	if (unit != 0)
		return (ENXIO);

	tp = dev->si_tty;
	if (tp->t_state & TS_ISOPEN) {
		(*linesw[tp->t_line].l_close)(tp, flag);
		ttyclose(tp);
	}

	return (0);
}
示例#28
0
static int
ucomclose(dev_t dev, int flag, int mode, usb_proc_ptr p)
{
	struct ucom_softc *sc;
	struct tty *tp;
	int s;

	USB_GET_SC(ucom, UCOMUNIT(dev), sc);

	tp = sc->sc_tty;

	DPRINTF(("%s: ucomclose: unit = %d\n",
		USBDEVNAME(sc->sc_dev), UCOMUNIT(dev)));

	if (!ISSET(tp->t_state, TS_ISOPEN))
		goto quit;

	s = spltty();
	(*linesw[tp->t_line].l_close)(tp, flag);
	disc_optim(tp, &tp->t_termios, sc);
	ttyclose(tp);
	splx(s);

	if (sc->sc_dying)
		goto quit;

	if (!ISSET(tp->t_state, TS_ISOPEN)) {
		/*
		 * Although we got a last close, the device may still be in
		 * use; e.g. if this was the dialout node, and there are still
		 * processes waiting for carrier on the non-dialout node.
		 */
		ucom_cleanup(sc);
	}

	if (sc->sc_callback->ucom_close != NULL)
		sc->sc_callback->ucom_close(sc->sc_parent, sc->sc_portno);

    quit:
	if (--sc->sc_refcnt < 0)
		usb_detach_wakeup(USBDEV(sc->sc_dev));

	return (0);
}
示例#29
0
static int
nmdmclose(struct dev_close_args *ap)
{
	cdev_t dev = ap->a_head.a_dev;
	struct tty *tp, *tp2;
	int err;
	struct softpart *ourpart, *otherpart;

	/*
	 * let the other end know that the game is up
	 */
	tp = dev->si_tty;
	lwkt_gettoken(&tp->t_token);
	GETPARTS(tp, ourpart, otherpart);
	tp2 = &otherpart->nm_tty;
	lwkt_gettoken(&tp2->t_token);
	(void)(*linesw[tp2->t_line].l_modem)(tp2, 0);

	/*
	 * XXX MDMBUF makes no sense for nmdms but would inhibit the above
	 * l_modem().  CLOCAL makes sense but isn't supported.   Special
	 * l_modem()s that ignore carrier drop make no sense for nmdms but
	 * may be in use because other parts of the line discipline make
	 * sense for nmdms.  Recover by doing everything that a normal
	 * ttymodem() would have done except for sending a SIGHUP.
	 */
	if (tp2->t_state & TS_ISOPEN) {
		tp2->t_state &= ~(TS_CARR_ON | TS_CONNECTED);
		tp2->t_state |= TS_ZOMBIE;
		ttyflush(tp2, FREAD | FWRITE);
	}

	err = (*linesw[tp->t_line].l_close)(tp, ap->a_fflag);
	ourpart->modemsignals &= ~TIOCM_DTR;
	nmdm_crossover(dev->si_drv1, ourpart, otherpart);
	nmdmstop(tp, FREAD|FWRITE);
	ttyclose(tp);
	lwkt_reltoken(&tp2->t_token);
	lwkt_reltoken(&tp->t_token);

	return (err);
}
示例#30
0
文件: ucom.c 项目: ryoon/netbsd-xhci
int
ucomclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev));
	struct tty *tp;
	int s;

	DPRINTF(("ucomclose: unit=%d\n", UCOMUNIT(dev)));

	if (sc == NULL)
		return 0;

	tp = sc->sc_tty;

	if (!ISSET(tp->t_state, TS_ISOPEN))
		return (0);

	s = spltty();
	sc->sc_refcnt++;

	(*tp->t_linesw->l_close)(tp, flag);
	ttyclose(tp);

	if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
		/*
		 * Although we got a last close, the device may still be in
		 * use; e.g. if this was the dialout node, and there are still
		 * processes waiting for carrier on the non-dialout node.
		 */
		ucom_cleanup(sc);
	}

	if (sc->sc_methods->ucom_close != NULL)
		sc->sc_methods->ucom_close(sc->sc_parent, sc->sc_portno);

	if (--sc->sc_refcnt < 0)
		usb_detach_wakeupold(sc->sc_dev);
	splx(s);

	return (0);
}