Home | History | Annotate | Line # | Download | only in ibus
dz_ibus.c revision 1.5
      1  1.5        ad /*	$NetBSD: dz_ibus.c,v 1.5 2007/10/09 16:53:00 ad Exp $	*/
      2  1.2        ad 
      3  1.2        ad /*-
      4  1.2        ad  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
      5  1.2        ad  * All rights reserved.
      6  1.2        ad  *
      7  1.2        ad  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2        ad  * by Andrew Doran.
      9  1.2        ad  *
     10  1.2        ad  * Redistribution and use in source and binary forms, with or without
     11  1.2        ad  * modification, are permitted provided that the following conditions
     12  1.2        ad  * are met:
     13  1.2        ad  * 1. Redistributions of source code must retain the above copyright
     14  1.2        ad  *    notice, this list of conditions and the following disclaimer.
     15  1.2        ad  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2        ad  *    notice, this list of conditions and the following disclaimer in the
     17  1.2        ad  *    documentation and/or other materials provided with the distribution.
     18  1.2        ad  * 3. All advertising materials mentioning features or use of this software
     19  1.2        ad  *    must display the following acknowledgement:
     20  1.2        ad  *        This product includes software developed by the NetBSD
     21  1.2        ad  *        Foundation, Inc. and its contributors.
     22  1.2        ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2        ad  *    contributors may be used to endorse or promote products derived
     24  1.2        ad  *    from this software without specific prior written permission.
     25  1.2        ad  *
     26  1.2        ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2        ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.2        ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2        ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2        ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.2        ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.2        ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.2        ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2        ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2        ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2        ad  * POSSIBILITY OF SUCH DAMAGE.
     37  1.2        ad  */
     38  1.2        ad 
     39  1.2        ad /*
     40  1.2        ad  * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
     41  1.2        ad  * All rights reserved.
     42  1.2        ad  *
     43  1.2        ad  * Redistribution and use in source and binary forms, with or without
     44  1.2        ad  * modification, are permitted provided that the following conditions
     45  1.2        ad  * are met:
     46  1.2        ad  * 1. Redistributions of source code must retain the above copyright
     47  1.2        ad  *    notice, this list of conditions and the following disclaimer.
     48  1.2        ad  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.2        ad  *    notice, this list of conditions and the following disclaimer in the
     50  1.2        ad  *    documentation and/or other materials provided with the distribution.
     51  1.2        ad  * 3. All advertising materials mentioning features or use of this software
     52  1.2        ad  *    must display the following acknowledgement:
     53  1.2        ad  *	This product includes software developed at Ludd, University of
     54  1.2        ad  *	Lule}, Sweden and its contributors.
     55  1.2        ad  * 4. The name of the author may not be used to endorse or promote products
     56  1.2        ad  *    derived from this software without specific prior written permission
     57  1.2        ad  *
     58  1.2        ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     59  1.2        ad  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     60  1.2        ad  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     61  1.2        ad  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     62  1.2        ad  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     63  1.2        ad  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     64  1.2        ad  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     65  1.2        ad  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     66  1.2        ad  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     67  1.2        ad  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     68  1.2        ad  */
     69  1.2        ad 
     70  1.2        ad #include <sys/cdefs.h>
     71  1.5        ad __KERNEL_RCSID(0, "$NetBSD: dz_ibus.c,v 1.5 2007/10/09 16:53:00 ad Exp $");
     72  1.2        ad 
     73  1.2        ad #include "dzkbd.h"
     74  1.2        ad #include "dzms.h"
     75  1.2        ad 
     76  1.2        ad #include <sys/param.h>
     77  1.2        ad #include <sys/proc.h>
     78  1.2        ad #include <sys/systm.h>
     79  1.2        ad #include <sys/ioctl.h>
     80  1.2        ad #include <sys/tty.h>
     81  1.2        ad #include <sys/file.h>
     82  1.2        ad #include <sys/conf.h>
     83  1.2        ad #include <sys/device.h>
     84  1.2        ad #include <sys/reboot.h>
     85  1.2        ad 
     86  1.2        ad #include <machine/bus.h>
     87  1.2        ad 
     88  1.2        ad #include <dev/cons.h>
     89  1.2        ad 
     90  1.2        ad #include <dev/tc/tcvar.h>		/* tc_addr_t */
     91  1.2        ad 
     92  1.2        ad #include <dev/dec/dzreg.h>
     93  1.2        ad #include <dev/dec/dzvar.h>
     94  1.2        ad #include <dev/dec/dzkbdvar.h>
     95  1.2        ad 
     96  1.2        ad #include <pmax/ibus/ibusvar.h>
     97  1.2        ad #include <pmax/pmax/pmaxtype.h>
     98  1.2        ad #include <pmax/pmax/cons.h>
     99  1.2        ad 
    100  1.2        ad #define	DZ_LINE_KBD	0
    101  1.2        ad #define	DZ_LINE_MOUSE	1
    102  1.2        ad #define	DZ_LINE_CONSOLE	2
    103  1.2        ad #define	DZ_LINE_AUX	3
    104  1.2        ad 
    105  1.2        ad int	dz_ibus_match(struct device *, struct cfdata *, void *);
    106  1.2        ad void	dz_ibus_attach(struct device *, struct device *, void *);
    107  1.2        ad int	dz_ibus_intr(void *);
    108  1.2        ad void	dz_ibus_cnsetup(paddr_t);
    109  1.2        ad int	dz_ibus_cngetc(dev_t);
    110  1.2        ad void	dz_ibus_cnputc(dev_t, int);
    111  1.2        ad void	dz_ibus_cnpollc(dev_t, int);
    112  1.2        ad int	dz_ibus_getmajor(void);
    113  1.2        ad int	dz_ibus_print(void *, const char *);
    114  1.2        ad 
    115  1.2        ad int	dzgetc(struct dz_linestate *);
    116  1.2        ad void	dzputc(struct dz_linestate *, int);
    117  1.2        ad 
    118  1.2        ad CFATTACH_DECL(dz_ibus, sizeof(struct dz_softc),
    119  1.2        ad     dz_ibus_match, dz_ibus_attach, NULL, NULL);
    120  1.2        ad 
    121  1.2        ad struct consdev dz_ibus_consdev = {
    122  1.2        ad 	NULL, NULL, dz_ibus_cngetc, dz_ibus_cnputc,
    123  1.2        ad 	dz_ibus_cnpollc, NULL, NULL, NULL, NODEV, CN_NORMAL,
    124  1.2        ad };
    125  1.2        ad 
    126  1.2        ad struct dzregs {
    127  1.2        ad 	uint16_t	csr;	/* 00 Csr: control/status */
    128  1.2        ad 	uint16_t	p0[3];
    129  1.2        ad 
    130  1.2        ad 	uint16_t	rbuf;	/* 08 Rbuf/Lpr: receive buffer/line param  */
    131  1.2        ad 	uint16_t	p1[3];
    132  1.2        ad 
    133  1.2        ad 	uint16_t	tcr;	/* 10 Tcr: transmit console */
    134  1.2        ad 	uint16_t	p2[3];
    135  1.2        ad 
    136  1.2        ad 	uint16_t	tdr;	/* 18 Msr/Tdr: modem status reg/xmit data */
    137  1.2        ad 	uint16_t	p3[3];
    138  1.2        ad } volatile *dzcn;
    139  1.2        ad 
    140  1.2        ad int	dz_ibus_iscn;
    141  1.2        ad int	dz_ibus_consln = -1;
    142  1.2        ad 
    143  1.2        ad int
    144  1.2        ad dz_ibus_match(struct device *parent, struct cfdata *cf, void *aux)
    145  1.2        ad {
    146  1.2        ad 	struct ibus_attach_args *iba;
    147  1.2        ad 
    148  1.2        ad 	iba = aux;
    149  1.2        ad 
    150  1.2        ad 	if (strcmp(iba->ia_name, "dc") != 0 &&
    151  1.2        ad 	    strcmp(iba->ia_name, "mdc") != 0 &&
    152  1.2        ad 	    strcmp(iba->ia_name, "dc7085") != 0)
    153  1.2        ad 		return (0);
    154  1.2        ad 
    155  1.4  christos 	if (badaddr((void *)iba->ia_addr, 2))
    156  1.2        ad 		return (0);
    157  1.2        ad 
    158  1.2        ad 	return (1);
    159  1.2        ad }
    160  1.2        ad 
    161  1.2        ad void
    162  1.2        ad dz_ibus_attach(struct device *parent, struct device *self, void *aux)
    163  1.2        ad {
    164  1.2        ad 	struct ibus_attach_args *iba;
    165  1.2        ad 	struct dz_softc *sc;
    166  1.2        ad 	volatile struct dzregs *dz;
    167  1.2        ad 	struct dzkm_attach_args daa;
    168  1.2        ad 	int i;
    169  1.2        ad 
    170  1.2        ad 	iba = aux;
    171  1.2        ad 	sc = (struct dz_softc *)self;
    172  1.2        ad 
    173  1.2        ad 	DELAY(100000);
    174  1.2        ad 
    175  1.2        ad 	/*
    176  1.2        ad 	 * XXX - This is evil and ugly, but... due to the nature of how
    177  1.2        ad 	 * bus_space_* works on pmax it will do for the time being.
    178  1.2        ad 	 */
    179  1.2        ad 	sc->sc_ioh = (bus_space_handle_t)MIPS_PHYS_TO_KSEG1(iba->ia_addr);
    180  1.2        ad 
    181  1.2        ad 	sc->sc_dr.dr_csr = 0;
    182  1.2        ad 	sc->sc_dr.dr_rbuf = 8;
    183  1.2        ad 	sc->sc_dr.dr_dtr = 17;
    184  1.2        ad 	sc->sc_dr.dr_break = 25;
    185  1.2        ad 	sc->sc_dr.dr_tbuf = 24;
    186  1.2        ad 	sc->sc_dr.dr_tcr = 16;
    187  1.2        ad 	sc->sc_dr.dr_dcd = 25;
    188  1.2        ad 	sc->sc_dr.dr_ring = 24;
    189  1.2        ad 
    190  1.2        ad 	sc->sc_dr.dr_firstreg = 0;
    191  1.2        ad 	sc->sc_dr.dr_winsize = sizeof(struct dzregs);
    192  1.2        ad 
    193  1.2        ad 	sc->sc_type = DZ_DZV;
    194  1.2        ad 
    195  1.2        ad 	dz = (volatile struct dzregs *)sc->sc_ioh;
    196  1.2        ad 	i = dz->tcr;
    197  1.2        ad 	dz->csr = DZ_CSR_MSE | DZ_CSR_TXIE;
    198  1.2        ad 	dz->tcr = 0;
    199  1.2        ad 	wbflush();
    200  1.2        ad 	DELAY(1000);
    201  1.2        ad 	dz->tcr = 1;
    202  1.2        ad 	wbflush();
    203  1.2        ad 	DELAY(100000);
    204  1.2        ad 	dz->tcr = i;
    205  1.2        ad 	wbflush();
    206  1.2        ad 
    207  1.2        ad 	sc->sc_dsr = 0x0f; /* XXX check if VS has modem ctrl bits */
    208  1.2        ad 
    209  1.2        ad 	printf(": DC-7085, 4 lines");
    210  1.2        ad 	ibus_intr_establish(parent, (void *)iba->ia_cookie, IPL_TTY,
    211  1.2        ad 	    dz_ibus_intr, sc);
    212  1.2        ad 	dzattach(sc, NULL, dz_ibus_consln);
    213  1.2        ad 	DELAY(10000);
    214  1.2        ad 
    215  1.2        ad 	if (systype == DS_PMAX || systype == DS_3MAX) {
    216  1.2        ad #if NDZKBD > 0
    217  1.2        ad 		if (!dz_ibus_iscn)
    218  1.2        ad 			dz->rbuf = DZ_LPR_RX_ENABLE | (DZ_LPR_B4800 << 8) |
    219  1.2        ad 			    DZ_LPR_8_BIT_CHAR | DZ_LINE_KBD;
    220  1.2        ad 		daa.daa_line = DZ_LINE_KBD;
    221  1.2        ad 		daa.daa_flags = (dz_ibus_iscn ? 0 : DZKBD_CONSOLE);
    222  1.2        ad 		config_found(self, &daa, dz_ibus_print);
    223  1.2        ad #endif
    224  1.2        ad #if NDZMS > 0
    225  1.2        ad 		dz->rbuf = DZ_LPR_RX_ENABLE | (DZ_LPR_B4800 << 8) |
    226  1.2        ad 		    DZ_LPR_8_BIT_CHAR | DZ_LPR_PARENB | DZ_LPR_OPAR |
    227  1.2        ad 		    DZ_LINE_MOUSE;
    228  1.2        ad 		daa.daa_line = DZ_LINE_MOUSE;
    229  1.2        ad 		daa.daa_flags = 0;
    230  1.2        ad 		config_found(self, &daa, dz_ibus_print);
    231  1.2        ad #endif
    232  1.2        ad 	}
    233  1.2        ad }
    234  1.2        ad 
    235  1.2        ad int
    236  1.2        ad dz_ibus_getmajor(void)
    237  1.2        ad {
    238  1.2        ad 	extern const struct cdevsw dz_cdevsw;
    239  1.2        ad 	static int cache = -1;
    240  1.2        ad 
    241  1.2        ad 	if (cache != -1)
    242  1.2        ad 		return (cache);
    243  1.2        ad 
    244  1.2        ad 	return (cache = cdevsw_lookup_major(&dz_cdevsw));
    245  1.2        ad }
    246  1.2        ad 
    247  1.2        ad int
    248  1.2        ad dz_ibus_intr(void *cookie)
    249  1.2        ad {
    250  1.2        ad 	struct dz_softc *sc;
    251  1.2        ad 	volatile struct dzregs *dzr;
    252  1.2        ad 	unsigned csr;
    253  1.2        ad 
    254  1.2        ad 	sc = cookie;
    255  1.2        ad 	dzr = (volatile struct dzregs *)sc->sc_ioh;
    256  1.2        ad 
    257  1.2        ad 	while (((csr = dzr->csr) & (DZ_CSR_RX_DONE | DZ_CSR_TX_READY)) != 0) {
    258  1.2        ad 		if ((csr & DZ_CSR_RX_DONE) != 0)
    259  1.2        ad 			dzrint(sc);
    260  1.2        ad 		if ((csr & DZ_CSR_TX_READY) != 0)
    261  1.2        ad 			dzxint(sc);
    262  1.2        ad 	}
    263  1.2        ad 
    264  1.2        ad 	return (0);
    265  1.2        ad }
    266  1.2        ad 
    267  1.2        ad void
    268  1.2        ad dz_ibus_cnsetup(paddr_t addr)
    269  1.2        ad {
    270  1.2        ad 
    271  1.2        ad 	dzcn = (void *)MIPS_PHYS_TO_KSEG1(addr);
    272  1.2        ad }
    273  1.2        ad 
    274  1.2        ad void
    275  1.2        ad dz_ibus_cnattach(int line)
    276  1.2        ad {
    277  1.2        ad 
    278  1.2        ad 	switch (line) {
    279  1.2        ad 	case 0:
    280  1.2        ad 		line = DZ_LINE_KBD;
    281  1.2        ad 		break;
    282  1.2        ad 	case 4:
    283  1.2        ad 		line = DZ_LINE_CONSOLE;
    284  1.2        ad 		break;
    285  1.2        ad 	default:
    286  1.2        ad 		line = DZ_LINE_AUX;
    287  1.2        ad 		break;
    288  1.2        ad 	}
    289  1.2        ad 
    290  1.2        ad 	dz_ibus_iscn = 1;
    291  1.2        ad 	dz_ibus_consln = line;
    292  1.2        ad 
    293  1.2        ad 	/* Disable scanning until init is done. */
    294  1.2        ad 	dzcn->csr = 0;
    295  1.2        ad 	wbflush();
    296  1.5        ad 	DELAY(1000);
    297  1.2        ad 
    298  1.2        ad 	/* Turn on transmitter for the console. */
    299  1.2        ad 	dzcn->tcr = (1 << line);
    300  1.2        ad 	wbflush();
    301  1.5        ad 	DELAY(1000);
    302  1.2        ad 
    303  1.2        ad 	/* Turn scanning back on. */
    304  1.2        ad 	dzcn->csr = 0x20;
    305  1.2        ad 	wbflush();
    306  1.5        ad 	DELAY(1000);
    307  1.2        ad 
    308  1.2        ad 	/*
    309  1.2        ad 	 * Point the console at the DZ-11.
    310  1.2        ad 	 */
    311  1.2        ad 	cn_tab = &dz_ibus_consdev;
    312  1.2        ad 	cn_tab->cn_pri = CN_REMOTE;
    313  1.2        ad 	cn_tab->cn_dev = makedev(dz_ibus_getmajor(), line);
    314  1.2        ad }
    315  1.2        ad 
    316  1.2        ad int
    317  1.2        ad dz_ibus_cngetc(dev_t dev)
    318  1.2        ad {
    319  1.2        ad 	int c, line, s;
    320  1.2        ad 	uint16_t rbuf;
    321  1.2        ad 
    322  1.2        ad 	c = 0;
    323  1.2        ad 	line = minor(dev);
    324  1.2        ad 	s = spltty();
    325  1.2        ad 
    326  1.2        ad 	do {
    327  1.2        ad 		while ((dzcn->csr & DZ_CSR_RX_DONE) == 0)
    328  1.2        ad 			DELAY(10);
    329  1.5        ad 		DELAY(10);
    330  1.2        ad 		rbuf = dzcn->rbuf;
    331  1.2        ad 		if (((rbuf >> 8) & 3) != line)
    332  1.2        ad 			continue;
    333  1.2        ad 		c = rbuf & 0x7f;
    334  1.2        ad 	} while (c == 17 || c == 19);		/* ignore XON/XOFF */
    335  1.2        ad 
    336  1.2        ad 	splx(s);
    337  1.2        ad 	if (c == 13)
    338  1.2        ad 		c = 10;
    339  1.2        ad 	return (c);
    340  1.2        ad }
    341  1.2        ad 
    342  1.2        ad void
    343  1.2        ad dz_ibus_cnputc(dev_t dev, int ch)
    344  1.2        ad {
    345  1.2        ad 	int timeout, s;
    346  1.2        ad 	uint16_t tcr;
    347  1.2        ad 
    348  1.2        ad 	s = spltty();
    349  1.2        ad 
    350  1.2        ad 	/* Don't hang the machine! */
    351  1.2        ad 	timeout = 1 << 15;
    352  1.2        ad 
    353  1.2        ad 	/* Remember which lines to scan */
    354  1.2        ad 	tcr = dzcn->tcr;
    355  1.2        ad 	dzcn->tcr = (1 << minor(dev));
    356  1.2        ad 	wbflush();
    357  1.5        ad 	DELAY(10);
    358  1.2        ad 
    359  1.2        ad 	/* Wait until ready */
    360  1.2        ad 	while ((dzcn->csr & 0x8000) == 0)
    361  1.2        ad 		if (--timeout < 0)
    362  1.2        ad 			break;
    363  1.5        ad 	DELAY(10);
    364  1.2        ad 
    365  1.2        ad 	/* Put the character */
    366  1.2        ad 	dzcn->tdr = ch;
    367  1.2        ad 	timeout = 1 << 15;
    368  1.2        ad 	wbflush();
    369  1.5        ad 	DELAY(10);
    370  1.2        ad 
    371  1.2        ad 	/* Wait until ready */
    372  1.2        ad 	while ((dzcn->csr & 0x8000) == 0)
    373  1.2        ad 		if (--timeout < 0)
    374  1.2        ad 			break;
    375  1.2        ad 
    376  1.5        ad 	DELAY(10);
    377  1.2        ad 	dzcn->tcr = tcr;
    378  1.2        ad 	wbflush();
    379  1.5        ad 	DELAY(10);
    380  1.2        ad 	splx(s);
    381  1.2        ad }
    382  1.2        ad 
    383  1.2        ad void
    384  1.2        ad dz_ibus_cnpollc(dev_t dev, int pollflag)
    385  1.2        ad {
    386  1.2        ad 
    387  1.2        ad }
    388  1.2        ad 
    389  1.2        ad #if NDZKBD > 0 || NDZMS > 0
    390  1.2        ad int
    391  1.2        ad dz_ibus_print(void *aux, const char *pnp)
    392  1.2        ad {
    393  1.2        ad 	struct dzkm_attach_args *daa;
    394  1.2        ad 
    395  1.2        ad 	daa = aux;
    396  1.2        ad 	if (pnp != NULL)
    397  1.2        ad 		printf("lkkbd/vsms at %s", pnp);
    398  1.2        ad 	printf(" line %d", daa->daa_line);
    399  1.2        ad 	return (UNCONF);
    400  1.2        ad }
    401  1.2        ad 
    402  1.2        ad int
    403  1.2        ad dzgetc(struct dz_linestate *ls)
    404  1.2        ad {
    405  1.2        ad 	volatile struct dzregs *dzr;
    406  1.2        ad 	int line, s;
    407  1.2        ad 	uint16_t rbuf;
    408  1.2        ad 
    409  1.2        ad 	if (ls == NULL) {
    410  1.2        ad 		/*
    411  1.2        ad 		 * dzkbd is the only thing that should put us here.
    412  1.2        ad 		 */
    413  1.2        ad 		line = DZ_LINE_KBD;
    414  1.2        ad 		dzr = dzcn;
    415  1.2        ad 	} else {
    416  1.2        ad 		line = ls->dz_line;
    417  1.2        ad 		dzr = (volatile struct dzregs *)ls->dz_sc->sc_ioh;
    418  1.2        ad 	}
    419  1.2        ad 
    420  1.2        ad 	s = spltty();
    421  1.2        ad 	for (;;) {
    422  1.2        ad 		while ((dzr->csr & DZ_CSR_RX_DONE) == 0)
    423  1.2        ad 			DELAY(10);
    424  1.5        ad 		DELAY(10);
    425  1.2        ad 		rbuf = dzr->rbuf;
    426  1.5        ad 		DELAY(10);
    427  1.2        ad 		if (((rbuf >> 8) & 3) == line)
    428  1.2        ad 			return (rbuf & 0xff);
    429  1.2        ad 	}
    430  1.2        ad 	splx(s);
    431  1.2        ad }
    432  1.2        ad 
    433  1.2        ad void
    434  1.2        ad dzputc(struct dz_linestate *ls, int ch)
    435  1.2        ad {
    436  1.2        ad 	volatile struct dzregs *dzr;
    437  1.2        ad 	int line;
    438  1.2        ad 	uint16_t tcr;
    439  1.2        ad 	int s;
    440  1.2        ad 
    441  1.2        ad 	/*
    442  1.2        ad 	 * If the dz has already been attached, the MI driver will do the
    443  1.2        ad 	 * transmitting:
    444  1.2        ad 	 */
    445  1.2        ad 	if (ls != NULL && ls->dz_sc != NULL) {
    446  1.2        ad 		line = ls->dz_line;
    447  1.2        ad 		dzr = (volatile struct dzregs *)ls->dz_sc->sc_ioh;
    448  1.2        ad 		s = spltty();
    449  1.2        ad 		putc(ch, &ls->dz_tty->t_outq);
    450  1.2        ad 		tcr = dzr->tcr;
    451  1.2        ad 		if ((tcr & (1 << line)) == 0) {
    452  1.2        ad 			dzr->tcr = tcr | (1 << line);
    453  1.2        ad 			wbflush();
    454  1.5        ad 			DELAY(10);
    455  1.2        ad 		}
    456  1.2        ad 		dzxint(ls->dz_sc);
    457  1.2        ad 		splx(s);
    458  1.2        ad 		return;
    459  1.2        ad 	}
    460  1.2        ad 
    461  1.2        ad 	/* Use dzcnputc to do the transmitting. */
    462  1.2        ad 	dz_ibus_cnputc(makedev(dz_ibus_getmajor(), DZ_LINE_KBD), ch);
    463  1.2        ad }
    464  1.2        ad #endif /* NDZKBD > 0 || NDZMS > 0 */
    465