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