Sync with sys/i386/isa/lpt.c revision 1.72.

This commit is contained in:
kato 1998-12-11 08:48:21 +00:00
parent 9e5ec90f20
commit 3f8a0805e6

View File

@ -46,7 +46,7 @@
* SUCH DAMAGE.
*
* from: unknown origin, 386BSD 0.1
* $Id: lpt.c,v 1.22 1998/08/17 08:21:09 kato Exp $
* $Id: lpt.c,v 1.23 1998/10/22 05:58:45 bde Exp $
*/
/*
@ -195,9 +195,12 @@
#ifndef DEBUG
#define lprintf (void)
#define lprintf(args)
#else
#define lprintf if (lptflag) printf
#define lprintf(args) do { \
if (lptflag) \
printf args; \
} while (0)
static int volatile lptflag = 1;
#endif
@ -325,8 +328,8 @@ lpt_port_test (int port, u_char data, u_char mask)
temp = inb(port) & mask;
}
while (temp != data && --timeout);
lprintf("Port 0x%x\tout=%x\tin=%x\ttout=%d\n",
port, data, temp, timeout);
lprintf(("Port 0x%x\tout=%x\tin=%x\ttout=%d\n",
port, data, temp, timeout));
return (temp == data);
}
@ -454,7 +457,7 @@ lptattach(struct isa_device *isdp)
#endif
/* check if we can use interrupt */
lprintf("oldirq %x\n", sc->sc_irq);
lprintf(("oldirq %x\n", sc->sc_irq));
if (isdp->id_irq) {
sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ;
printf("lpt%d: Interrupt-driven port\n", unit);
@ -463,9 +466,9 @@ lptattach(struct isa_device *isdp)
#endif
} else {
sc->sc_irq = 0;
lprintf("lpt%d: Polled port\n", unit);
lprintf(("lpt%d: Polled port\n", unit));
}
lprintf("irq %x\n", sc->sc_irq);
lprintf(("irq %x\n", sc->sc_irq));
#ifdef DEVFS
/* XXX what to do about the flags in the minor number? */
@ -503,7 +506,7 @@ lptopen (dev_t dev, int flags, int fmt, struct proc *p)
#endif
if (sc->sc_state) {
lprintf("lp: still open %x\n", sc->sc_state);
lprintf(("lp: still open %x\n", sc->sc_state));
return(EBUSY);
} else
sc->sc_state |= INIT;
@ -517,7 +520,7 @@ lptopen (dev_t dev, int flags, int fmt, struct proc *p)
}
s = spltty();
lprintf("lp flags 0x%x\n", sc->sc_flags);
lprintf(("lp flags 0x%x\n", sc->sc_flags));
port = sc->sc_port;
/* set IRQ status according to ENABLE_IRQ flag */
@ -545,7 +548,7 @@ lptopen (dev_t dev, int flags, int fmt, struct proc *p)
if (trys++ >= LPINITRDY*4) {
splx(s);
sc->sc_state = 0;
lprintf ("status %x\n", inb(port+lpt_status) );
lprintf(("status %x\n", inb(port+lpt_status)));
return (EBUSY);
}
@ -578,14 +581,14 @@ lptopen (dev_t dev, int flags, int fmt, struct proc *p)
splx(s);
/* only use timeout if using interrupt */
lprintf("irq %x\n", sc->sc_irq);
lprintf(("irq %x\n", sc->sc_irq));
if (sc->sc_irq & LP_USE_IRQ) {
sc->sc_state |= TOUT;
timeout (lptout, (caddr_t)sc,
(sc->sc_backoff = hz/LPTOUTINITIAL));
}
lprintf("opened.\n");
lprintf(("opened.\n"));
return(0);
}
@ -595,7 +598,7 @@ lptout (void *arg)
struct lpt_softc *sc = arg;
int pl;
lprintf ("T %x ", inb(sc->sc_port+lpt_status));
lprintf(("T %x ", inb(sc->sc_port+lpt_status)));
if (sc->sc_state & OPEN) {
sc->sc_backoff++;
if (sc->sc_backoff > hz/LPTOUTMAX)
@ -654,7 +657,7 @@ lptclose(dev_t dev, int flags, int fmt, struct proc *p)
end_close:
sc->sc_state = 0;
sc->sc_xfercnt = 0;
lprintf("closed.\n");
lprintf(("closed.\n"));
return(0);
}
@ -673,7 +676,7 @@ pushbytes(struct lpt_softc * sc)
char ch;
int port = sc->sc_port;
lprintf("p");
lprintf(("p"));
/* loop for every character .. */
while (sc->sc_xfercnt > 0) {
/* printer data */
@ -751,16 +754,16 @@ lptwrite(dev_t dev, struct uio * uio, int ioflag)
uiomove(sc->sc_cp, n, uio);
sc->sc_xfercnt = n ;
while ((sc->sc_xfercnt > 0)&&(sc->sc_irq & LP_USE_IRQ)) {
lprintf("i");
lprintf(("i"));
/* if the printer is ready for a char, */
/* give it one */
if ((sc->sc_state & OBUSY) == 0){
lprintf("\nC %d. ", sc->sc_xfercnt);
lprintf(("\nC %d. ", sc->sc_xfercnt));
pl = spltty();
lptintr(sc - lpt_sc);
(void) splx(pl);
}
lprintf("W ");
lprintf(("W "));
if (sc->sc_state & OBUSY)
if ((err = tsleep ((caddr_t)sc,
LPPRI|PCATCH, "lpwrite", 0))) {
@ -770,7 +773,7 @@ lptwrite(dev_t dev, struct uio * uio, int ioflag)
}
/* check to see if we must do a polled write */
if(!(sc->sc_irq & LP_USE_IRQ) && (sc->sc_xfercnt)) {
lprintf("p");
lprintf(("p"));
if((err = pushbytes(sc)))
return(err);
}
@ -816,7 +819,7 @@ lptintr(int unit)
if (sc->sc_xfercnt) {
/* send char */
/*lprintf("%x ", *sc->sc_cp); */
/*lprintf(("%x ", *sc->sc_cp)); */
outb(port+lpt_data, *sc->sc_cp++) ;
outb(port+lpt_control, sc->sc_control|LPC_STB);
/* DELAY(X) */
@ -833,7 +836,7 @@ lptintr(int unit)
sc->sc_state &= ~OBUSY;
if(!(sc->sc_state & INTERRUPTED))
wakeup((caddr_t)sc);
lprintf("w ");
lprintf(("w "));
return;
} else { /* check for error */
if(((sts & (LPS_NERR | LPS_OUT) ) != LPS_NERR) &&
@ -842,7 +845,7 @@ lptintr(int unit)
/* lptout() will jump in and try to restart. */
}
#endif
lprintf("sts %x ", sts);
lprintf(("sts %x ", sts));
}
static int
@ -1029,7 +1032,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
break;
default:
lprintf("LP:ioctl(0x%lx)\n", cmd);
lprintf(("LP:ioctl(0x%lx)\n", cmd));
return EINVAL;
}
return 0;
@ -1126,7 +1129,7 @@ lpintr (int unit)
sc->sc_iferrs = 0;
if (IF_QFULL(&ipintrq)) {
lprintf("DROP");
lprintf(("DROP"));
IF_DROP(&ipintrq);
goto done;
}
@ -1175,7 +1178,7 @@ lpintr (int unit)
sc->sc_iferrs = 0;
if (IF_QFULL(&ipintrq)) {
lprintf("DROP");
lprintf(("DROP"));
IF_DROP(&ipintrq);
goto done;
}
@ -1197,7 +1200,7 @@ lpintr (int unit)
err:
outb(lpt_data_port, 0);
lprintf("R");
lprintf(("R"));
sc->sc_if.if_ierrors++;
sc->sc_iferrs++;
@ -1263,7 +1266,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
if (ifp->if_flags & IFF_LINK0) {
if (!(inb(lpt_stat_port) & CLPIP_SHAKE)) {
lprintf("&");
lprintf(("&"));
lptintr(ifp->if_unit);
}
@ -1323,7 +1326,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
nend:
if (err) { /* if we didn't timeout... */
ifp->if_oerrors++;
lprintf("X");
lprintf(("X"));
} else {
ifp->if_opackets++;
ifp->if_obytes += m->m_pkthdr.len;
@ -1332,7 +1335,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
m_freem(m);
if (!(inb(lpt_stat_port) & CLPIP_SHAKE)) {
lprintf("^");
lprintf(("^"));
lptintr(ifp->if_unit);
}
(void) splx(s);
@ -1340,7 +1343,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
}
if (inb(lpt_stat_port) & LPIP_SHAKE) {
lprintf("&");
lprintf(("&"));
lptintr(ifp->if_unit);
}
@ -1365,7 +1368,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
if (err) { /* if we didn't timeout... */
ifp->if_oerrors++;
lprintf("X");
lprintf(("X"));
} else {
ifp->if_opackets++;
ifp->if_obytes += m->m_pkthdr.len;
@ -1393,7 +1396,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m,
m_freem(m);
if (inb(lpt_stat_port) & LPIP_SHAKE) {
lprintf("^");
lprintf(("^"));
lptintr(ifp->if_unit);
}