summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornsouch <nsouch@FreeBSD.org>1998-09-13 18:26:26 +0000
committernsouch <nsouch@FreeBSD.org>1998-09-13 18:26:26 +0000
commit5cc33ee728b656673a8728d17e20571446aa70b5 (patch)
tree5c6c2e36e8a7af235f1d9c33ab99602d4dbed9a1
parenta35f9a9ecfa09df02ced63a2453c256721f8ad38 (diff)
downloadFreeBSD-src-5cc33ee728b656673a8728d17e20571446aa70b5.zip
FreeBSD-src-5cc33ee728b656673a8728d17e20571446aa70b5.tar.gz
ppbus enhanced to support ZIP+ : 1284 code added, microseq improved +
some bugs corrected in vpoio.
-rw-r--r--sys/dev/ppbus/ppb_1284.c89
-rw-r--r--sys/dev/ppbus/ppb_1284.h48
-rw-r--r--sys/dev/ppbus/ppb_base.c4
-rw-r--r--sys/dev/ppbus/ppb_msq.c10
-rw-r--r--sys/dev/ppbus/ppb_msq.h22
-rw-r--r--sys/dev/ppbus/ppbconf.c25
-rw-r--r--sys/dev/ppbus/ppbconf.h9
-rw-r--r--sys/dev/ppbus/vpo.c59
-rw-r--r--sys/dev/ppbus/vpoio.c136
-rw-r--r--sys/dev/ppbus/vpoio.h13
10 files changed, 286 insertions, 129 deletions
diff --git a/sys/dev/ppbus/ppb_1284.c b/sys/dev/ppbus/ppb_1284.c
index 0a0ddeb..e13a69c 100644
--- a/sys/dev/ppbus/ppb_1284.c
+++ b/sys/dev/ppbus/ppb_1284.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_1284.c,v 1.3 1998/01/31 07:23:06 eivind Exp $
+ * $Id: ppb_1284.c,v 1.4 1998/08/03 19:14:31 msmith Exp $
*
*/
@@ -107,7 +107,7 @@ nibble_1284_inbyte(struct ppb_device *dev, char *buffer)
for (i = 0; i < 2; i++) {
/* ready to take data (nAUTO low) */
- ppb_wctr(dev, AUTOFEED | nSTROBE | nINIT | nSELECTIN);
+ ppb_wctr(dev, AUTOFEED & ~(STROBE | SELECTIN));
if ((error = do_1284_wait(dev, nACK, 0)))
return (error);
@@ -115,12 +115,8 @@ nibble_1284_inbyte(struct ppb_device *dev, char *buffer)
/* read nibble */
nibble[i] = ppb_rstr(dev);
-#ifdef DEBUG_1284
- printf("nibble_1284_inbyte: nibble[%d]=0x%x\n", i, nibble[i]);
-#endif
-
/* ack, not ready for another nibble */
- ppb_wctr(dev, nAUTOFEED | nSTROBE | nINIT | nSELECTIN);
+ ppb_wctr(dev, 0 & ~(AUTOFEED | STROBE | SELECTIN));
/* wait ack from peripherial */
if ((error = do_1284_wait(dev, nACK, nACK)))
@@ -130,10 +126,6 @@ nibble_1284_inbyte(struct ppb_device *dev, char *buffer)
*buffer = ((nibble2char(nibble[1]) << 4) & 0xf0) |
(nibble2char(nibble[0]) & 0x0f);
-#ifdef DEBUG_1284
- printf("nibble_1284_inbyte: byte=0x%x\n", *buffer);
-#endif
-
return (0);
}
@@ -160,35 +152,80 @@ nibble_1284_sync(struct ppb_device *dev)
}
/*
- * nibble_1284_mode()
+ * ppb_1284_negociate()
*
* Normal nibble mode or request device id mode (see ppb_1284.h)
*/
int
-nibble_1284_mode(struct ppb_device *dev, int mode)
+ppb_1284_negociate(struct ppb_device *dev, int mode)
{
- char ctrl;
int error;
+ int phase = 0;
- ctrl = ppb_rctr(dev);
+ ppb_wctr(dev, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED));
+ DELAY(1);
ppb_wdtr(dev, mode);
- DELAY(5);
+ DELAY(1);
- ppb_wctr(dev, (ctrl & ~SELECTIN) | AUTOFEED);
- if ((error = do_1284_wait(dev, nACK | ERROR | SELECT | nFAULT,
- ERROR | SELECT | nFAULT))) {
- ppb_wctr(dev, ctrl);
- return (error);
- }
+ ppb_wctr(dev, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN));
- ppb_wctr(dev, ppb_rctr(dev) | STROBE);
- DELAY(5);
+ if ((error = do_1284_wait(dev, nACK | PERROR | SELECT | nFAULT,
+ PERROR | SELECT | nFAULT)))
+ goto error;
- ppb_wctr(dev, ppb_rctr(dev) & ~STROBE);
+ phase = 1;
+
+ ppb_wctr(dev, (nINIT | STROBE | AUTOFEED) & ~SELECTIN);
DELAY(5);
- ppb_wctr(dev, ppb_rctr(dev) & ~AUTOFEED);
+ ppb_wctr(dev, nINIT & ~(SELECTIN | AUTOFEED | STROBE));
+
+#if 0 /* not respected by most devices */
+ if ((error = do_1284_wait(dev, nACK, nACK)))
+ goto error;
+
+ if (mode == 0)
+ if ((error = do_1284_wait(dev, SELECT, 0)))
+ goto error;
+ else
+ if ((error = do_1284_wait(dev, SELECT, SELECT)))
+ goto error;
+#endif
+
+ return (0);
+
+error:
+ if (bootverbose)
+ printf("%s: status=0x%x %d\n", __FUNCTION__, ppb_rstr(dev), phase);
+
+ return (error);
+}
+
+int
+ppb_1284_terminate(struct ppb_device *dev, int how)
+{
+ int error;
+
+ switch (how) {
+ case VALID_STATE:
+
+ ppb_wctr(dev, SELECTIN & ~(STROBE | AUTOFEED));
+
+ if ((error = do_1284_wait(dev, nACK | nBUSY | nFAULT, nFAULT)))
+ return (error);
+
+ ppb_wctr(dev, (SELECTIN | AUTOFEED) & ~STROBE);
+
+ if ((error = do_1284_wait(dev, nACK, nACK)))
+ return (error);
+
+ ppb_wctr(dev, SELECTIN & ~(STROBE | AUTOFEED));
+ break;
+
+ default:
+ return (EINVAL);
+ }
return (0);
}
diff --git a/sys/dev/ppbus/ppb_1284.h b/sys/dev/ppbus/ppb_1284.h
index 980fe68..1cc98d4 100644
--- a/sys/dev/ppbus/ppb_1284.h
+++ b/sys/dev/ppbus/ppb_1284.h
@@ -23,21 +23,63 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_1284.h,v 1.1 1997/08/16 14:05:33 msmith Exp $
+ * $Id: ppb_1284.h,v 1.2 1998/08/03 19:14:31 msmith Exp $
*
*/
#ifndef __1284_H
#define __1284_H
+/*
+ * IEEE1284 signals
+ */
+
+/* host driven signals */
+
+#define nHostClk STROBE
+#define Write STROBE
+
+#define nHostBusy AUTOFEED
+#define nHostAck AUTOFEED
+#define DStrb AUTOFEED
+
+#define nReveseRequest nINIT
+
+#define nActive1284 SELECTIN
+#define AStrb SELECTIN
+
+/* peripheral driven signals */
+
+#define nDataAvail nFAULT
+#define nPeriphRequest nFAULT
+
+#define Xflag SELECT
+
+#define AckDataReq PERROR
+#define nAckReverse PERROR
+
+#define nPtrBusy nBUSY
+#define nPeriphAck nBUSY
+#define Wait nBUSY
+
+#define PtrClk nACK
+#define PeriphClk nACK
+#define Intr nACK
+
+/* request mode values */
#define NIBBLE_1284_NORMAL 0
#define NIBBLE_1284_REQUEST_ID 4
-extern int do_1284_wait(struct ppb_device *, char, char);
+/* how to terminate */
+#define VALID_STATE 0
+#define IMMEDIATE 1
-extern int byte_1284_inbyte(struct ppb_device *, char *);
+extern int do_1284_wait(struct ppb_device *, char, char);
extern int nibble_1284_inbyte(struct ppb_device *, char *);
extern void nibble_1284_sync(struct ppb_device *);
extern int nibble_1284_mode(struct ppb_device *, 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 6bea760..7555b24 100644
--- a/sys/dev/ppbus/ppb_base.c
+++ b/sys/dev/ppbus/ppb_base.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppb_base.c,v 1.3 1997/09/01 00:51:45 bde Exp $
+ * $Id: ppb_base.c,v 1.4 1998/08/03 19:14:31 msmith Exp $
*
*/
#include <sys/param.h>
@@ -172,7 +172,7 @@ ppb_get_status(struct ppb_device *dev, struct ppb_status *status)
status->timeout = r & TIMEOUT;
status->error = !(r & nFAULT);
status->select = r & SELECT;
- status->paper_end = r & ERROR;
+ status->paper_end = r & PERROR;
status->ack = !(r & nACK);
status->busy = !(r & nBUSY);
diff --git a/sys/dev/ppbus/ppb_msq.c b/sys/dev/ppbus/ppb_msq.c
index fff70a7..0890e49 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.1.2.4 1998/06/16 23:35:51 son Exp $
+ * $Id: ppb_msq.c,v 1.1.2.3 1998/06/14 14:36:26 son Exp $
*
*/
#include <machine/stdarg.h>
@@ -215,7 +215,7 @@ ppb_MS_init_msq(struct ppb_microseq *msq, int nbparam, ...)
break;
case MS_TYP_CHA:
- msq[ins].arg[arg].c = va_arg(p_list, char);
+ msq[ins].arg[arg].i = (int)va_arg(p_list, char);
break;
case MS_TYP_PTR:
@@ -303,7 +303,8 @@ ppb_MS_microseq(struct ppb_device *dev, struct ppb_microseq *msq, int *ret)
break;
case MS_OP_RET:
- *ret = mi->arg[0].i; /* return code */
+ if (ret)
+ *ret = mi->arg[0].i; /* return code */
return (0);
break;
@@ -320,7 +321,8 @@ ppb_MS_microseq(struct ppb_device *dev, struct ppb_microseq *msq, int *ret)
}
}
error:
- *ret = error;
+ if (ret)
+ *ret = error;
return (0);
}
diff --git a/sys/dev/ppbus/ppb_msq.h b/sys/dev/ppbus/ppb_msq.h
index 71e41b2..cdc8154 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.1.2.6 1998/06/17 00:37:12 son Exp $
+ * $Id: ppb_msq.h,v 1.1.2.7 1998/06/20 19:03:47 son Exp $
*
*/
#ifndef __PPB_MSQ_H
@@ -73,8 +73,8 @@
#define MS_OP_RET 10 /* ret <retcode> */
#define MS_OP_C_CALL 11 /* c_call <function>, <parameter> */
#define MS_OP_PTR 12 /* ptr <pointer> */
-#define MS_RESERVED_1 13 /* reserved */
-#define MS_RESERVED_2 14 /* reserved */
+#define MS_OP_ADELAY 13 /* adelay <val> */
+#define MS_OP_BRSTAT 14 /* brstat <mask>, <mask>, <offset> */
#define MS_OP_SUBRET 15 /* subret <code> */
#define MS_OP_CALL 16 /* call <microsequence> */
#define MS_OP_RASSERT_P 17 /* rassert_p <iter>, <reg> */
@@ -88,7 +88,11 @@
#define MS_FETCH_ALL 0xff
/* undefined parameter value */
-#define MS_UNKNOWN 0
+#define MS_NULL 0
+#define MS_UNKNOWN MS_NULL
+
+/* predifined parameters */
+#define MS_ACCUM -1 /* use accum previously set by MS_OP_SET */
/* these are register numbers according to our PC-like parallel port model */
#define MS_REG_DTR 0x0
@@ -121,9 +125,12 @@
#define MS_SASS(byte) MS_RASSERT(MS_REG_STR,byte)
#define MS_CASS(byte) MS_RASSERT(MS_REG_CTR,byte)
-#define MS_SET(offset) { MS_OP_SET, { offset } }
+#define MS_SET(accum) { MS_OP_SET, { accum } }
#define MS_BRSET(mask,offset) { MS_OP_BRSET, { mask, offset } }
#define MS_DBRA(offset) { MS_OP_DBRA, { offset } }
+#define MS_BRCLEAR(mask,offset) { MS_OP_BRCLEAR, { mask, offset } }
+#define MS_BRSTAT(mask_set,mask_clr,offset) \
+ { MS_OP_BRSTAT, { mask_set, mask_clr, offset } }
/* C function or submicrosequence call */
#define MS_C_CALL(function,parameter) \
@@ -137,7 +144,10 @@
#define MS_GET(ptr,len) { MS_OP_GET, { ptr, len } }
/* delay in microseconds */
-#define MS_DELAY(delay) { MS_OP_DELAY, { delay } }
+#define MS_DELAY(udelay) { MS_OP_DELAY, { udelay } }
+
+/* asynchroneous delay in ms */
+#define MS_ADELAY(mdelay) { MS_OP_ADELAY, { mdelay } }
/* return from submicrosequence execution or microseqence execution */
#define MS_SUBRET(code) { MS_OP_SUBRET, { code } }
diff --git a/sys/dev/ppbus/ppbconf.c b/sys/dev/ppbus/ppbconf.c
index 5756327..b9c2ca0 100644
--- a/sys/dev/ppbus/ppbconf.c
+++ b/sys/dev/ppbus/ppbconf.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ppbconf.c,v 1.4 1997/09/01 00:51:46 bde Exp $
+ * $Id: ppbconf.c,v 1.6 1998/08/03 19:14:31 msmith Exp $
*
*/
#include <sys/param.h>
@@ -94,6 +94,8 @@ static char *pnp_classes[] = {
* search_token()
*
* Search the first occurence of a token within a string
+ *
+ * XXX should use strxxx() calls
*/
static char *
search_token(char *str, int slen, char *token)
@@ -155,23 +157,25 @@ ppb_pnp_detect(struct ppb_data *ppb)
return (-1);
}
- ppb_wctr(&pnpdev, nINIT | SELECTIN);
-
- /* select NIBBLE_1284_REQUEST_ID mode */
- if ((error = nibble_1284_mode(&pnpdev, NIBBLE_1284_REQUEST_ID))) {
+ if ((error = ppb_1284_negociate(&pnpdev, NIBBLE_1284_REQUEST_ID))) {
if (bootverbose)
- printf("ppb: <PnP> nibble_1284_mode()=%d\n", error);
+ printf("ppb: <PnP> ppb_1284_negociate()=%d\n", error);
+
goto end_detect;
}
-
+
len = 0;
- for (q = str; !(ppb_rstr(&pnpdev) & ERROR); q++) {
+ for (q=str; !(ppb_rstr(&pnpdev) & PERROR); q++) {
if ((error = nibble_1284_inbyte(&pnpdev, q))) {
- if (bootverbose)
+ 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;
}
+
if (len++ >= PPB_PnP_STRING_SIZE) {
printf("ppb: <PnP> not space left!\n");
goto end_detect;
@@ -237,6 +241,9 @@ ppb_pnp_detect(struct ppb_data *ppb)
class_id = PPB_PnP_UNKNOWN;
end_detect:
+ if ((error = ppb_1284_terminate(&pnpdev, VALID_STATE)) && bootverbose)
+ printf("ppb: ppb_1284_terminate()=%d\n", error);
+
ppb_release_bus(&pnpdev);
return (class_id);
}
diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h
index fc723d4..c941541 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.6 1998/06/07 19:44:21 phk Exp $
+ * $Id: ppbconf.h,v 1.7 1998/08/03 19:14:31 msmith Exp $
*
*/
#ifndef __PPBCONF_H
@@ -51,6 +51,8 @@
#define PPB_IS_EPP(mode) (mode & PPB_EPP)
#define PPB_IN_EPP_MODE(dev) (PPB_IS_EPP (ppb_get_mode (dev)))
+#define PPB_IN_NIBBLE_MODE(dev) (ppb_get_mode (dev) & PPB_NIBBLE)
+#define PPB_IN_PS2_MODE(dev) (ppb_get_mode (dev) & PPB_PS2)
#define n(flags) (~(flags) & (flags))
@@ -76,7 +78,7 @@
#define TIMEOUT 0x01
#define nFAULT 0x08
#define SELECT 0x10
-#define ERROR 0x20
+#define PERROR 0x20
#define nACK 0x40
#define nBUSY 0x80
@@ -115,7 +117,6 @@ struct ppb_status {
union ppb_insarg {
int i;
- char c;
void *p;
int (* f)(void *, char *);
};
@@ -214,6 +215,8 @@ struct ppb_link {
int adapter_unit; /* unit of the adapter */
int base; /* base address of the port */
int id_irq; /* != 0 if irq enabled */
+ int accum; /* microseq accum */
+ char *ptr; /* current buffer pointer */
#define EPP_1_9 0x0 /* default */
#define EPP_1_7 0x1
diff --git a/sys/dev/ppbus/vpo.c b/sys/dev/ppbus/vpo.c
index aa5779a..d728b62 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.4 1997/09/01 00:51:52 bde Exp $
+ * $Id: vpo.c,v 1.6 1998/08/03 19:14:31 msmith Exp $
*
*/
@@ -61,6 +61,8 @@ struct vpo_data {
int vpo_count;
int vpo_error;
+ int vpo_isplus;
+
struct ppb_status vpo_status;
struct vpo_sense vpo_sense;
@@ -162,7 +164,10 @@ vpoprobe(struct ppb_data *ppb)
/* low level probe */
vpoio_set_unit(&vpo->vpo_io, vpo->vpo_unit);
- if (!(dev = vpoio_probe(ppb, &vpo->vpo_io))) {
+ if ((dev = imm_probe(ppb, &vpo->vpo_io))) {
+ vpo->vpo_isplus = 1;
+
+ } else if (!(dev = vpoio_probe(ppb, &vpo->vpo_io))) {
free(vpo, M_DEVBUF);
return (NULL);
}
@@ -183,8 +188,13 @@ vpoattach(struct ppb_device *dev)
struct vpo_data *vpo = vpodata[dev->id_unit];
/* low level attachment */
- if (!vpoio_attach(&vpo->vpo_io))
- return (0);
+ if (vpo->vpo_isplus) {
+ if (!imm_attach(&vpo->vpo_io))
+ return (0);
+ } else {
+ if (!vpoio_attach(&vpo->vpo_io))
+ return (0);
+ }
vpo->sc_link.adapter_unit = vpo->vpo_unit;
vpo->sc_link.adapter_targ = VP0_INITIATOR;
@@ -202,7 +212,8 @@ vpoattach(struct ppb_device *dev)
scbus->adapter_link = &vpo->sc_link;
/* all went ok */
- printf("vpo%d: <Iomega PPA-3/VPI0 SCSI controller>\n", dev->id_unit);
+ printf("vpo%d: <Iomega PPA-3/VPI0/IMM SCSI controller>\n",
+ dev->id_unit);
scsi_attachdevs(scbus);
@@ -231,10 +242,17 @@ vpo_intr(struct vpo_data *vpo, struct scsi_xfer *xs)
if (xs->datalen && !(xs->flags & SCSI_DATA_IN))
bcopy(xs->data, vpo->vpo_buffer, xs->datalen);
- errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
- xs->sc_link->target, (char *)xs->cmd, xs->cmdlen,
- vpo->vpo_buffer, xs->datalen, &vpo->vpo_stat, &vpo->vpo_count,
- &vpo->vpo_error);
+ if (vpo->vpo_isplus) {
+ errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
+ xs->sc_link->target, (char *)xs->cmd, xs->cmdlen,
+ vpo->vpo_buffer, xs->datalen, &vpo->vpo_stat,
+ &vpo->vpo_count, &vpo->vpo_error);
+ } else {
+ errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
+ xs->sc_link->target, (char *)xs->cmd, xs->cmdlen,
+ vpo->vpo_buffer, xs->datalen, &vpo->vpo_stat,
+ &vpo->vpo_count, &vpo->vpo_error);
+ }
#ifdef VP0_DEBUG
printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
@@ -269,12 +287,23 @@ vpo_intr(struct vpo_data *vpo, struct scsi_xfer *xs)
vpo->vpo_sense.cmd.length = sizeof(xs->sense);
vpo->vpo_sense.cmd.control = 0;
- errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
- xs->sc_link->target, (char *)&vpo->vpo_sense.cmd,
- sizeof(vpo->vpo_sense.cmd),
- (char *)&xs->sense, sizeof(xs->sense),
- &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
- &vpo->vpo_error);
+ if (vpo->vpo_isplus) {
+ errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
+ xs->sc_link->target,
+ (char *)&vpo->vpo_sense.cmd,
+ sizeof(vpo->vpo_sense.cmd),
+ (char *)&xs->sense, sizeof(xs->sense),
+ &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
+ &vpo->vpo_error);
+ } else {
+ errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
+ xs->sc_link->target,
+ (char *)&vpo->vpo_sense.cmd,
+ sizeof(vpo->vpo_sense.cmd),
+ (char *)&xs->sense, sizeof(xs->sense),
+ &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
+ &vpo->vpo_error);
+ }
if (errno)
/* connection to ppbus interrupted */
diff --git a/sys/dev/ppbus/vpoio.c b/sys/dev/ppbus/vpoio.c
index c853846..8c1bf18 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.1.2.4 1998/06/16 23:35:52 son Exp $
+ * $Id: vpoio.c,v 1.1.2.6 1998/08/07 01:59:49 son Exp $
*
*/
@@ -77,8 +77,8 @@
#define H_nBSY nBUSY
#define H_SEL SELECT
#define H_nSEL n(SELECT)
-#define H_ERR ERROR
-#define H_nERR n(ERROR)
+#define H_ERR PERROR
+#define H_nERR n(PERROR)
#define H_ACK nACK
#define H_nACK n(nACK)
#define H_FLT nFAULT
@@ -92,8 +92,18 @@
* Microcode to execute very fast I/O sequences at the lowest bus level.
*/
-#define trig_d_pulse MS_TRIG(MS_REG_CTR,5,(int)d_pulse)
-char d_pulse[] = {
+/* call this macro to initialize connect/disconnect microsequences */
+#define INIT_TRIG_MICROSEQ { \
+ int i; \
+ for (i=1; i <= 7; i+=2) { \
+ disconnect_microseq[i].arg[2] = (void *)d_pulse; \
+ connect_epp_microseq[i].arg[2] = \
+ connect_spp_microseq[i].arg[2] = (void *)c_pulse; \
+ } \
+}
+
+#define trig_d_pulse MS_TRIG(MS_REG_CTR,5,MS_UNKNOWN /* d_pulse */)
+static char d_pulse[] = {
H_AUTO | H_nSELIN | H_INIT | H_STROBE, 0,
H_nAUTO | H_nSELIN | H_INIT | H_STROBE, VP0_PULSE,
H_AUTO | H_nSELIN | H_INIT | H_STROBE, 0,
@@ -101,8 +111,8 @@ char d_pulse[] = {
H_AUTO | H_nSELIN | H_INIT | H_STROBE, VP0_PULSE
};
-#define trig_c_pulse MS_TRIG(MS_REG_CTR,5,(int)c_pulse)
-char c_pulse[] = {
+#define trig_c_pulse MS_TRIG(MS_REG_CTR,5,MS_UNKNOWN /* c_pulse */)
+static char c_pulse[] = {
H_AUTO | H_nSELIN | H_INIT | H_STROBE, 0,
H_AUTO | H_SELIN | H_INIT | H_STROBE, 0,
H_nAUTO | H_SELIN | H_INIT | H_STROBE, VP0_PULSE,
@@ -110,17 +120,17 @@ char c_pulse[] = {
H_AUTO | H_nSELIN | H_INIT | H_STROBE, VP0_PULSE
};
-struct ppb_microseq disconnect_microseq[] = {
+static struct ppb_microseq disconnect_microseq[] = {
MS_DASS(0x0), trig_d_pulse, MS_DASS(0x3c), trig_d_pulse,
MS_DASS(0x20), trig_d_pulse, MS_DASS(0xf), trig_d_pulse, MS_RET(0)
};
-struct ppb_microseq connect_epp_microseq[] = {
+static struct ppb_microseq connect_epp_microseq[] = {
MS_DASS(0x0), trig_c_pulse, MS_DASS(0x3c), trig_c_pulse,
MS_DASS(0x20), trig_c_pulse, MS_DASS(0xcf), trig_c_pulse, MS_RET(0)
};
-struct ppb_microseq connect_spp_microseq[] = {
+static struct ppb_microseq connect_spp_microseq[] = {
MS_DASS(0x0), trig_c_pulse, MS_DASS(0x3c), trig_c_pulse,
MS_DASS(0x20), trig_c_pulse, MS_DASS(0x8f), trig_c_pulse, MS_RET(0)
};
@@ -144,6 +154,8 @@ nibble_inbyte_hook (void *p, char *ptr)
/*
* Macro used to initialize each vpoio_data structure during
* low level attachment
+ *
+ * XXX should be converted to ppb_MS_init_msq()
*/
#define INIT_NIBBLE_INBYTE_SUBMICROSEQ(vpo) { \
(vpo)->vpo_nibble_inbyte_msq[2].arg[2].p = \
@@ -161,7 +173,7 @@ nibble_inbyte_hook (void *p, char *ptr)
* Retrieve the two nibbles and call the C function to generate the character
* and store it in the buffer (see nibble_inbyte_hook())
*/
-struct ppb_microseq nibble_inbyte_submicroseq[] = {
+static struct ppb_microseq nibble_inbyte_submicroseq[] = {
/* loop: */
MS_CASS( H_AUTO | H_SELIN | H_INIT | H_STROBE),
@@ -181,7 +193,7 @@ struct ppb_microseq nibble_inbyte_submicroseq[] = {
/*
* This is the sub-microseqence for MS_GET in PS2 mode
*/
-struct ppb_microseq ps2_inbyte_submicroseq[] = {
+static struct ppb_microseq ps2_inbyte_submicroseq[] = {
MS_CASS(PCD | H_AUTO | H_SELIN | H_INIT | H_nSTROBE),
/* loop: */
@@ -197,7 +209,7 @@ struct ppb_microseq ps2_inbyte_submicroseq[] = {
/*
* This is the sub-microsequence for MS_PUT in both NIBBLE and PS2 modes
*/
-struct ppb_microseq spp_outbyte_submicroseq[] = {
+static struct ppb_microseq spp_outbyte_submicroseq[] = {
/* loop: */
MS_RASSERT_P(1, MS_REG_DTR),
@@ -211,7 +223,7 @@ struct ppb_microseq spp_outbyte_submicroseq[] = {
};
/* EPP 1.7 microsequences, ptr and len set at runtime */
-struct ppb_microseq epp17_outstr_body[] = {
+static struct ppb_microseq epp17_outstr_body[] = {
MS_CASS(H_AUTO | H_SELIN | H_INIT | H_STROBE),
/* loop: */
@@ -226,7 +238,7 @@ struct ppb_microseq epp17_outstr_body[] = {
MS_RET(1)
};
-struct ppb_microseq epp17_instr_body[] = {
+static struct ppb_microseq epp17_instr_body[] = {
MS_CASS(PCD | H_AUTO | H_SELIN | H_INIT | H_STROBE),
/* loop: */
@@ -241,6 +253,19 @@ struct ppb_microseq epp17_instr_body[] = {
MS_RET(1)
};
+static struct ppb_microseq in_disk_mode[] = {
+ MS_CASS( H_AUTO | H_nSELIN | H_INIT | H_STROBE),
+ MS_CASS(H_nAUTO | H_nSELIN | H_INIT | H_STROBE),
+
+ MS_BRCLEAR(H_FLT, 4 /* error */),
+ MS_CASS( H_AUTO | H_nSELIN | H_INIT | H_STROBE),
+ MS_BRSET(H_FLT, 2 /* error */),
+
+ MS_RET(0),
+/* error: */
+ MS_RET(1)
+};
+
static int
vpoio_disconnect(struct vpoio_data *vpo)
{
@@ -271,52 +296,43 @@ vpoio_connect(struct vpoio_data *vpo, int how)
}
/*
- * vpoio_in_disk_mode()
- *
- * Check if we are in disk mode
+ * vpoio_reset()
*
- * XXX should be ported to microseq with MS_ASSERT()
+ * SCSI reset signal, the drive must be in disk mode
*/
-static int
-vpoio_in_disk_mode(struct vpoio_data *vpo)
+static void
+vpoio_reset (struct vpoio_data *vpo)
{
+ int ret;
- /* first, set H_AUTO high */
- ppb_wctr(&vpo->vpo_dev, H_AUTO | H_nSELIN | H_INIT | H_STROBE);
+ struct ppb_microseq reset_microseq[] = {
- /* when H_AUTO is set low, H_FLT should be high */
- ppb_wctr(&vpo->vpo_dev, H_nAUTO | H_nSELIN | H_INIT | H_STROBE);
- if ((ppb_rstr(&vpo->vpo_dev) & H_FLT) == 0)
- return (0);
+ #define INITIATOR MS_PARAM(0, 1, MS_TYP_INT)
- /* when H_AUTO is set high, H_FLT should be low */
- ppb_wctr(&vpo->vpo_dev, H_AUTO | H_nSELIN | H_INIT | H_STROBE);
- if ((ppb_rstr(&vpo->vpo_dev) & H_FLT) != 0)
- return (0);
+ MS_DASS(MS_UNKNOWN),
+ MS_CASS(H_AUTO | H_nSELIN | H_nINIT | H_STROBE),
+ MS_DELAY(25),
+ MS_CASS(H_AUTO | H_nSELIN | H_INIT | H_STROBE),
+ MS_RET(0)
+ };
- return (1);
+ ppb_MS_init_msq(reset_microseq, 1, INITIATOR, 1 << VP0_INITIATOR);
+ ppb_MS_microseq(&vpo->vpo_dev, reset_microseq, &ret);
+
+ return;
}
/*
- * vpoio_reset()
- *
- * SCSI reset signal, the drive must be in disk mode
- *
- * XXX should be ported to microseq with MS_TRIG()
+ * vpoio_in_disk_mode()
*/
-static void
-vpoio_reset (struct vpoio_data *vpo)
+static int
+vpoio_in_disk_mode(struct vpoio_data *vpo)
{
+ int ret;
- /*
- * SCSI reset signal.
- */
- ppb_wdtr(&vpo->vpo_dev, (1 << VP0_INITIATOR));
- ppb_wctr(&vpo->vpo_dev, H_AUTO | H_nSELIN | H_nINIT | H_STROBE);
- DELAY(25);
- ppb_wctr(&vpo->vpo_dev, H_AUTO | H_nSELIN | H_INIT | H_STROBE);
+ ppb_MS_microseq(&vpo->vpo_dev, in_disk_mode, &ret);
- return;
+ return (ret);
}
/*
@@ -324,14 +340,13 @@ vpoio_reset (struct vpoio_data *vpo)
*
* Detect and initialise the VP0 adapter.
*/
-int
+static int
vpoio_detect(struct vpoio_data *vpo)
{
-
vpoio_disconnect(vpo);
vpoio_connect(vpo, PPB_DONTWAIT);
- if (!vpoio_in_disk_mode(vpo)) {
+ if (vpoio_in_disk_mode(vpo)) {
vpoio_disconnect(vpo);
return (VP0_EINITFAILED);
}
@@ -341,7 +356,10 @@ vpoio_detect(struct vpoio_data *vpo)
vpoio_disconnect(vpo);
- if (vpoio_in_disk_mode(vpo))
+ /* ensure we are disconnected or daisy chained peripheral
+ * may cause serious problem to the disk */
+
+ if (!vpoio_in_disk_mode(vpo))
return (VP0_EINITFAILED);
return (0);
@@ -524,6 +542,11 @@ vpoio_probe(struct ppb_data *ppb, struct vpoio_data *vpo)
vpo->vpo_dev.name = "vpo";
vpo->vpo_dev.ppb = ppb;
+ /*
+ * Initialize microsequence code
+ */
+ INIT_TRIG_MICROSEQ;
+
/* now, try to initialise the drive */
if (vpoio_detect(vpo)) {
return (NULL);
@@ -546,12 +569,9 @@ vpoio_attach(struct vpoio_data *vpo)
/*
* Report ourselves
*/
- printf("vpo%d: <Iomega VPI0 Parallel to SCSI adapter> on ppbus %d\n",
+ printf("vpo%d: <Iomega VPI0 Parallel to SCSI interface> on ppbus %d\n",
vpo->vpo_dev.id_unit, vpo->vpo_dev.ppb->ppb_link->adapter_unit);
- /*
- * Initialize microsequence code
- */
vpo->vpo_nibble_inbyte_msq = (struct ppb_microseq *)malloc(
sizeof(nibble_inbyte_submicroseq), M_DEVBUF, M_NOWAIT);
@@ -646,9 +666,7 @@ int
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) == 0)) {
-
+ if (vpoio_connect(vpo, PPB_WAIT|PPB_INTR) || vpoio_in_disk_mode(vpo)) {
/* release ppbus */
vpoio_disconnect(vpo);
return (1);
@@ -691,7 +709,7 @@ vpoio_do_scsi(struct vpoio_data *vpo, int host, int target, char *command,
if ((error = vpoio_connect(vpo, PPB_WAIT|PPB_INTR)))
return (error);
- if (!vpoio_in_disk_mode(vpo)) {
+ if (vpoio_in_disk_mode(vpo)) {
*ret = VP0_ECONNECT; goto error;
}
diff --git a/sys/dev/ppbus/vpoio.h b/sys/dev/ppbus/vpoio.h
index 40c5c01..1bd7d11 100644
--- a/sys/dev/ppbus/vpoio.h
+++ b/sys/dev/ppbus/vpoio.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: vpoio.h,v 1.1.2.3 1998/06/14 15:37:21 son Exp $
+ * $Id: vpoio.h,v 1.1.2.2 1998/06/14 14:37:43 son Exp $
*
*/
#ifndef __VP0IO_H
@@ -41,6 +41,7 @@
#define VP0_EDATA_OVERFLOW 5
#define VP0_EDISCONNECT 6
#define VP0_EPPDATA_TIMEOUT 7
+#define VP0_ENEGOCIATE 8
#define VP0_ENOPORT 9
#define VP0_EINITFAILED 10
#define VP0_EINTR 12
@@ -74,11 +75,19 @@ struct vpoio_data {
struct ppb_device *vpoio_probe(struct ppb_data *ppb, struct vpoio_data *vpo);
int vpoio_attach(struct vpoio_data *vpo);
-int vpoio_detect(struct vpoio_data *vpo);
int vpoio_reset_bus(struct vpoio_data *vpo);
int vpoio_do_scsi(struct vpoio_data *vpo, int host, int target, char *command,
int clen, char *buffer, int blen, int *result, int *count,
int *ret);
+struct ppb_device *imm_probe(struct ppb_data *ppb, struct vpoio_data *vpo);
+
+int imm_attach(struct vpoio_data *vpo);
+int imm_reset_bus(struct vpoio_data *vpo);
+
+int imm_do_scsi(struct vpoio_data *vpo, int host, int target, char *command,
+ int clen, char *buffer, int blen, int *result, int *count,
+ int *ret);
+
#endif
OpenPOWER on IntegriCloud