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