summaryrefslogtreecommitdiff
path: root/sys/dev/ppbus
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ppbus')
-rw-r--r--sys/dev/ppbus/if_plip.c24
-rw-r--r--sys/dev/ppbus/immio.c24
-rw-r--r--sys/dev/ppbus/lpbb.c319
-rw-r--r--sys/dev/ppbus/nlpt.c171
-rw-r--r--sys/dev/ppbus/nlpt.h6
-rw-r--r--sys/dev/ppbus/ppb_1284.c777
-rw-r--r--sys/dev/ppbus/ppb_1284.h61
-rw-r--r--sys/dev/ppbus/ppb_base.c49
-rw-r--r--sys/dev/ppbus/ppb_msq.c22
-rw-r--r--sys/dev/ppbus/ppb_msq.h4
-rw-r--r--sys/dev/ppbus/ppbconf.c216
-rw-r--r--sys/dev/ppbus/ppbconf.h37
-rw-r--r--sys/dev/ppbus/ppi.c324
-rw-r--r--sys/dev/ppbus/pps.c5
-rw-r--r--sys/dev/ppbus/vpo.c15
-rw-r--r--sys/dev/ppbus/vpoio.c23
16 files changed, 255 insertions, 1822 deletions
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index 7d64cd24fef6..4bee255fd5a6 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*
* From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
- * $Id: if_plip.c,v 1.6 1998/11/07 14:35:41 nsouch Exp $
+ * $Id: if_plip.c,v 1.3 1998/08/17 01:05:23 bde Exp $
*/
/*
@@ -129,9 +129,7 @@
#define LPIPTBLSIZE 256 /* Size of octet translation table */
-#ifndef DEBUG
#define DEBUG
-#endif
#ifndef DEBUG
#define lprintf (void)
@@ -336,16 +334,17 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
}
if (((ifp->if_flags & IFF_UP)) && (!(ifp->if_flags & IFF_RUNNING))) {
- /* XXX
+ /*
+ * Try to allocate the ppbus as soon as possible
+ * With ppbus allocation, interrupts are enabled
+ * Now IFF_UP means that we own the bus
+ *
+ * XXX
* Should the request be interruptible?
*/
if ((error = ppb_request_bus(&sc->lp_dev, PPB_WAIT|PPB_INTR)))
return (error);
- /* Now IFF_UP means that we own the bus */
-
- ppb_set_mode(&sc->lp_dev, PPB_COMPATIBLE);
-
if (lpinittables()) {
ppb_release_bus(&sc->lp_dev);
return ENOBUFS;
@@ -394,13 +393,6 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
}
break;
- case SIOCGIFMEDIA:
- /*
- * No ifmedia support at this stage; maybe use it
- * in future for eg. protocol selection.
- */
- return EINVAL;
-
default:
lprintf("LP:ioctl(0x%lx)\n", cmd);
return EINVAL;
@@ -427,7 +419,7 @@ clpoutbyte (u_char byte, int spin, struct ppb_device *dev)
static __inline int
clpinbyte (int spin, struct ppb_device *dev)
{
- u_char c, cl;
+ int c, cl;
while((ppb_rstr(dev) & CLPIP_SHAKE))
if(!--spin) {
diff --git a/sys/dev/ppbus/immio.c b/sys/dev/ppbus/immio.c
index 67054f79bea2..630707cb0ad0 100644
--- a/sys/dev/ppbus/immio.c
+++ b/sys/dev/ppbus/immio.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: immio.c,v 1.4 1998/10/31 11:35:21 nsouch Exp $
+ * $Id: immio.c,v 1.2 1998/09/20 14:41:54 nsouch Exp $
*
*/
@@ -47,8 +47,6 @@
#include <sys/kernel.h>
#endif /*KERNEL */
-#include "opt_vpo.h"
-
#include <dev/ppbus/ppbconf.h>
#include <dev/ppbus/ppb_msq.h>
#include <dev/ppbus/vpoio.h>
@@ -288,13 +286,9 @@ imm_disconnect(struct vpoio_data *vpo, int *connected, int release_bus)
ppb_MS_microseq(&vpo->vpo_dev, cpp_microseq, &ret);
- if ((s1 != (char)0xb8 || s2 != (char)0x18 || s3 != (char)0x38)) {
- if (bootverbose)
- printf("imm%d: (disconnect) s1=0x%x s2=0x%x, s3=0x%x\n",
- vpo->vpo_unit, s1 & 0xff, s2 & 0xff, s3 & 0xff);
- if (connected)
- *connected = VP0_ECONNECT;
- }
+ if ((s1 != (char)0xb8 || s2 != (char)0x18 || s3 != (char)0x38) &&
+ connected)
+ *connected = VP0_ECONNECT;
if (release_bus)
return (ppb_release_bus(&vpo->vpo_dev));
@@ -340,13 +334,9 @@ imm_connect(struct vpoio_data *vpo, int how, int *disconnected, int request_bus)
ppb_MS_microseq(&vpo->vpo_dev, cpp_microseq, &ret);
- if ((s1 != (char)0xb8 || s2 != (char)0x18 || s3 != (char)0x30)) {
- if (bootverbose)
- printf("imm%d: (connect) s1=0x%x s2=0x%x, s3=0x%x\n",
- vpo->vpo_unit, s1 & 0xff, s2 & 0xff, s3 & 0xff);
- if (disconnected)
- *disconnected = VP0_ECONNECT;
- }
+ if ((s1 != (char)0xb8 || s2 != (char)0x18 || s3 != (char)0x30)
+ && disconnected)
+ *disconnected = VP0_ECONNECT;
return (0);
}
diff --git a/sys/dev/ppbus/lpbb.c b/sys/dev/ppbus/lpbb.c
deleted file mode 100644
index cd8ff244a0c6..000000000000
--- a/sys/dev/ppbus/lpbb.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*-
- * Copyright (c) 1998 Nicolas Souchu, Marc Bouget
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: lpbb.c,v 1.3 1998/12/07 21:58:16 archie Exp $
- *
- */
-
-/*
- * I2C Bit-Banging over parallel port
- *
- * See the Official Philips interface description in lpbb(4)
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/buf.h>
-#include <sys/uio.h>
-#include <sys/malloc.h>
-
-#include <machine/clock.h>
-
-#include <dev/ppbus/ppbconf.h>
-
-#include <dev/iicbus/iiconf.h>
-#include <dev/iicbus/iicbus.h>
-
-#include "iicbb_if.h"
-
-/* iicbus softc */
-struct lpbb_softc {
-
- struct ppb_device lpbb_dev;
-};
-
-static int lpbb_detect(struct lpbb_softc *);
-
-static int lpbb_probe(device_t);
-static int lpbb_attach(device_t);
-static void lpbb_print_child(device_t, device_t);
-
-static int lpbb_callback(device_t, int, caddr_t *);
-static void lpbb_setlines(device_t, int, int);
-static int lpbb_getdataline(device_t);
-static int lpbb_reset(device_t, u_char, u_char, u_char *);
-
-static devclass_t lpbb_devclass;
-
-static device_method_t lpbb_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, lpbb_probe),
- DEVMETHOD(device_attach, lpbb_attach),
-
- /* bus interface */
- DEVMETHOD(bus_print_child, lpbb_print_child),
-
- /* iicbb interface */
- DEVMETHOD(iicbb_callback, lpbb_callback),
- DEVMETHOD(iicbb_setlines, lpbb_setlines),
- DEVMETHOD(iicbb_getdataline, lpbb_getdataline),
- DEVMETHOD(iicbb_reset, lpbb_reset),
-
- { 0, 0 }
-};
-
-static driver_t lpbb_driver = {
- "lpbb",
- lpbb_methods,
- DRIVER_TYPE_MISC,
- sizeof(struct lpbb_softc),
-};
-
-/*
- * Make ourselves visible as a ppbus driver
- */
-static struct ppb_device *lpbb_ppb_probe(struct ppb_data *ppb);
-static int lpbb_ppb_attach(struct ppb_device *dev);
-
-#define MAXLPBB 8 /* XXX not much better! */
-static struct lpbb_softc *lpbbdata[MAXLPBB];
-static int nlpbb = 0;
-
-#ifdef KERNEL
-
-static struct ppb_driver lpbbdriver = {
- lpbb_ppb_probe, lpbb_ppb_attach, "lpbb"
-};
-DATA_SET(ppbdriver_set, lpbbdriver);
-
-#endif /* KERNEL */
-
-static int
-lpbb_probe(device_t dev)
-{
- struct lpbb_softc *sc = lpbbdata[device_get_unit(dev)];
- struct lpbb_softc *scdst = (struct lpbb_softc *)device_get_softc(dev);
-
- /* XXX copy softc. Yet, ppbus device is sc->lpbb_dev, but will be
- * dev->parent when ppbus will be ported to the new bus architecture */
- bcopy(sc, scdst, sizeof(struct lpbb_softc));
-
- device_set_desc(dev, "parallel I2C bit-banging interface");
-
- /* probe done by ppbus initialization */
- return (0);
-}
-
-static int
-lpbb_attach(device_t dev)
-{
- device_t bitbang, iicbus;
-
- /* add generic bit-banging code */
- bitbang = device_add_child(dev, "iicbb", -1, NULL);
-
- /* add the iicbus to the tree */
- iicbus = iicbus_alloc_bus(bitbang);
-
- device_probe_and_attach(bitbang);
-
- /* XXX should be in iicbb_attach! */
- device_probe_and_attach(iicbus);
-
- return (0);
-}
-
-/*
- * lppbb_ppb_probe()
- */
-static struct ppb_device *
-lpbb_ppb_probe(struct ppb_data *ppb)
-{
- struct lpbb_softc *sc;
-
- sc = (struct lpbb_softc *) malloc(sizeof(struct lpbb_softc),
- M_TEMP, M_NOWAIT);
- if (!sc) {
- printf("lpbb: cannot malloc!\n");
- return (0);
- }
- bzero(sc, sizeof(struct lpbb_softc));
-
- lpbbdata[nlpbb] = sc;
-
- /*
- * ppbus dependent initialisation.
- */
- sc->lpbb_dev.id_unit = nlpbb;
- sc->lpbb_dev.name = lpbbdriver.name;
- sc->lpbb_dev.ppb = ppb;
- sc->lpbb_dev.intr = 0;
-
- if (!lpbb_detect(sc)) {
- free(sc, M_TEMP);
- return (NULL);
- }
-
- /* Ok, go to next device on next probe */
- nlpbb ++;
-
- /* XXX wrong according to new bus architecture. ppbus needs to be
- * ported
- */
- return (&sc->lpbb_dev);
-}
-
-static int
-lpbb_ppb_attach(struct ppb_device *dev)
-{
- /* add the parallel port I2C interface to the bus tree */
- if (!device_add_child(root_bus, "lpbb", dev->id_unit, NULL))
- return (0);
-
- return (1);
-}
-
-static int
-lpbb_callback(device_t dev, int index, caddr_t *data)
-{
- struct lpbb_softc *sc = (struct lpbb_softc *)device_get_softc(dev);
- int error = 0;
- int how;
-
- switch (index) {
- case IIC_REQUEST_BUS:
- /* request the ppbus */
- how = *(int *)data;
- error = ppb_request_bus(&sc->lpbb_dev, how);
- break;
-
- case IIC_RELEASE_BUS:
- /* release the ppbus */
- error = ppb_release_bus(&sc->lpbb_dev);
- break;
-
- default:
- error = EINVAL;
- }
-
- return (error);
-}
-
-#define SDA_out 0x80
-#define SCL_out 0x08
-#define SDA_in 0x80
-#define SCL_in 0x08
-#define ALIM 0x20
-#define I2CKEY 0x50
-
-static int getSDA(struct lpbb_softc *sc)
-{
-if((ppb_rstr(&sc->lpbb_dev)&SDA_in)==SDA_in)
- return 1;
-else
- return 0;
-}
-
-static void setSDA(struct lpbb_softc *sc, char val)
-{
-if(val==0)
- ppb_wdtr(&sc->lpbb_dev, (u_char)SDA_out);
-else
- ppb_wdtr(&sc->lpbb_dev, (u_char)~SDA_out);
-}
-
-static void setSCL(struct lpbb_softc *sc, unsigned char val)
-{
-if(val==0)
- ppb_wctr(&sc->lpbb_dev, (u_char)(ppb_rctr(&sc->lpbb_dev)&~SCL_out));
-else
- ppb_wctr(&sc->lpbb_dev, (u_char)(ppb_rctr(&sc->lpbb_dev)|SCL_out));
-}
-
-static int lpbb_detect(struct lpbb_softc *sc)
-{
- if (ppb_request_bus(&sc->lpbb_dev, PPB_DONTWAIT)) {
- printf("lpbb: can't allocate ppbus\n");
- return (0);
- }
-
- /* reset bus */
- setSDA(sc, 1);
- setSCL(sc, 1);
-
- if ((ppb_rstr(&sc->lpbb_dev) & I2CKEY) ||
- ((ppb_rstr(&sc->lpbb_dev) & ALIM) != ALIM)) {
-
- ppb_release_bus(&sc->lpbb_dev);
- return (0);
- }
-
- ppb_release_bus(&sc->lpbb_dev);
-
- return (1);
-}
-
-static int
-lpbb_reset(device_t dev, u_char speed, u_char addr, u_char * oldaddr)
-{
- struct lpbb_softc *sc = (struct lpbb_softc *)device_get_softc(dev);
-
- /* reset bus */
- setSDA(sc, 1);
- setSCL(sc, 1);
-
- return (IIC_ENOADDR);
-}
-
-static void
-lpbb_setlines(device_t dev, int ctrl, int data)
-{
- struct lpbb_softc *sc = (struct lpbb_softc *)device_get_softc(dev);
-
- setSCL(sc, ctrl);
- setSDA(sc, data);
-}
-
-static int
-lpbb_getdataline(device_t dev)
-{
- struct lpbb_softc *sc = (struct lpbb_softc *)device_get_softc(dev);
-
- return (getSDA(sc));
-}
-
-static void
-lpbb_print_child(device_t bus, device_t dev)
-{
- printf(" on %s%d", device_get_name(bus), device_get_unit(bus));
-
- return;
-}
-
-DRIVER_MODULE(lpbb, root, lpbb_driver, lpbb_devclass, 0, 0);
diff --git a/sys/dev/ppbus/nlpt.c b/sys/dev/ppbus/nlpt.c
index 89d6c7f5a5a3..2a48eb4a2b76 100644
--- a/sys/dev/ppbus/nlpt.c
+++ b/sys/dev/ppbus/nlpt.c
@@ -47,7 +47,7 @@
*
* from: unknown origin, 386BSD 0.1
* From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
- * $Id: nlpt.c,v 1.11 1998/12/04 22:00:33 archie Exp $
+ * $Id: nlpt.c,v 1.9 1998/08/03 19:14:31 msmith Exp $
*/
/*
@@ -81,19 +81,12 @@
#endif /*KERNEL*/
#include <dev/ppbus/ppbconf.h>
-#include <dev/ppbus/ppb_1284.h>
#include <dev/ppbus/nlpt.h>
-#include "opt_nlpt.h"
-
#ifndef NLPT_DEBUG
-#define nlprintf(args)
+#define nlprintf (void)
#else
-#define nlprintf(args) \
- do { \
- if (nlptflag) \
- printf args; \
- } while (0)
+#define nlprintf if (nlptflag) printf
static int volatile nlptflag = 1;
#endif
@@ -102,7 +95,6 @@ static int volatile nlptflag = 1;
#define LPTOUTMAX 1 /* maximal timeout 1 s */
#define LPPRI (PZERO+8)
#define BUFSIZE 1024
-#define BUFSTATSIZE 32
#define LPTUNIT(s) ((s)&0x03)
#define LPTFLAGS(s) ((s)&0xfc)
@@ -167,12 +159,11 @@ DATA_SET(ppbdriver_set, nlptdriver);
static d_open_t nlptopen;
static d_close_t nlptclose;
static d_write_t nlptwrite;
-static d_read_t nlptread;
static d_ioctl_t nlptioctl;
#define CDEV_MAJOR 16
static struct cdevsw nlpt_cdevsw =
- { nlptopen, nlptclose, nlptread, nlptwrite, /*16*/
+ { nlptopen, nlptclose, noread, nlptwrite, /*16*/
nlptioctl, nullstop, nullreset, nodevtotty, /* lpt */
seltrue, nommap, nostrat, LPT_NAME, NULL, -1 };
@@ -181,9 +172,6 @@ lpt_request_ppbus(struct lpt_data *sc, int how)
{
int error;
- if (sc->sc_state & HAVEBUS)
- return (0);
-
/* we have the bus only if the request succeded */
if ((error = ppb_request_bus(&sc->lpt_dev, how)) == 0)
sc->sc_state |= HAVEBUS;
@@ -194,10 +182,13 @@ lpt_request_ppbus(struct lpt_data *sc, int how)
static int
lpt_release_ppbus(struct lpt_data *sc)
{
- ppb_release_bus(&sc->lpt_dev);
- sc->sc_state &= ~HAVEBUS;
+ int error;
+
+ /* we do not have the bus only if the request succeeded */
+ if ((error = ppb_release_bus(&sc->lpt_dev)) == 0)
+ sc->sc_state &= ~HAVEBUS;
- return (0);
+ return (error);
}
/*
@@ -216,7 +207,7 @@ nlpt_port_test(struct lpt_data *sc, u_char data, u_char mask)
temp = ppb_rdtr(&sc->lpt_dev) & mask;
}
while (temp != data && --timeout);
- nlprintf(("out=%x\tin=%x\ttout=%d\n", data, temp, timeout));
+ nlprintf("out=%x\tin=%x\ttout=%d\n", data, temp, timeout);
return (temp == data);
}
@@ -377,15 +368,15 @@ nlptattach(struct ppb_device *dev)
ppb_wctr(&sc->lpt_dev, LPC_NINIT);
/* check if we can use interrupt, should be done by ppc stuff */
- nlprintf(("oldirq %x\n", sc->sc_irq));
+ nlprintf("oldirq %x\n", sc->sc_irq);
if (ppb_get_irq(&sc->lpt_dev)) {
sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ;
printf(LPT_NAME "%d: Interrupt-driven port\n", dev->id_unit);
} else {
sc->sc_irq = 0;
- nlprintf((LPT_NAME "%d: Polled port\n", dev->id_unit));
+ nlprintf(LPT_NAME "%d: Polled port\n", dev->id_unit);
}
- nlprintf(("irq %x\n", sc->sc_irq));
+ nlprintf("irq %x\n", sc->sc_irq);
lpt_release_ppbus(sc);
@@ -407,7 +398,7 @@ nlptout(void *arg)
struct lpt_data *sc = arg;
int pl;
- nlprintf(("T %x ", ppb_rstr(&sc->lpt_dev)));
+ nlprintf ("T %x ", ppb_rstr(&sc->lpt_dev));
if (sc->sc_state & OPEN) {
sc->sc_backoff++;
if (sc->sc_backoff > hz/LPTOUTMAX)
@@ -444,7 +435,7 @@ nlptopen(dev_t dev, int flags, int fmt, struct proc *p)
struct lpt_data *sc;
int s;
- int trys, err;
+ int trys;
u_int unit = LPTUNIT(minor(dev));
if ((unit >= nlpt))
@@ -453,7 +444,7 @@ nlptopen(dev_t dev, int flags, int fmt, struct proc *p)
sc = lptdata[unit];
if (sc->sc_state) {
- nlprintf((LPT_NAME ": still open %x\n", sc->sc_state));
+ nlprintf(LPT_NAME ": still open %x\n", sc->sc_state);
return(EBUSY);
} else
sc->sc_state |= LPTINIT;
@@ -467,11 +458,12 @@ nlptopen(dev_t dev, int flags, int fmt, struct proc *p)
}
/* request the ppbus only if we don't have it already */
- if (err = lpt_request_ppbus(sc, PPB_WAIT|PPB_INTR))
- return (err);
+ if ((sc->sc_state & HAVEBUS) == 0 &&
+ lpt_request_ppbus(sc, PPB_WAIT|PPB_INTR))
+ return (EINTR);
s = spltty();
- nlprintf((LPT_NAME " flags 0x%x\n", sc->sc_flags));
+ nlprintf(LPT_NAME " flags 0x%x\n", sc->sc_flags);
/* set IRQ status according to ENABLE_IRQ flag */
if (sc->sc_irq & LP_ENABLE_IRQ)
@@ -497,7 +489,7 @@ nlptopen(dev_t dev, int flags, int fmt, struct proc *p)
if (trys++ >= LPINITRDY*4) {
splx(s);
sc->sc_state = 0;
- nlprintf(("status %x\n", ppb_rstr(&sc->lpt_dev)));
+ nlprintf ("status %x\n", ppb_rstr(&sc->lpt_dev) );
lpt_release_ppbus(sc);
return (EBUSY);
@@ -530,7 +522,6 @@ nlptopen(dev_t dev, int flags, int fmt, struct proc *p)
sc->sc_state = OPEN;
sc->sc_inbuf = geteblk(BUFSIZE);
- sc->sc_statbuf = geteblk(BUFSTATSIZE);
sc->sc_xfercnt = 0;
splx(s);
@@ -538,14 +529,14 @@ nlptopen(dev_t dev, int flags, int fmt, struct proc *p)
lpt_release_ppbus(sc);
/* only use timeout if using interrupt */
- nlprintf(("irq %x\n", sc->sc_irq));
+ nlprintf("irq %x\n", sc->sc_irq);
if (sc->sc_irq & LP_USE_IRQ) {
sc->sc_state |= TOUT;
timeout(nlptout, (caddr_t)sc,
(sc->sc_backoff = hz/LPTOUTINITIAL));
}
- nlprintf(("opened.\n"));
+ nlprintf("opened.\n");
return(0);
}
@@ -564,7 +555,8 @@ nlptclose(dev_t dev, int flags, int fmt, struct proc *p)
if(sc->sc_flags & LP_BYPASS)
goto end_close;
- if (err = lpt_request_ppbus(sc, PPB_WAIT|PPB_INTR))
+ if ((sc->sc_state & HAVEBUS) == 0 &&
+ (err = lpt_request_ppbus(sc, PPB_WAIT|PPB_INTR)))
return (err);
sc->sc_state &= ~OPEN;
@@ -581,7 +573,6 @@ nlptclose(dev_t dev, int flags, int fmt, struct proc *p)
ppb_wctr(&sc->lpt_dev, LPC_NINIT);
brelse(sc->sc_inbuf);
- brelse(sc->sc_statbuf);
end_close:
/* release the bus anyway */
@@ -589,7 +580,7 @@ end_close:
sc->sc_state = 0;
sc->sc_xfercnt = 0;
- nlprintf(("closed.\n"));
+ nlprintf("closed.\n");
return(0);
}
@@ -607,7 +598,7 @@ nlpt_pushbytes(struct lpt_data *sc)
int spin, err, tic;
char ch;
- nlprintf(("p"));
+ nlprintf("p");
/* loop for every character .. */
while (sc->sc_xfercnt > 0) {
/* printer data */
@@ -654,40 +645,6 @@ nlpt_pushbytes(struct lpt_data *sc)
}
/*
- * nlptread --retrieve printer status in IEEE1284 NIBBLE mode
- */
-
-static int
-nlptread(dev_t dev, struct uio *uio, int ioflag)
-{
- struct lpt_data *sc = lptdata[LPTUNIT(minor(dev))];
- int error = 0, len;
-
- if ((error = ppb_1284_negociate(&sc->lpt_dev, PPB_NIBBLE, 0)))
- return (error);
-
- /* read data in an other buffer, read/write may be simultaneous */
- len = 0;
- while (uio->uio_resid) {
- if ((error = ppb_1284_read(&sc->lpt_dev, PPB_NIBBLE,
- sc->sc_statbuf->b_data, min(BUFSTATSIZE,
- uio->uio_resid), &len))) {
- goto error;
- }
-
- if (!len)
- goto error; /* no more data */
-
- if ((error = uiomove(sc->sc_statbuf->b_data, len, uio)))
- goto error;
- }
-
-error:
- ppb_1284_terminate(&sc->lpt_dev);
- return (error);
-}
-
-/*
* nlptwrite --copy a line from user space to a local buffer, then call
* putc to get the chars moved to the output queue.
*
@@ -699,7 +656,6 @@ nlptwrite(dev_t dev, struct uio *uio, int ioflag)
{
register unsigned n;
int pl, err;
- u_int unit = LPTUNIT(minor(dev));
struct lpt_data *sc = lptdata[LPTUNIT(minor(dev))];
if(sc->sc_flags & LP_BYPASS) {
@@ -708,46 +664,26 @@ nlptwrite(dev_t dev, struct uio *uio, int ioflag)
}
/* request the ppbus only if we don't have it already */
- if (err = lpt_request_ppbus(sc, PPB_WAIT|PPB_INTR))
- return (err);
+ if ((sc->sc_state & HAVEBUS) == 0 &&
+ lpt_request_ppbus(sc, PPB_WAIT|PPB_INTR))
+ return (EINTR);
sc->sc_state &= ~INTERRUPTED;
while ((n = min(BUFSIZE, uio->uio_resid)) != 0) {
sc->sc_cp = sc->sc_inbuf->b_data ;
uiomove(sc->sc_cp, n, uio);
sc->sc_xfercnt = n ;
-
- if (sc->sc_irq & LP_ENABLE_EXT) {
- /* try any extended mode */
- err = ppb_write(&sc->lpt_dev, sc->sc_cp,
- sc->sc_xfercnt, 0);
- switch (err) {
- case 0:
- /* if not all data was sent, we could rely
- * on polling for the last bytes */
- sc->sc_xfercnt = 0;
- break;
- case EINTR:
- sc->sc_state |= INTERRUPTED;
- return(err);
- case EINVAL:
- /* advanced mode not avail */
- log(LOG_NOTICE, LPT_NAME "%d: advanced mode not avail, polling\n", unit);
- break;
- default:
- return(err);
- }
- } else while ((sc->sc_xfercnt > 0)&&(sc->sc_irq & LP_USE_IRQ)) {
- nlprintf(("i"));
+ while ((sc->sc_xfercnt > 0)&&(sc->sc_irq & LP_USE_IRQ)) {
+ nlprintf("i");
/* if the printer is ready for a char, */
/* give it one */
if ((sc->sc_state & OBUSY) == 0){
- nlprintf(("\nC %d. ", sc->sc_xfercnt));
+ nlprintf("\nC %d. ", sc->sc_xfercnt);
pl = spltty();
nlpt_intr(sc->lpt_unit);
(void) splx(pl);
}
- nlprintf(("W "));
+ nlprintf("W ");
if (sc->sc_state & OBUSY)
if ((err = tsleep((caddr_t)sc,
LPPRI|PCATCH, LPT_NAME "write", 0))) {
@@ -755,10 +691,9 @@ nlptwrite(dev_t dev, struct uio *uio, int ioflag)
return(err);
}
}
-
/* check to see if we must do a polled write */
if(!(sc->sc_irq & LP_USE_IRQ) && (sc->sc_xfercnt)) {
- nlprintf(("p"));
+ nlprintf("p");
err = nlpt_pushbytes(sc);
@@ -806,7 +741,7 @@ nlpt_intr(int unit)
if (sc->sc_xfercnt) {
/* send char */
- /*nlprintf(("%x ", *sc->sc_cp)); */
+ /*nlprintf("%x ", *sc->sc_cp); */
ppb_wdtr(&sc->lpt_dev, *sc->sc_cp++) ;
ppb_wctr(&sc->lpt_dev, sc->sc_control|LPC_STB);
/* DELAY(X) */
@@ -824,7 +759,7 @@ nlpt_intr(int unit)
if(!(sc->sc_state & INTERRUPTED))
wakeup((caddr_t)sc);
- nlprintf(("w "));
+ nlprintf("w ");
return;
} else { /* check for error */
if(((sts & (LPS_NERR | LPS_OUT) ) != LPS_NERR) &&
@@ -832,7 +767,7 @@ nlpt_intr(int unit)
sc->sc_state |= EERROR;
/* nlptout() will jump in and try to restart. */
}
- nlprintf(("sts %x ", sts));
+ nlprintf("sts %x ", sts);
}
static void
@@ -870,35 +805,15 @@ nlptioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
* this gets syslog'd.
*/
old_sc_irq = sc->sc_irq;
- switch(*(int*)data) {
- case 0:
+ if(*(int*)data == 0)
sc->sc_irq &= (~LP_ENABLE_IRQ);
- break;
- case 1:
- sc->sc_irq &= (~LP_ENABLE_EXT);
+ else
sc->sc_irq |= LP_ENABLE_IRQ;
- break;
- case 2:
- /* classic irq based transfer and advanced
- * modes are in conflict
- */
- sc->sc_irq &= (~LP_ENABLE_IRQ);
- sc->sc_irq |= LP_ENABLE_EXT;
- break;
- case 3:
- sc->sc_irq &= (~LP_ENABLE_EXT);
- break;
- default:
- break;
- }
-
if (old_sc_irq != sc->sc_irq )
- log(LOG_NOTICE, LPT_NAME "%d: switched to %s %s mode\n",
+ log(LOG_NOTICE, LPT_NAME "%d: switched to %s mode\n",
unit,
(sc->sc_irq & LP_ENABLE_IRQ)?
- "interrupt-driven":"polled",
- (sc->sc_irq & LP_ENABLE_EXT)?
- "extended":"standard");
+ "interrupt-driven":"polled");
} else /* polled port */
error = EOPNOTSUPP;
break;
diff --git a/sys/dev/ppbus/nlpt.h b/sys/dev/ppbus/nlpt.h
index 31292b9f7ed7..b0b3df6457a7 100644
--- a/sys/dev/ppbus/nlpt.h
+++ b/sys/dev/ppbus/nlpt.h
@@ -27,7 +27,7 @@
* @(#)lptreg.h 1.1 (Berkeley) 12/19/90
* Id: lptreg.h,v 1.6 1997/02/22 09:36:52 peter Exp
*
- * $Id: nlpt.h,v 1.2 1997/08/16 14:05:32 msmith Exp $
+ * $Id: nlpt.h,v 1.1 1997/08/14 13:57:40 msmith Exp $
*/
#ifndef __NLPT_H
#define __NLPT_H
@@ -61,15 +61,13 @@ struct lpt_data {
#define LP_AUTOLF 0x40 /* tell printer to do an automatic lf */
#define LP_BYPASS 0x80 /* bypass printer ready checks */
struct buf *sc_inbuf;
- struct buf *sc_statbuf;
short sc_xfercnt ;
char sc_primed;
char *sc_cp ;
- u_short sc_irq ; /* IRQ status of port */
+ u_char sc_irq ; /* IRQ status of port */
#define LP_HAS_IRQ 0x01 /* we have an irq available */
#define LP_USE_IRQ 0x02 /* we are using our irq */
#define LP_ENABLE_IRQ 0x04 /* enable IRQ on open */
-#define LP_ENABLE_EXT 0x10 /* we shall use advanced mode when possible */
u_char sc_backoff ; /* time to call lptout() again */
#ifdef DEVFS
diff --git a/sys/dev/ppbus/ppb_1284.c b/sys/dev/ppbus/ppb_1284.c
index 5da5fa3eac3a..56524d1052e7 100644
--- a/sys/dev/ppbus/ppb_1284.c
+++ b/sys/dev/ppbus/ppb_1284.c
@@ -23,15 +23,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_1284.c,v 1.7 1999/01/10 12:04:54 nsouch Exp $
+ * $Id: ppb_1284.c,v 1.5 1998/09/13 18:26:26 nsouch Exp $
*
*/
-/*
- * General purpose routines for the IEEE1284-1994 Standard
- */
-
-#include "opt_ppb_1284.h"
+#include "opt_debug_1284.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -46,414 +42,24 @@
*
* Wait for the peripherial up to 40ms
*/
-static int
-do_1284_wait(struct ppb_device *dev, char mask, char status)
-{
- return (ppb_poll_device(dev, 4, mask, status, PPB_NOINTR | PPB_POLL));
-}
-
-static int
-do_peripheral_wait(struct ppb_device *dev, char mask, char status)
-{
- return (ppb_poll_device(dev, 100, mask, status, PPB_NOINTR | PPB_POLL));
-}
-
-#define nibble2char(s) (((s & ~nACK) >> 3) | (~s & nBUSY) >> 4)
-
-/*
- * ppb_1284_reset_error()
- *
- * Unconditionaly reset the error field
- */
-static int
-ppb_1284_reset_error(struct ppb_device *dev, int state)
-{
- dev->ppb->error = PPB_NO_ERROR;
- dev->ppb->state = state;
-
- return (0);
-}
-
-/*
- * ppb_1284_get_state()
- *
- * Get IEEE1284 state
- */
-static int
-ppb_1284_get_state(struct ppb_device *dev)
-{
- return (dev->ppb->state);
-}
-
-/*
- * ppb_1284_set_state()
- *
- * Change IEEE1284 state if no error occured
- */
-static int
-ppb_1284_set_state(struct ppb_device *dev, int state)
-{
- /* call ppb_1284_reset_error() if you absolutly want to change
- * the state from PPB_ERROR to another */
- if ((dev->ppb->state != PPB_ERROR) &&
- (dev->ppb->error == PPB_NO_ERROR)) {
- dev->ppb->state = state;
- dev->ppb->error = PPB_NO_ERROR;
- }
-
- return (0);
-}
-
-static int
-ppb_1284_set_error(struct ppb_device *dev, int error, int event)
-{
- /* do not accumulate errors */
- if ((dev->ppb->error == PPB_NO_ERROR) &&
- (dev->ppb->state != PPB_ERROR)) {
- dev->ppb->error = error;
- dev->ppb->state = PPB_ERROR;
- }
-
-#ifdef DEBUG_1284
- printf("ppb1284: error=%d status=0x%x event=%d\n", error,
- ppb_rstr(dev) & 0xff, event);
-#endif
-
- return (0);
-}
-
-/*
- * ppb_request_mode()
- *
- * Converts mode+options into ext. value
- */
-static int
-ppb_request_mode(int mode, int options)
-{
- int request_mode = 0;
-
- if (options & PPB_EXTENSIBILITY_LINK) {
- request_mode = EXT_LINK_1284_NORMAL;
-
- } else {
- switch (mode) {
- case PPB_NIBBLE:
- request_mode = (options & PPB_REQUEST_ID) ?
- NIBBLE_1284_REQUEST_ID :
- NIBBLE_1284_NORMAL;
- break;
- case PPB_PS2:
- request_mode = (options & PPB_REQUEST_ID) ?
- BYTE_1284_REQUEST_ID :
- BYTE_1284_NORMAL;
- break;
- case PPB_ECP:
- if (options & PPB_USE_RLE)
- request_mode = (options & PPB_REQUEST_ID) ?
- ECP_1284_RLE_REQUEST_ID :
- ECP_1284_RLE;
- else
- request_mode = (options & PPB_REQUEST_ID) ?
- ECP_1284_REQUEST_ID :
- ECP_1284_NORMAL;
- break;
- case PPB_EPP:
- request_mode = EPP_1284_NORMAL;
- break;
- default:
- panic("%s: unsupported mode %d\n", __FUNCTION__, mode);
- }
- }
-
- return (request_mode);
-}
-
-/*
- * ppb_peripheral_negociate()
- *
- * Negociate the peripheral side
- */
int
-ppb_peripheral_negociate(struct ppb_device *dev, int mode, int options)
-{
- int spin, request_mode, error = 0;
- char r;
-
- ppb_set_mode(dev, PPB_COMPATIBLE);
- ppb_1284_set_state(dev, PPB_PERIPHERAL_NEGOCIATION);
-
- /* compute ext. value */
- request_mode = ppb_request_mode(mode, options);
-
- /* wait host */
- spin = 10;
- while (spin-- && (ppb_rstr(dev) & nBUSY))
- DELAY(1);
-
- /* check termination */
- if (!(ppb_rstr(dev) & SELECT) || !spin) {
- error = ENODEV;
- goto error;
- }
-
- /* Event 4 - read ext. value */
- r = ppb_rdtr(dev);
-
- /* nibble mode is not supported */
- if ((r == (char)request_mode) ||
- (r == NIBBLE_1284_NORMAL)) {
-
- /* Event 5 - restore direction bit, no data avail */
- ppb_wctr(dev, (STROBE | nINIT) & ~(SELECTIN));
- DELAY(1);
-
- /* Event 6 */
- ppb_wctr(dev, (nINIT) & ~(SELECTIN | STROBE));
-
- if (r == NIBBLE_1284_NORMAL) {
-#ifdef DEBUG_1284
- printf("R");
-#endif
- ppb_1284_set_error(dev, PPB_MODE_UNSUPPORTED, 4);
- error = EINVAL;
- goto error;
- } else {
- ppb_1284_set_state(dev, PPB_PERIPHERAL_IDLE);
- switch (r) {
- case BYTE_1284_NORMAL:
- ppb_set_mode(dev, PPB_BYTE);
- break;
- default:
- break;
- }
-#ifdef DEBUG_1284
- printf("A");
-#endif
- /* negociation succeeds */
- }
- } else {
- /* Event 5 - mode not supported */
- ppb_wctr(dev, SELECTIN);
- DELAY(1);
-
- /* Event 6 */
- ppb_wctr(dev, (SELECTIN) & ~(STROBE | nINIT));
- ppb_1284_set_error(dev, PPB_MODE_UNSUPPORTED, 4);
-
-#ifdef DEBUG_1284
- printf("r");
-#endif
- error = EINVAL;
- goto error;
- }
-
- return (0);
-
-error:
- ppb_peripheral_terminate(dev, PPB_WAIT);
- return (error);
-}
-
-/*
- * ppb_peripheral_terminate()
- *
- * Terminate peripheral transfer side
- *
- * Always return 0 in compatible mode
- */
-int
-ppb_peripheral_terminate(struct ppb_device *dev, int how)
-{
- int error = 0;
-
-#ifdef DEBUG_1284
- printf("t");
-#endif
-
- ppb_1284_set_state(dev, PPB_PERIPHERAL_TERMINATION);
-
- /* Event 22 - wait up to host response time (1s) */
- if ((error = do_peripheral_wait(dev, SELECT | nBUSY, 0))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 22);
- goto error;
- }
-
- /* Event 24 */
- ppb_wctr(dev, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN));
-
- /* Event 25 - wait up to host response time (1s) */
- if ((error = do_peripheral_wait(dev, nBUSY, nBUSY))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 25);
- goto error;
- }
-
- /* Event 26 */
- ppb_wctr(dev, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED));
- DELAY(1);
- /* Event 27 */
- ppb_wctr(dev, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED));
-
- /* Event 28 - wait up to host response time (1s) */
- if ((error = do_peripheral_wait(dev, nBUSY, 0))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 28);
- goto error;
- }
-
-error:
- ppb_set_mode(dev, PPB_COMPATIBLE);
- ppb_1284_set_state(dev, PPB_FORWARD_IDLE);
-
- return (0);
-}
-
-/*
- * byte_peripheral_outbyte()
- *
- * Write 1 byte in BYTE mode
- */
-static int
-byte_peripheral_outbyte(struct ppb_device *dev, char *buffer, int last)
-{
- int error = 0;
-
- /* Event 7 */
- if ((error = do_1284_wait(dev, nBUSY, nBUSY))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 7);
- goto error;
- }
-
- /* check termination */
- if (!(ppb_rstr(dev) & SELECT)) {
- ppb_peripheral_terminate(dev, PPB_WAIT);
- goto error;
- }
-
- /* Event 15 - put byte on data lines */
-#ifdef DEBUG_1284
- printf("B");
-#endif
- ppb_wdtr(dev, *buffer);
-
- /* Event 9 */
- ppb_wctr(dev, (AUTOFEED | STROBE) & ~(nINIT | SELECTIN));
-
- /* Event 10 - wait data read */
- if ((error = do_peripheral_wait(dev, nBUSY, 0))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 16);
- goto error;
- }
-
- /* Event 11 */
- if (!last) {
- ppb_wctr(dev, (AUTOFEED) & ~(nINIT | STROBE | SELECTIN));
- } else {
- ppb_wctr(dev, (nINIT) & ~(STROBE | SELECTIN | AUTOFEED));
- }
-
-#if 0
- /* Event 16 - wait strobe */
- if ((error = do_peripheral_wait(dev, nACK | nBUSY, 0))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 16);
- goto error;
- }
-#endif
-
- /* check termination */
- if (!(ppb_rstr(dev) & SELECT)) {
- ppb_peripheral_terminate(dev, PPB_WAIT);
- goto error;
- }
-
-error:
- return (error);
-}
-
-/*
- * byte_peripheral_write()
- *
- * Write n bytes in BYTE mode
- */
-int
-byte_peripheral_write(struct ppb_device *dev, char *buffer, int len, int *sent)
+do_1284_wait(struct ppb_device *dev, char mask, char status)
{
- int error = 0, i;
+ int i;
char r;
- ppb_1284_set_state(dev, PPB_PERIPHERAL_TRANSFER);
-
- /* wait forever, the remote host is master and should initiate
- * termination
- */
- for (i=0; i<len; i++) {
- /* force remote nFAULT low to release the remote waiting
- * process, if any
- */
- r = ppb_rctr(dev);
- ppb_wctr(dev, r & ~nINIT);
-
-#ifdef DEBUG_1284
- printf("y");
-#endif
- /* Event 7 */
- error = ppb_poll_device(dev, PPB_FOREVER, nBUSY, nBUSY,
- PPB_INTR);
-
- if (error && error != EWOULDBLOCK)
- goto error;
-
-#ifdef DEBUG_1284
- printf("b");
-#endif
- if ((error = byte_peripheral_outbyte(dev, buffer+i, (i == len-1))))
- goto error;
+ /* try up to 5ms */
+ for (i = 0; i < 20; i++) {
+ r = ppb_rstr(dev);
+ DELAY(25);
+ if ((r & mask) == status)
+ return (0);
}
-error:
- if (!error)
- ppb_1284_set_state(dev, PPB_PERIPHERAL_IDLE);
- *sent = i;
- return (error);
+ return (ppb_poll_device(dev, 4, mask, status, PPB_NOINTR));
}
-/*
- * byte_1284_inbyte()
- *
- * Read 1 byte in BYTE mode
- */
-int
-byte_1284_inbyte(struct ppb_device *dev, char *buffer)
-{
- int error = 0;
-
- /* Event 7 - ready to take data (nAUTO low) */
- ppb_wctr(dev, (PCD | nINIT | AUTOFEED) & ~(STROBE | SELECTIN));
-
- /* Event 9 - peripheral set nAck low */
- if ((error = do_1284_wait(dev, nACK, 0))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 9);
- goto error;
- }
-
- /* read the byte */
- *buffer = ppb_rdtr(dev);
-
- /* Event 10 - data received, can't accept more */
- ppb_wctr(dev, (nINIT) & ~(AUTOFEED | STROBE | SELECTIN));
-
- /* Event 11 - peripheral ack */
- if ((error = do_1284_wait(dev, nACK, nACK))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 11);
- goto error;
- }
-
- /* Event 16 - strobe */
- ppb_wctr(dev, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN));
- DELAY(3);
- ppb_wctr(dev, (nINIT) & ~(AUTOFEED | STROBE | SELECTIN));
-
-error:
- return (error);
-}
+#define nibble2char(s) (((s & ~nACK) >> 3) | (~s & nBUSY) >> 4)
/*
* nibble_1284_inbyte()
@@ -467,379 +73,126 @@ nibble_1284_inbyte(struct ppb_device *dev, char *buffer)
int i, error;
for (i = 0; i < 2; i++) {
+ /* ready to take data (nAUTO low) */
+ ppb_wctr(dev, AUTOFEED & ~(STROBE | SELECTIN));
- /* Event 7 - ready to take data (nAUTO low) */
- ppb_wctr(dev, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN));
-
- /* Event 8 - peripheral writes the first nibble */
-
- /* Event 9 - peripheral set nAck low */
- if ((error = do_1284_wait(dev, nACK, 0))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 9);
- goto error;
- }
+ if ((error = do_1284_wait(dev, nACK, 0)))
+ return (error);
/* read nibble */
nibble[i] = ppb_rstr(dev);
- /* Event 10 - ack, nibble received */
- ppb_wctr(dev, nINIT & ~(AUTOFEED | STROBE | SELECTIN));
+ /* ack, not ready for another nibble */
+ ppb_wctr(dev, 0 & ~(AUTOFEED | STROBE | SELECTIN));
- /* Event 11 - wait ack from peripherial */
- if ((error = do_1284_wait(dev, nACK, nACK))) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 11);
- goto error;
- }
+ /* wait ack from peripherial */
+ if ((error = do_1284_wait(dev, nACK, nACK)))
+ return (error);
}
*buffer = ((nibble2char(nibble[1]) << 4) & 0xf0) |
(nibble2char(nibble[0]) & 0x0f);
-error:
- return (error);
-}
-
-/*
- * spp_1284_read()
- *
- * Read in IEEE1284 NIBBLE/BYTE mode
- */
-int
-spp_1284_read(struct ppb_device *dev, int mode, char *buffer, int max, int *read)
-{
- int error = 0, len = 0;
- int terminate_after_transfer = 1;
- int state;
-
- *read = len = 0;
-
- state = ppb_1284_get_state(dev);
-
- switch (state) {
- case PPB_FORWARD_IDLE:
- if ((error = ppb_1284_negociate(dev, mode, 0)))
- return (error);
- break;
-
- case PPB_REVERSE_IDLE:
- terminate_after_transfer = 0;
- break;
-
- default:
- ppb_1284_terminate(dev);
- if ((error = ppb_1284_negociate(dev, mode, 0)))
- return (error);
- break;
- }
-
- while ((len < max) && !(ppb_rstr(dev) & (nFAULT))) {
-
- ppb_1284_set_state(dev, PPB_REVERSE_TRANSFER);
-
-#ifdef DEBUG_1284
- printf("B");
-#endif
-
- switch (mode) {
- case PPB_NIBBLE:
- /* read a byte, error means no more data */
- if (nibble_1284_inbyte(dev, buffer+len))
- goto end_while;
- break;
- case PPB_BYTE:
- if (byte_1284_inbyte(dev, buffer+len))
- goto end_while;
- break;
- default:
- error = EINVAL;
- goto end_while;
- }
- len ++;
- }
-end_while:
-
- if (!error)
- ppb_1284_set_state(dev, PPB_REVERSE_IDLE);
-
- *read = len;
-
- if (terminate_after_transfer || error)
- ppb_1284_terminate(dev);
-
- return (error);
+ return (0);
}
/*
- * ppb_1284_read_id()
- *
+ * nibble_1284_sync()
*/
-int
-ppb_1284_read_id(struct ppb_device *dev, int mode, char *buffer,
- int max, int *read)
+void
+nibble_1284_sync(struct ppb_device *dev)
{
- int error = 0;
+ char ctr;
- /* fill the buffer with 0s */
- bzero(buffer, max);
+ ctr = ppb_rctr(dev);
- switch (mode) {
- case PPB_NIBBLE:
- case PPB_ECP:
- if ((error = ppb_1284_negociate(dev, PPB_NIBBLE, PPB_REQUEST_ID)))
- return (error);
- error = spp_1284_read(dev, PPB_NIBBLE, buffer, max, read);
- break;
- case PPB_BYTE:
- if ((error = ppb_1284_negociate(dev, PPB_BYTE, PPB_REQUEST_ID)))
- return (error);
- error = spp_1284_read(dev, PPB_BYTE, buffer, max, read);
- break;
- default:
- panic("%s: unsupported mode %d\n", __FUNCTION__, mode);
- }
-
- ppb_1284_terminate(dev);
- return (error);
-}
+ ppb_wctr(dev, (ctr & ~AUTOFEED) | SELECTIN);
+ if (do_1284_wait(dev, nACK, 0))
+ return;
-/*
- * ppb_1284_read()
- *
- * IEEE1284 read
- */
-int
-ppb_1284_read(struct ppb_device *dev, int mode, char *buffer,
- int max, int *read)
-{
- int error = 0;
+ ppb_wctr(dev, ctr | AUTOFEED);
+ do_1284_wait(dev, nACK, nACK);
- switch (mode) {
- case PPB_NIBBLE:
- case PPB_BYTE:
- error = spp_1284_read(dev, mode, buffer, max, read);
- break;
- default:
- return (EINVAL);
- }
+ ppb_wctr(dev, (ctr & ~AUTOFEED) | SELECTIN);
- return (error);
+ return;
}
/*
* ppb_1284_negociate()
*
- * IEEE1284 negociation phase
- *
* Normal nibble mode or request device id mode (see ppb_1284.h)
- *
- * After negociation, nFAULT is low if data is available
*/
int
-ppb_1284_negociate(struct ppb_device *dev, int mode, int options)
+ppb_1284_negociate(struct ppb_device *dev, int mode)
{
int error;
- int request_mode;
-
-#ifdef DEBUG_1284
- printf("n");
-#endif
-
- if (ppb_1284_get_state(dev) >= PPB_PERIPHERAL_NEGOCIATION)
- ppb_peripheral_terminate(dev, PPB_WAIT);
-
- if (ppb_1284_get_state(dev) != PPB_FORWARD_IDLE)
- ppb_1284_terminate(dev);
-
-#ifdef DEBUG_1284
- printf("%d", mode);
-#endif
-
- /* ensure the host is in compatible mode */
- ppb_set_mode(dev, PPB_COMPATIBLE);
-
- /* reset error to catch the actual negociation error */
- ppb_1284_reset_error(dev, PPB_FORWARD_IDLE);
+ int phase = 0;
- /* calculate ext. value */
- request_mode = ppb_request_mode(mode, options);
-
- /* default state */
ppb_wctr(dev, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED));
DELAY(1);
- /* enter negociation phase */
- ppb_1284_set_state(dev, PPB_NEGOCIATION);
-
- /* Event 0 - put the exten. value on the data lines */
- ppb_wdtr(dev, request_mode);
-
-#ifdef PERIPH_1284
- /* request remote host attention */
- ppb_wctr(dev, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN));
- DELAY(1);
- ppb_wctr(dev, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN));
-#else
+ ppb_wdtr(dev, mode);
DELAY(1);
-#endif /* !PERIPH_1284 */
-
- /* Event 1 - enter IEEE1284 mode */
ppb_wctr(dev, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN));
-#ifdef PERIPH_1284
- /* ignore the PError line, wait a bit more, remote host's
- * interrupts don't respond fast enough */
- if (ppb_poll_device(dev, 40, nACK | SELECT | nFAULT,
- SELECT | nFAULT, PPB_NOINTR | PPB_POLL)) {
- ppb_1284_set_error(dev, PPB_NOT_IEEE1284, 2);
- error = ENODEV;
- goto error;
- }
-#else
- /* Event 2 - trying IEEE1284 dialog */
- if (do_1284_wait(dev, nACK | PERROR | SELECT | nFAULT,
- PERROR | SELECT | nFAULT)) {
- ppb_1284_set_error(dev, PPB_NOT_IEEE1284, 2);
- error = ENODEV;
+ if ((error = do_1284_wait(dev, nACK | PERROR | SELECT | nFAULT,
+ PERROR | SELECT | nFAULT)))
goto error;
- }
-#endif /* !PERIPH_1284 */
- /* Event 3 - latch the ext. value to the peripheral */
+ phase = 1;
+
ppb_wctr(dev, (nINIT | STROBE | AUTOFEED) & ~SELECTIN);
- DELAY(1);
+ DELAY(5);
- /* Event 4 - IEEE1284 device recognized */
ppb_wctr(dev, nINIT & ~(SELECTIN | AUTOFEED | STROBE));
- /* Event 6 - waiting for status lines */
- if (do_1284_wait(dev, nACK, nACK)) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 6);
- error = EBUSY;
+#if 0 /* not respected by most devices */
+ if ((error = do_1284_wait(dev, nACK, nACK)))
goto error;
- }
-
- /* Event 7 - quering result consider nACK not to misunderstand
- * a remote computer terminate sequence */
- if (options & PPB_EXTENSIBILITY_LINK) {
- /* XXX not fully supported yet */
- ppb_1284_terminate(dev);
- return (0);
-
- }
- if (request_mode == NIBBLE_1284_NORMAL) {
- if (do_1284_wait(dev, nACK | SELECT, nACK)) {
- ppb_1284_set_error(dev, PPB_MODE_UNSUPPORTED, 7);
- error = ENODEV;
+ if (mode == 0)
+ if ((error = do_1284_wait(dev, SELECT, 0)))
goto error;
- }
- } else {
- if (do_1284_wait(dev, nACK | SELECT, SELECT | nACK)) {
- ppb_1284_set_error(dev, PPB_MODE_UNSUPPORTED, 7);
- error = ENODEV;
- goto error;
- }
- }
-
- switch (mode) {
- case PPB_NIBBLE:
- case PPB_PS2:
- /* enter reverse idle phase */
- ppb_1284_set_state(dev, PPB_REVERSE_IDLE);
- break;
- case PPB_ECP:
- /* negociation ok, now setup the communication */
- ppb_1284_set_state(dev, PPB_SETUP);
- ppb_wctr(dev, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE));
-
-#ifdef PERIPH_1284
- /* ignore PError line */
- if (do_1284_wait(dev, nACK | SELECT | nBUSY,
- nACK | SELECT | nBUSY)) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 30);
- error = ENODEV;
- goto error;
- }
-#else
- if (do_1284_wait(dev, nACK | SELECT | PERROR | nBUSY,
- nACK | SELECT | PERROR | nBUSY)) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 30);
- error = ENODEV;
+ else
+ if ((error = do_1284_wait(dev, SELECT, SELECT)))
goto error;
- }
-#endif /* !PERIPH_1284 */
-
- /* ok, the host enters the ForwardIdle state */
- ppb_1284_set_state(dev, PPB_ECP_FORWARD_IDLE);
- break;
- case PPB_EPP:
- ppb_1284_set_state(dev, PPB_EPP_IDLE);
- break;
-
- default:
- panic("%s: unknown mode (%d)!", __FUNCTION__, mode);
- }
- ppb_set_mode(dev, mode);
+#endif
return (0);
error:
- ppb_1284_terminate(dev);
+ if (bootverbose)
+ printf("%s: status=0x%x %d\n", __FUNCTION__, ppb_rstr(dev), phase);
return (error);
}
-/*
- * ppb_1284_terminate()
- *
- * IEEE1284 termination phase, return code should ignored since the host
- * is _always_ in compatible mode after ppb_1284_terminate()
- */
int
-ppb_1284_terminate(struct ppb_device *dev)
+ppb_1284_terminate(struct ppb_device *dev, int how)
{
+ int error;
-#ifdef DEBUG_1284
- printf("T");
-#endif
-
- /* do not reset error here to keep the error that
- * may occured before the ppb_1284_terminate() call */
- ppb_1284_set_state(dev, PPB_TERMINATION);
+ switch (how) {
+ case VALID_STATE:
-#ifdef PERIPH_1284
- /* request remote host attention */
- ppb_wctr(dev, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED));
- DELAY(1);
-#endif /* PERIPH_1284 */
+ ppb_wctr(dev, SELECTIN & ~(STROBE | AUTOFEED));
- /* Event 22 - set nSelectin low and nAutoFeed high */
- ppb_wctr(dev, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED));
+ if ((error = do_1284_wait(dev, nACK | nBUSY | nFAULT, nFAULT)))
+ return (error);
- /* Event 24 - waiting for peripheral, Xflag ignored */
- if (do_1284_wait(dev, nACK | nBUSY | nFAULT, nFAULT)) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 24);
- goto error;
- }
+ ppb_wctr(dev, (SELECTIN | AUTOFEED) & ~STROBE);
- /* Event 25 - set nAutoFd low */
- ppb_wctr(dev, (nINIT | SELECTIN | AUTOFEED) & ~STROBE);
+ if ((error = do_1284_wait(dev, nACK, nACK)))
+ return (error);
- /* Event 26 - compatible mode status is set */
+ ppb_wctr(dev, SELECTIN & ~(STROBE | AUTOFEED));
+ break;
- /* Event 27 - peripheral set nAck high */
- if (do_1284_wait(dev, nACK, nACK)) {
- ppb_1284_set_error(dev, PPB_TIMEOUT, 27);
+ default:
+ return (EINVAL);
}
- /* Event 28 - end termination, return to idle phase */
- ppb_wctr(dev, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED));
-
-error:
- /* return to compatible mode */
- ppb_set_mode(dev, PPB_COMPATIBLE);
- ppb_1284_set_state(dev, PPB_FORWARD_IDLE);
-
return (0);
}
diff --git a/sys/dev/ppbus/ppb_1284.h b/sys/dev/ppbus/ppb_1284.h
index ea009b7d381d..1cc98d4614a5 100644
--- a/sys/dev/ppbus/ppb_1284.h
+++ b/sys/dev/ppbus/ppb_1284.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_1284.h,v 1.3 1998/09/13 18:26:26 nsouch Exp $
+ * $Id: ppb_1284.h,v 1.2 1998/08/03 19:14:31 msmith Exp $
*
*/
#ifndef __1284_H
@@ -66,59 +66,20 @@
#define Intr nACK
/* request mode values */
-#define NIBBLE_1284_NORMAL 0x0
-#define NIBBLE_1284_REQUEST_ID 0x4
-#define BYTE_1284_NORMAL 0x1
-#define BYTE_1284_REQUEST_ID 0x5
-#define ECP_1284_NORMAL 0x10
-#define ECP_1284_REQUEST_ID 0x14
-#define ECP_1284_RLE 0x30
-#define ECP_1284_RLE_REQUEST_ID 0x34
-#define EPP_1284_NORMAL 0x40
-#define EXT_LINK_1284_NORMAL 0x80
+#define NIBBLE_1284_NORMAL 0
+#define NIBBLE_1284_REQUEST_ID 4
-/* ieee1284 mode options */
-#define PPB_REQUEST_ID 0x1
-#define PPB_USE_RLE 0x2
-#define PPB_EXTENSIBILITY_LINK 0x4
+/* how to terminate */
+#define VALID_STATE 0
+#define IMMEDIATE 1
-/* ieee1284 errors */
-#define PPB_NO_ERROR 0
-#define PPB_MODE_UNSUPPORTED 1 /* mode not supported by peripheral */
-#define PPB_NOT_IEEE1284 2 /* not an IEEE1284 compliant periph. */
-#define PPB_TIMEOUT 3 /* timeout */
-#define PPB_INVALID_MODE 4 /* current mode is incorrect */
-
-/* ieee1284 host side states */
-#define PPB_ERROR 0
-#define PPB_FORWARD_IDLE 1
-#define PPB_NEGOCIATION 2
-#define PPB_SETUP 3
-#define PPB_ECP_FORWARD_IDLE 4
-#define PPB_FWD_TO_REVERSE 5
-#define PPB_REVERSE_IDLE 6
-#define PPB_REVERSE_TRANSFER 7
-#define PPB_REVERSE_TO_FWD 8
-#define PPB_EPP_IDLE 9
-#define PPB_TERMINATION 10
-
-/* peripheral side states */
-#define PPB_PERIPHERAL_NEGOCIATION 11
-#define PPB_PERIPHERAL_IDLE 12
-#define PPB_PERIPHERAL_TRANSFER 13
-#define PPB_PERIPHERAL_TERMINATION 14
+extern int do_1284_wait(struct ppb_device *, char, char);
extern int nibble_1284_inbyte(struct ppb_device *, char *);
-extern int byte_1284_inbyte(struct ppb_device *, char *);
-extern int spp_1284_read(struct ppb_device *, int, char *, int, int *);
-
-extern int ppb_1284_negociate(struct ppb_device *, int, int);
-extern int ppb_1284_terminate(struct ppb_device *);
-extern int ppb_1284_read_id(struct ppb_device *, int, char *, int, int *);
-extern int ppb_1284_read(struct ppb_device *, int, char *, int, int *);
+extern void nibble_1284_sync(struct ppb_device *);
+extern int nibble_1284_mode(struct ppb_device *, int);
-extern int ppb_peripheral_terminate(struct ppb_device *, int);
-extern int ppb_peripheral_negociate(struct ppb_device *, int, int);
-extern int byte_peripheral_write(struct ppb_device *, char *, int, int *);
+extern int ppb_1284_negociate(struct ppb_device *, int);
+extern int ppb_1284_terminate(struct ppb_device *, int how);
#endif
diff --git a/sys/dev/ppbus/ppb_base.c b/sys/dev/ppbus/ppb_base.c
index 83fc26ef0294..7555b24f752e 100644
--- a/sys/dev/ppbus/ppb_base.c
+++ b/sys/dev/ppbus/ppb_base.c
@@ -23,13 +23,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_base.c,v 1.5 1998/09/13 18:26:26 nsouch Exp $
+ * $Id: ppb_base.c,v 1.4 1998/08/03 19:14:31 msmith Exp $
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <machine/clock.h>
#include <dev/ppbus/ppbconf.h>
@@ -71,39 +70,28 @@ int
ppb_poll_device(struct ppb_device *dev, int max,
char mask, char status, int how)
{
- int i, j, error;
- char r;
+ int i, error;
- /* try at least up to 10ms */
- for (j = 0; j < ((how & PPB_POLL) ? max : 1); j++) {
- for (i = 0; i < 10000; i++) {
- r = ppb_rstr(dev);
- DELAY(1);
- if ((r & mask) == status)
- return (0);
- }
- }
-
- if (!(how & PPB_POLL)) {
- for (i = 0; max == PPB_FOREVER || i < max-1; i++) {
+ for (i = 0; i < max; i++) {
if ((ppb_rstr(dev) & mask) == status)
return (0);
switch (how) {
case PPB_NOINTR:
/* wait 10 ms */
- tsleep((caddr_t)dev, PPBPRI, "ppbpoll", hz/100);
+ if ((error = tsleep((caddr_t)dev, PPBPRI,
+ "ppbpoll", hz/100)))
+ return (error);
break;
case PPB_INTR:
default:
/* wait 10 ms */
if ((error = tsleep((caddr_t)dev, PPBPRI | PCATCH,
- "ppbpoll", hz/100)) != EWOULDBLOCK)
+ "ppbpoll", hz/100)))
return (error);
break;
}
- }
}
return (EWOULDBLOCK);
@@ -120,31 +108,16 @@ ppb_set_mode(struct ppb_device *dev, int mode)
struct ppb_data *ppb = dev->ppb;
int old_mode = ppb_get_mode(dev);
- if ((*ppb->ppb_link->adapter->setmode)(
- ppb->ppb_link->adapter_unit, mode))
+ if ((*ppb->ppb_link->adapter->setmode)(dev->id_unit, mode))
return (-1);
/* XXX yet device mode = ppbus mode = chipset mode */
- dev->mode = ppb->mode = (mode & PPB_MASK);
+ dev->mode = ppb->mode = mode;
return (old_mode);
}
/*
- * ppb_write()
- *
- * Write charaters to the port
- */
-int
-ppb_write(struct ppb_device *dev, char *buf, int len, int how)
-{
- struct ppb_data *ppb = dev->ppb;
-
- return (ppb->ppb_link->adapter->write(ppb->ppb_link->adapter_unit,
- buf, len, how));
-}
-
-/*
* ppb_reset_epp_timeout()
*
* Reset the EPP timeout bit in the status register
@@ -157,7 +130,7 @@ ppb_reset_epp_timeout(struct ppb_device *dev)
if (ppb->ppb_owner != dev)
return (EACCES);
- (*ppb->ppb_link->adapter->reset_epp_timeout)(ppb->ppb_link->adapter_unit);
+ (*ppb->ppb_link->adapter->reset_epp_timeout)(dev->id_unit);
return (0);
}
@@ -175,7 +148,7 @@ ppb_ecp_sync(struct ppb_device *dev)
if (ppb->ppb_owner != dev)
return (EACCES);
- (*ppb->ppb_link->adapter->ecp_sync)(ppb->ppb_link->adapter_unit);
+ (*ppb->ppb_link->adapter->ecp_sync)(dev->id_unit);
return (0);
}
diff --git a/sys/dev/ppbus/ppb_msq.c b/sys/dev/ppbus/ppb_msq.c
index addcf041ab48..7e631e494521 100644
--- a/sys/dev/ppbus/ppb_msq.c
+++ b/sys/dev/ppbus/ppb_msq.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_msq.c,v 1.3 1998/09/20 14:41:54 nsouch Exp $
+ * $Id: ppb_msq.c,v 1.2 1998/09/13 18:26:26 nsouch Exp $
*
*/
#include <machine/stdarg.h>
@@ -272,19 +272,9 @@ ppb_MS_microseq(struct ppb_device *dev, struct ppb_microseq *msq, int *ret)
xfer = mode2xfer(dev, mi->opcode);
/* figure out if we should use ieee1284 code */
- if (!xfer->loop) {
- if (mi->opcode == MS_OP_PUT) {
- if ((error = ppb->ppb_link->adapter->write(
- ppb->ppb_link->adapter_unit,
- (char *)mi->arg[0].p,
- mi->arg[1].i, 0)))
- goto error;
-
- INCR_PC;
- goto next;
- } else
- panic("%s: IEEE1284 read not supported", __FUNCTION__);
- }
+ if (!xfer->loop)
+ panic("%s: IEEE1284 code not supported",
+ __FUNCTION__);
/* XXX should use ppb_MS_init_msq() */
initxfer[0].arg[0].p = mi->arg[0].p;
@@ -319,12 +309,10 @@ ppb_MS_microseq(struct ppb_device *dev, struct ppb_microseq *msq, int *ret)
* is unknown here
*/
if ((error = ppb->ppb_link->adapter->exec_microseq(
- ppb->ppb_link->adapter_unit,
- &mi)))
+ dev->id_unit, &mi)))
goto error;
break;
}
- next:
}
error:
return (error);
diff --git a/sys/dev/ppbus/ppb_msq.h b/sys/dev/ppbus/ppb_msq.h
index 4bba2997ac25..cdc815408d7f 100644
--- a/sys/dev/ppbus/ppb_msq.h
+++ b/sys/dev/ppbus/ppb_msq.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_msq.h,v 1.2 1998/09/13 18:26:26 nsouch Exp $
+ * $Id: ppb_msq.h,v 1.1.2.7 1998/06/20 19:03:47 son Exp $
*
*/
#ifndef __PPB_MSQ_H
@@ -34,7 +34,7 @@
*/
/* microsequence parameter descriptor */
-#define MS_INS_MASK 0x00ff /* mask to retrieve the instruction position < 256 XXX */
+#define MS_INS_MASK 0x00ff /* mask to retrieve the instruction position */
#define MS_ARG_MASK 0x0f00 /* mask to retrieve the argument number */
#define MS_TYP_MASK 0xf000 /* mask to retrieve the type of the param */
diff --git a/sys/dev/ppbus/ppbconf.c b/sys/dev/ppbus/ppbconf.c
index 01ac663a2252..86ebe024e606 100644
--- a/sys/dev/ppbus/ppbconf.c
+++ b/sys/dev/ppbus/ppbconf.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
+ * Copyright (c) 1997, 1998 Nicolas Souchu
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,12 +23,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppbconf.c,v 1.12 1999/01/11 21:22:41 nsouch Exp $
+ * $Id: ppbconf.c,v 1.7 1998/09/13 18:26:26 nsouch Exp $
*
*/
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/linker_set.h>
+#include <sys/kernel.h>
#include <sys/malloc.h>
#include <vm/vm.h>
@@ -37,8 +37,6 @@
#include <dev/ppbus/ppbconf.h>
#include <dev/ppbus/ppb_1284.h>
-#include "opt_ppb_1284.h"
-
LIST_HEAD(, ppb_data) ppbdata; /* list of existing ppbus */
/*
@@ -82,30 +80,15 @@ ppb_alloc_bus(void)
return(ppb);
}
-#define PPB_PNP_PRINTER 0
-#define PPB_PNP_MODEM 1
-#define PPB_PNP_NET 2
-#define PPB_PNP_HDC 3
-#define PPB_PNP_PCMCIA 4
-#define PPB_PNP_MEDIA 5
-#define PPB_PNP_FDC 6
-#define PPB_PNP_PORTS 7
-#define PPB_PNP_SCANNER 8
-#define PPB_PNP_DIGICAM 9
-
-#ifndef DONTPROBE_1284
-
static char *pnp_tokens[] = {
"PRINTER", "MODEM", "NET", "HDC", "PCMCIA", "MEDIA",
"FDC", "PORTS", "SCANNER", "DIGICAM", "", NULL };
-#if 0
static char *pnp_classes[] = {
"printer", "modem", "network device",
"hard disk", "PCMCIA", "multimedia device",
"floppy disk", "ports", "scanner",
"digital camera", "unknown device", NULL };
-#endif
/*
* search_token()
@@ -151,40 +134,75 @@ search_token(char *str, int slen, char *token)
* Returns the class id. of the peripherial, -1 otherwise
*/
static int
-ppb_pnp_detect(struct ppb_data *ppb, struct ppb_device *pnpdev)
+ppb_pnp_detect(struct ppb_data *ppb)
{
- char *token, *class = 0;
+ char *token, *q, *class = 0;
int i, len, error;
int class_id = -1;
char str[PPB_PnP_STRING_SIZE+1];
+ struct ppb_device pnpdev; /* temporary device to perform I/O */
- printf("Probing for PnP devices on ppbus%d:\n",
+ /* initialize the pnpdev structure for future use */
+ bzero(&pnpdev, sizeof(pnpdev));
+
+ pnpdev.ppb = ppb;
+
+ if (bootverbose)
+ printf("ppb: <PnP> probing devices on ppbus %d...\n",
ppb->ppb_link->adapter_unit);
-
- if ((error = ppb_1284_read_id(pnpdev, PPB_NIBBLE, str,
- PPB_PnP_STRING_SIZE, &len)))
+
+ if (ppb_request_bus(&pnpdev, PPB_DONTWAIT)) {
+ if (bootverbose)
+ printf("ppb: <PnP> cannot allocate ppbus!\n");
+ return (-1);
+ }
+
+ if ((error = ppb_1284_negociate(&pnpdev, NIBBLE_1284_REQUEST_ID))) {
+ if (bootverbose)
+ printf("ppb: <PnP> ppb_1284_negociate()=%d\n", error);
+
goto end_detect;
+ }
+
+ len = 0;
+ for (q=str; !(ppb_rstr(&pnpdev) & PERROR); q++) {
+ if ((error = nibble_1284_inbyte(&pnpdev, q))) {
+ if (bootverbose) {
+ *q = '\0';
+ printf("ppb: <PnP> len=%d, %s\n", len, str);
+ printf("ppb: <PnP> nibble_1284_inbyte()=%d\n",
+ error);
+ }
+ goto end_detect;
+ }
-#ifdef DEBUG_1284
- printf("ppb: <PnP> %d characters: ", len);
- for (i = 0; i < len; i++)
- printf("%c(0x%x) ", str[i], str[i]);
- printf("\n");
-#endif
+ if (len++ >= PPB_PnP_STRING_SIZE) {
+ printf("ppb: <PnP> not space left!\n");
+ goto end_detect;
+ }
+ }
+ *q = '\0';
+
+ nibble_1284_sync(&pnpdev);
+
+ if (bootverbose) {
+ printf("ppb: <PnP> %d characters: ", len);
+ for (i = 0; i < len; i++)
+ printf("0x%x ", str[i]);
+ printf("\n");
+ }
/* replace ';' characters by '\0' */
for (i = 0; i < len; i++)
str[i] = (str[i] == ';') ? '\0' : str[i];
- if ((token = search_token(str, len, "MFG")) != NULL ||
- (token = search_token(str, len, "MANUFACTURER")) != NULL)
+ if ((token = search_token(str, len, "MFG")) != NULL)
printf("ppbus%d: <%s", ppb->ppb_link->adapter_unit,
search_token(token, UNKNOWN_LENGTH, ":") + 1);
else
printf("ppbus%d: <unknown", ppb->ppb_link->adapter_unit);
- if ((token = search_token(str, len, "MDL")) != NULL ||
- (token = search_token(str, len, "MODEL")) != NULL)
+ if ((token = search_token(str, len, "MDL")) != NULL)
printf(" %s",
search_token(token, UNKNOWN_LENGTH, ":") + 1);
else
@@ -205,8 +223,7 @@ ppb_pnp_detect(struct ppb_data *ppb, struct ppb_device *pnpdev)
printf(" %s", class);
}
- if ((token = search_token(str, len, "CMD")) != NULL ||
- (token = search_token(str, len, "COMMAND")) != NULL)
+ if ((token = search_token(str, len, "CMD")) != NULL)
printf(" %s",
search_token(token, UNKNOWN_LENGTH, ":") + 1);
@@ -224,120 +241,13 @@ ppb_pnp_detect(struct ppb_data *ppb, struct ppb_device *pnpdev)
class_id = PPB_PnP_UNKNOWN;
end_detect:
- return (class_id);
-}
-
-/*
- * ppb_scan_bus()
- *
- * Scan the ppbus for IEEE1284 compliant devices
- */
-static int
-ppb_scan_bus(struct ppb_data *ppb)
-{
- struct ppb_device pnpdev; /* temporary device to perform I/O */
- int error = 0;
-
- /* initialize the pnpdev structure for future use */
- bzero(&pnpdev, sizeof(pnpdev));
- pnpdev.ppb = ppb;
-
- if ((error = ppb_request_bus(&pnpdev, PPB_DONTWAIT))) {
- if (bootverbose)
- printf("ppb: cannot allocate ppbus!\n");
-
- return (error);
- }
-
- /* try all IEEE1284 modes, for one device only
- *
- * XXX We should implement the IEEE1284.3 standard to detect
- * daisy chained devices
- */
-
- error = ppb_1284_negociate(&pnpdev, PPB_NIBBLE, PPB_REQUEST_ID);
+ if ((error = ppb_1284_terminate(&pnpdev, VALID_STATE)) && bootverbose)
+ printf("ppb: ppb_1284_terminate()=%d\n", error);
- if ((ppb->state == PPB_ERROR) && (ppb->error == PPB_NOT_IEEE1284))
- goto end_scan;
-
- ppb_1284_terminate(&pnpdev);
-
- printf("ppb%d: IEEE1284 device found ", ppb->ppb_link->adapter_unit);
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_NIBBLE, 0))) {
- printf("/NIBBLE");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_PS2, 0))) {
- printf("/PS2");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_ECP, 0))) {
- printf("/ECP");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_ECP, PPB_USE_RLE))) {
- printf("/ECP_RLE");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_EPP, 0))) {
- printf("/EPP");
- ppb_1284_terminate(&pnpdev);
- }
-
- /* try more IEEE1284 modes */
- if (bootverbose) {
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_NIBBLE,
- PPB_REQUEST_ID))) {
- printf("/NIBBLE_ID");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_PS2,
- PPB_REQUEST_ID))) {
- printf("/PS2_ID");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_ECP,
- PPB_REQUEST_ID))) {
- printf("/ECP_ID");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_ECP,
- PPB_REQUEST_ID | PPB_USE_RLE))) {
- printf("/ECP_RLE_ID");
- ppb_1284_terminate(&pnpdev);
- }
-
- if (!(error = ppb_1284_negociate(&pnpdev, PPB_COMPATIBLE,
- PPB_EXTENSIBILITY_LINK))) {
- printf("/Extensibility Link");
- ppb_1284_terminate(&pnpdev);
- }
- }
-
- printf("\n");
-
- /* detect PnP devices */
- ppb->class_id = ppb_pnp_detect(ppb, &pnpdev);
-
- ppb_release_bus(&pnpdev);
-
- return (0);
-
-end_scan:
ppb_release_bus(&pnpdev);
- return (error);
+ return (class_id);
}
-#endif /* !DONTPROBE_1284 */
-
/*
* ppb_attachdevs()
*
@@ -347,16 +257,18 @@ end_scan:
int
ppb_attachdevs(struct ppb_data *ppb)
{
+ int error;
struct ppb_device *dev;
struct ppb_driver **p_drvpp, *p_drvp;
LIST_INIT(&ppb->ppb_devs); /* initialise device/driver list */
p_drvpp = (struct ppb_driver **)ppbdriver_set.ls_items;
-#ifndef DONTPROBE_1284
- /* detect IEEE1284 compliant devices */
- ppb_scan_bus(ppb);
-#endif /* !DONTPROBE_1284 */
+/* XXX wait for ieee1284 good support */
+#if 0
+ /* detect PnP devices */
+ ppb->class_id = ppb_pnp_detect(ppb);
+#endif
/*
* Blindly try all probes here. Later we should look at
diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h
index c47e4ab7d04d..80efe282a62b 100644
--- a/sys/dev/ppbus/ppbconf.h
+++ b/sys/dev/ppbus/ppbconf.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppbconf.h,v 1.10 1999/01/10 12:04:55 nsouch Exp $
+ * $Id: ppbconf.h,v 1.8 1998/09/13 18:26:26 nsouch Exp $
*
*/
#ifndef __PPBCONF_H
@@ -47,12 +47,7 @@
#define PPB_EPP 0x4 /* EPP mode, 32 bit */
#define PPB_ECP 0x8 /* ECP mode */
-/* mode aliases */
-#define PPB_SPP PPB_NIBBLE|PPB_PS2
-#define PPB_BYTE PPB_PS2
-
-#define PPB_MASK 0x0f
-#define PPB_OPTIONS_MASK 0xf0
+#define PPB_SPP PPB_NIBBLE|PPB_PS2
#define PPB_IS_EPP(mode) (mode & PPB_EPP)
#define PPB_IN_EPP_MODE(dev) (PPB_IS_EPP (ppb_get_mode (dev)))
@@ -108,8 +103,6 @@ struct ppb_status {
#define PPB_NOINTR 0
#define PPB_WAIT 0x1
#define PPB_INTR 0x2
-#define PPB_POLL 0x4
-#define PPB_FOREVER -1
/*
* Microsequence stuff.
@@ -151,14 +144,14 @@ struct ppb_context {
struct microseq *curmsq; /* currently executed microseqence */
};
+
struct ppb_device {
int id_unit; /* unit of the device */
char *name; /* name of the device */
ushort mode; /* current mode of the device */
- ushort avm; /* available IEEE1284 modes of
- * the device */
+ ushort avm; /* available modes of the device */
struct ppb_context ctx; /* context of the device */
@@ -191,8 +184,6 @@ struct ppb_adapter {
int (*exec_microseq)(int, struct ppb_microseq **);
int (*setmode)(int, int);
- int (*read)(int, char *, int, int);
- int (*write)(int, char *, int, int);
void (*outsb_epp)(int, char *, int);
void (*outsw_epp)(int, char *, int);
@@ -201,12 +192,12 @@ struct ppb_adapter {
void (*insw_epp)(int, char *, int);
void (*insl_epp)(int, char *, int);
- u_char (*r_dtr)(int);
- u_char (*r_str)(int);
- u_char (*r_ctr)(int);
- u_char (*r_epp)(int);
- u_char (*r_ecr)(int);
- u_char (*r_fifo)(int);
+ char (*r_dtr)(int);
+ char (*r_str)(int);
+ char (*r_ctr)(int);
+ char (*r_epp)(int);
+ char (*r_ecr)(int);
+ char (*r_fifo)(int);
void (*w_dtr)(int, char);
void (*w_str)(int, char);
@@ -239,7 +230,7 @@ struct ppb_link {
/*
* Maximum size of the PnP info string
*/
-#define PPB_PnP_STRING_SIZE 256 /* XXX */
+#define PPB_PnP_STRING_SIZE 128 /* XXX */
/*
* Parallel Port Bus structure.
@@ -259,11 +250,10 @@ struct ppb_data {
#define PPB_PnP_UNKNOWN 10
int class_id; /* not a PnP device if class_id < 0 */
- int state; /* current IEEE1284 state */
- int error; /* last IEEE1284 error */
-
ushort mode; /* IEEE 1284-1994 mode
* NIBBLE, PS2, EPP or ECP */
+ ushort avm; /* IEEE 1284-1994 available
+ * modes */
struct ppb_link *ppb_link; /* link to the adapter */
struct ppb_device *ppb_owner; /* device which owns the bus */
@@ -304,7 +294,6 @@ extern int ppb_ecp_sync(struct ppb_device *);
extern int ppb_get_status(struct ppb_device *, struct ppb_status *);
extern int ppb_set_mode(struct ppb_device *, int);
-extern int ppb_write(struct ppb_device *, char *, int, int);
/*
* These are defined as macros for speedup.
diff --git a/sys/dev/ppbus/ppi.c b/sys/dev/ppbus/ppi.c
index e0072f3e4cda..f742e4b56fae 100644
--- a/sys/dev/ppbus/ppi.c
+++ b/sys/dev/ppbus/ppi.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppi.c,v 1.8 1998/12/07 21:58:16 archie Exp $
+ * $Id: ppi.c,v 1.6 1998/01/02 09:30:39 msmith Exp $
*
*/
#include "ppi.h"
@@ -34,35 +34,18 @@
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
-#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/fcntl.h>
-#include <machine/clock.h>
-
#include <dev/ppbus/ppbconf.h>
-#include <dev/ppbus/ppb_msq.h>
-
-#include "opt_ppb_1284.h"
-
-#ifdef PERIPH_1284
-#include <dev/ppbus/ppb_1284.h>
-#endif
-
#include <dev/ppbus/ppi.h>
-#define BUFSIZE 512
struct ppi_data {
int ppi_unit;
int ppi_flags;
#define HAVE_PPBUS (1<<0)
-#define HAD_PPBUS (1<<1)
-
- int ppi_count;
- int ppi_mode; /* IEEE1284 mode */
- char ppi_buffer[BUFSIZE];
struct ppb_device ppi_dev;
};
@@ -87,41 +70,13 @@ DATA_SET(ppbdriver_set, ppidriver);
static d_open_t ppiopen;
static d_close_t ppiclose;
static d_ioctl_t ppiioctl;
-static d_write_t ppiwrite;
-static d_read_t ppiread;
#define CDEV_MAJOR 82
static struct cdevsw ppi_cdevsw =
- { ppiopen, ppiclose, ppiread, ppiwrite, /* 82 */
+ { ppiopen, ppiclose, noread, nowrite, /* 82 */
ppiioctl, nullstop, nullreset, nodevtotty,
seltrue, nommap, nostrat, "ppi", NULL, -1 };
-#ifdef PERIPH_1284
-
-static void
-ppi_enable_intr(struct ppi_data *ppi)
-{
- char r;
-
- r = ppb_rctr(&ppi->ppi_dev);
- ppb_wctr(&ppi->ppi_dev, r | IRQENABLE);
-
- return;
-}
-
-static void
-ppi_disable_intr(struct ppi_data *ppi)
-{
- char r;
-
- r = ppb_rctr(&ppi->ppi_dev);
- ppb_wctr(&ppi->ppi_dev, r & ~IRQENABLE);
-
- return;
-}
-
-#endif /* PERIPH_1284 */
-
/*
* ppiprobe()
*/
@@ -161,6 +116,8 @@ ppiprobe(struct ppb_data *ppb)
static int
ppiattach(struct ppb_device *dev)
{
+ struct ppi_data *ppi = ppidata[dev->id_unit];
+
/*
* Report ourselves
*/
@@ -170,72 +127,9 @@ ppiattach(struct ppb_device *dev)
return (1);
}
-/*
- * Cable
- * -----
- *
- * Use an IEEE1284 compliant (DB25/DB25) cable with the following tricks:
- *
- * nStrobe <-> nAck 1 <-> 10
- * nAutofd <-> Busy 11 <-> 14
- * nSelectin <-> Select 17 <-> 13
- * nInit <-> nFault 15 <-> 16
- *
- */
static void
ppiintr(int unit)
{
-#ifdef PERIPH_1284
- struct ppi_data *ppi = ppidata[unit];
-
- ppi_disable_intr(ppi);
-
- switch (ppi->ppi_dev.ppb->state) {
-
- /* accept IEEE1284 negociation then wakeup an waiting process to
- * continue negociation at process level */
- case PPB_FORWARD_IDLE:
- /* Event 1 */
- if ((ppb_rstr(&ppi->ppi_dev) & (SELECT | nBUSY)) ==
- (SELECT | nBUSY)) {
- /* IEEE1284 negociation */
-#ifdef DEBUG_1284
- printf("N");
-#endif
-
- /* Event 2 - prepare for reading the ext. value */
- ppb_wctr(&ppi->ppi_dev, (PCD | STROBE | nINIT) & ~SELECTIN);
-
- ppi->ppi_dev.ppb->state = PPB_NEGOCIATION;
-
- } else {
-#ifdef DEBUG_1284
- printf("0x%x", ppb_rstr(&ppi->ppi_dev));
-#endif
- ppb_peripheral_terminate(&ppi->ppi_dev, PPB_DONTWAIT);
- break;
- }
-
- /* wake up any process waiting for negociation from
- * remote master host */
-
- /* XXX should set a variable to warn the process about
- * the interrupt */
-
- wakeup(ppi);
- break;
- default:
-#ifdef DEBUG_1284
- printf("?%d", ppi->ppi_dev.ppb->state);
-#endif
- ppi->ppi_dev.ppb->state = PPB_FORWARD_IDLE;
- ppb_set_mode(&ppi->ppi_dev, PPB_COMPATIBLE);
- break;
- }
-
- ppi_enable_intr(ppi);
-#endif /* PERIPH_1284 */
-
return;
}
@@ -249,16 +143,11 @@ ppiopen(dev_t dev, int flags, int fmt, struct proc *p)
if (unit >= nppi)
return (ENXIO);
- if (!(ppi->ppi_flags & HAVE_PPBUS)) {
- if ((res = ppb_request_bus(&ppi->ppi_dev,
- (flags & O_NONBLOCK) ? PPB_DONTWAIT :
- (PPB_WAIT | PPB_INTR))))
+ if (!(ppi->ppi_flags & HAVE_PPBUS))
+ if ((res = ppb_request_bus(&ppi->ppi_dev, (flags & O_NONBLOCK) ? PPB_DONTWAIT : (PPB_WAIT | PPB_INTR))))
return (res);
- ppi->ppi_flags |= HAVE_PPBUS;
- }
- ppi->ppi_count += 1;
-
+ ppi->ppi_flags |= HAVE_PPBUS;
return (0);
}
@@ -268,206 +157,12 @@ ppiclose(dev_t dev, int flags, int fmt, struct proc *p)
u_int unit = minor(dev);
struct ppi_data *ppi = ppidata[unit];
- ppi->ppi_count --;
- if (!ppi->ppi_count) {
-
-#ifdef PERIPH_1284
- switch (ppi->ppi_dev.ppb->state) {
- case PPB_PERIPHERAL_IDLE:
- ppb_peripheral_terminate(&ppi->ppi_dev, 0);
- break;
- case PPB_REVERSE_IDLE:
- case PPB_EPP_IDLE:
- case PPB_ECP_FORWARD_IDLE:
- default:
- ppb_1284_terminate(&ppi->ppi_dev);
- break;
- }
-#endif /* PERIPH_1284 */
-
+ if (ppi->ppi_flags & HAVE_PPBUS)
ppb_release_bus(&ppi->ppi_dev);
- ppi->ppi_flags &= ~HAVE_PPBUS;
- }
-
+ ppi->ppi_flags &= ~HAVE_PPBUS;
return (0);
}
-/*
- * ppiread()
- *
- * IEEE1284 compliant read.
- *
- * First, try negociation to BYTE then NIBBLE mode
- * If no data is available, wait for it otherwise transfer as much as possible
- */
-static int
-ppiread(dev_t dev, struct uio *uio, int ioflag)
-{
-#ifdef PERIPH_1284
- u_int unit = minor(dev);
- struct ppi_data *ppi = ppidata[unit];
- int len, error = 0;
-
- switch (ppi->ppi_dev.ppb->state) {
- case PPB_PERIPHERAL_IDLE:
- ppb_peripheral_terminate(&ppi->ppi_dev, 0);
- /* fall throught */
-
- case PPB_FORWARD_IDLE:
- /* if can't negociate NIBBLE mode then try BYTE mode,
- * the peripheral may be a computer
- */
- if ((ppb_1284_negociate(&ppi->ppi_dev,
- ppi->ppi_mode = PPB_NIBBLE, 0))) {
-
- /* XXX Wait 2 seconds to let the remote host some
- * time to terminate its interrupt
- */
- tsleep(ppi, PPBPRI, "ppiread", 2*hz);
-
- if ((error = ppb_1284_negociate(&ppi->ppi_dev,
- ppi->ppi_mode = PPB_BYTE, 0)))
- return (error);
- }
- break;
-
- case PPB_REVERSE_IDLE:
- case PPB_EPP_IDLE:
- case PPB_ECP_FORWARD_IDLE:
- default:
- break;
- }
-
-#ifdef DEBUG_1284
- printf("N");
-#endif
- /* read data */
- len = 0;
- while (uio->uio_resid) {
- if ((error = ppb_1284_read(&ppi->ppi_dev, ppi->ppi_mode,
- ppi->ppi_buffer, min(BUFSIZE, uio->uio_resid),
- &len))) {
- goto error;
- }
-
- if (!len)
- goto error; /* no more data */
-
-#ifdef DEBUG_1284
- printf("d");
-#endif
- if ((error = uiomove(ppi->ppi_buffer, len, uio)))
- goto error;
- }
-
-error:
-
-#else /* PERIPH_1284 */
- int error = ENODEV;
-#endif
-
- return (error);
-}
-
-/*
- * ppiwrite()
- *
- * IEEE1284 compliant write
- *
- * Actually, this is the peripheral side of a remote IEEE1284 read
- *
- * The first part of the negociation (IEEE1284 device detection) is
- * done at interrupt level, then the remaining is done by the writing
- * process
- *
- * Once negociation done, transfer data
- */
-static int
-ppiwrite(dev_t dev, struct uio *uio, int ioflag)
-{
-#ifdef PERIPH_1284
- u_int unit = minor(dev);
- struct ppi_data *ppi = ppidata[unit];
- struct ppb_data *ppb = ppi->ppi_dev.ppb;
- int len, error = 0, sent;
-
-#if 0
- int ret;
-
- #define ADDRESS MS_PARAM(0, 0, MS_TYP_PTR)
- #define LENGTH MS_PARAM(0, 1, MS_TYP_INT)
-
- struct ppb_microseq msq[] = {
- { MS_OP_PUT, { MS_UNKNOWN, MS_UNKNOWN, MS_UNKNOWN } },
- MS_RET(0)
- };
-
- /* negociate ECP mode */
- if (ppb_1284_negociate(&ppi->ppi_dev, PPB_ECP, 0)) {
- printf("ppiwrite: ECP negociation failed\n");
- }
-
- while (!error && (len = min(uio->uio_resid, BUFSIZE))) {
- uiomove(ppi->ppi_buffer, len, uio);
-
- ppb_MS_init_msq(msq, 2, ADDRESS, ppi->ppi_buffer, LENGTH, len);
-
- error = ppb_MS_microseq(&ppi->ppi_dev, msq, &ret);
- }
-#endif
-
- /* we have to be peripheral to be able to send data, so
- * wait for the appropriate state
- */
- if (ppb->state < PPB_PERIPHERAL_NEGOCIATION)
- ppb_1284_terminate(&ppi->ppi_dev);
-
- while (ppb->state != PPB_PERIPHERAL_IDLE) {
- /* XXX should check a variable before sleeping */
-#ifdef DEBUG_1284
- printf("s");
-#endif
-
- ppi_enable_intr(ppi);
-
- /* sleep until IEEE1284 negociation starts */
- error = tsleep(ppi, PCATCH | PPBPRI, "ppiwrite", 0);
-
- switch (error) {
- case 0:
- /* negociate peripheral side with BYTE mode */
- ppb_peripheral_negociate(&ppi->ppi_dev, PPB_BYTE, 0);
- break;
- case EWOULDBLOCK:
- break;
- default:
- goto error;
- }
- }
-#ifdef DEBUG_1284
- printf("N");
-#endif
-
- /* negociation done, write bytes to master host */
- while (len = min(uio->uio_resid, BUFSIZE)) {
- uiomove(ppi->ppi_buffer, len, uio);
- if ((error = byte_peripheral_write(&ppi->ppi_dev,
- ppi->ppi_buffer, len, &sent)))
- goto error;
-#ifdef DEBUG_1284
- printf("d");
-#endif
- }
-
-error:
-
-#else /* PERIPH_1284 */
- int error = ENODEV;
-#endif
-
- return (error);
-}
-
static int
ppiioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
{
@@ -515,6 +210,7 @@ ppiioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
case PPISFIFO: /* write FIFO */
ppb_wfifo(&ppi->ppi_dev, *val);
break;
+
default:
error = ENOTTY;
break;
diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c
index 95b255cb1bb3..9d1f20d9e04b 100644
--- a/sys/dev/ppbus/pps.c
+++ b/sys/dev/ppbus/pps.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: pps.c,v 1.11 1998/08/24 16:31:27 phk Exp $
+ * $Id: pps.c,v 1.10 1998/08/03 19:14:31 msmith Exp $
*
* This driver implements a draft-mogul-pps-api-02.txt PPS source.
*
@@ -153,6 +153,7 @@ ppsintr(int unit)
{
struct pps_data *sc = softc[unit];
struct timespec tc;
+ struct timeval tv;
nanotime(&tc);
if (!(ppb_rstr(&sc->pps_dev) & nACK))
@@ -170,8 +171,6 @@ ppsintr(int unit)
sc->ppsinfo.assert_sequence++;
#ifdef PPS_SYNC
if (sc->ppsparam.mode & PPS_HARDPPSONASSERT) {
- struct timeval tv;
-
tv.tv_sec = tc.tv_sec;
tv.tv_usec = tc.tv_nsec / 1000;
hardpps(&tv, tv.tv_usec);
diff --git a/sys/dev/ppbus/vpo.c b/sys/dev/ppbus/vpo.c
index 17b67c5f632d..0585a497cd9b 100644
--- a/sys/dev/ppbus/vpo.c
+++ b/sys/dev/ppbus/vpo.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vpo.c,v 1.10 1999/01/09 18:05:46 nsouch Exp $
+ * $Id: vpo.c,v 1.4 1997/09/01 00:51:52 bde Exp $
*
*/
@@ -51,8 +51,6 @@
#include <sys/kernel.h>
#endif /*KERNEL */
-#include "opt_vpo.h"
-
#include <dev/ppbus/ppbconf.h>
#include <dev/ppbus/vpoio.h>
@@ -159,6 +157,7 @@ vpoprobe(struct ppb_data *ppb)
static int
vpoattach(struct ppb_device *dev)
{
+ struct scsibus_data *scbus;
struct vpo_data *vpo = vpodata[dev->id_unit];
struct cam_devq *devq;
@@ -212,11 +211,9 @@ vpoattach(struct ppb_device *dev)
static void
vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio)
{
- int errno; /* error in errno.h */
+
+ int i, errno; /* error in errno.h */
int s;
-#ifdef VP0_DEBUG
- int i;
-#endif
s = splcam();
@@ -413,10 +410,6 @@ vpo_action(struct cam_sim *sim, union ccb *ccb)
printf("vpo%d: XPT_PATH_INQ request\n", vpo->vpo_unit);
#endif
cpi->version_num = 1; /* XXX??? */
- cpi->hba_inquiry = 0;
- cpi->target_sprt = 0;
- cpi->hba_misc = 0;
- cpi->hba_eng_cnt = 0;
cpi->max_target = 7;
cpi->max_lun = 0;
cpi->initiator_id = VP0_INITIATOR;
diff --git a/sys/dev/ppbus/vpoio.c b/sys/dev/ppbus/vpoio.c
index 54791ee44dcc..a416efefb8ef 100644
--- a/sys/dev/ppbus/vpoio.c
+++ b/sys/dev/ppbus/vpoio.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vpoio.c,v 1.4 1998/12/07 21:58:16 archie Exp $
+ * $Id: vpoio.c,v 1.2 1998/09/13 18:26:26 nsouch Exp $
*
*/
@@ -41,8 +41,6 @@
#include <sys/kernel.h>
#endif /*KERNEL */
-#include "opt_vpo.h"
-
#include <dev/ppbus/ppbconf.h>
#include <dev/ppbus/ppb_msq.h>
#include <dev/ppbus/vpoio.h>
@@ -286,13 +284,8 @@ vpoio_connect(struct vpoio_data *vpo, int how)
int error;
int ret;
- if ((error = ppb_request_bus(&vpo->vpo_dev, how))) {
-
-#ifdef VP0_DEBUG
- printf("%s: can't request bus!\n", __FUNCTION__);
-#endif
+ if ((error = ppb_request_bus(&vpo->vpo_dev, how)))
return error;
- }
if (PPB_IN_EPP_MODE(&vpo->vpo_dev))
ppb_MS_microseq(&vpo->vpo_dev, connect_epp_microseq, &ret);
@@ -444,8 +437,8 @@ vpoio_outstr(struct vpoio_data *vpo, char *buffer, int size)
ppb_wctr(&vpo->vpo_dev,
H_AUTO | H_nSELIN | H_INIT | H_STROBE);
}
+ /* ppb_ecp_sync(&vpo->vpo_dev); */
#endif
- ppb_ecp_sync(&vpo->vpo_dev);
return (error);
}
@@ -456,7 +449,10 @@ vpoio_outstr(struct vpoio_data *vpo, char *buffer, int size)
static int
vpoio_instr(struct vpoio_data *vpo, char *buffer, int size)
{
+
+ register int k;
int error = 0;
+ int r, mode, epp;
ppb_MS_exec(&vpo->vpo_dev, MS_OP_GET, buffer, size, MS_UNKNOWN, &error);
@@ -483,8 +479,8 @@ vpoio_instr(struct vpoio_data *vpo, char *buffer, int size)
ppb_wctr(&vpo->vpo_dev, PCD |
H_AUTO | H_nSELIN | H_INIT | H_STROBE);
}
+ /* ppb_ecp_sync(&vpo->vpo_dev); */
#endif
- ppb_ecp_sync(&vpo->vpo_dev);
return (error);
}
@@ -492,6 +488,7 @@ vpoio_instr(struct vpoio_data *vpo, char *buffer, int size)
static char
vpoio_select(struct vpoio_data *vpo, int initiator, int target)
{
+ register int k;
int ret;
struct ppb_microseq select_microseq[] = {
@@ -708,10 +705,6 @@ vpoio_reset_bus(struct vpoio_data *vpo)
{
/* first, connect to the drive */
if (vpoio_connect(vpo, PPB_WAIT|PPB_INTR) || !vpoio_in_disk_mode(vpo)) {
-
-#ifdef VP0_DEBUG
- printf("%s: not in disk mode!\n", __FUNCTION__);
-#endif
/* release ppbus */
vpoio_disconnect(vpo);
return (1);