Lines Matching refs:sc

318 	struct	lpt_softc	*sc;
322 sc = device_get_softc(dev);
323 callout_init(&sc->timer, 0);
326 sc->res_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid,
328 if (sc->res_port == NULL)
330 isa_load_resourcev(sc->res_port, lpt_iat, 4);
332 sc->sc_port = rman_get_start(sc->res_port);
333 sc->sc_primed = 0; /* not primed yet */
335 outb(sc->sc_port+lpt_pstb_ctrl, LPC_DIS_PSTB); /* PSTB disable */
336 outb(sc->sc_port+lpt_control, LPC_MODE8255); /* 8255 mode set */
337 outb(sc->sc_port+lpt_control, LPC_NIRQ8); /* IRQ8 inactive */
338 outb(sc->sc_port+lpt_control, LPC_NPSTB); /* PSTB inactive */
339 outb(sc->sc_port+lpt_pstb_ctrl, LPC_EN_PSTB); /* PSTB enable */
341 sc->sc_irq = 0;
344 sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
346 if (sc->res_irq == NULL) {
348 sc->res_port);
351 if (bus_setup_intr(dev, sc->res_irq, INTR_TYPE_TTY, NULL, lpt_intr,
352 sc, &sc->sc_ih)) {
354 sc->res_port);
356 sc->res_irq);
359 sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ;
365 cdev->si_drv1 = sc;
368 cdev->si_drv1 = sc;
382 struct lpt_softc *sc = dev->si_drv1;
386 if (sc->sc_port == 0)
389 if (sc->sc_state) {
390 lprintf(("lp: still open %x\n", sc->sc_state));
393 sc->sc_state |= INIT;
395 sc->sc_flags = dev2unit(dev);
398 if (sc->sc_flags & LP_BYPASS) {
399 sc->sc_state = OPEN;
404 lprintf(("lp flags 0x%x\n", sc->sc_flags));
405 port = sc->sc_port;
408 if (sc->sc_irq & LP_ENABLE_IRQ)
409 sc->sc_irq |= LP_USE_IRQ;
411 sc->sc_irq &= ~LP_USE_IRQ;
414 sc->sc_state = OPEN;
415 sc->sc_inbuf = malloc(BUFSIZE, M_DEVBUF, M_WAITOK);
416 sc->sc_xfercnt = 0;
420 lprintf(("irq %x\n", sc->sc_irq));
421 if (sc->sc_irq & LP_USE_IRQ) {
422 sc->sc_state |= TOUT;
423 sc->sc_backoff = hz / LPTOUTINITIAL;
424 callout_reset(&sc->timer, sc->sc_backoff, lptout, sc);
434 struct lpt_softc *sc = arg;
437 lprintf(("T %x ", inb(sc->sc_port+lpt_status)));
438 if (sc->sc_state & OPEN) {
439 sc->sc_backoff++;
440 if (sc->sc_backoff > hz/LPTOUTMAX)
441 sc->sc_backoff = sc->sc_backoff > hz/LPTOUTMAX;
442 callout_reset(&sc->timer, sc->sc_backoff, lptout, sc);
444 sc->sc_state &= ~TOUT;
446 if (sc->sc_state & ERROR)
447 sc->sc_state &= ~ERROR;
452 if (sc->sc_xfercnt) {
454 lpt_intr(sc);
457 sc->sc_state &= ~OBUSY;
458 wakeup(sc);
471 struct lpt_softc *sc = dev->si_drv1;
473 if(sc->sc_flags & LP_BYPASS)
476 sc->sc_state &= ~OPEN;
477 free(sc->sc_inbuf, M_DEVBUF);
480 sc->sc_state = 0;
481 sc->sc_xfercnt = 0;
495 pushbytes(struct lpt_softc * sc)
499 int port = sc->sc_port;
503 while (sc->sc_xfercnt > 0) {
505 ch = *(sc->sc_cp);
506 sc->sc_cp++;
507 sc->sc_xfercnt--;
529 err = tsleep(sc, LPPRI,
559 struct lpt_softc *sc = dev->si_drv1;
561 if(sc->sc_flags & LP_BYPASS) {
566 sc->sc_state &= ~INTERRUPTED;
568 sc->sc_cp = sc->sc_inbuf;
569 uiomove(sc->sc_cp, n, uio);
570 sc->sc_xfercnt = n ;
571 while ((sc->sc_xfercnt > 0)&&(sc->sc_irq & LP_USE_IRQ)) {
575 if ((sc->sc_state & OBUSY) == 0){
576 lprintf(("\nC %d. ", sc->sc_xfercnt));
578 lpt_intr(sc);
582 if (sc->sc_state & OBUSY)
583 if ((err = tsleep (sc,
585 sc->sc_state |= INTERRUPTED;
590 if(!(sc->sc_irq & LP_USE_IRQ) && (sc->sc_xfercnt)) {
592 if((err = pushbytes(sc)))
615 struct lpt_softc *sc = dev->si_drv1;
620 if(sc->sc_irq & LP_HAS_IRQ) {
630 old_sc_irq = sc->sc_irq;
632 sc->sc_irq &= (~LP_ENABLE_IRQ);
634 sc->sc_irq |= LP_ENABLE_IRQ;
635 if (old_sc_irq != sc->sc_irq )
638 (sc->sc_irq & LP_ENABLE_IRQ)?