Add an assertion mechanism to check for more abnormal conditions.
This commit is contained in:
parent
58cb5339d6
commit
51bed8d804
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: aic6360.c,v 1.17 1994/11/29 20:57:28 mycroft Exp $ */
|
/* $NetBSD: aic6360.c,v 1.18 1994/11/29 21:29:56 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||||
@ -622,9 +622,11 @@ struct aic_softc { /* One of these per adapter */
|
|||||||
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; /**/
|
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; /**/
|
||||||
#define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
|
#define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
|
||||||
#define AIC_BREAK() do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
|
#define AIC_BREAK() do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
|
||||||
|
#define AIC_ASSERT(x) do {if (x) {} else {printf("aic at line %d: assertion failed\n", __LINE__); Debugger();}} while (0)
|
||||||
#else
|
#else
|
||||||
#define AIC_PRINT(b, s)
|
#define AIC_PRINT(b, s)
|
||||||
#define AIC_BREAK()
|
#define AIC_BREAK()
|
||||||
|
#define AIC_ASSERT(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
|
#define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
|
||||||
@ -888,7 +890,7 @@ aic_init(aic)
|
|||||||
TAILQ_INIT(&aic->ready_list);
|
TAILQ_INIT(&aic->ready_list);
|
||||||
TAILQ_INIT(&aic->nexus_list);
|
TAILQ_INIT(&aic->nexus_list);
|
||||||
TAILQ_INIT(&aic->free_list);
|
TAILQ_INIT(&aic->free_list);
|
||||||
aic->nexus = 0;
|
aic->nexus = NULL;
|
||||||
acb = aic->acb;
|
acb = aic->acb;
|
||||||
bzero(acb, sizeof(aic->acb));
|
bzero(acb, sizeof(aic->acb));
|
||||||
for (r = 0; r < sizeof(aic->acb) / sizeof(*acb); r++) {
|
for (r = 0; r < sizeof(aic->acb) / sizeof(*acb); r++) {
|
||||||
@ -1180,7 +1182,8 @@ aic_sched(aic)
|
|||||||
* Find first acb in ready queue that is for a target/lunit pair that
|
* Find first acb in ready queue that is for a target/lunit pair that
|
||||||
* is not busy.
|
* is not busy.
|
||||||
*/
|
*/
|
||||||
for (acb = aic->ready_list.tqh_first; acb; acb = acb->chain.tqe_next) {
|
for (acb = aic->ready_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next) {
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
ti = &aic->tinfo[sc->target];
|
ti = &aic->tinfo[sc->target];
|
||||||
if ((ti->lubusy & (1<<sc->lun)) == 0) {
|
if ((ti->lubusy & (1<<sc->lun)) == 0) {
|
||||||
@ -1286,7 +1289,7 @@ aic_done(acb)
|
|||||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||||
} else {
|
} else {
|
||||||
register struct acb *acb2;
|
register struct acb *acb2;
|
||||||
for (acb2 = aic->nexus_list.tqh_first; acb2;
|
for (acb2 = aic->nexus_list.tqh_first; acb2 != NULL;
|
||||||
acb2 = acb2->chain.tqe_next)
|
acb2 = acb2->chain.tqe_next)
|
||||||
if (acb2 == acb) {
|
if (acb2 == acb) {
|
||||||
TAILQ_REMOVE(&aic->nexus_list, acb, chain);
|
TAILQ_REMOVE(&aic->nexus_list, acb, chain);
|
||||||
@ -1294,7 +1297,7 @@ aic_done(acb)
|
|||||||
/* XXXX Should we call aic_sched() here? */
|
/* XXXX Should we call aic_sched() here? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (acb2)
|
if (acb2 != NULL)
|
||||||
;
|
;
|
||||||
else if (acb->chain.tqe_next) {
|
else if (acb->chain.tqe_next) {
|
||||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||||
@ -1447,15 +1450,17 @@ nextbyte:
|
|||||||
u_char selid, target, lun;
|
u_char selid, target, lun;
|
||||||
|
|
||||||
case AIC_CONNECTED:
|
case AIC_CONNECTED:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
sc = acb->xs->sc_link;
|
ti = &aic->tinfo[acb->xs->sc_link->target];
|
||||||
ti = &aic->tinfo[sc->target];
|
|
||||||
|
|
||||||
switch (aic->imess[0]) {
|
switch (aic->imess[0]) {
|
||||||
case MSG_CMDCOMPLETE:
|
case MSG_CMDCOMPLETE:
|
||||||
if (aic->dleft < 0) {
|
if (aic->dleft < 0) {
|
||||||
printf("aic: %d extra bytes from %d:%d\n",
|
sc = acb->xs->sc_link;
|
||||||
-aic->dleft, sc->target, sc->lun);
|
printf("%s: %d extra bytes from %d:%d\n",
|
||||||
|
aic->sc_dev.dv_xname,
|
||||||
|
-aic->dleft, sc->target, sc->lun);
|
||||||
acb->dleft = 0;
|
acb->dleft = 0;
|
||||||
}
|
}
|
||||||
acb->xs->resid = acb->dleft = aic->dleft;
|
acb->xs->resid = acb->dleft = aic->dleft;
|
||||||
@ -1595,13 +1600,13 @@ nextbyte:
|
|||||||
*/
|
*/
|
||||||
target = ffs(selid) - 1;
|
target = ffs(selid) - 1;
|
||||||
lun = aic->imess[0] & 0x07;
|
lun = aic->imess[0] & 0x07;
|
||||||
for (acb = aic->nexus_list.tqh_first; acb != 0;
|
for (acb = aic->nexus_list.tqh_first; acb != NULL;
|
||||||
acb = acb->chain.tqe_next) {
|
acb = acb->chain.tqe_next) {
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
if (sc->target == target && sc->lun == lun)
|
if (sc->target == target && sc->lun == lun)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (acb == 0) {
|
if (acb == NULL) {
|
||||||
printf("aic at line %d: reselect from target %d lun %d with no nexus; sending DEVICE RESET\n", __LINE__, target, lun);
|
printf("aic at line %d: reselect from target %d lun %d with no nexus; sending DEVICE RESET\n", __LINE__, target, lun);
|
||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
@ -1720,6 +1725,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
aic->omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun);
|
aic->omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun);
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -1731,6 +1737,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
||||||
aic->omess[4] = MSG_EXTENDED;
|
aic->omess[4] = MSG_EXTENDED;
|
||||||
aic->omess[3] = 3;
|
aic->omess[3] = 3;
|
||||||
@ -1746,6 +1753,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
||||||
aic->omess[3] = MSG_EXTENDED;
|
aic->omess[3] = MSG_EXTENDED;
|
||||||
aic->omess[2] = 2;
|
aic->omess[2] = 2;
|
||||||
@ -2181,6 +2189,7 @@ aicintr(aic)
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
|
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
@ -2222,6 +2231,7 @@ aicintr(aic)
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
|
|
||||||
outb(SXFRCTL1, 0);
|
outb(SXFRCTL1, 0);
|
||||||
@ -2267,11 +2277,13 @@ aicintr(aic)
|
|||||||
printf("aic at line %d: unexpected BUS FREE; aborting\n", __LINE__);
|
printf("aic at line %d: unexpected BUS FREE; aborting\n", __LINE__);
|
||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
acb->xs->error = XS_DRIVER_STUFFUP;
|
acb->xs->error = XS_DRIVER_STUFFUP;
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
case AIC_DISCONNECT:
|
case AIC_DISCONNECT:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
aic->state = AIC_IDLE;
|
aic->state = AIC_IDLE;
|
||||||
aic->nexus = NULL;
|
aic->nexus = NULL;
|
||||||
@ -2280,6 +2292,7 @@ aicintr(aic)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
case AIC_CMDCOMPLETE:
|
case AIC_CMDCOMPLETE:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
finish:
|
finish:
|
||||||
untimeout(aic_timeout, acb);
|
untimeout(aic_timeout, acb);
|
||||||
@ -2321,6 +2334,7 @@ aicintr(aic)
|
|||||||
case PH_CMD: /* CMD phase & REQ asserted */
|
case PH_CMD: /* CMD phase & REQ asserted */
|
||||||
#if AIC_DEBUG
|
#if AIC_DEBUG
|
||||||
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
printf("cmd=0x%02x+%d ",
|
printf("cmd=0x%02x+%d ",
|
||||||
acb->cmd.opcode, acb->clen-1);
|
acb->cmd.opcode, acb->clen-1);
|
||||||
@ -2345,6 +2359,7 @@ aicintr(aic)
|
|||||||
goto nextphase;
|
goto nextphase;
|
||||||
|
|
||||||
case PH_STAT:
|
case PH_STAT:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
outb(SXFRCTL0, CHEN|SPIOEN);
|
outb(SXFRCTL0, CHEN|SPIOEN);
|
||||||
outb(DMACNTRL0, RSTFIFO);
|
outb(DMACNTRL0, RSTFIFO);
|
||||||
@ -2434,13 +2449,15 @@ aic_print_active_acb()
|
|||||||
struct aic_softc *aic = aiccd.cd_devs[0];
|
struct aic_softc *aic = aiccd.cd_devs[0];
|
||||||
|
|
||||||
printf("ready list:\n");
|
printf("ready list:\n");
|
||||||
for (acb = aic->ready_list.tqh_first; acb; acb = acb->chain.tqe_next)
|
for (acb = aic->ready_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next)
|
||||||
aic_print_acb(acb);
|
aic_print_acb(acb);
|
||||||
printf("nexus:\n");
|
printf("nexus:\n");
|
||||||
if (aic->nexus)
|
if (aic->nexus != NULL)
|
||||||
aic_print_acb(aic->nexus);
|
aic_print_acb(aic->nexus);
|
||||||
printf("nexus list:\n");
|
printf("nexus list:\n");
|
||||||
for (acb = aic->nexus_list.tqh_first; acb; acb = acb->chain.tqe_next)
|
for (acb = aic->nexus_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next)
|
||||||
aic_print_acb(acb);
|
aic_print_acb(acb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: aic6360.c,v 1.17 1994/11/29 20:57:28 mycroft Exp $ */
|
/* $NetBSD: aic6360.c,v 1.18 1994/11/29 21:29:56 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||||
@ -622,9 +622,11 @@ struct aic_softc { /* One of these per adapter */
|
|||||||
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; /**/
|
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; /**/
|
||||||
#define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
|
#define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
|
||||||
#define AIC_BREAK() do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
|
#define AIC_BREAK() do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
|
||||||
|
#define AIC_ASSERT(x) do {if (x) {} else {printf("aic at line %d: assertion failed\n", __LINE__); Debugger();}} while (0)
|
||||||
#else
|
#else
|
||||||
#define AIC_PRINT(b, s)
|
#define AIC_PRINT(b, s)
|
||||||
#define AIC_BREAK()
|
#define AIC_BREAK()
|
||||||
|
#define AIC_ASSERT(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
|
#define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
|
||||||
@ -888,7 +890,7 @@ aic_init(aic)
|
|||||||
TAILQ_INIT(&aic->ready_list);
|
TAILQ_INIT(&aic->ready_list);
|
||||||
TAILQ_INIT(&aic->nexus_list);
|
TAILQ_INIT(&aic->nexus_list);
|
||||||
TAILQ_INIT(&aic->free_list);
|
TAILQ_INIT(&aic->free_list);
|
||||||
aic->nexus = 0;
|
aic->nexus = NULL;
|
||||||
acb = aic->acb;
|
acb = aic->acb;
|
||||||
bzero(acb, sizeof(aic->acb));
|
bzero(acb, sizeof(aic->acb));
|
||||||
for (r = 0; r < sizeof(aic->acb) / sizeof(*acb); r++) {
|
for (r = 0; r < sizeof(aic->acb) / sizeof(*acb); r++) {
|
||||||
@ -1180,7 +1182,8 @@ aic_sched(aic)
|
|||||||
* Find first acb in ready queue that is for a target/lunit pair that
|
* Find first acb in ready queue that is for a target/lunit pair that
|
||||||
* is not busy.
|
* is not busy.
|
||||||
*/
|
*/
|
||||||
for (acb = aic->ready_list.tqh_first; acb; acb = acb->chain.tqe_next) {
|
for (acb = aic->ready_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next) {
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
ti = &aic->tinfo[sc->target];
|
ti = &aic->tinfo[sc->target];
|
||||||
if ((ti->lubusy & (1<<sc->lun)) == 0) {
|
if ((ti->lubusy & (1<<sc->lun)) == 0) {
|
||||||
@ -1286,7 +1289,7 @@ aic_done(acb)
|
|||||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||||
} else {
|
} else {
|
||||||
register struct acb *acb2;
|
register struct acb *acb2;
|
||||||
for (acb2 = aic->nexus_list.tqh_first; acb2;
|
for (acb2 = aic->nexus_list.tqh_first; acb2 != NULL;
|
||||||
acb2 = acb2->chain.tqe_next)
|
acb2 = acb2->chain.tqe_next)
|
||||||
if (acb2 == acb) {
|
if (acb2 == acb) {
|
||||||
TAILQ_REMOVE(&aic->nexus_list, acb, chain);
|
TAILQ_REMOVE(&aic->nexus_list, acb, chain);
|
||||||
@ -1294,7 +1297,7 @@ aic_done(acb)
|
|||||||
/* XXXX Should we call aic_sched() here? */
|
/* XXXX Should we call aic_sched() here? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (acb2)
|
if (acb2 != NULL)
|
||||||
;
|
;
|
||||||
else if (acb->chain.tqe_next) {
|
else if (acb->chain.tqe_next) {
|
||||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||||
@ -1447,15 +1450,17 @@ nextbyte:
|
|||||||
u_char selid, target, lun;
|
u_char selid, target, lun;
|
||||||
|
|
||||||
case AIC_CONNECTED:
|
case AIC_CONNECTED:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
sc = acb->xs->sc_link;
|
ti = &aic->tinfo[acb->xs->sc_link->target];
|
||||||
ti = &aic->tinfo[sc->target];
|
|
||||||
|
|
||||||
switch (aic->imess[0]) {
|
switch (aic->imess[0]) {
|
||||||
case MSG_CMDCOMPLETE:
|
case MSG_CMDCOMPLETE:
|
||||||
if (aic->dleft < 0) {
|
if (aic->dleft < 0) {
|
||||||
printf("aic: %d extra bytes from %d:%d\n",
|
sc = acb->xs->sc_link;
|
||||||
-aic->dleft, sc->target, sc->lun);
|
printf("%s: %d extra bytes from %d:%d\n",
|
||||||
|
aic->sc_dev.dv_xname,
|
||||||
|
-aic->dleft, sc->target, sc->lun);
|
||||||
acb->dleft = 0;
|
acb->dleft = 0;
|
||||||
}
|
}
|
||||||
acb->xs->resid = acb->dleft = aic->dleft;
|
acb->xs->resid = acb->dleft = aic->dleft;
|
||||||
@ -1595,13 +1600,13 @@ nextbyte:
|
|||||||
*/
|
*/
|
||||||
target = ffs(selid) - 1;
|
target = ffs(selid) - 1;
|
||||||
lun = aic->imess[0] & 0x07;
|
lun = aic->imess[0] & 0x07;
|
||||||
for (acb = aic->nexus_list.tqh_first; acb != 0;
|
for (acb = aic->nexus_list.tqh_first; acb != NULL;
|
||||||
acb = acb->chain.tqe_next) {
|
acb = acb->chain.tqe_next) {
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
if (sc->target == target && sc->lun == lun)
|
if (sc->target == target && sc->lun == lun)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (acb == 0) {
|
if (acb == NULL) {
|
||||||
printf("aic at line %d: reselect from target %d lun %d with no nexus; sending DEVICE RESET\n", __LINE__, target, lun);
|
printf("aic at line %d: reselect from target %d lun %d with no nexus; sending DEVICE RESET\n", __LINE__, target, lun);
|
||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
@ -1720,6 +1725,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
aic->omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun);
|
aic->omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun);
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -1731,6 +1737,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
||||||
aic->omess[4] = MSG_EXTENDED;
|
aic->omess[4] = MSG_EXTENDED;
|
||||||
aic->omess[3] = 3;
|
aic->omess[3] = 3;
|
||||||
@ -1746,6 +1753,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
||||||
aic->omess[3] = MSG_EXTENDED;
|
aic->omess[3] = MSG_EXTENDED;
|
||||||
aic->omess[2] = 2;
|
aic->omess[2] = 2;
|
||||||
@ -2181,6 +2189,7 @@ aicintr(aic)
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
|
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
@ -2222,6 +2231,7 @@ aicintr(aic)
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
|
|
||||||
outb(SXFRCTL1, 0);
|
outb(SXFRCTL1, 0);
|
||||||
@ -2267,11 +2277,13 @@ aicintr(aic)
|
|||||||
printf("aic at line %d: unexpected BUS FREE; aborting\n", __LINE__);
|
printf("aic at line %d: unexpected BUS FREE; aborting\n", __LINE__);
|
||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
acb->xs->error = XS_DRIVER_STUFFUP;
|
acb->xs->error = XS_DRIVER_STUFFUP;
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
case AIC_DISCONNECT:
|
case AIC_DISCONNECT:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
aic->state = AIC_IDLE;
|
aic->state = AIC_IDLE;
|
||||||
aic->nexus = NULL;
|
aic->nexus = NULL;
|
||||||
@ -2280,6 +2292,7 @@ aicintr(aic)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
case AIC_CMDCOMPLETE:
|
case AIC_CMDCOMPLETE:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
finish:
|
finish:
|
||||||
untimeout(aic_timeout, acb);
|
untimeout(aic_timeout, acb);
|
||||||
@ -2321,6 +2334,7 @@ aicintr(aic)
|
|||||||
case PH_CMD: /* CMD phase & REQ asserted */
|
case PH_CMD: /* CMD phase & REQ asserted */
|
||||||
#if AIC_DEBUG
|
#if AIC_DEBUG
|
||||||
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
printf("cmd=0x%02x+%d ",
|
printf("cmd=0x%02x+%d ",
|
||||||
acb->cmd.opcode, acb->clen-1);
|
acb->cmd.opcode, acb->clen-1);
|
||||||
@ -2345,6 +2359,7 @@ aicintr(aic)
|
|||||||
goto nextphase;
|
goto nextphase;
|
||||||
|
|
||||||
case PH_STAT:
|
case PH_STAT:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
outb(SXFRCTL0, CHEN|SPIOEN);
|
outb(SXFRCTL0, CHEN|SPIOEN);
|
||||||
outb(DMACNTRL0, RSTFIFO);
|
outb(DMACNTRL0, RSTFIFO);
|
||||||
@ -2434,13 +2449,15 @@ aic_print_active_acb()
|
|||||||
struct aic_softc *aic = aiccd.cd_devs[0];
|
struct aic_softc *aic = aiccd.cd_devs[0];
|
||||||
|
|
||||||
printf("ready list:\n");
|
printf("ready list:\n");
|
||||||
for (acb = aic->ready_list.tqh_first; acb; acb = acb->chain.tqe_next)
|
for (acb = aic->ready_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next)
|
||||||
aic_print_acb(acb);
|
aic_print_acb(acb);
|
||||||
printf("nexus:\n");
|
printf("nexus:\n");
|
||||||
if (aic->nexus)
|
if (aic->nexus != NULL)
|
||||||
aic_print_acb(aic->nexus);
|
aic_print_acb(aic->nexus);
|
||||||
printf("nexus list:\n");
|
printf("nexus list:\n");
|
||||||
for (acb = aic->nexus_list.tqh_first; acb; acb = acb->chain.tqe_next)
|
for (acb = aic->nexus_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next)
|
||||||
aic_print_acb(acb);
|
aic_print_acb(acb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: aic6360.c,v 1.17 1994/11/29 20:57:28 mycroft Exp $ */
|
/* $NetBSD: aic6360.c,v 1.18 1994/11/29 21:29:56 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
* Copyright (c) 1994 Charles Hannum. All rights reserved.
|
||||||
@ -622,9 +622,11 @@ struct aic_softc { /* One of these per adapter */
|
|||||||
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; /**/
|
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; /**/
|
||||||
#define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
|
#define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
|
||||||
#define AIC_BREAK() do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
|
#define AIC_BREAK() do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
|
||||||
|
#define AIC_ASSERT(x) do {if (x) {} else {printf("aic at line %d: assertion failed\n", __LINE__); Debugger();}} while (0)
|
||||||
#else
|
#else
|
||||||
#define AIC_PRINT(b, s)
|
#define AIC_PRINT(b, s)
|
||||||
#define AIC_BREAK()
|
#define AIC_BREAK()
|
||||||
|
#define AIC_ASSERT(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
|
#define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
|
||||||
@ -888,7 +890,7 @@ aic_init(aic)
|
|||||||
TAILQ_INIT(&aic->ready_list);
|
TAILQ_INIT(&aic->ready_list);
|
||||||
TAILQ_INIT(&aic->nexus_list);
|
TAILQ_INIT(&aic->nexus_list);
|
||||||
TAILQ_INIT(&aic->free_list);
|
TAILQ_INIT(&aic->free_list);
|
||||||
aic->nexus = 0;
|
aic->nexus = NULL;
|
||||||
acb = aic->acb;
|
acb = aic->acb;
|
||||||
bzero(acb, sizeof(aic->acb));
|
bzero(acb, sizeof(aic->acb));
|
||||||
for (r = 0; r < sizeof(aic->acb) / sizeof(*acb); r++) {
|
for (r = 0; r < sizeof(aic->acb) / sizeof(*acb); r++) {
|
||||||
@ -1180,7 +1182,8 @@ aic_sched(aic)
|
|||||||
* Find first acb in ready queue that is for a target/lunit pair that
|
* Find first acb in ready queue that is for a target/lunit pair that
|
||||||
* is not busy.
|
* is not busy.
|
||||||
*/
|
*/
|
||||||
for (acb = aic->ready_list.tqh_first; acb; acb = acb->chain.tqe_next) {
|
for (acb = aic->ready_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next) {
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
ti = &aic->tinfo[sc->target];
|
ti = &aic->tinfo[sc->target];
|
||||||
if ((ti->lubusy & (1<<sc->lun)) == 0) {
|
if ((ti->lubusy & (1<<sc->lun)) == 0) {
|
||||||
@ -1286,7 +1289,7 @@ aic_done(acb)
|
|||||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||||
} else {
|
} else {
|
||||||
register struct acb *acb2;
|
register struct acb *acb2;
|
||||||
for (acb2 = aic->nexus_list.tqh_first; acb2;
|
for (acb2 = aic->nexus_list.tqh_first; acb2 != NULL;
|
||||||
acb2 = acb2->chain.tqe_next)
|
acb2 = acb2->chain.tqe_next)
|
||||||
if (acb2 == acb) {
|
if (acb2 == acb) {
|
||||||
TAILQ_REMOVE(&aic->nexus_list, acb, chain);
|
TAILQ_REMOVE(&aic->nexus_list, acb, chain);
|
||||||
@ -1294,7 +1297,7 @@ aic_done(acb)
|
|||||||
/* XXXX Should we call aic_sched() here? */
|
/* XXXX Should we call aic_sched() here? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (acb2)
|
if (acb2 != NULL)
|
||||||
;
|
;
|
||||||
else if (acb->chain.tqe_next) {
|
else if (acb->chain.tqe_next) {
|
||||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||||
@ -1447,15 +1450,17 @@ nextbyte:
|
|||||||
u_char selid, target, lun;
|
u_char selid, target, lun;
|
||||||
|
|
||||||
case AIC_CONNECTED:
|
case AIC_CONNECTED:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
sc = acb->xs->sc_link;
|
ti = &aic->tinfo[acb->xs->sc_link->target];
|
||||||
ti = &aic->tinfo[sc->target];
|
|
||||||
|
|
||||||
switch (aic->imess[0]) {
|
switch (aic->imess[0]) {
|
||||||
case MSG_CMDCOMPLETE:
|
case MSG_CMDCOMPLETE:
|
||||||
if (aic->dleft < 0) {
|
if (aic->dleft < 0) {
|
||||||
printf("aic: %d extra bytes from %d:%d\n",
|
sc = acb->xs->sc_link;
|
||||||
-aic->dleft, sc->target, sc->lun);
|
printf("%s: %d extra bytes from %d:%d\n",
|
||||||
|
aic->sc_dev.dv_xname,
|
||||||
|
-aic->dleft, sc->target, sc->lun);
|
||||||
acb->dleft = 0;
|
acb->dleft = 0;
|
||||||
}
|
}
|
||||||
acb->xs->resid = acb->dleft = aic->dleft;
|
acb->xs->resid = acb->dleft = aic->dleft;
|
||||||
@ -1595,13 +1600,13 @@ nextbyte:
|
|||||||
*/
|
*/
|
||||||
target = ffs(selid) - 1;
|
target = ffs(selid) - 1;
|
||||||
lun = aic->imess[0] & 0x07;
|
lun = aic->imess[0] & 0x07;
|
||||||
for (acb = aic->nexus_list.tqh_first; acb != 0;
|
for (acb = aic->nexus_list.tqh_first; acb != NULL;
|
||||||
acb = acb->chain.tqe_next) {
|
acb = acb->chain.tqe_next) {
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
if (sc->target == target && sc->lun == lun)
|
if (sc->target == target && sc->lun == lun)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (acb == 0) {
|
if (acb == NULL) {
|
||||||
printf("aic at line %d: reselect from target %d lun %d with no nexus; sending DEVICE RESET\n", __LINE__, target, lun);
|
printf("aic at line %d: reselect from target %d lun %d with no nexus; sending DEVICE RESET\n", __LINE__, target, lun);
|
||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
@ -1720,6 +1725,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
aic->omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun);
|
aic->omess[0] = MSG_IDENTIFY(acb->xs->sc_link->lun);
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -1731,6 +1737,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
||||||
aic->omess[4] = MSG_EXTENDED;
|
aic->omess[4] = MSG_EXTENDED;
|
||||||
aic->omess[3] = 3;
|
aic->omess[3] = 3;
|
||||||
@ -1746,6 +1753,7 @@ nextmsg:
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto noop;
|
goto noop;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
ti = &aic->tinfo[aic->nexus->xs->sc_link->target];
|
||||||
aic->omess[3] = MSG_EXTENDED;
|
aic->omess[3] = MSG_EXTENDED;
|
||||||
aic->omess[2] = 2;
|
aic->omess[2] = 2;
|
||||||
@ -2181,6 +2189,7 @@ aicintr(aic)
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
|
|
||||||
sc = acb->xs->sc_link;
|
sc = acb->xs->sc_link;
|
||||||
@ -2222,6 +2231,7 @@ aicintr(aic)
|
|||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
|
|
||||||
outb(SXFRCTL1, 0);
|
outb(SXFRCTL1, 0);
|
||||||
@ -2267,11 +2277,13 @@ aicintr(aic)
|
|||||||
printf("aic at line %d: unexpected BUS FREE; aborting\n", __LINE__);
|
printf("aic at line %d: unexpected BUS FREE; aborting\n", __LINE__);
|
||||||
AIC_BREAK();
|
AIC_BREAK();
|
||||||
}
|
}
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
acb->xs->error = XS_DRIVER_STUFFUP;
|
acb->xs->error = XS_DRIVER_STUFFUP;
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
case AIC_DISCONNECT:
|
case AIC_DISCONNECT:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
aic->state = AIC_IDLE;
|
aic->state = AIC_IDLE;
|
||||||
aic->nexus = NULL;
|
aic->nexus = NULL;
|
||||||
@ -2280,6 +2292,7 @@ aicintr(aic)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
case AIC_CMDCOMPLETE:
|
case AIC_CMDCOMPLETE:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
finish:
|
finish:
|
||||||
untimeout(aic_timeout, acb);
|
untimeout(aic_timeout, acb);
|
||||||
@ -2321,6 +2334,7 @@ aicintr(aic)
|
|||||||
case PH_CMD: /* CMD phase & REQ asserted */
|
case PH_CMD: /* CMD phase & REQ asserted */
|
||||||
#if AIC_DEBUG
|
#if AIC_DEBUG
|
||||||
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
printf("cmd=0x%02x+%d ",
|
printf("cmd=0x%02x+%d ",
|
||||||
acb->cmd.opcode, acb->clen-1);
|
acb->cmd.opcode, acb->clen-1);
|
||||||
@ -2345,6 +2359,7 @@ aicintr(aic)
|
|||||||
goto nextphase;
|
goto nextphase;
|
||||||
|
|
||||||
case PH_STAT:
|
case PH_STAT:
|
||||||
|
AIC_ASSERT(aic->nexus != NULL);
|
||||||
acb = aic->nexus;
|
acb = aic->nexus;
|
||||||
outb(SXFRCTL0, CHEN|SPIOEN);
|
outb(SXFRCTL0, CHEN|SPIOEN);
|
||||||
outb(DMACNTRL0, RSTFIFO);
|
outb(DMACNTRL0, RSTFIFO);
|
||||||
@ -2434,13 +2449,15 @@ aic_print_active_acb()
|
|||||||
struct aic_softc *aic = aiccd.cd_devs[0];
|
struct aic_softc *aic = aiccd.cd_devs[0];
|
||||||
|
|
||||||
printf("ready list:\n");
|
printf("ready list:\n");
|
||||||
for (acb = aic->ready_list.tqh_first; acb; acb = acb->chain.tqe_next)
|
for (acb = aic->ready_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next)
|
||||||
aic_print_acb(acb);
|
aic_print_acb(acb);
|
||||||
printf("nexus:\n");
|
printf("nexus:\n");
|
||||||
if (aic->nexus)
|
if (aic->nexus != NULL)
|
||||||
aic_print_acb(aic->nexus);
|
aic_print_acb(aic->nexus);
|
||||||
printf("nexus list:\n");
|
printf("nexus list:\n");
|
||||||
for (acb = aic->nexus_list.tqh_first; acb; acb = acb->chain.tqe_next)
|
for (acb = aic->nexus_list.tqh_first; acb != NULL;
|
||||||
|
acb = acb->chain.tqe_next)
|
||||||
aic_print_acb(acb);
|
aic_print_acb(acb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user