zs.c revision 1.49 1 /* $NetBSD: zs.c,v 1.49 1997/10/05 20:59:02 gwr Exp $ */
2
3 /*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gordon W. Ross.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Zilog Z8530 Dual UART driver (machine-dependent part)
41 *
42 * Runs two serial lines per chip using slave drivers.
43 * Plain tty/async lines use the zs_async slave.
44 * Sun keyboard/mouse uses the zs_kbd/zs_ms slaves.
45 */
46
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/conf.h>
50 #include <sys/device.h>
51 #include <sys/file.h>
52 #include <sys/ioctl.h>
53 #include <sys/kernel.h>
54 #include <sys/proc.h>
55 #include <sys/tty.h>
56 #include <sys/time.h>
57 #include <sys/syslog.h>
58
59 #include <machine/autoconf.h>
60 #include <machine/cpu.h>
61 #include <machine/obio.h>
62 #include <machine/machdep.h>
63 #include <machine/mon.h>
64 #include <machine/z8530var.h>
65
66 #include <dev/cons.h>
67 #include <dev/ic/z8530reg.h>
68
69 #include <sun3/dev/zs_cons.h>
70 #include "kbd.h"
71
72 extern void Debugger __P((void));
73
74 /*
75 * XXX: Hard code this to make console init easier...
76 */
77 #define NZSC 2 /* XXX */
78
79 /*
80 * Some warts needed by z8530tty.c -
81 * The default parity REALLY needs to be the same as the PROM uses,
82 * or you can not see messages done with printf during boot-up...
83 */
84 int zs_def_cflag = (CREAD | CS8 | HUPCL);
85 int zs_major = 12;
86
87 /*
88 * The Sun3 provides a 4.9152 MHz clock to the ZS chips.
89 */
90 #define PCLK (9600 * 512) /* PCLK pin input clock rate */
91
92 /*
93 * Define interrupt levels.
94 */
95 #define ZSHARD_PRI 6 /* Wired on the CPU board... */
96 #define ZSSOFT_PRI 3 /* Want tty pri (4) but this is OK. */
97
98 #define ZS_DELAY() delay(2)
99
100 /* The layout of this is hardware-dependent (padding, order). */
101 struct zschan {
102 volatile u_char zc_csr; /* ctrl,status, and indirect access */
103 u_char zc_xxx0;
104 volatile u_char zc_data; /* data */
105 u_char zc_xxx1;
106 };
107 struct zsdevice {
108 /* Yes, they are backwards. */
109 struct zschan zs_chan_b;
110 struct zschan zs_chan_a;
111 };
112
113
114 /* Default OBIO addresses. */
115 static int zs_physaddr[NZSC] = {
116 OBIO_ZS_KBD_MS,
117 OBIO_ZS_TTY_AB };
118
119 /* Saved PROM mappings */
120 static struct zsdevice *zsaddr[NZSC]; /* See zs_init() */
121
122 /* Flags from cninit() */
123 static int zs_hwflags[NZSC][2];
124
125 /* Default speed for each channel */
126 static int zs_defspeed[NZSC][2] = {
127 { 1200, /* keyboard */
128 1200 }, /* mouse */
129 { 9600, /* ttya */
130 9600 }, /* ttyb */
131 };
132
133 static u_char zs_init_reg[16] = {
134 0, /* 0: CMD (reset, etc.) */
135 0, /* 1: No interrupts yet. */
136 0x18 + ZSHARD_PRI, /* IVECT */
137 ZSWR3_RX_8 | ZSWR3_RX_ENABLE,
138 ZSWR4_CLK_X16 | ZSWR4_ONESB | ZSWR4_EVENP,
139 ZSWR5_TX_8 | ZSWR5_TX_ENABLE,
140 0, /* 6: TXSYNC/SYNCLO */
141 0, /* 7: RXSYNC/SYNCHI */
142 0, /* 8: alias for data port */
143 ZSWR9_MASTER_IE,
144 0, /*10: Misc. TX/RX control bits */
145 ZSWR11_TXCLK_BAUD | ZSWR11_RXCLK_BAUD,
146 14, /*12: BAUDLO (default=9600) */
147 0, /*13: BAUDHI (default=9600) */
148 ZSWR14_BAUD_ENA | ZSWR14_BAUD_FROM_PCLK,
149 ZSWR15_BREAK_IE | ZSWR15_DCD_IE,
150 };
151
152
153 /* Find PROM mappings (for console support). */
154 void
155 zs_init()
156 {
157 int i;
158
159 for (i = 0; i < NZSC; i++) {
160 zsaddr[i] = (struct zsdevice *)
161 obio_find_mapping(zs_physaddr[i], sizeof(struct zschan));
162 }
163 }
164
165 struct zschan *
166 zs_get_chan_addr(zsc_unit, channel)
167 int zsc_unit, channel;
168 {
169 struct zsdevice *addr;
170 struct zschan *zc;
171
172 if (zsc_unit >= NZSC)
173 return NULL;
174 addr = zsaddr[zsc_unit];
175 if (addr == NULL)
176 return NULL;
177 if (channel == 0) {
178 zc = &addr->zs_chan_a;
179 } else {
180 zc = &addr->zs_chan_b;
181 }
182 return (zc);
183 }
184
185
186 /****************************************************************
187 * Autoconfig
188 ****************************************************************/
189
190 /* Definition of the driver for autoconfig. */
191 static int zsc_match __P((struct device *, struct cfdata *, void *));
192 static void zsc_attach __P((struct device *, struct device *, void *));
193 static int zsc_print __P((void *, const char *name));
194
195 struct cfattach zsc_ca = {
196 sizeof(struct zsc_softc), zsc_match, zsc_attach
197 };
198
199 struct cfdriver zsc_cd = {
200 NULL, "zsc", DV_DULL
201 };
202
203 static int zshard __P((void *));
204 static int zssoft __P((void *));
205 static int zs_get_speed __P((struct zs_chanstate *));
206
207
208 /*
209 * Is the zs chip present?
210 */
211 static int
212 zsc_match(parent, cf, aux)
213 struct device *parent;
214 struct cfdata *cf;
215 void *aux;
216 {
217 struct confargs *ca = aux;
218 int unit;
219 void *va;
220
221 /* We have arrays sized with NZSC so validate. */
222 unit = cf->cf_unit;
223 if (unit < 0 || unit >= NZSC)
224 return (0);
225
226 /*
227 * This driver only supports its wired-in mappings,
228 * because the console support depends on those.
229 */
230 if (ca->ca_paddr != zs_physaddr[unit])
231 return (0);
232
233 /* Make sure zs_init() found mappings. */
234 va = zsaddr[unit];
235 if (va == NULL)
236 return (0);
237
238 /* This returns -1 on a fault (bus error). */
239 if (peek_byte(va) == -1)
240 return (0);
241
242 /* Default interrupt priority (always splbio==2) */
243 if (ca->ca_intpri == -1)
244 ca->ca_intpri = ZSHARD_PRI;
245
246 return (1);
247 }
248
249 /*
250 * Attach a found zs.
251 *
252 * Match slave number to zs unit number, so that misconfiguration will
253 * not set up the keyboard as ttya, etc.
254 */
255 static void
256 zsc_attach(parent, self, aux)
257 struct device *parent;
258 struct device *self;
259 void *aux;
260 {
261 struct zsc_softc *zsc = (void *) self;
262 struct confargs *ca = aux;
263 struct zsc_attach_args zsc_args;
264 volatile struct zschan *zc;
265 struct zs_chanstate *cs;
266 int s, zsc_unit, channel;
267
268 zsc_unit = zsc->zsc_dev.dv_unit;
269
270 printf(": (softpri %d)\n", ZSSOFT_PRI);
271
272 /* Use the mapping setup by the Sun PROM. */
273 if (zsaddr[zsc_unit] == NULL)
274 panic("zs_attach: zs%d not mapped\n", zsc_unit);
275
276 /*
277 * Initialize software state for each channel.
278 */
279 for (channel = 0; channel < 2; channel++) {
280 zsc_args.channel = channel;
281 zsc_args.hwflags = zs_hwflags[zsc_unit][channel];
282 cs = &zsc->zsc_cs_store[channel];
283 zsc->zsc_cs[channel] = cs;
284
285 cs->cs_channel = channel;
286 cs->cs_private = NULL;
287 cs->cs_ops = &zsops_null;
288 cs->cs_brg_clk = PCLK / 16;
289
290 zc = zs_get_chan_addr(zsc_unit, channel);
291 cs->cs_reg_csr = &zc->zc_csr;
292 cs->cs_reg_data = &zc->zc_data;
293
294 bcopy(zs_init_reg, cs->cs_creg, 16);
295 bcopy(zs_init_reg, cs->cs_preg, 16);
296
297 /* XXX: Get these from the EEPROM instead? */
298 /* XXX: See the mvme167 code. Better. */
299 if (zsc_args.hwflags & ZS_HWFLAG_CONSOLE)
300 cs->cs_defspeed = zs_get_speed(cs);
301 else
302 cs->cs_defspeed = zs_defspeed[zsc_unit][channel];
303 cs->cs_defcflag = zs_def_cflag;
304
305 /* Make these correspond to cs_defcflag (-crtscts) */
306 cs->cs_rr0_dcd = ZSRR0_DCD;
307 cs->cs_rr0_cts = 0;
308 cs->cs_wr5_dtr = ZSWR5_DTR | ZSWR5_RTS;
309 cs->cs_wr5_rts = 0;
310
311 /*
312 * Clear the master interrupt enable.
313 * The INTENA is common to both channels,
314 * so just do it on the A channel.
315 */
316 if (channel == 0) {
317 zs_write_reg(cs, 9, 0);
318 }
319
320 /*
321 * Look for a child driver for this channel.
322 * The child attach will setup the hardware.
323 */
324 if (!config_found(self, (void *)&zsc_args, zsc_print)) {
325 /* No sub-driver. Just reset it. */
326 u_char reset = (channel == 0) ?
327 ZSWR9_A_RESET : ZSWR9_B_RESET;
328 s = splhigh();
329 zs_write_reg(cs, 9, reset);
330 splx(s);
331 }
332 }
333
334 /*
335 * Now safe to install interrupt handlers. Note the arguments
336 * to the interrupt handlers aren't used. Note, we only do this
337 * once since both SCCs interrupt at the same level and vector.
338 */
339 if (zsc_unit == 0) {
340 isr_add_autovect(zssoft, NULL, ZSSOFT_PRI);
341 isr_add_autovect(zshard, NULL, ca->ca_intpri);
342 }
343
344 /*
345 * Set the master interrupt enable and interrupt vector.
346 * (common to both channels, do it on A)
347 */
348 cs = zsc->zsc_cs[0];
349 s = splhigh();
350 /* interrupt vector */
351 zs_write_reg(cs, 2, zs_init_reg[2]);
352 /* master interrupt control (enable) */
353 zs_write_reg(cs, 9, zs_init_reg[9]);
354 splx(s);
355
356 /*
357 * XXX: L1A hack - We would like to be able to break into
358 * the debugger during the rest of autoconfiguration, so
359 * lower interrupts just enough to let zs interrupts in.
360 * This is done after both zsc devices are attached.
361 */
362 if (zsc_unit == 1) {
363 printf("zsc1: enabling zs interrupts\n");
364 (void)spl5(); /* splzs - 1 */
365 }
366 }
367
368 static int
369 zsc_print(aux, name)
370 void *aux;
371 const char *name;
372 {
373 struct zsc_attach_args *args = aux;
374
375 if (name != NULL)
376 printf("%s: ", name);
377
378 if (args->channel != -1)
379 printf(" channel %d", args->channel);
380
381 return UNCONF;
382 }
383
384 static volatile int zssoftpending;
385
386 /*
387 * Our ZS chips all share a common, autovectored interrupt,
388 * so we have to look at all of them on each interrupt.
389 */
390 static int
391 zshard(arg)
392 void *arg;
393 {
394 register struct zsc_softc *zsc;
395 register int unit, rval, softreq;
396
397 rval = softreq = 0;
398 for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
399 zsc = zsc_cd.cd_devs[unit];
400 if (zsc == NULL)
401 continue;
402 rval |= zsc_intr_hard(zsc);
403 softreq |= zsc->zsc_cs[0]->cs_softreq;
404 softreq |= zsc->zsc_cs[1]->cs_softreq;
405 }
406
407 /* We are at splzs here, so no need to lock. */
408 if (softreq && (zssoftpending == 0)) {
409 zssoftpending = ZSSOFT_PRI;
410 isr_soft_request(ZSSOFT_PRI);
411 }
412 return (rval);
413 }
414
415 /*
416 * Similar scheme as for zshard (look at all of them)
417 */
418 static int
419 zssoft(arg)
420 void *arg;
421 {
422 register struct zsc_softc *zsc;
423 register int s, unit;
424
425 /* This is not the only ISR on this IPL. */
426 if (zssoftpending == 0)
427 return (0);
428
429 /*
430 * The soft intr. bit will be set by zshard only if
431 * the variable zssoftpending is zero. The order of
432 * these next two statements prevents our clearing
433 * the soft intr bit just after zshard has set it.
434 */
435 isr_soft_clear(ZSSOFT_PRI);
436 zssoftpending = 0;
437
438 /* Make sure we call the tty layer at spltty. */
439 s = spltty();
440 for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
441 zsc = zsc_cd.cd_devs[unit];
442 if (zsc == NULL)
443 continue;
444 (void) zsc_intr_soft(zsc);
445 }
446 splx(s);
447 return (1);
448 }
449
450
451 /*
452 * Compute the current baud rate given a ZSCC channel.
453 */
454 static int
455 zs_get_speed(cs)
456 struct zs_chanstate *cs;
457 {
458 int tconst;
459
460 tconst = zs_read_reg(cs, 12);
461 tconst |= zs_read_reg(cs, 13) << 8;
462 return (TCONST_TO_BPS(cs->cs_brg_clk, tconst));
463 }
464
465 /*
466 * MD functions for setting the baud rate and control modes.
467 */
468 int
469 zs_set_speed(cs, bps)
470 struct zs_chanstate *cs;
471 int bps; /* bits per second */
472 {
473 int tconst, real_bps;
474
475 if (bps == 0)
476 return (0);
477
478 #ifdef DIAGNOSTIC
479 if (cs->cs_brg_clk == 0)
480 panic("zs_set_speed");
481 #endif
482
483 tconst = BPS_TO_TCONST(cs->cs_brg_clk, bps);
484 if (tconst < 0)
485 return (EINVAL);
486
487 /* Convert back to make sure we can do it. */
488 real_bps = TCONST_TO_BPS(cs->cs_brg_clk, tconst);
489
490 /* XXX - Allow some tolerance here? */
491 if (real_bps != bps)
492 return (EINVAL);
493
494 cs->cs_preg[12] = tconst;
495 cs->cs_preg[13] = tconst >> 8;
496
497 /* Caller will stuff the pending registers. */
498 return (0);
499 }
500
501 int
502 zs_set_modes(cs, cflag)
503 struct zs_chanstate *cs;
504 int cflag; /* bits per second */
505 {
506 int s;
507
508 /*
509 * Output hardware flow control on the chip is horrendous:
510 * if carrier detect drops, the receiver is disabled, and if
511 * CTS drops, the transmitter is stoped IN MID CHARACTER!
512 * Therefore, NEVER set the HFC bit, and instead use the
513 * status interrupt to detect CTS changes.
514 */
515 s = splzs();
516 #if 0 /* XXX - See below. */
517 if (cflag & CLOCAL) {
518 cs->cs_rr0_dcd = 0;
519 cs->cs_preg[15] &= ~ZSWR15_DCD_IE;
520 } else {
521 /* XXX - Need to notice DCD change here... */
522 cs->cs_rr0_dcd = ZSRR0_DCD;
523 cs->cs_preg[15] |= ZSWR15_DCD_IE;
524 }
525 #endif /* XXX */
526 if (cflag & CRTSCTS) {
527 cs->cs_wr5_dtr = ZSWR5_DTR;
528 cs->cs_wr5_rts = ZSWR5_RTS;
529 cs->cs_rr0_cts = ZSRR0_CTS;
530 cs->cs_preg[15] |= ZSWR15_CTS_IE;
531 } else {
532 cs->cs_wr5_dtr = ZSWR5_DTR | ZSWR5_RTS;
533 cs->cs_wr5_rts = 0;
534 cs->cs_rr0_cts = 0;
535 cs->cs_preg[15] &= ~ZSWR15_CTS_IE;
536 }
537 splx(s);
538
539 /* Caller will stuff the pending registers. */
540 return (0);
541 }
542
543
544 /*
545 * Read or write the chip with suitable delays.
546 */
547
548 u_char
549 zs_read_reg(cs, reg)
550 struct zs_chanstate *cs;
551 u_char reg;
552 {
553 u_char val;
554
555 *cs->cs_reg_csr = reg;
556 ZS_DELAY();
557 val = *cs->cs_reg_csr;
558 ZS_DELAY();
559 return val;
560 }
561
562 void
563 zs_write_reg(cs, reg, val)
564 struct zs_chanstate *cs;
565 u_char reg, val;
566 {
567 *cs->cs_reg_csr = reg;
568 ZS_DELAY();
569 *cs->cs_reg_csr = val;
570 ZS_DELAY();
571 }
572
573 u_char zs_read_csr(cs)
574 struct zs_chanstate *cs;
575 {
576 register u_char val;
577
578 val = *cs->cs_reg_csr;
579 ZS_DELAY();
580 return val;
581 }
582
583 void zs_write_csr(cs, val)
584 struct zs_chanstate *cs;
585 u_char val;
586 {
587 *cs->cs_reg_csr = val;
588 ZS_DELAY();
589 }
590
591 u_char zs_read_data(cs)
592 struct zs_chanstate *cs;
593 {
594 register u_char val;
595
596 val = *cs->cs_reg_data;
597 ZS_DELAY();
598 return val;
599 }
600
601 void zs_write_data(cs, val)
602 struct zs_chanstate *cs;
603 u_char val;
604 {
605 *cs->cs_reg_data = val;
606 ZS_DELAY();
607 }
608
609 /****************************************************************
610 * Console support functions (Sun3 specific!)
611 * Note: this code is allowed to know about the layout of
612 * the chip registers, and uses that to keep things simple.
613 * XXX - I think I like the mvme167 code better. -gwr
614 ****************************************************************/
615
616 void *zs_conschan;
617
618 /*
619 * Handle user request to enter kernel debugger.
620 */
621 void
622 zs_abort(cs)
623 struct zs_chanstate *cs;
624 {
625 register volatile struct zschan *zc = zs_conschan;
626 int rr0;
627
628 /* Wait for end of break to avoid PROM abort. */
629 /* XXX - Limit the wait? */
630 do {
631 rr0 = zc->zc_csr;
632 ZS_DELAY();
633 } while (rr0 & ZSRR0_BREAK);
634
635 /* XXX - Always available, but may be the PROM monitor. */
636 Debugger();
637 }
638
639 /*
640 * Polled input char.
641 */
642 int
643 zs_getc(arg)
644 void *arg;
645 {
646 register volatile struct zschan *zc = arg;
647 register int s, c, rr0;
648
649 s = splhigh();
650 /* Wait for a character to arrive. */
651 do {
652 rr0 = zc->zc_csr;
653 ZS_DELAY();
654 } while ((rr0 & ZSRR0_RX_READY) == 0);
655
656 c = zc->zc_data;
657 ZS_DELAY();
658 splx(s);
659
660 /*
661 * This is used by the kd driver to read scan codes,
662 * so don't translate '\r' ==> '\n' here...
663 */
664 return (c);
665 }
666
667 /*
668 * Polled output char.
669 */
670 void
671 zs_putc(arg, c)
672 void *arg;
673 int c;
674 {
675 register volatile struct zschan *zc = arg;
676 register int s, rr0;
677
678 s = splhigh();
679 /* Wait for transmitter to become ready. */
680 do {
681 rr0 = zc->zc_csr;
682 ZS_DELAY();
683 } while ((rr0 & ZSRR0_TX_READY) == 0);
684
685 zc->zc_data = c;
686 ZS_DELAY();
687 splx(s);
688 }
689
690 extern struct consdev consdev_kd; /* keyboard/display */
691 extern struct consdev consdev_tty;
692 extern struct consdev *cn_tab; /* physical console device info */
693
694 static struct {
695 int zsc_unit, channel;
696 } zstty_conf[NZSC*2] = {
697 /* XXX: knowledge from the config file here... */
698 { 1, 0 }, /* ttya */
699 { 1, 1 }, /* ttyb */
700 { 0, 0 }, /* ttyc */
701 { 0, 1 }, /* ttyd */
702 };
703
704 static char *prom_inSrc_name[] = {
705 "keyboard/display",
706 "ttya", "ttyb",
707 "ttyc", "ttyd" };
708
709 /*
710 * This function replaces sys/dev/cninit.c
711 * Determine which device is the console using
712 * the PROM "input source" and "output sink".
713 */
714 void
715 cninit()
716 {
717 MachMonRomVector *v;
718 struct zschan *zc;
719 struct consdev *cn;
720 int channel, zsc_unit, zstty_unit;
721 u_char inSource;
722
723 v = romVectorPtr;
724 inSource = *(v->inSource);
725
726 if (inSource != *(v->outSink)) {
727 mon_printf("cninit: mismatched PROM output selector\n");
728 }
729
730 switch (inSource) {
731
732 default:
733 mon_printf("cninit: invalid inSource=%d\n", inSource);
734 sunmon_abort();
735 inSource = 0;
736 /* fall through */
737
738 case 0: /* keyboard/display */
739 #if NKBD > 0
740 zsc_unit = 0;
741 channel = 0;
742 cn = &consdev_kd;
743 /* Set cn_dev, cn_pri in kd.c */
744 break;
745 #else /* NKBD */
746 mon_printf("cninit: kdb/display not configured\n");
747 sunmon_abort();
748 inSource = 1;
749 /* fall through */
750 #endif /* NKBD */
751
752 case 1: /* ttya */
753 case 2: /* ttyb */
754 case 3: /* ttyc (rewired keyboard connector) */
755 case 4: /* ttyd (rewired mouse connector) */
756 zstty_unit = inSource - 1;
757 zsc_unit = zstty_conf[zstty_unit].zsc_unit;
758 channel = zstty_conf[zstty_unit].channel;
759 cn = &consdev_tty;
760 cn->cn_dev = makedev(zs_major, zstty_unit);
761 cn->cn_pri = CN_REMOTE;
762 break;
763
764 }
765 /* Now that inSource has been validated, print it. */
766 mon_printf("console is %s\n", prom_inSrc_name[inSource]);
767
768 zc = zs_get_chan_addr(zsc_unit, channel);
769 if (zc == NULL) {
770 mon_printf("cninit: zs not mapped.\n");
771 return;
772 }
773 zs_conschan = zc;
774 zs_hwflags[zsc_unit][channel] = ZS_HWFLAG_CONSOLE;
775 cn_tab = cn;
776 (*cn->cn_init)(cn);
777 #ifdef KGDB
778 zs_kgdb_init();
779 #endif
780 }
781
782
783 static void zscn_nop __P((struct consdev *));
784 static int zscngetc __P((dev_t));
785 static void zscnputc __P((dev_t, int));
786
787 struct consdev consdev_tty = {
788 zscn_nop,
789 zscn_nop,
790 zscngetc,
791 zscnputc,
792 nullcnpollc,
793 };
794
795 static void
796 zscn_nop(cn)
797 struct consdev *cn;
798 {
799 }
800
801 /*
802 * Polled console input putchar.
803 */
804 static int
805 zscngetc(dev)
806 dev_t dev;
807 {
808 register int c;
809
810 c = zs_getc(zs_conschan);
811 return (c);
812 }
813
814 /*
815 * Polled console output putchar.
816 */
817 static void
818 zscnputc(dev, c)
819 dev_t dev;
820 int c;
821 {
822
823 zs_putc(zs_conschan, c);
824 }
825
826