/* $NetBSD: aha1542.c,v 1.53 1995/10/03 20:58:56 mycroft Exp $ */
+
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
*
* cannot be serviced at interrupt time.
*/
#ifdef i386
-#include <machine/vmparam.h>
#define VOLATILE_XS(xs) \
((xs)->datalen > 0 && (xs)->bp == NULL && \
((xs)->flags & SCSI_POLL) == 0)
u_char seg_len[3];
u_char seg_addr[3];
} scat_gath[AHA_NSEG];
-#define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
/*----------------------------------------------------------------*/
+#define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
TAILQ_ENTRY(aha_ccb) chain;
struct aha_ccb *nexthash;
struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
struct aha_mbx_out *mbx; /* pointer to mail box */
struct isadma_seg ccb_phys[1]; /* phys segment of this ccb */
struct isadma_seg data_phys[AHA_NSEG]; /* phys segments of data */
- int data_nseg;
+ int data_nseg; /* number of phys segments of data */
};
/*
struct aha_ccb *ccb;
int flags;
{
- int s;
+ int s, hashnum;
+ struct aha_ccb **hashccb;
s = splbio();
if (ccb->ccb_phys[0].addr)
isadma_unmap((caddr_t)ccb, CCB_PHYS_SIZE, 1, ccb->ccb_phys);
+ /* remove from hash table */
+
+ hashnum = CCB_HASH(ccb->ccb_phys[0].addr);
+ hashccb = &aha->ccbhash[hashnum];
+
+ while (*hashccb) {
+ if ((*hashccb)->ccb_phys[0].addr == ccb->ccb_phys[0].addr) {
+ *hashccb = (*hashccb)->nexthash;
+ break;
+ }
+ (*hashccb) = (*hashccb)->nexthash;
+ }
+
ccb->flags = CCB_FREE;
TAILQ_INSERT_HEAD(&aha->free_ccb, ccb, chain);
struct aha_softc *aha;
struct aha_ccb *ccb;
{
- int hashnum;
-
bzero(ccb, sizeof(struct aha_ccb));
}
u_long ccb_phys;
{
int hashnum = CCB_HASH(ccb_phys);
- struct aha_ccb *res, **ccb = &aha->ccbhash[hashnum];
+ struct aha_ccb *res = aha->ccbhash[hashnum];
- while (*ccb) {
- if ((*ccb)->ccb_phys[0].addr == ccb_phys)
+ while (res) {
+ if (res->ccb_phys[0].addr == ccb_phys)
break;
- (*ccb) = (*ccb)->nexthash;
+ res = res->nexthash;
}
- if (res = *ccb)
- *ccb = (*ccb)->nexthash;
-
return res;
}
if (VOLATILE_XS(xs)) {
timeout(aha_timeout, ccb, (xs->timeout * hz) / 1000);
while ((ccb->xs->flags & ITSDONE) == 0) {
- tsleep(ccb, PRIBIO, "ahawait",
- (xs->timeout * hz) / 1000);
+ tsleep(ccb, PRIBIO, "ahawait", 0);
}
splx(s);
if (ccb->data_nseg) {
/* $NetBSD: aha1542.c,v 1.53 1995/10/03 20:58:56 mycroft Exp $ */
+
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
*
* cannot be serviced at interrupt time.
*/
#ifdef i386
-#include <machine/vmparam.h>
#define VOLATILE_XS(xs) \
((xs)->datalen > 0 && (xs)->bp == NULL && \
((xs)->flags & SCSI_POLL) == 0)
u_char seg_len[3];
u_char seg_addr[3];
} scat_gath[AHA_NSEG];
-#define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
/*----------------------------------------------------------------*/
+#define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
TAILQ_ENTRY(aha_ccb) chain;
struct aha_ccb *nexthash;
struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
struct aha_mbx_out *mbx; /* pointer to mail box */
struct isadma_seg ccb_phys[1]; /* phys segment of this ccb */
struct isadma_seg data_phys[AHA_NSEG]; /* phys segments of data */
- int data_nseg;
+ int data_nseg; /* number of phys segments of data */
};
/*
struct aha_ccb *ccb;
int flags;
{
- int s;
+ int s, hashnum;
+ struct aha_ccb **hashccb;
s = splbio();
if (ccb->ccb_phys[0].addr)
isadma_unmap((caddr_t)ccb, CCB_PHYS_SIZE, 1, ccb->ccb_phys);
+ /* remove from hash table */
+
+ hashnum = CCB_HASH(ccb->ccb_phys[0].addr);
+ hashccb = &aha->ccbhash[hashnum];
+
+ while (*hashccb) {
+ if ((*hashccb)->ccb_phys[0].addr == ccb->ccb_phys[0].addr) {
+ *hashccb = (*hashccb)->nexthash;
+ break;
+ }
+ (*hashccb) = (*hashccb)->nexthash;
+ }
+
ccb->flags = CCB_FREE;
TAILQ_INSERT_HEAD(&aha->free_ccb, ccb, chain);
struct aha_softc *aha;
struct aha_ccb *ccb;
{
- int hashnum;
-
bzero(ccb, sizeof(struct aha_ccb));
}
u_long ccb_phys;
{
int hashnum = CCB_HASH(ccb_phys);
- struct aha_ccb *res, **ccb = &aha->ccbhash[hashnum];
+ struct aha_ccb *res = aha->ccbhash[hashnum];
- while (*ccb) {
- if ((*ccb)->ccb_phys[0].addr == ccb_phys)
+ while (res) {
+ if (res->ccb_phys[0].addr == ccb_phys)
break;
- (*ccb) = (*ccb)->nexthash;
+ res = res->nexthash;
}
- if (res = *ccb)
- *ccb = (*ccb)->nexthash;
-
return res;
}
if (VOLATILE_XS(xs)) {
timeout(aha_timeout, ccb, (xs->timeout * hz) / 1000);
while ((ccb->xs->flags & ITSDONE) == 0) {
- tsleep(ccb, PRIBIO, "ahawait",
- (xs->timeout * hz) / 1000);
+ tsleep(ccb, PRIBIO, "ahawait", 0);
}
splx(s);
if (ccb->data_nseg) {