1 /* $OpenBSD: scif.c,v 1.15 2011/04/30 16:08:44 miod Exp $ */ 2 /* $NetBSD: scif.c,v 1.47 2006/07/23 22:06:06 ad Exp $ */ 3 4 /*- 5 * Copyright (C) 1999 T.Horiuchi and SAITOH Masanobu. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 /*- 31 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. 32 * All rights reserved. 33 * 34 * This code is derived from software contributed to The NetBSD Foundation 35 * by Charles M. Hannum. 36 * 37 * Redistribution and use in source and binary forms, with or without 38 * modification, are permitted provided that the following conditions 39 * are met: 40 * 1. Redistributions of source code must retain the above copyright 41 * notice, this list of conditions and the following disclaimer. 42 * 2. Redistributions in binary form must reproduce the above copyright 43 * notice, this list of conditions and the following disclaimer in the 44 * documentation and/or other materials provided with the distribution. 45 * 46 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 47 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 48 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 49 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 50 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 51 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 52 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 53 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 54 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 55 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 56 * POSSIBILITY OF SUCH DAMAGE. 57 */ 58 59 /* 60 * Copyright (c) 1991 The Regents of the University of California. 61 * All rights reserved. 62 * 63 * Redistribution and use in source and binary forms, with or without 64 * modification, are permitted provided that the following conditions 65 * are met: 66 * 1. Redistributions of source code must retain the above copyright 67 * notice, this list of conditions and the following disclaimer. 68 * 2. Redistributions in binary form must reproduce the above copyright 69 * notice, this list of conditions and the following disclaimer in the 70 * documentation and/or other materials provided with the distribution. 71 * 3. Neither the name of the University nor the names of its contributors 72 * may be used to endorse or promote products derived from this software 73 * without specific prior written permission. 74 * 75 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 76 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 77 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 78 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 79 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 80 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 81 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 82 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 83 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 84 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 85 * SUCH DAMAGE. 86 * 87 * @(#)com.c 7.5 (Berkeley) 5/16/91 88 */ 89 90 /* 91 * SH internal serial driver 92 * 93 * This code is derived from both z8530tty.c and com.c 94 */ 95 96 #include <sys/param.h> 97 #include <sys/systm.h> 98 #include <sys/tty.h> 99 #include <sys/proc.h> 100 #include <sys/conf.h> 101 #include <sys/file.h> 102 #include <sys/syslog.h> 103 #include <sys/kernel.h> 104 #include <sys/device.h> 105 #include <sys/malloc.h> 106 #include <sys/timeout.h> 107 108 #include <dev/cons.h> 109 110 #include <sh/clock.h> 111 #include <sh/trap.h> 112 #include <machine/intr.h> 113 #include <machine/conf.h> 114 115 #include <sh/dev/scifreg.h> 116 117 #ifdef DDB 118 #include <ddb/db_var.h> 119 #endif 120 121 void scifstart(struct tty *); 122 int scifparam(struct tty *, struct termios *); 123 124 cons_decl(scif); 125 void scif_intr_init(void); 126 int scifintr(void *); 127 128 struct scif_softc { 129 struct device sc_dev; /* boilerplate */ 130 struct tty *sc_tty; 131 void *sc_si; 132 133 struct timeout sc_diag_tmo; 134 135 #if 0 136 bus_space_tag_t sc_iot; /* ISA i/o space identifier */ 137 bus_space_handle_t sc_ioh; /* ISA io handle */ 138 139 int sc_drq; 140 141 int sc_frequency; 142 #endif 143 144 u_int sc_overflows, 145 sc_floods, 146 sc_errors; /* number of retries so far */ 147 u_char sc_status[7]; /* copy of registers */ 148 149 int sc_hwflags; 150 int sc_swflags; 151 u_int sc_fifolen; 152 153 u_int sc_r_hiwat, 154 sc_r_lowat; 155 u_char *volatile sc_rbget, 156 *volatile sc_rbput; 157 volatile u_int sc_rbavail; 158 u_char *sc_rbuf, 159 *sc_ebuf; 160 161 u_char *sc_tba; /* transmit buffer address */ 162 u_int sc_tbc, /* transmit byte count */ 163 sc_heldtbc; 164 165 volatile u_char sc_rx_flags, 166 #define RX_TTY_BLOCKED 0x01 167 #define RX_TTY_OVERFLOWED 0x02 168 #define RX_IBUF_BLOCKED 0x04 169 #define RX_IBUF_OVERFLOWED 0x08 170 #define RX_ANY_BLOCK 0x0f 171 sc_tx_busy, /* working on an output chunk */ 172 sc_tx_done, /* done with one output chunk */ 173 sc_tx_stopped, /* H/W level stop (lost CTS) */ 174 sc_st_check, /* got a status interrupt */ 175 sc_rx_ready; 176 177 volatile u_char sc_heldchange; 178 }; 179 180 /* controller driver configuration */ 181 int scif_match(struct device *, void *, void *); 182 void scif_attach(struct device *, struct device *, void *); 183 184 void scif_break(struct scif_softc *, int); 185 void scif_iflush(struct scif_softc *); 186 187 void scifsoft(void *); 188 void scif_rxsoft(struct scif_softc *, struct tty *); 189 void scif_txsoft(struct scif_softc *, struct tty *); 190 void scif_stsoft(struct scif_softc *, struct tty *); 191 void scif_schedrx(struct scif_softc *); 192 void scifdiag(void *); 193 194 195 #define SCIFUNIT_MASK 0x7ffff 196 #define SCIFDIALOUT_MASK 0x80000 197 198 #define SCIFUNIT(x) (minor(x) & SCIFUNIT_MASK) 199 #define SCIFDIALOUT(x) (minor(x) & SCIFDIALOUT_MASK) 200 201 /* Hardware flag masks */ 202 #define SCIF_HW_NOIEN 0x01 203 #define SCIF_HW_FIFO 0x02 204 #define SCIF_HW_FLOW 0x08 205 #define SCIF_HW_DEV_OK 0x20 206 #define SCIF_HW_CONSOLE 0x40 207 208 /* Buffer size for character buffer */ 209 #define SCIF_RING_SIZE 2048 210 211 /* Stop input when 3/4 of the ring is full; restart when only 1/4 is full. */ 212 u_int scif_rbuf_hiwat = (SCIF_RING_SIZE * 1) / 4; 213 u_int scif_rbuf_lowat = (SCIF_RING_SIZE * 3) / 4; 214 215 #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 216 int scifconscflag = CONMODE; 217 int scifisconsole = 0; 218 219 #ifdef SCIFCN_SPEED 220 unsigned int scifcn_speed = SCIFCN_SPEED; 221 #else 222 unsigned int scifcn_speed = 9600; 223 #endif 224 225 #define divrnd(n, q) (((n)*2/(q)+1)/2) /* divide and round off */ 226 227 u_int scif_rbuf_size = SCIF_RING_SIZE; 228 229 struct cfattach scif_ca = { 230 sizeof(struct scif_softc), scif_match, scif_attach 231 }; 232 233 struct cfdriver scif_cd = { 234 0, "scif", DV_DULL 235 }; 236 237 static int scif_attached; 238 239 void InitializeScif(unsigned int); 240 241 /* 242 * following functions are debugging prupose only 243 */ 244 #define CR 0x0D 245 #define USART_ON (unsigned int)~0x08 246 247 void scif_putc(unsigned char); 248 unsigned char scif_getc(void); 249 int ScifErrCheck(void); 250 251 252 /* XXX: uwe 253 * Prepare for bus_spacification. The difference in access widths is 254 * still handled by the magic definitions in scifreg.h 255 */ 256 #define scif_smr_read() SHREG_SCSMR2 257 #define scif_smr_write(v) (SHREG_SCSMR2 = (v)) 258 259 #define scif_brr_read() SHREG_SCBRR2 260 #define scif_brr_write(v) (SHREG_SCBRR2 = (v)) 261 262 #define scif_scr_read() SHREG_SCSCR2 263 #define scif_scr_write(v) (SHREG_SCSCR2 = (v)) 264 265 #define scif_ftdr_write(v) (SHREG_SCFTDR2 = (v)) 266 267 #define scif_ssr_read() SHREG_SCSSR2 268 #define scif_ssr_write(v) (SHREG_SCSSR2 = (v)) 269 270 #define scif_frdr_read() SHREG_SCFRDR2 271 272 #define scif_fcr_read() SHREG_SCFCR2 273 #define scif_fcr_write(v) (SHREG_SCFCR2 = (v)) 274 275 #define scif_fdr_read() SHREG_SCFDR2 276 277 #ifdef SH4 /* additional registers in sh4 */ 278 279 #define scif_sptr_read() SHREG_SCSPTR2 280 #define scif_sptr_write(v) (SHREG_SCSPTR2 = (v)) 281 282 #define scif_lsr_read() SHREG_SCLSR2 283 #define scif_lsr_write(v) (SHREG_SCLSR2 = (v)) 284 285 #endif /* SH4 */ 286 287 288 /* 289 * InitializeScif 290 * : unsigned int bps; 291 * : SCIF(Serial Communication Interface) 292 */ 293 294 void 295 InitializeScif(unsigned int bps) 296 { 297 /* Initialize SCR */ 298 scif_scr_write(0x00); 299 300 #if 0 301 scif_fcr_write(SCFCR2_TFRST | SCFCR2_RFRST | SCFCR2_MCE); 302 #else 303 scif_fcr_write(SCFCR2_TFRST | SCFCR2_RFRST); 304 #endif 305 /* Serial Mode Register */ 306 scif_smr_write(0x00); /* 8bit,NonParity,Even,1Stop */ 307 308 /* Bit Rate Register */ 309 scif_brr_write(divrnd(sh_clock_get_pclock(), 32 * bps) - 1); 310 311 /* 312 * wait 2m Sec, because Send/Recv must begin 1 bit period after 313 * BRR is set. 314 */ 315 delay(2000); 316 317 #if 0 318 scif_fcr_write(FIFO_RCV_TRIGGER_14 | FIFO_XMT_TRIGGER_1 | SCFCR2_MCE); 319 #else 320 scif_fcr_write(FIFO_RCV_TRIGGER_14 | FIFO_XMT_TRIGGER_1); 321 #endif 322 323 /* Send permission, Receive permission ON */ 324 scif_scr_write(SCSCR2_TE | SCSCR2_RE); 325 326 /* Serial Status Register */ 327 scif_ssr_write(scif_ssr_read() & SCSSR2_TDFE); /* Clear Status */ 328 } 329 330 331 /* 332 * scif_putc 333 * : unsigned char c; 334 */ 335 336 void 337 scif_putc(unsigned char c) 338 { 339 /* wait for ready */ 340 while ((scif_fdr_read() & SCFDR2_TXCNT) == SCFDR2_TXF_FULL) 341 continue; 342 343 /* write send data to send register */ 344 scif_ftdr_write(c); 345 346 /* clear ready flag */ 347 scif_ssr_write(scif_ssr_read() & ~(SCSSR2_TDFE | SCSSR2_TEND)); 348 } 349 350 /* 351 * : ScifErrCheck 352 * 0x80 = error 353 * 0x08 = frame error 354 * 0x04 = parity error 355 */ 356 int 357 ScifErrCheck(void) 358 { 359 return (scif_ssr_read() & (SCSSR2_ER | SCSSR2_FER | SCSSR2_PER)); 360 } 361 362 /* 363 * scif_getc 364 */ 365 unsigned char 366 scif_getc(void) 367 { 368 unsigned char c, err_c; 369 #ifdef SH4 370 unsigned short err_c2 = 0; /* XXXGCC: -Wuninitialized */ 371 #endif 372 373 for (;;) { 374 /* wait for ready */ 375 while ((scif_fdr_read() & SCFDR2_RECVCNT) == 0) 376 continue; 377 378 c = scif_frdr_read(); 379 err_c = scif_ssr_read(); 380 scif_ssr_write(scif_ssr_read() 381 & ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_RDF | SCSSR2_DR)); 382 #ifdef SH4 383 if (CPU_IS_SH4) { 384 err_c2 = scif_lsr_read(); 385 scif_lsr_write(scif_lsr_read() & ~SCLSR2_ORER); 386 } 387 #endif 388 if ((err_c & (SCSSR2_ER | SCSSR2_BRK | SCSSR2_FER 389 | SCSSR2_PER)) == 0) { 390 #ifdef SH4 391 if (CPU_IS_SH4 && ((err_c2 & SCLSR2_ORER) == 0)) 392 #endif 393 return(c); 394 } 395 } 396 397 } 398 399 int 400 scif_match(struct device *parent, void *vcf, void *aux) 401 { 402 if (scif_attached != 0) 403 return 0; 404 405 return 1; 406 } 407 408 void 409 scif_attach(struct device *parent, struct device *self, void *aux) 410 { 411 struct scif_softc *sc = (struct scif_softc *)self; 412 struct tty *tp; 413 414 scif_attached = 1; 415 416 sc->sc_hwflags = 0; /* XXX */ 417 sc->sc_swflags = 0; /* XXX */ 418 sc->sc_fifolen = 16; 419 420 if (scifisconsole) { 421 /* InitializeScif(scifcn_speed); */ 422 SET(sc->sc_hwflags, SCIF_HW_CONSOLE); 423 SET(sc->sc_swflags, TIOCFLAG_SOFTCAR); 424 printf("\n%s: console\n", sc->sc_dev.dv_xname); 425 } else { 426 InitializeScif(9600); 427 printf("\n"); 428 } 429 430 timeout_set(&sc->sc_diag_tmo, scifdiag, sc); 431 #ifdef SH4 432 intc_intr_establish(SH4_INTEVT_SCIF_ERI, IST_LEVEL, IPL_TTY, 433 scifintr, sc, self->dv_xname); 434 intc_intr_establish(SH4_INTEVT_SCIF_RXI, IST_LEVEL, IPL_TTY, 435 scifintr, sc, self->dv_xname); 436 intc_intr_establish(SH4_INTEVT_SCIF_BRI, IST_LEVEL, IPL_TTY, 437 scifintr, sc, self->dv_xname); 438 intc_intr_establish(SH4_INTEVT_SCIF_TXI, IST_LEVEL, IPL_TTY, 439 scifintr, sc, self->dv_xname); 440 #else 441 intc_intr_establish(SH7709_INTEVT2_SCIF_ERI, IST_LEVEL, IPL_TTY, 442 scifintr, sc, self->dv_xname); 443 intc_intr_establish(SH7709_INTEVT2_SCIF_RXI, IST_LEVEL, IPL_TTY, 444 scifintr, sc, self->dv_xname); 445 intc_intr_establish(SH7709_INTEVT2_SCIF_BRI, IST_LEVEL, IPL_TTY, 446 scifintr, sc, self->dv_xname); 447 intc_intr_establish(SH7709_INTEVT2_SCIF_TXI, IST_LEVEL, IPL_TTY, 448 scifintr, sc, self->dv_xname); 449 #endif 450 451 sc->sc_si = softintr_establish(IPL_SOFTSERIAL, scifsoft, sc); 452 SET(sc->sc_hwflags, SCIF_HW_DEV_OK); 453 454 tp = ttymalloc(0); 455 tp->t_oproc = scifstart; 456 tp->t_param = scifparam; 457 tp->t_hwiflow = NULL; 458 459 sc->sc_tty = tp; 460 sc->sc_rbuf = malloc(scif_rbuf_size << 1, M_DEVBUF, M_NOWAIT); 461 if (sc->sc_rbuf == NULL) { 462 printf("%s: unable to allocate ring buffer\n", 463 sc->sc_dev.dv_xname); 464 return; 465 } 466 sc->sc_ebuf = sc->sc_rbuf + (scif_rbuf_size << 1); 467 } 468 469 /* 470 * Start or restart transmission. 471 */ 472 void 473 scifstart(struct tty *tp) 474 { 475 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(tp->t_dev)]; 476 int s; 477 478 s = spltty(); 479 if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP)) 480 goto out; 481 if (sc->sc_tx_stopped) 482 goto out; 483 484 ttwakeupwr(tp); 485 if (tp->t_outq.c_cc == 0) 486 goto out; 487 488 /* Grab the first contiguous region of buffer space. */ 489 { 490 u_char *tba; 491 int tbc; 492 493 tba = tp->t_outq.c_cf; 494 tbc = ndqb(&tp->t_outq, 0); 495 496 497 sc->sc_tba = tba; 498 sc->sc_tbc = tbc; 499 } 500 501 SET(tp->t_state, TS_BUSY); 502 sc->sc_tx_busy = 1; 503 504 /* Enable transmit completion interrupts if necessary. */ 505 scif_scr_write(scif_scr_read() | SCSCR2_TIE | SCSCR2_RIE); 506 507 /* Output the first chunk of the contiguous buffer. */ 508 { 509 int n; 510 int maxchars; 511 int i; 512 513 n = sc->sc_tbc; 514 maxchars = sc->sc_fifolen 515 - ((scif_fdr_read() & SCFDR2_TXCNT) >> 8); 516 if (n > maxchars) 517 n = maxchars; 518 519 for (i = 0; i < n; i++) { 520 scif_putc(*(sc->sc_tba)); 521 sc->sc_tba++; 522 } 523 sc->sc_tbc -= n; 524 } 525 out: 526 splx(s); 527 return; 528 } 529 530 /* 531 * Set SCIF tty parameters from termios. 532 * XXX - Should just copy the whole termios after 533 * making sure all the changes could be done. 534 */ 535 int 536 scifparam(struct tty *tp, struct termios *t) 537 { 538 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(tp->t_dev)]; 539 int ospeed = t->c_ospeed; 540 int s; 541 542 /* Check requested parameters. */ 543 if (ospeed < 0) 544 return (EINVAL); 545 if (t->c_ispeed && t->c_ispeed != t->c_ospeed) 546 return (EINVAL); 547 548 /* 549 * For the console, always force CLOCAL and !HUPCL, so that the port 550 * is always active. 551 */ 552 if (ISSET(sc->sc_swflags, TIOCFLAG_SOFTCAR) || 553 ISSET(sc->sc_hwflags, SCIF_HW_CONSOLE)) { 554 SET(t->c_cflag, CLOCAL); 555 CLR(t->c_cflag, HUPCL); 556 } 557 558 /* 559 * If there were no changes, don't do anything. This avoids dropping 560 * input and improves performance when all we did was frob things like 561 * VMIN and VTIME. 562 */ 563 if (tp->t_ospeed == t->c_ospeed && 564 tp->t_cflag == t->c_cflag) 565 return (0); 566 567 #if 0 568 /* XXX (msaitoh) */ 569 lcr = ISSET(sc->sc_lcr, LCR_SBREAK) | cflag2lcr(t->c_cflag); 570 #endif 571 572 s = spltty(); 573 574 /* 575 * Set the flow control pins depending on the current flow control 576 * mode. 577 */ 578 if (ISSET(t->c_cflag, CRTSCTS)) { 579 scif_fcr_write(scif_fcr_read() | SCFCR2_MCE); 580 } else { 581 scif_fcr_write(scif_fcr_read() & ~SCFCR2_MCE); 582 } 583 584 scif_brr_write(divrnd(sh_clock_get_pclock(), 32 * ospeed) -1); 585 586 /* 587 * Set the FIFO threshold based on the receive speed. 588 * 589 * * If it's a low speed, it's probably a mouse or some other 590 * interactive device, so set the threshold low. 591 * * If it's a high speed, trim the trigger level down to prevent 592 * overflows. 593 * * Otherwise set it a bit higher. 594 */ 595 #if 0 596 /* XXX (msaitoh) */ 597 if (ISSET(sc->sc_hwflags, SCIF_HW_HAYESP)) 598 sc->sc_fifo = FIFO_DMA_MODE | FIFO_ENABLE | FIFO_TRIGGER_8; 599 else if (ISSET(sc->sc_hwflags, SCIF_HW_FIFO)) 600 sc->sc_fifo = FIFO_ENABLE | 601 (t->c_ospeed <= 1200 ? FIFO_TRIGGER_1 : 602 t->c_ospeed <= 38400 ? FIFO_TRIGGER_8 : FIFO_TRIGGER_4); 603 else 604 sc->sc_fifo = 0; 605 #endif 606 607 /* And copy to tty. */ 608 tp->t_ispeed = 0; 609 tp->t_ospeed = t->c_ospeed; 610 tp->t_cflag = t->c_cflag; 611 612 if (!sc->sc_heldchange) { 613 if (sc->sc_tx_busy) { 614 sc->sc_heldtbc = sc->sc_tbc; 615 sc->sc_tbc = 0; 616 sc->sc_heldchange = 1; 617 } 618 #if 0 619 /* XXX (msaitoh) */ 620 else 621 scif_loadchannelregs(sc); 622 #endif 623 } 624 625 if (!ISSET(t->c_cflag, CHWFLOW)) { 626 /* Disable the high water mark. */ 627 sc->sc_r_hiwat = 0; 628 sc->sc_r_lowat = 0; 629 if (ISSET(sc->sc_rx_flags, RX_TTY_OVERFLOWED)) { 630 CLR(sc->sc_rx_flags, RX_TTY_OVERFLOWED); 631 scif_schedrx(sc); 632 } 633 } else { 634 sc->sc_r_hiwat = scif_rbuf_hiwat; 635 sc->sc_r_lowat = scif_rbuf_lowat; 636 } 637 638 splx(s); 639 640 #ifdef SCIF_DEBUG 641 if (scif_debug) 642 scifstatus(sc, "scifparam "); 643 #endif 644 645 if (!ISSET(t->c_cflag, CHWFLOW)) { 646 if (sc->sc_tx_stopped) { 647 sc->sc_tx_stopped = 0; 648 scifstart(tp); 649 } 650 } 651 652 return (0); 653 } 654 655 void 656 scif_iflush(struct scif_softc *sc) 657 { 658 int i; 659 unsigned char c; 660 661 i = scif_fdr_read() & SCFDR2_RECVCNT; 662 663 while (i > 0) { 664 c = scif_frdr_read(); 665 scif_ssr_write(scif_ssr_read() & ~(SCSSR2_RDF | SCSSR2_DR)); 666 i--; 667 } 668 } 669 670 int 671 scifopen(dev_t dev, int flag, int mode, struct proc *p) 672 { 673 int unit = SCIFUNIT(dev); 674 struct scif_softc *sc; 675 struct tty *tp; 676 int s; 677 int error; 678 679 if (unit >= scif_cd.cd_ndevs) 680 return (ENXIO); 681 sc = scif_cd.cd_devs[unit]; 682 if (sc == 0 || !ISSET(sc->sc_hwflags, SCIF_HW_DEV_OK) || 683 sc->sc_rbuf == NULL) 684 return (ENXIO); 685 686 tp = sc->sc_tty; 687 688 if (ISSET(tp->t_state, TS_ISOPEN) && 689 ISSET(tp->t_state, TS_XCLUDE) && 690 suser(p, 0) != 0) 691 return (EBUSY); 692 693 s = spltty(); 694 695 /* 696 * Do the following iff this is a first open. 697 */ 698 if (!ISSET(tp->t_state, TS_ISOPEN)) { 699 struct termios t; 700 701 tp->t_dev = dev; 702 703 704 /* Turn on interrupts. */ 705 scif_scr_write(scif_scr_read() | SCSCR2_TIE | SCSCR2_RIE); 706 707 /* 708 * Initialize the termios status to the defaults. Add in the 709 * sticky bits from TIOCSFLAGS. 710 */ 711 t.c_ispeed = 0; 712 if (ISSET(sc->sc_hwflags, SCIF_HW_CONSOLE)) { 713 t.c_ospeed = scifcn_speed; /* XXX (msaitoh) */ 714 t.c_cflag = scifconscflag; 715 } else { 716 t.c_ospeed = TTYDEF_SPEED; 717 t.c_cflag = TTYDEF_CFLAG; 718 } 719 if (ISSET(sc->sc_swflags, TIOCFLAG_CLOCAL)) 720 SET(t.c_cflag, CLOCAL); 721 if (ISSET(sc->sc_swflags, TIOCFLAG_CRTSCTS)) 722 SET(t.c_cflag, CRTSCTS); 723 if (ISSET(sc->sc_swflags, TIOCFLAG_MDMBUF)) 724 SET(t.c_cflag, MDMBUF); 725 /* Make sure scifparam() will do something. */ 726 tp->t_ospeed = 0; 727 (void) scifparam(tp, &t); 728 729 /* 730 * XXX landisk has no hardware flow control! 731 * When porting to another platform, fix this somehow 732 */ 733 SET(tp->t_state, TS_CARR_ON); 734 735 tp->t_iflag = TTYDEF_IFLAG; 736 tp->t_oflag = TTYDEF_OFLAG; 737 tp->t_lflag = TTYDEF_LFLAG; 738 ttychars(tp); 739 ttsetwater(tp); 740 741 /* Clear the input ring, and unblock. */ 742 sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf; 743 sc->sc_rbavail = scif_rbuf_size; 744 scif_iflush(sc); 745 CLR(sc->sc_rx_flags, RX_ANY_BLOCK); 746 #if 0 747 /* XXX (msaitoh) */ 748 scif_hwiflow(sc); 749 #endif 750 751 #ifdef SCIF_DEBUG 752 if (scif_debug) 753 scifstatus(sc, "scifopen "); 754 #endif 755 756 } 757 758 splx(s); 759 760 error = ttyopen(dev, tp, p); 761 if (error) 762 goto bad; 763 764 error = (*linesw[tp->t_line].l_open)(dev, tp, p); 765 if (error) 766 goto bad; 767 768 return (0); 769 770 bad: 771 772 return (error); 773 } 774 775 int 776 scifclose(dev_t dev, int flag, int mode, struct proc *p) 777 { 778 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(dev)]; 779 struct tty *tp = sc->sc_tty; 780 781 /* XXX This is for cons.c. */ 782 if (!ISSET(tp->t_state, TS_ISOPEN)) 783 return (0); 784 785 (*linesw[tp->t_line].l_close)(tp, flag, p); 786 ttyclose(tp); 787 788 return (0); 789 } 790 791 int 792 scifread(dev_t dev, struct uio *uio, int flag) 793 { 794 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(dev)]; 795 struct tty *tp = sc->sc_tty; 796 797 return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); 798 } 799 800 int 801 scifwrite(dev_t dev, struct uio *uio, int flag) 802 { 803 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(dev)]; 804 struct tty *tp = sc->sc_tty; 805 806 return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); 807 } 808 809 #if 0 810 int 811 scifpoll(dev_t dev, int events, struct proc *p) 812 { 813 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(dev)]; 814 struct tty *tp = sc->sc_tty; 815 816 return ((*linesw[tp->t_line].l_poll)(tp, events, p)); 817 } 818 #endif 819 820 struct tty * 821 sciftty(dev_t dev) 822 { 823 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(dev)]; 824 struct tty *tp = sc->sc_tty; 825 826 return (tp); 827 } 828 829 int 830 scifioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) 831 { 832 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(dev)]; 833 struct tty *tp = sc->sc_tty; 834 int error; 835 int s; 836 837 error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); 838 if (error != -1) 839 return (error); 840 841 error = ttioctl(tp, cmd, data, flag, p); 842 if (error != -1) 843 return (error); 844 845 error = 0; 846 847 s = spltty(); 848 849 switch (cmd) { 850 case TIOCSBRK: 851 scif_break(sc, 1); 852 break; 853 854 case TIOCCBRK: 855 scif_break(sc, 0); 856 break; 857 858 case TIOCGFLAGS: 859 *(int *)data = sc->sc_swflags; 860 break; 861 862 case TIOCSFLAGS: 863 error = suser(p, 0); 864 if (error) 865 break; 866 sc->sc_swflags = *(int *)data; 867 break; 868 869 default: 870 error = -1; 871 break; 872 } 873 874 splx(s); 875 876 return (error); 877 } 878 879 void 880 scif_schedrx(struct scif_softc *sc) 881 { 882 sc->sc_rx_ready = 1; 883 884 /* Wake up the poller. */ 885 softintr_schedule(sc->sc_si); 886 } 887 888 void 889 scif_break(struct scif_softc *sc, int onoff) 890 { 891 if (onoff) 892 scif_ssr_write(scif_ssr_read() & ~SCSSR2_TDFE); 893 else 894 scif_ssr_write(scif_ssr_read() | SCSSR2_TDFE); 895 896 #if 0 /* XXX */ 897 if (!sc->sc_heldchange) { 898 if (sc->sc_tx_busy) { 899 sc->sc_heldtbc = sc->sc_tbc; 900 sc->sc_tbc = 0; 901 sc->sc_heldchange = 1; 902 } else 903 scif_loadchannelregs(sc); 904 } 905 #endif 906 } 907 908 /* 909 * Stop output, e.g., for ^S or output flush. 910 */ 911 int 912 scifstop(struct tty *tp, int flag) 913 { 914 struct scif_softc *sc = scif_cd.cd_devs[SCIFUNIT(tp->t_dev)]; 915 int s; 916 917 s = spltty(); 918 if (ISSET(tp->t_state, TS_BUSY)) { 919 /* Stop transmitting at the next chunk. */ 920 sc->sc_tbc = 0; 921 sc->sc_heldtbc = 0; 922 if (!ISSET(tp->t_state, TS_TTSTOP)) 923 SET(tp->t_state, TS_FLUSH); 924 } 925 splx(s); 926 return (0); 927 } 928 929 void 930 scif_intr_init() 931 { 932 /* XXX */ 933 } 934 935 void 936 scifdiag(void *arg) 937 { 938 struct scif_softc *sc = arg; 939 int overflows, floods; 940 int s; 941 942 s = spltty(); 943 overflows = sc->sc_overflows; 944 sc->sc_overflows = 0; 945 floods = sc->sc_floods; 946 sc->sc_floods = 0; 947 sc->sc_errors = 0; 948 splx(s); 949 950 log(LOG_WARNING, "%s: %d silo overflow%s, %d ibuf flood%s\n", 951 sc->sc_dev.dv_xname, 952 overflows, overflows == 1 ? "" : "s", 953 floods, floods == 1 ? "" : "s"); 954 } 955 956 void 957 scif_rxsoft(struct scif_softc *sc, struct tty *tp) 958 { 959 int (*rint)(int, struct tty *) = *linesw[tp->t_line].l_rint; 960 u_char *get, *end; 961 u_int cc, scc; 962 u_char ssr2; 963 int code; 964 int s; 965 966 end = sc->sc_ebuf; 967 get = sc->sc_rbget; 968 scc = cc = scif_rbuf_size - sc->sc_rbavail; 969 970 if (cc == scif_rbuf_size) { 971 sc->sc_floods++; 972 if (sc->sc_errors++ == 0) 973 timeout_add_sec(&sc->sc_diag_tmo, 60); 974 } 975 976 while (cc) { 977 code = get[0]; 978 ssr2 = get[1]; 979 if (ISSET(ssr2, SCSSR2_BRK | SCSSR2_FER | SCSSR2_PER)) { 980 if (ISSET(ssr2, SCSSR2_BRK | SCSSR2_FER)) 981 SET(code, TTY_FE); 982 if (ISSET(ssr2, SCSSR2_PER)) 983 SET(code, TTY_PE); 984 } 985 if ((*rint)(code, tp) == -1) { 986 /* 987 * The line discipline's buffer is out of space. 988 */ 989 if (!ISSET(sc->sc_rx_flags, RX_TTY_BLOCKED)) { 990 /* 991 * We're either not using flow control, or the 992 * line discipline didn't tell us to block for 993 * some reason. Either way, we have no way to 994 * know when there's more space available, so 995 * just drop the rest of the data. 996 */ 997 get += cc << 1; 998 if (get >= end) 999 get -= scif_rbuf_size << 1; 1000 cc = 0; 1001 } else { 1002 /* 1003 * Don't schedule any more receive processing 1004 * until the line discipline tells us there's 1005 * space available (through scifhwiflow()). 1006 * Leave the rest of the data in the input 1007 * buffer. 1008 */ 1009 SET(sc->sc_rx_flags, RX_TTY_OVERFLOWED); 1010 } 1011 break; 1012 } 1013 get += 2; 1014 if (get >= end) 1015 get = sc->sc_rbuf; 1016 cc--; 1017 } 1018 1019 if (cc != scc) { 1020 sc->sc_rbget = get; 1021 s = spltty(); 1022 cc = sc->sc_rbavail += scc - cc; 1023 /* Buffers should be ok again, release possible block. */ 1024 if (cc >= sc->sc_r_lowat) { 1025 if (ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) { 1026 CLR(sc->sc_rx_flags, RX_IBUF_OVERFLOWED); 1027 scif_scr_write(scif_scr_read() | SCSCR2_RIE); 1028 } 1029 #if 0 1030 if (ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED)) { 1031 CLR(sc->sc_rx_flags, RX_IBUF_BLOCKED); 1032 scif_hwiflow(sc); 1033 } 1034 #endif 1035 } 1036 splx(s); 1037 } 1038 } 1039 1040 void 1041 scif_txsoft(struct scif_softc *sc, struct tty *tp) 1042 { 1043 CLR(tp->t_state, TS_BUSY); 1044 if (ISSET(tp->t_state, TS_FLUSH)) 1045 CLR(tp->t_state, TS_FLUSH); 1046 else 1047 ndflush(&tp->t_outq, (int)(sc->sc_tba - tp->t_outq.c_cf)); 1048 (*linesw[tp->t_line].l_start)(tp); 1049 } 1050 1051 void 1052 scif_stsoft(struct scif_softc *sc, struct tty *tp) 1053 { 1054 #if 0 1055 /* XXX (msaitoh) */ 1056 u_char msr, delta; 1057 int s; 1058 1059 s = spltty(); 1060 msr = sc->sc_msr; 1061 delta = sc->sc_msr_delta; 1062 sc->sc_msr_delta = 0; 1063 splx(s); 1064 1065 if (ISSET(delta, sc->sc_msr_dcd)) { 1066 /* 1067 * Inform the tty layer that carrier detect changed. 1068 */ 1069 (void) (*linesw[tp->t_line].l_modem)(tp, ISSET(msr, MSR_DCD)); 1070 } 1071 1072 if (ISSET(delta, sc->sc_msr_cts)) { 1073 /* Block or unblock output according to flow control. */ 1074 if (ISSET(msr, sc->sc_msr_cts)) { 1075 sc->sc_tx_stopped = 0; 1076 (*linesw[tp->t_line].l_start)(tp); 1077 } else { 1078 sc->sc_tx_stopped = 1; 1079 } 1080 } 1081 1082 #ifdef SCIF_DEBUG 1083 if (scif_debug) 1084 scifstatus(sc, "scif_stsoft"); 1085 #endif 1086 #endif 1087 } 1088 1089 void 1090 scifsoft(void *arg) 1091 { 1092 struct scif_softc *sc = arg; 1093 struct tty *tp; 1094 1095 tp = sc->sc_tty; 1096 1097 if (sc->sc_rx_ready) { 1098 sc->sc_rx_ready = 0; 1099 scif_rxsoft(sc, tp); 1100 } 1101 1102 #if 0 1103 if (sc->sc_st_check) { 1104 sc->sc_st_check = 0; 1105 scif_stsoft(sc, tp); 1106 } 1107 #endif 1108 1109 if (sc->sc_tx_done) { 1110 sc->sc_tx_done = 0; 1111 scif_txsoft(sc, tp); 1112 } 1113 } 1114 1115 int 1116 scifintr(void *arg) 1117 { 1118 struct scif_softc *sc = arg; 1119 u_char *put, *end; 1120 u_int cc; 1121 u_short ssr2; 1122 int count; 1123 1124 end = sc->sc_ebuf; 1125 put = sc->sc_rbput; 1126 cc = sc->sc_rbavail; 1127 1128 do { 1129 ssr2 = scif_ssr_read(); 1130 if (ISSET(ssr2, SCSSR2_BRK)) { 1131 scif_ssr_write(scif_ssr_read() 1132 & ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_DR)); 1133 #ifdef DDB 1134 if (ISSET(sc->sc_hwflags, SCIF_HW_CONSOLE) && 1135 db_console != 0) { 1136 Debugger(); 1137 } 1138 #endif /* DDB */ 1139 } 1140 count = scif_fdr_read() & SCFDR2_RECVCNT; 1141 if (count != 0) { 1142 for (;;) { 1143 u_char c = scif_frdr_read(); 1144 u_char err = (u_char)(scif_ssr_read() & 0x00ff); 1145 1146 scif_ssr_write(scif_ssr_read() 1147 & ~(SCSSR2_ER | SCSSR2_RDF | SCSSR2_DR)); 1148 #ifdef SH4 1149 if (CPU_IS_SH4) 1150 scif_lsr_write(scif_lsr_read() 1151 & ~SCLSR2_ORER); 1152 #endif 1153 if ((cc > 0) && (count > 0)) { 1154 put[0] = c; 1155 put[1] = err; 1156 put += 2; 1157 if (put >= end) 1158 put = sc->sc_rbuf; 1159 cc--; 1160 count--; 1161 } else 1162 break; 1163 } 1164 1165 /* 1166 * Current string of incoming characters ended because 1167 * no more data was available or we ran out of space. 1168 * Schedule a receive event if any data was received. 1169 * If we're out of space, turn off receive interrupts. 1170 */ 1171 sc->sc_rbput = put; 1172 sc->sc_rbavail = cc; 1173 if (!ISSET(sc->sc_rx_flags, RX_TTY_OVERFLOWED)) 1174 sc->sc_rx_ready = 1; 1175 1176 /* 1177 * See if we are in danger of overflowing a buffer. If 1178 * so, use hardware flow control to ease the pressure. 1179 */ 1180 if (!ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED) && 1181 cc < sc->sc_r_hiwat) { 1182 SET(sc->sc_rx_flags, RX_IBUF_BLOCKED); 1183 #if 0 1184 scif_hwiflow(sc); 1185 #endif 1186 } 1187 1188 /* 1189 * If we're out of space, disable receive interrupts 1190 * until the queue has drained a bit. 1191 */ 1192 if (!cc) { 1193 SET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED); 1194 scif_scr_write(scif_scr_read() & ~SCSCR2_RIE); 1195 } 1196 } else { 1197 if (scif_ssr_read() & (SCSSR2_RDF | SCSSR2_DR)) { 1198 scif_scr_write(scif_scr_read() 1199 & ~(SCSCR2_TIE | SCSCR2_RIE)); 1200 delay(10); 1201 scif_scr_write(scif_scr_read() 1202 | SCSCR2_TIE | SCSCR2_RIE); 1203 continue; 1204 } 1205 } 1206 } while (scif_ssr_read() & (SCSSR2_RDF | SCSSR2_DR)); 1207 1208 #if 0 1209 msr = bus_space_read_1(iot, ioh, scif_msr); 1210 delta = msr ^ sc->sc_msr; 1211 sc->sc_msr = msr; 1212 if (ISSET(delta, sc->sc_msr_mask)) { 1213 SET(sc->sc_msr_delta, delta); 1214 1215 /* 1216 * Pulse-per-second clock signal on edge of DCD? 1217 */ 1218 if (ISSET(delta, sc->sc_ppsmask)) { 1219 struct timeval tv; 1220 if (ISSET(msr, sc->sc_ppsmask) == 1221 sc->sc_ppsassert) { 1222 /* XXX nanotime() */ 1223 microtime(&tv); 1224 TIMEVAL_TO_TIMESPEC(&tv, 1225 &sc->ppsinfo.assert_timestamp); 1226 if (sc->ppsparam.mode & PPS_OFFSETASSERT) { 1227 timespecadd(&sc->ppsinfo.assert_timestamp, 1228 &sc->ppsparam.assert_offset, 1229 &sc->ppsinfo.assert_timestamp); 1230 TIMESPEC_TO_TIMEVAL(&tv, &sc->ppsinfo.assert_timestamp); 1231 } 1232 1233 #ifdef PPS_SYNC 1234 if (sc->ppsparam.mode & PPS_HARDPPSONASSERT) 1235 hardpps(&tv, tv.tv_usec); 1236 #endif 1237 sc->ppsinfo.assert_sequence++; 1238 sc->ppsinfo.current_mode = 1239 sc->ppsparam.mode; 1240 1241 } else if (ISSET(msr, sc->sc_ppsmask) == 1242 sc->sc_ppsclear) { 1243 /* XXX nanotime() */ 1244 microtime(&tv); 1245 TIMEVAL_TO_TIMESPEC(&tv, 1246 &sc->ppsinfo.clear_timestamp); 1247 if (sc->ppsparam.mode & PPS_OFFSETCLEAR) { 1248 timespecadd(&sc->ppsinfo.clear_timestamp, 1249 &sc->ppsparam.clear_offset, 1250 &sc->ppsinfo.clear_timestamp); 1251 TIMESPEC_TO_TIMEVAL(&tv, &sc->ppsinfo.clear_timestamp); 1252 } 1253 1254 #ifdef PPS_SYNC 1255 if (sc->ppsparam.mode & PPS_HARDPPSONCLEAR) 1256 hardpps(&tv, tv.tv_usec); 1257 #endif 1258 sc->ppsinfo.clear_sequence++; 1259 sc->ppsinfo.current_mode = 1260 sc->ppsparam.mode; 1261 } 1262 } 1263 1264 /* 1265 * Stop output immediately if we lose the output 1266 * flow control signal or carrier detect. 1267 */ 1268 if (ISSET(~msr, sc->sc_msr_mask)) { 1269 sc->sc_tbc = 0; 1270 sc->sc_heldtbc = 0; 1271 #ifdef SCIF_DEBUG 1272 if (scif_debug) 1273 scifstatus(sc, "scifintr "); 1274 #endif 1275 } 1276 1277 sc->sc_st_check = 1; 1278 } 1279 #endif 1280 1281 /* 1282 * Done handling any receive interrupts. See if data can be 1283 * transmitted as well. Schedule tx done event if no data left 1284 * and tty was marked busy. 1285 */ 1286 if (((scif_fdr_read() & SCFDR2_TXCNT) >> 8) != 16) { /* XXX (msaitoh) */ 1287 /* 1288 * If we've delayed a parameter change, do it now, and restart 1289 * output. 1290 */ 1291 if (sc->sc_heldchange) { 1292 sc->sc_heldchange = 0; 1293 sc->sc_tbc = sc->sc_heldtbc; 1294 sc->sc_heldtbc = 0; 1295 } 1296 1297 /* Output the next chunk of the contiguous buffer, if any. */ 1298 if (sc->sc_tbc > 0) { 1299 int n; 1300 int maxchars; 1301 int i; 1302 1303 n = sc->sc_tbc; 1304 maxchars = sc->sc_fifolen - 1305 ((scif_fdr_read() & SCFDR2_TXCNT) >> 8); 1306 if (n > maxchars) 1307 n = maxchars; 1308 1309 for (i = 0; i < n; i++) { 1310 scif_putc(*(sc->sc_tba)); 1311 sc->sc_tba++; 1312 } 1313 sc->sc_tbc -= n; 1314 } else { 1315 /* Disable transmit completion interrupts if necessary. */ 1316 #if 0 1317 if (ISSET(sc->sc_ier, IER_ETXRDY)) 1318 #endif 1319 scif_scr_write(scif_scr_read() & ~SCSCR2_TIE); 1320 1321 if (sc->sc_tx_busy) { 1322 sc->sc_tx_busy = 0; 1323 sc->sc_tx_done = 1; 1324 } 1325 } 1326 } 1327 1328 /* Wake up the poller. */ 1329 softintr_schedule(sc->sc_si); 1330 1331 return (1); 1332 } 1333 1334 void 1335 scifcnprobe(struct consdev *cp) 1336 { 1337 int maj; 1338 1339 /* locate the major number */ 1340 for (maj = 0; maj < nchrdev; maj++) 1341 if (cdevsw[maj].d_open == scifopen) 1342 break; 1343 1344 cp->cn_dev = makedev(maj, 0); 1345 #ifdef SCIFCONSOLE 1346 cp->cn_pri = CN_HIGHPRI; 1347 #else 1348 cp->cn_pri = CN_LOWPRI; 1349 #endif 1350 } 1351 1352 void 1353 scifcninit(struct consdev *cp) 1354 { 1355 InitializeScif(scifcn_speed); 1356 scifisconsole = 1; 1357 } 1358 1359 int 1360 scifcngetc(dev_t dev) 1361 { 1362 int c; 1363 int s; 1364 1365 s = spltty(); 1366 c = scif_getc(); 1367 splx(s); 1368 1369 return (c); 1370 } 1371 1372 void 1373 scifcnputc(dev_t dev, int c) 1374 { 1375 int s; 1376 1377 s = spltty(); 1378 scif_putc((u_char)c); 1379 splx(s); 1380 } 1381