summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-01 17:41:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-01 17:41:01 +0000
commita9f0a5dc11acde8c2901b36ff5d4f5ad288d20c6 (patch)
treeef6037cd2df8f15d794a207d25908c3466886f2f
parent66e65e13d60443077f12a35777f4fb1641bb3ad7 (diff)
from netbsd
-rw-r--r--sys/arch/atari/dev/ncr5380.c68
1 files changed, 50 insertions, 18 deletions
diff --git a/sys/arch/atari/dev/ncr5380.c b/sys/arch/atari/dev/ncr5380.c
index 7111d6b4ab0..25911577caa 100644
--- a/sys/arch/atari/dev/ncr5380.c
+++ b/sys/arch/atari/dev/ncr5380.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ncr5380.c,v 1.11.2.1 1995/10/19 09:46:57 leo Exp $ */
+/* $NetBSD: ncr5380.c,v 1.11.2.2 1995/10/27 15:41:01 leo Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
@@ -392,7 +392,7 @@ ncr5380_scsi_cmd(struct scsi_xfer *xs)
#ifdef AUTO_SENSE
if (link) {
link->link = reqp;
- link->xcmd.bytes[link->xs->cmdlen-1] |= 1;
+ link->xcmd.bytes[link->xs->cmdlen-2] |= 1;
}
#endif
}
@@ -406,8 +406,8 @@ ncr5380_scsi_cmd(struct scsi_xfer *xs)
run_main(xs->sc_link->adapter_softc);
- if (xs->flags & SCSI_POLL)
- return (COMPLETE); /* We're booting */
+ if (xs->flags & (SCSI_POLL|ITSDONE))
+ return (COMPLETE); /* We're booting or run_main has completed */
return (SUCCESSFULLY_QUEUED);
}
@@ -549,6 +549,7 @@ struct ncr_softc *sc;
else splx(sps);
connected:
if (connected) {
+#ifdef REAL_DMA
/*
* If the host is currently connected but a 'real-dma' transfer
* is in progress, the 'end-of-dma' interrupt restarts main.
@@ -560,6 +561,7 @@ connected:
goto main_exit;
}
splx(sps);
+#endif /* REAL_DMA */
/*
* Let the target guide us through the bus-phases
@@ -1067,6 +1069,7 @@ SC_REQ *reqp;
u_int msg;
{
int sps;
+ SC_REQ *prev, *req;
PID("hmessage1");
switch (msg) {
@@ -1086,10 +1089,13 @@ u_int msg;
return (-1);
}
ack_message();
- reqp->xs->error = 0;
+ if (!(reqp->dr_flag & DRIVER_AUTOSEN)) {
+ reqp->xs->resid = reqp->xdata_len;
+ reqp->xs->error = 0;
+ }
#ifdef AUTO_SENSE
- if (check_autosense(reqp, 0) == -1)
+ if (check_autosense(reqp, 1) == -1)
return (-1);
#endif /* AUTO_SENSE */
@@ -1098,6 +1104,25 @@ u_int msg;
show_request(reqp->link, "LINK");
#endif
connected = reqp->link;
+
+ /*
+ * Unlink the 'linked' request from the issue_q
+ */
+ sps = splbio();
+ prev = NULL;
+ req = issue_q;
+ for (; req != NULL; prev = req, req = req->next) {
+ if (req == connected)
+ break;
+ }
+ if (req == NULL)
+ panic("Inconsistent issue_q");
+ if (prev == NULL)
+ issue_q = req->next;
+ else prev->next = req->next;
+ req->next = NULL;
+ splx(sps);
+
finish_req(reqp);
PID("hmessage3");
return (-1);
@@ -1187,17 +1212,8 @@ struct ncr_softc *sc;
* choose something long enough to suit all targets.
*/
SET_5380_REG(NCR5380_ICOM, SC_A_BSY);
- len = 1000;
+ len = 250000;
while ((GET_5380_REG(NCR5380_IDSTAT) & SC_S_SEL) && (len > 0)) {
-#ifdef notyet /* LWP: Should be looked after */
- if(!GET_5380_REG(NCR5380_DATA)) {
- /*
- * We stepped into the reselection timeout....
- */
- SET_5380_REG(NCR5380_ICOM, 0);
- return;
- }
-#endif /* notyet */
delay(1);
len--;
}
@@ -1210,6 +1226,18 @@ struct ncr_softc *sc;
SET_5380_REG(NCR5380_ICOM, 0);
/*
+ * Check if the reselection is still valid. Check twice because
+ * of possible line glitches - cheaper than delay(1) and we need
+ * only a few nanoseconds.
+ */
+ if (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY)) {
+ if (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY)) {
+ ncr_aprint(sc, "Stepped into the reselection timeout\n");
+ return;
+ }
+ }
+
+ /*
* Get the expected identify message.
*/
phase = PH_MSGIN;
@@ -1512,8 +1540,9 @@ int linked;
*/
PID("cautos1");
if (!(reqp->dr_flag & DRIVER_AUTOSEN)) {
- if (reqp->status == SCSCHKC) {
- memcpy(&reqp->xcmd, sense_cmd, sizeof(sense_cmd));
+ switch (reqp->status & SCSMASK) {
+ case SCSCHKC:
+ bcopy(sense_cmd, &reqp->xcmd, sizeof(sense_cmd));
reqp->xdata_ptr = (u_char *)&reqp->xs->sense;
reqp->xdata_len = sizeof(reqp->xs->sense);
reqp->dr_flag |= DRIVER_AUTOSEN;
@@ -1533,6 +1562,9 @@ int linked;
#endif
PID("cautos2");
return (-1);
+ case SCSBUSY:
+ reqp->xs->error = XS_BUSY;
+ return (0);
}
}
else {