summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorcsgr <csgr@FreeBSD.org>1994-09-03 22:47:08 +0000
committercsgr <csgr@FreeBSD.org>1994-09-03 22:47:08 +0000
commit7b6e72a847a7d44c2c26046d7b7b45ffb24d6bac (patch)
treefae137773c8b7b37ab895b0c2108c844082d5eb7 /sys
parent010d228ad6975af67848079ecbeca590d3ac7ed1 (diff)
downloadFreeBSD-src-7b6e72a847a7d44c2c26046d7b7b45ffb24d6bac.zip
FreeBSD-src-7b6e72a847a7d44c2c26046d7b7b45ffb24d6bac.tar.gz
Make it possible to run lptcontrol on a printer port which does not
actually have a printer connected or online: - MAKEDEV: remove all signs of lpa add lpctl? devices (minor # = unit + 128) - usr.sbin/Makefile add lptcontrol - sys/i386/isa/lpt.c implement the LP_BYPASS flag: when a unit is opened with this flag set, the printer is not primed, and no check is made to see that the printer is online. This can only be used to pass ioctls. (giving us /dev/lpctl?) - lptcontrol.c use /dev/lpctl? (LP_BYPASS) -f flag removed, -u flag added - lptcontrol.8 document changes in lptcontrol rewrite using mandoc macros Submitted by: Geoff.
Diffstat (limited to 'sys')
-rw-r--r--sys/i386/isa/lpt.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/sys/i386/isa/lpt.c b/sys/i386/isa/lpt.c
index 00080c3..4b03ae3 100644
--- a/sys/i386/isa/lpt.c
+++ b/sys/i386/isa/lpt.c
@@ -46,7 +46,7 @@
* SUCH DAMAGE.
*
* from: unknown origin, 386BSD 0.1
- * $Id: lpt.c,v 1.15 1994/08/14 01:46:28 phk Exp $
+ * $Id: lpt.c,v 1.16 1994/08/23 07:52:20 paul Exp $
*/
/*
@@ -397,7 +397,7 @@ lptattach(struct isa_device *isdp)
sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ;
printf("lpt%d: Interrupt-driven port\n", isdp->id_unit);
#ifdef INET
- lpattach(sc,isdp->id_unit);
+ lpattach(sc,isdp->id_unit);
#endif
} else {
sc->sc_irq = 0;
@@ -410,6 +410,8 @@ lptattach(struct isa_device *isdp)
/*
* lptopen -- reset the printer, then wait until it's selected and not busy.
+ * If LP_BYPASS flag is selected, then we do not try to select the
+ * printer -- this is just used for passing ioctls.
*/
int
@@ -434,8 +436,15 @@ lptopen(dev_t dev, int flag)
return(EBUSY);
} else sc->sc_state |= INIT;
- s = spltty();
sc->sc_flags = LPTFLAGS(minor(dev));
+
+ /* Check for open with BYPASS flag set. */
+ if(sc->sc_flags & LP_BYPASS) {
+ sc->sc_state = OPEN;
+ return(0);
+ }
+
+ s = spltty();
lprintf("lp flags 0x%x\n", sc->sc_flags);
port = sc->sc_port;
@@ -540,6 +549,9 @@ lptclose(dev_t dev, int flag)
struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev));
int port = sc->sc_port;
+ if(sc->sc_flags & LP_BYPASS)
+ goto end_close;
+
sc->sc_state &= ~OPEN;
/* if the last write was interrupted, don't complete it */
@@ -551,10 +563,11 @@ lptclose(dev_t dev, int flag)
"lpclose", hz) != EWOULDBLOCK)
break;
- sc->sc_state = 0;
- sc->sc_xfercnt = 0;
outb(sc->sc_port+lpt_control, LPC_NINIT);
brelse(sc->sc_inbuf);
+end_close:
+ sc->sc_state = 0;
+ sc->sc_xfercnt = 0;
lprintf("closed.\n");
return(0);
}
@@ -634,6 +647,11 @@ lptwrite(dev_t dev, struct uio * uio)
int pl, err;
struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev));
+ if(sc->sc_flags & LP_BYPASS) {
+ /* we can't do writes in bypass mode */
+ return(EPERM);
+ }
+
sc->sc_state &= ~INTERRUPTED;
while (n = min(BUFSIZE, uio->uio_resid)) {
sc->sc_cp = sc->sc_inbuf->b_un.b_addr ;
OpenPOWER on IntegriCloud