DragonFly BSD
DragonFly submit List (threaded) for 2005-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Patches/cleanup for vpo driver


From: Jonathon McKitrick <jcm@xxxxxxxxxxxxxxxxx>
Date: Wed, 26 Jan 2005 15:57:03 +0000

I worked on this for a while, so I'll take responsibility for maintaining
it, if that's ok.

I don't think there are many parallel port ZIP disks out there anyway,
besides my own.  ;-)

Jonathon
--
The beaten path is for the beaten man.
Index: immio.c
===================================================================
RCS file: /usr/home/dcvs/src/sys/dev/disk/vpo/immio.c,v
retrieving revision 1.5
diff -u -r1.5 immio.c
--- immio.c	15 Mar 2004 01:10:44 -0000	1.5
+++ immio.c	24 Jan 2005 15:56:32 -0000
@@ -41,8 +41,7 @@
 #include <sys/module.h>
 #include <sys/bus.h>
 #include <sys/malloc.h>
-
-#endif	/* _KERNEL */
+#endif
 
 #include "opt_vpo.h"
 
@@ -54,16 +53,9 @@
 
 #include "ppbus_if.h"
 
-#define VP0_SELTMO		5000	/* select timeout */
-#define VP0_FAST_SPINTMO	500000	/* wait status timeout */
-#define VP0_LOW_SPINTMO		5000000	/* wait status timeout */
-
-#define VP0_SECTOR_SIZE	512
-
 /*
  * Microcode to execute very fast I/O sequences at the lowest bus level.
  */
-
 #define WAIT_RET		MS_PARAM(7, 2, MS_TYP_PTR)
 #define WAIT_TMO		MS_PARAM(1, 0, MS_TYP_INT)
 
@@ -71,15 +63,15 @@
 struct ppb_microseq wait_microseq[] = {					\
 	MS_CASS(0x0c),							\
 	MS_SET(MS_UNKNOWN),						\
-	/* loop */							\
-	MS_BRSET(nBUSY, 4 /* ready */),					\
-	MS_DBRA(-2 /* loop */),						\
+/* _loop */								\
+	MS_BRSET(nBUSY, 4 /* _ready */),				\
+	MS_DBRA(-2 /* _loop */),					\
 	MS_CASS(0x04),							\
 	MS_RET(1), /* timed out */					\
-	/* ready */							\
+/* _ready */								\
 	MS_CASS(0x04),							\
 	MS_RFETCH(MS_REG_STR, 0xb8, MS_UNKNOWN ),			\
-	MS_RET(0) /* no error */					\
+	MS_RET(0)							\
 }
 
 #define SELECT_TARGET		MS_PARAM(6, 1, MS_TYP_CHA)
@@ -87,27 +79,27 @@
 #define DECLARE_SELECT_MICROSEQUENCE \
 struct ppb_microseq select_microseq[] = {				\
 	MS_CASS(0xc),							\
-	/* first, check there is nothing holding onto the bus */	\
+	/* check there is nothing holding onto the bus */		\
 	MS_SET(VP0_SELTMO),						\
 /* _loop: */								\
 	MS_BRCLEAR(0x8, 2 /* _ready */),				\
 	MS_DBRA(-2 /* _loop */),					\
-	MS_RET(2),			/* bus busy */			\
+	MS_RET(2),	/* bus busy */					\
 /* _ready: */								\
 	MS_CASS(0x4),							\
 	MS_DASS(MS_UNKNOWN /* 0x80 | 1 << target */),			\
 	MS_DELAY(1),							\
 	MS_CASS(0xc),							\
 	MS_CASS(0xd),							\
-	/* now, wait until the drive is ready */			\
+	/* wait until the drive is ready */				\
 	MS_SET(VP0_SELTMO),						\
-/* loop: */								\
-	MS_BRSET(0x8, 3 /* ready */),					\
-	MS_DBRA(-2 /* loop */),						\
-/* error: */								\
+/* _loop2: */								\
+	MS_BRSET(0x8, 3 /* _ready2 */),					\
+	MS_DBRA(-2 /* _loop2 */),					\
+/* _error: */								\
 	MS_CASS(0xc),							\
 	MS_RET(VP0_ESELECT_TIMEOUT),					\
-/* ready: */								\
+/* _ready2: */								\
 	MS_CASS(0xc),							\
 	MS_RET(0)							\
 }
@@ -146,23 +138,23 @@
 	MS_RET(0)							\
 }
 
-#define NEGOCIATED_MODE		MS_PARAM(2, 1, MS_TYP_CHA)
+#define NEGOTIATED_MODE		MS_PARAM(2, 1, MS_TYP_CHA)
 
-#define DECLARE_NEGOCIATE_MICROSEQ \
-struct ppb_microseq negociate_microseq[] = {				\
+#define DECLARE_NEGOTIATE_MICROSEQ \
+struct ppb_microseq negotiate_microseq[] = {				\
 	MS_CASS(0x4),							\
 	MS_DELAY(5),							\
 	MS_DASS(MS_UNKNOWN /* mode */),					\
 	MS_DELAY(100),							\
 	MS_CASS(0x6),							\
 	MS_DELAY(5),							\
-	MS_BRSET(0x20, 5 /* continue */),				\
+	MS_BRSET(0x20, 5 /* _continue */),				\
 	MS_DELAY(5),							\
 	MS_CASS(0x7),							\
 	MS_DELAY(5),							\
 	MS_CASS(0x6),							\
-	MS_RET(VP0_ENEGOCIATE),						\
-/* continue: */								\
+	MS_RET(VP0_ENEGOTIATE),						\
+/* _continue: */							\
 	MS_DELAY(5),							\
 	MS_CASS(0x7),							\
 	MS_DELAY(5),							\
@@ -180,22 +172,21 @@
  * Retrieve the two nibbles and call the C function to generate the character
  * and store it in the buffer (see nibble_inbyte_hook())
  */
-
 #define DECLARE_NIBBLE_INBYTE_SUBMICROSEQ \
 struct ppb_microseq nibble_inbyte_submicroseq[] = {			\
 	MS_CASS(0x4),							\
-/* loop: */								\
+/* _loop: */								\
 	MS_CASS(0x6),							\
 	MS_DELAY(1),							\
-	MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* low nibble */),\
+	MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* lo nibble */),\
 	MS_CASS(0x5),							\
 	MS_DELAY(1),							\
-	MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* high nibble */),\
+	MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* hi nibble */),\
 	MS_CASS(0x4),							\
 	MS_DELAY(1),							\
 	/* do a C call to format the received nibbles */		\
 	MS_C_CALL(MS_UNKNOWN /* C hook */, MS_UNKNOWN /* param */),	\
-	MS_DBRA(-7 /* loop */),						\
+	MS_DBRA(-7 /* _loop */),					\
 	MS_RET(0)							\
 }
 
@@ -212,9 +203,7 @@
 };
 
 /*
- * nibble_inbyte_hook()
- *
- * Formats high and low nibble into a character
+ * Format high and low nibble into a character.
  */
 static int
 nibble_inbyte_hook (void *p, char *ptr)
@@ -223,45 +212,41 @@
 
 	/* increment the buffer pointer */
 	*ptr = ((s->l >> 4) & 0x0f) + (s->h & 0xf0);
-
-	return (0);
+	return(0);
 }
 
 /*
- * This is the sub-microseqence for MS_GET in PS2 mode
+ * Sub-microseqence for MS_GET in PS2 mode.
  */
 static struct ppb_microseq ps2_inbyte_submicroseq[] = {
 	  MS_CASS(0x4),
-
-/* loop: */
+/* _loop: */
 	  MS_CASS(PCD | 0x6),
 	  MS_RFETCH_P(1, MS_REG_DTR, MS_FETCH_ALL),
 	  MS_CASS(PCD | 0x5),
-	  MS_DBRA(-4 /* loop */),
-
+	  MS_DBRA(-4 /* _loop */),
 	  MS_RET(0)
 };
 
 /*
- * This is the sub-microsequence for MS_PUT in both NIBBLE and PS2 modes
+ * Sub-microsequence for MS_PUT in both NIBBLE and PS2 modes.
  */
 static struct ppb_microseq spp_outbyte_submicroseq[] = {
 	  MS_CASS(0x4),
-
-/* loop: */
+/* _loop: */
 	  MS_RASSERT_P(1, MS_REG_DTR), 
 	  MS_CASS(0x5),
 	  MS_DBRA(0),				/* decrement counter */
 	  MS_RASSERT_P(1, MS_REG_DTR), 
 	  MS_CASS(0x0),
-	  MS_DBRA(-6 /* loop */),
-
-	  /* return from the put call */
+	  MS_DBRA(-6 /* _loop */),
 	  MS_CASS(0x4),
 	  MS_RET(0)
 };
 
-/* EPP 1.7 microsequences, ptr and len set at runtime */
+/* 
+ * EPP 1.7 microsequences, ptr and len set at runtime.
+ */
 static struct ppb_microseq epp17_outstr[] = {
 	  MS_CASS(0x4),
 	  MS_RASSERT_P(MS_ACCUM, MS_REG_EPP_D), 
@@ -280,12 +265,10 @@
 imm_disconnect(struct vpoio_data *vpo, int *connected, int release_bus)
 {
 	DECLARE_CPP_MICROSEQ;
-
 	device_t ppbus = device_get_parent(vpo->vpo_dev);
 	char s1, s2, s3;
 	int ret;
 
-	/* all should be ok */
 	if (connected)
 		*connected = 0;
 
@@ -304,31 +287,29 @@
 	}
 
 	if (release_bus)
-		return (ppb_release_bus(ppbus, vpo->vpo_dev));
+		return(ppb_release_bus(ppbus, vpo->vpo_dev));
 	else
-		return (0);
+		return(0);
 }
 
 /*
- * how	: PPB_WAIT or PPB_DONTWAIT
+ * Connect the IMM adapter.
  */
 static int
-imm_connect(struct vpoio_data *vpo, int how, int *disconnected, int request_bus)
+imm_connect(struct vpoio_data *vpo, int wait_mode, int *disconnected, int request_bus)
 {
 	DECLARE_CPP_MICROSEQ;
-
 	device_t ppbus = device_get_parent(vpo->vpo_dev);
 	char s1, s2, s3;
 	int error;
 	int ret;
 
-	/* all should be ok */
 	if (disconnected)
 		*disconnected = 0;
 
 	if (request_bus)
-		if ((error = ppb_request_bus(ppbus, vpo->vpo_dev, how)))
-			return (error);
+		if ((error = ppb_request_bus(ppbus, vpo->vpo_dev, wait_mode)))
+			return(error);
 
 	ppb_MS_init_msq(cpp_microseq, 3, CPP_S1, (void *)&s1,
 			CPP_S2, (void *)&s2, CPP_S3, (void *)&s3);
@@ -356,12 +337,10 @@
 			*disconnected = VP0_ECONNECT;
 	}
 
-	return (0);
+	return(0);
 }
 
 /*
- * imm_detect()
- *
  * Detect and initialise the VP0 adapter.
  */
 static int
@@ -371,24 +350,22 @@
 	int error;
 
 	if ((error = ppb_request_bus(ppbus, vpo->vpo_dev, PPB_DONTWAIT)))
-		return (error);
+		return(error);
 
-	/* disconnect the drive, keep the bus */
+	/* Disconnect the drive, keep the bus. */
 	imm_disconnect(vpo, NULL, 0);
 
 	vpo->vpo_mode_found = VP0_MODE_UNDEFINED;
 	error = 1;
 
-	/* try to enter EPP mode since vpoio failure put the bus in NIBBLE */
-	if (ppb_set_mode(ppbus, PPB_EPP) != -1) {
+	/* Try to enter EPP mode since vpoio failure put the bus in NIBBLE. */
+	if (ppb_set_mode(ppbus, PPB_EPP) != -1)
 		imm_connect(vpo, PPB_DONTWAIT, &error, 0);
-	}
 
 	/* if connection failed try PS/2 then NIBBLE modes */
 	if (error) {
-		if (ppb_set_mode(ppbus, PPB_PS2) != -1) {
+		if (ppb_set_mode(ppbus, PPB_PS2) != -1)
 			imm_connect(vpo, PPB_DONTWAIT, &error, 0);
-		}
 		if (error) {
 			if (ppb_set_mode(ppbus, PPB_NIBBLE) != -1) {
 				imm_connect(vpo, PPB_DONTWAIT, &error, 0);
@@ -406,15 +383,16 @@
 		vpo->vpo_mode_found = VP0_MODE_EPP;
 	}
 
-	/* send SCSI reset signal */
+	/* Send SCSI reset signal. */
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, reset_microseq, NULL);
 
-	/* release the bus now */
+	/* Release the bus. */
 	imm_disconnect(vpo, &error, 1);
 
-	/* ensure we are disconnected or daisy chained peripheral 
-	 * may cause serious problem to the disk */
-
+	/* 
+	 * Ensure we are disconnected or daisy chained peripheral 
+	 * may cause serious problem to the disk.
+	 */
 	if (error) {
 		if (bootverbose)
 			printf("imm%d: can't disconnect from the drive\n",
@@ -422,15 +400,15 @@
 		goto error;
 	}
 
-	return (0);
+	return(0);
 
 error:
 	ppb_release_bus(ppbus, vpo->vpo_dev);
-	return (VP0_EINITFAILED);
+	return(VP0_EINITFAILED);
 }
 
 /*
- * imm_outstr()
+ * Send data to the drive.
  */
 static int
 imm_outstr(struct vpoio_data *vpo, char *buffer, int size)
@@ -444,11 +422,11 @@
 	ppb_MS_exec(ppbus, vpo->vpo_dev, MS_OP_PUT, (union ppb_insarg)buffer,
 		(union ppb_insarg)size, (union ppb_insarg)MS_UNKNOWN, &error);
 
-	return (error);
+	return(error);
 }
 
 /*
- * imm_instr()
+ * Read data from the drive.
  */
 static int
 imm_instr(struct vpoio_data *vpo, char *buffer, int size)
@@ -462,9 +440,12 @@
 	ppb_MS_exec(ppbus, vpo->vpo_dev, MS_OP_GET, (union ppb_insarg)buffer,
 		(union ppb_insarg)size, (union ppb_insarg)MS_UNKNOWN, &error);
 
-	return (error);
+	return(error);
 }
 
+/*
+ * Select the drive to accept our commands.
+ */
 static char
 imm_select(struct vpoio_data *vpo, int initiator, int target)
 {
@@ -478,20 +459,13 @@
 				
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, select_microseq, &ret);
 
-	return (ret);
+	return(ret);
 }
 
-/*
- * imm_wait()
- *
- * H_SELIN must be low.
- *
- */
 static char
 imm_wait(struct vpoio_data *vpo, int tmo)
 {
 	DECLARE_WAIT_MICROSEQUENCE;
-
 	device_t ppbus = device_get_parent(vpo->vpo_dev);
 	int ret, err;
 
@@ -502,7 +476,6 @@
 	 *		0xa8 = ZIP+ wants command
 	 *		0xb8 = end of transfer, ZIP+ is sending status
 	 */
-
 	ppb_MS_init_msq(wait_microseq, 2,
 			WAIT_RET, (void *)&ret,
 			WAIT_TMO, tmo);
@@ -510,68 +483,60 @@
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, wait_microseq, &err);
 
 	if (err)
-		return (0);			   /* command timed out */	
+		return(0);			   /* command timed out */	
 
 	return(ret);
 }
 
 static int
-imm_negociate(struct vpoio_data *vpo)
+imm_negotiate(struct vpoio_data *vpo)
 {
-	DECLARE_NEGOCIATE_MICROSEQ;
+	DECLARE_NEGOTIATE_MICROSEQ;
 	device_t ppbus = device_get_parent(vpo->vpo_dev);
-	int negociate_mode;
+	int negotiate_mode;
 	int ret;
 
 	if (PPB_IN_NIBBLE_MODE(ppbus))
-		negociate_mode = 0;
+		negotiate_mode = 0;
 	else if (PPB_IN_PS2_MODE(ppbus))
-		negociate_mode = 1;
+		negotiate_mode = 1;
 	else
-		return (0);
+		return(0);
 
 #if 0 /* XXX use standalone code not to depend on ppb_1284 code yet */
-	ret = ppb_1284_negociate(ppbus, negociate_mode);
+	ret = ppb_1284_negotiate(ppbus, negotiate_mode);
 
 	if (ret)
-		return (VP0_ENEGOCIATE);
+		return(VP0_ENEGOTIATE);
 #endif
 	
-	ppb_MS_init_msq(negociate_microseq, 1,
-			NEGOCIATED_MODE, negociate_mode);
+	ppb_MS_init_msq(negotiate_microseq, 1,
+			NEGOTIATED_MODE, negotiate_mode);
 
-	ppb_MS_microseq(ppbus, vpo->vpo_dev, negociate_microseq, &ret);
+	ppb_MS_microseq(ppbus, vpo->vpo_dev, negotiate_microseq, &ret);
 
-	return (ret);
+	return(ret);
 }
 
 /*
- * imm_probe()
- *
- * Low level probe of vpo device
- *
+ * Low level probe of imm device.
  */
 int
 imm_probe(device_t dev, struct vpoio_data *vpo)
 {
-	int error;
+	int error = 0;
 
-	/* ppbus dependent initialisation */
+	/* ppbus dependent initialisation. */
 	vpo->vpo_dev = dev;
 
-	/* now, try to initialise the drive */
-	if ((error = imm_detect(vpo))) {
-		return (error);
-	}
+	/* Try to initialise the drive. */
+	error = imm_detect(vpo);
 
-	return (0);
+	return(error);
 }
 
 /*
- * imm_attach()
- *
- * Low level attachment of vpo device
- *
+ * Low level attachment of imm device.
  */
 int
 imm_attach(struct vpoio_data *vpo)
@@ -580,9 +545,7 @@
 	device_t ppbus = device_get_parent(vpo->vpo_dev);
 	int error = 0;
 
-	/*
-	 * Initialize microsequence code
-	 */
+	/* Initialize microsequence code */
 	vpo->vpo_nibble_inbyte_msq = malloc(sizeof(nibble_inbyte_submicroseq),
 						M_DEVBUF, M_WAITOK);
 
@@ -596,13 +559,11 @@
 		INB_NIBBLE_F, nibble_inbyte_hook,
 		INB_NIBBLE_P, (void *)&(vpo)->vpo_nibble); 
 
-	/*
-	 * Initialize mode dependent in/out microsequences
-	 */
+	/* Initialize mode dependent in/out microsequences */
 	if ((error = ppb_request_bus(ppbus, vpo->vpo_dev, PPB_WAIT)))
 	    goto error;
 
-	/* ppbus automatically restore the last mode entered during detection */
+	/* ppbus restores the last mode entered during detection. */
 	switch (vpo->vpo_mode_found) {
 	case VP0_MODE_EPP:
 		ppb_MS_GET_init(ppbus, vpo->vpo_dev, epp17_instr);
@@ -625,39 +586,29 @@
 
 	ppb_release_bus(ppbus, vpo->vpo_dev);
  error:
-	return (error);
+	return(error);
 }
 
-/*
- * imm_reset_bus()
- *
- */
 int
 imm_reset_bus(struct vpoio_data *vpo)
 {
 	device_t ppbus = device_get_parent(vpo->vpo_dev);
 	int disconnected;
 
-	/* first, connect to the drive and request the bus */
+	/* Connect to the drive and request the bus. */
 	imm_connect(vpo, PPB_WAIT|PPB_INTR, &disconnected, 1);
 
 	if (!disconnected) {
-
-		/* reset the SCSI bus */
+		/* Reset the SCSI bus and disconnect. */
 		ppb_MS_microseq(ppbus, vpo->vpo_dev, reset_microseq, NULL);
-
-		/* then disconnect */
 		imm_disconnect(vpo, NULL, 1);
 	}
 
-	return (0);
+	return(0);
 }
 
 /*
- * imm_do_scsi()
- *
- * Send an SCSI command
- *
+ * Send a SCSI command.
  */
 int 
 imm_do_scsi(struct vpoio_data *vpo, int host, int target, char *command,
@@ -669,33 +620,34 @@
 	char l, h = 0;
 	int len, error = 0, not_connected = 0;
 	int k;
-	int negociated = 0;
+	int negotiated = 0;
 
 	/*
-	 * enter disk state, allocate the ppbus
+	 * Enter disk state, allocate the ppbus.
 	 *
 	 * XXX
 	 * Should we allow this call to be interruptible?
 	 * The only way to report the interruption is to return
 	 * EIO to upper SCSI code :^(
 	 */
-	if ((error = imm_connect(vpo, PPB_WAIT|PPB_INTR, &not_connected, 1)))
-		return (error);
+	if ((error = imm_connect(vpo, PPB_WAIT | PPB_INTR, &not_connected, 1)))
+		return(error);
 
 	if (not_connected) {
-		*ret = VP0_ECONNECT; goto error;
+		*ret = VP0_ECONNECT;
+		goto error;
 	}
 
 	/*
-	 * Select the drive ...
+	 * Select the drive.
 	 */
 	if ((*ret = imm_select(vpo,host,target)))
 		goto error;
 
 	/*
-	 * Send the command ...
+	 * Send the command.
 	 */
-	for (k = 0; k < clen; k+=2) {
+	for (k = 0; k < clen; k += 2) {
 		if (imm_wait(vpo, VP0_FAST_SPINTMO) != (char)0xa8) {
 			*ret = VP0_ECMD_TIMEOUT;
 			goto error;
@@ -707,28 +659,29 @@
 	}
 
 	if (!(r = imm_wait(vpo, VP0_LOW_SPINTMO))) {
-		*ret = VP0_ESTATUS_TIMEOUT; goto error;
+		*ret = VP0_ESTATUS_TIMEOUT;
+		goto error;
 	}
 
 	if ((r & 0x30) == 0x10) {
-		if (imm_negociate(vpo)) {
-			*ret = VP0_ENEGOCIATE;
+		if (imm_negotiate(vpo)) {
+			*ret = VP0_ENEGOTIATE;
 			goto error;
 		} else
-			negociated = 1;
+			negotiated = 1;
 	}
 
 	/* 
-	 * Complete transfer ... 
+	 * Complete transfer.
 	 */
 	*count = 0;
 	for (;;) {
-
 		if (!(r = imm_wait(vpo, VP0_LOW_SPINTMO))) {
-			*ret = VP0_ESTATUS_TIMEOUT; goto error;
+			*ret = VP0_ESTATUS_TIMEOUT;
+			goto error;
 		}
 
-		/* stop when the ZIP+ wants to send status */
+		/* Stop when the ZIP+ wants to send status. */
 		if (r == (char)0xb8)
 			break;
 
@@ -761,42 +714,42 @@
 		*count += len;
 	}
 
-	if ((PPB_IN_NIBBLE_MODE(ppbus) ||
-			PPB_IN_PS2_MODE(ppbus)) && negociated)
+	if ((PPB_IN_NIBBLE_MODE(ppbus) || PPB_IN_PS2_MODE(ppbus)) && negotiated)
 		ppb_MS_microseq(ppbus, vpo->vpo_dev, transfer_epilog, NULL);
 
 	/*
-	 * Retrieve status ...
+	 * Retrieve status.
 	 */
-	if (imm_negociate(vpo)) {
-		*ret = VP0_ENEGOCIATE;
+	if (imm_negotiate(vpo)) {
+		*ret = VP0_ENEGOTIATE;
 		goto error;
 	} else
-		negociated = 1;
+		negotiated = 1;
 
 	if (imm_instr(vpo, &l, 1)) {
-		*ret = VP0_EOTHER; goto error;
+		*ret = VP0_EOTHER;
+		goto error;
 	}
 
 	/* check if the ZIP+ wants to send more status */
 	if (imm_wait(vpo, VP0_FAST_SPINTMO) == (char)0xb8)
 		if (imm_instr(vpo, &h, 1)) {
-			*ret = VP0_EOTHER+2; goto error;
+			*ret = VP0_EOTHER + 2;
+			goto error;
 		}
 
 	/* Experience showed that we should discard this */
 	if (h == -1)
 		h = 0;
 
-	*result = ((int) h << 8) | ((int) l & 0xff);
+	*result = ((int)h << 8) | ((int)l & 0xff);
 
 error:
-	if ((PPB_IN_NIBBLE_MODE(ppbus) ||
-			PPB_IN_PS2_MODE(ppbus)) && negociated)
+	if ((PPB_IN_NIBBLE_MODE(ppbus) || PPB_IN_PS2_MODE(ppbus)) && negotiated)
 		ppb_MS_microseq(ppbus, vpo->vpo_dev, transfer_epilog, NULL);
 
 	/* return to printer state, release the ppbus */
 	imm_disconnect(vpo, NULL, 1);
 
-	return (0);
+	return(0);
 }
Index: vpo.c
===================================================================
RCS file: /usr/home/dcvs/src/sys/dev/disk/vpo/vpo.c,v
retrieving revision 1.4
diff -u -r1.4 vpo.c
--- vpo.c	15 Mar 2004 01:10:44 -0000	1.4
+++ vpo.c	24 Jan 2005 15:47:13 -0000
@@ -91,13 +91,9 @@
 static void
 vpo_identify(driver_t *driver, device_t parent)
 {
-
 	BUS_ADD_CHILD(parent, 0, "vpo", 0);
 }
 
-/*
- * vpo_probe()
- */
 static int
 vpo_probe(device_t dev)
 {
@@ -127,12 +123,9 @@
 		return (error);
 	}
 
-	return (0);
+	return(0);
 }
 
-/*
- * vpo_attach()
- */
 static int
 vpo_attach(device_t dev)
 {
@@ -143,39 +136,36 @@
 	/* low level attachment */
 	if (vpo->vpo_isplus) {
 		if ((error = imm_attach(&vpo->vpo_io)))
-			return (error);
+			return(error);
 	} else {
 		if ((error = vpoio_attach(&vpo->vpo_io)))
-			return (error);
+			return(error);
 	}
 
 	/*
-	**	Now tell the generic SCSI layer
-	**	about our bus.
-	*/
+	 *	Now tell the generic SCSI layer
+	 *	about our bus.
+	 */
 	devq = cam_simq_alloc(/*maxopenings*/1);
 	/* XXX What about low-level detach on error? */
 	if (devq == NULL)
-		return (ENXIO);
+		return(ENXIO);
 
 	vpo->sim = cam_sim_alloc(vpo_action, vpo_poll, "vpo", vpo,
 				 device_get_unit(dev),
 				 /*untagged*/1, /*tagged*/0, devq);
 	cam_simq_release(devq);
 	if (vpo->sim == NULL) {
-		return (ENXIO);
+		return(ENXIO);
 	}
 
 	if (xpt_bus_register(vpo->sim, /*bus*/0) != CAM_SUCCESS) {
 		cam_sim_free(vpo->sim);
-		return (ENXIO);
+		return(ENXIO);
 	}
 
-	/* all went ok */
-
 	vpo_cam_rescan(vpo);	/* have CAM rescan the bus */
-
-	return (0);
+	return(0);
 }
 
 static void
@@ -207,9 +197,6 @@
         /* The scan is in progress now. */
 }
 
-/*
- * vpo_intr()
- */
 static void
 vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio)
 {
@@ -268,7 +255,6 @@
 
 	   /* check if we have to sense the drive */
 	   if ((vpo->vpo_stat & SCSI_STATUS_CHECK_COND) != 0) {
-
 		vpo->vpo_sense.cmd.opcode = REQUEST_SENSE;
 		vpo->vpo_sense.cmd.length = csio->sense_len;
 		vpo->vpo_sense.cmd.control = 0;
@@ -291,7 +277,6 @@
 				&vpo->vpo_error);
 		}
 			
-
 #ifdef VP0_DEBUG
 		printf("(sense) vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n", 
 			errno, vpo->vpo_sense.stat, vpo->vpo_sense.count, vpo->vpo_error);
@@ -299,7 +284,6 @@
 
 		/* check sense return status */
 		if (errno == 0 && vpo->vpo_sense.stat == SCSI_STATUS_OK) {
-		   /* sense ok */
 		   csio->ccb_h.status = CAM_AUTOSNS_VALID | CAM_SCSI_STATUS_ERROR;
 		   csio->sense_resid = csio->sense_len - vpo->vpo_sense.count;
 
@@ -319,7 +303,6 @@
 		/* no sense */
 		csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;			
 	   }
-
 	   goto error;
 	}
 
@@ -328,14 +311,11 @@
 
 error:
 	splx(s);
-
-	return;
 }
 
 static void
 vpo_action(struct cam_sim *sim, union ccb *ccb)
 {
-
 	struct vpo_data *vpo = (struct vpo_data *)sim->softc;
 
 	switch (ccb->ccb_h.func_code) {
@@ -351,14 +331,12 @@
 #endif
 		
 		vpo_intr(vpo, csio);
-
 		xpt_done(ccb);
-
 		break;
 	}
 	case XPT_CALC_GEOMETRY:
 	{
-		struct	  ccb_calc_geometry *ccg;
+		struct ccb_calc_geometry *ccg;
 
 		ccg = &ccb->ccg;
 
@@ -437,15 +415,12 @@
 		xpt_done(ccb);
 		break;
 	}
-
-	return;
 }
 
 static void
 vpo_poll(struct cam_sim *sim)
 {       
-	/* The ZIP is actually always polled throw vpo_action() */
-	return;
+	/* The ZIP is actually always polled through vpo_action() */
 }
 
 static devclass_t vpo_devclass;
Index: vpoio.c
===================================================================
RCS file: /usr/home/dcvs/src/sys/dev/disk/vpo/vpoio.c,v
retrieving revision 1.5
diff -u -r1.5 vpoio.c
--- vpoio.c	15 Mar 2004 01:10:44 -0000	1.5
+++ vpoio.c	22 Jan 2005 13:59:14 -0000
@@ -55,13 +55,7 @@
 /*
  * The driver pools the drive. We may add a timeout queue to avoid
  * active polling on nACK. I've tried this but it leads to unreliable
- * transfers
- */
-#define VP0_SELTMO		5000	/* select timeout */
-#define VP0_FAST_SPINTMO	500000	/* wait status timeout */
-#define VP0_LOW_SPINTMO		5000000	/* wait status timeout */
-
-/*
+ * transfers.
  * Actually, VP0 timings are more accurate (about few 16MHZ cycles),
  * but succeeding in respecting such timings leads to architecture
  * dependent considerations.
@@ -98,7 +92,6 @@
 /*
  * Microcode to execute very fast I/O sequences at the lowest bus level.
  */
-
 #define WAIT_RET	MS_PARAM(4, 2, MS_TYP_PTR)
 #define WAIT_TMO	MS_PARAM(0, 0, MS_TYP_INT)
 
@@ -183,15 +176,14 @@
  * Retrieve the two nibbles and call the C function to generate the character
  * and store it in the buffer (see nibble_inbyte_hook())
  */
-
 #define DECLARE_NIBBLE_INBYTE_SUBMICROSEQ			\
 struct ppb_microseq nibble_inbyte_submicroseq[] = {		\
 /* loop: */							\
 	  MS_CASS( H_AUTO | H_SELIN | H_INIT | H_STROBE),	\
 	  MS_DELAY(VP0_PULSE),					\
-	  MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* high nibble */),\
+	  MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* hi nibble */),\
 	  MS_CASS(H_nAUTO | H_SELIN | H_INIT | H_STROBE),	\
-	  MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* low nibble */),\
+	  MS_RFETCH(MS_REG_STR, MS_FETCH_ALL, MS_UNKNOWN /* lo nibble */),\
 	  /* do a C call to format the received nibbles */	\
 	  MS_C_CALL(MS_UNKNOWN /* C hook */, MS_UNKNOWN /* param */),\
 	  MS_DBRA(-7 /* loop */),				\
@@ -282,7 +274,7 @@
 	int ret;
 
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, disconnect_microseq, &ret);
-	return (ppb_release_bus(ppbus, vpo->vpo_dev));
+	return(ppb_release_bus(ppbus, vpo->vpo_dev));
 }
 
 /*
 #ifdef VP0_DEBUG
 		printf("%s: can't request bus!\n", __FUNCTION__);
 #endif
-		return error;
+		return(error);
 	}
 
 	if (PPB_IN_EPP_MODE(ppbus))
@@ -308,7 +300,7 @@
 	else
 		ppb_MS_microseq(ppbus, vpo->vpo_dev, connect_spp_microseq, &ret);
 
-	return (0);
+	return(0);
 }
 
 /*
@@ -335,8 +327,6 @@
 
 	ppb_MS_init_msq(reset_microseq, 1, INITIATOR, 1 << VP0_INITIATOR);
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, reset_microseq, &ret);
-
-	return;
 }
 
 /*
@@ -349,8 +339,7 @@
 	int ret;
 
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, in_disk_mode, &ret);
-
-	return (ret);
+	return(ret);
 }
 
 /*
@@ -429,11 +418,11 @@
 	}
 
 	ppb_release_bus(ppbus, vpo->vpo_dev);
-	return (0);
+	return(0);
 
 error:
 	ppb_release_bus(ppbus, vpo->vpo_dev);
-	return (VP0_EINITFAILED);
+	return(VP0_EINITFAILED);
 }
 
 /*
@@ -450,7 +439,7 @@
 
 	ppb_ecp_sync(ppbus);
 
-	return (error);
+	return(error);
 }
 
 /*
@@ -467,7 +456,7 @@
 
 	ppb_ecp_sync(ppbus);
 
-	return (error);
+	return(error);
 }
 
 static char
@@ -506,9 +495,9 @@
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, select_microseq, &ret);
 
 	if (ret)
-		return (VP0_ESELECT_TIMEOUT);
+		return(VP0_ESELECT_TIMEOUT);
 
-	return (0);
+	return(0);
 }
 
 /*
@@ -548,7 +537,7 @@
 	ppb_MS_microseq(ppbus, vpo->vpo_dev, wait_microseq, &err);
 
 	if (err)
-		return (0);	 /* command timed out */	
+		return(0);	 /* command timed out */	
 
 	return(ret);
 }
@@ -577,7 +566,7 @@
 		return (error);
 	}
 
-	return (0);
+	return(0);
 }
 
 /*
@@ -636,7 +625,7 @@
 	ppb_release_bus(ppbus, vpo->vpo_dev);
 
 error:
-	return (error);
+	return(error);
 }
 
 /*
@@ -654,21 +643,16 @@
 #endif
 		/* release ppbus */
 		vpoio_disconnect(vpo);
-		return (1);
+		return(1);
 	}
 
 	/* reset the SCSI bus */
 	vpoio_reset(vpo);
-
-	/* then disconnect */
 	vpoio_disconnect(vpo);
-
-	return (0);
+	return(0);
 }
 
 /*
- * vpoio_do_scsi()
- *
  * Send an SCSI command
  *
  */
@@ -692,10 +676,11 @@
 	 * EIO do upper SCSI code :^(
 	 */
 	if ((error = vpoio_connect(vpo, PPB_WAIT|PPB_INTR)))
-		return (error);
+		return(error);
 
 	if (!vpoio_in_disk_mode(vpo)) {
-		*ret = VP0_ECONNECT; goto error;
+		*ret = VP0_ECONNECT; 
+		goto error;
 	}
 
 	if ((*ret = vpoio_select(vpo,host,target)))
@@ -727,7 +712,8 @@
 	for (;;) {
 
 		if (!(r = vpoio_wait(vpo, VP0_LOW_SPINTMO))) {
-			*ret = VP0_ESTATUS_TIMEOUT; goto error;
+			*ret = VP0_ESTATUS_TIMEOUT; 
+			goto error;
 		}
 
 		/* stop when the ZIP wants to send status */
@@ -763,13 +749,15 @@
 	}
 
 	if (vpoio_instr(vpo, &l, 1)) {
-		*ret = VP0_EOTHER; goto error;
+		*ret = VP0_EOTHER; 
+		goto error;
 	}
 
 	/* check if the ZIP wants to send more status */
 	if (vpoio_wait(vpo, VP0_FAST_SPINTMO) == (char)0xf0)
 		if (vpoio_instr(vpo, &h, 1)) {
-			*ret = VP0_EOTHER+2; goto error;
+			*ret = VP0_EOTHER+2; 
+			goto error;
 		}
 
 	*result = ((int) h << 8) | ((int) l & 0xff);
@@ -777,5 +765,5 @@
 error:
 	/* return to printer state, release the ppbus */
 	vpoio_disconnect(vpo);
-	return (0);
+	return(0);
 }
Index: vpoio.h
===================================================================
RCS file: /usr/home/dcvs/src/sys/dev/disk/vpo/vpoio.h,v
retrieving revision 1.2
diff -u -r1.2 vpoio.h
--- vpoio.h	17 Jun 2003 04:28:29 -0000	1.2
+++ vpoio.h	22 Jan 2005 13:59:42 -0000
@@ -30,10 +30,8 @@
 #ifndef __VP0IO_H
 #define __VP0IO_H
 
-/*
- * The ZIP drive cannot act as an initiator.
- */
-#define VP0_INITIATOR	0x7
+/* The ZIP drive cannot act as an initiator. */
+#define VP0_INITIATOR		0x7
 
 #define VP0_ESELECT_TIMEOUT	1
 #define VP0_ECMD_TIMEOUT	2
@@ -42,23 +40,17 @@
 #define VP0_EDATA_OVERFLOW	5	
 #define VP0_EDISCONNECT		6
 #define VP0_EPPDATA_TIMEOUT	7
-#define VP0_ENEGOCIATE		8
+#define VP0_ENEGOTIATE		8
 #define VP0_ENOPORT		9
 #define VP0_EINITFAILED		10
 #define VP0_EINTR		12
-
 #define VP0_EOTHER		13
 
-#define VP0_OPENNINGS	1
+#define VP0_SECTOR_SIZE		512
 
-/*
- * Data structure used during microsequence execution
- * when characters are received in nibble mode
- */
-struct vpo_nibble {
-	char h;			/* most significant nibble */
-	char l;			/* less significant nibble */
-};
+#define VP0_SELTMO              5000    /* select timeout */
+#define VP0_FAST_SPINTMO        500000  /* wait status timeout */
+#define VP0_LOW_SPINTMO         5000000 /* wait status timeout */
 
 /* Mode found during initialisation */
 #define VP0_MODE_UNDEFINED	0x0
@@ -66,34 +58,35 @@
 #define VP0_MODE_PS2		0x2
 #define VP0_MODE_EPP		0x3
 
+#define vpoio_set_unit(vpo, unit) ((vpo)->vpo_unit = unit)
+
+/*
+ * Data structure used during microsequence execution
+ * when characters are received in nibble mode.
+ */
+struct vpo_nibble {
+	char h;			/* hi nibble */
+	char l;			/* lo nibble */
+};
+
+/* Per-unit data for vpo driver. */
 struct vpoio_data {
 	unsigned short int vpo_unit;
-	int vpo_mode_found;		/* Mode found during init */
-
+	int vpo_mode_found;
 	struct vpo_nibble vpo_nibble;
-
-	/* each device must have its own nibble inbyte microsequence */
 	struct ppb_microseq *vpo_nibble_inbyte_msq;
-
 	device_t vpo_dev;
 };
 
-#define vpoio_set_unit(vpo,unit) ((vpo)->vpo_unit = unit)
-
 int vpoio_probe(device_t dev, struct vpoio_data *vpo);
-
 int vpoio_attach(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);
-
+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);
 int imm_probe(device_t dev, 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);


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]