Subject: Re: Adaptec SATA RAID 2410SA driver
To: None <fvdl@NetBSD.org>
From: D'Arcy J.M. Cain <darcy@NetBSD.org>
List: tech-kern
Date: 03/12/2005 18:21:53
On Fri, 11 Mar 2005 11:59:43 -0500
"D'Arcy J.M. Cain" <darcy@NetBSD.org> wrote:
> I looked at fixing the driver but I am afraid I am a little out of my
> depth with the changes and I don't have the card specs anyway.  I
> think I have to look into using a supported card.  The config file
> mentions these cards: 

I didn't get any response so I attacked the aac driver anyway.  I made
enough changes to get it to compile but it still doesn't work.  Here are
the diffs.  The card is still nor recognized though.  Any thoughts?

I am moving to tech-kern since this is not really architecture specific.

Index: aac.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/aac.c,v
retrieving revision 1.18
diff -u -b -u -r1.18 aac.c
--- aac.c	12 Mar 2005 10:35:29 -0000	1.18
+++ aac.c	12 Mar 2005 23:13:10 -0000
@@ -371,8 +371,8 @@
 	}
 	if (bufsize != sizeof(*info)) {
 		aprint_error("%s: "
-		    "RequestAdapterInfo returned wrong data size (%d != %d)\n",
-		    sc->sc_dv.dv_xname, bufsize, sizeof(*info));
+		    "RequestAdapterInfo returned wrong data size (%u != %u)\n",
+		    sc->sc_dv.dv_xname, (u_int16_t) bufsize, (u_int16_t)
sizeof(*info));
 		return;
 	}
 	info = (struct aac_adapter_info *)&buf[0];
@@ -454,8 +454,7 @@
 {
 	int nsegs, i, rv, state, norm, high;
 	struct aac_adapter_init	*ip;
-	u_int32_t code;
-	u_int8_t *qaddr;
+	u_int32_t code, qoffset;
 
 	state = 0;
 
@@ -554,9 +553,10 @@
 	 * generic list manipulation functions which 'know' the size of
each
 	 * list by virtue of a table.
 	 */
-	qaddr = &sc->sc_common->ac_qbuf[0] + AAC_QUEUE_ALIGN;
-	qaddr -= (u_int32_t)qaddr % AAC_QUEUE_ALIGN; 	/* XXX not portable */
-	sc->sc_queues = (struct aac_queue_table *)qaddr;
+	qoffset = offsetof(struct aac_common, ac_qbuf) + AAC_QUEUE_ALIGN;
+	qoffset &= ~(AAC_QUEUE_ALIGN - 1);
+	sc->sc_queues =
+		(struct aac_queue_table *)((uintptr_t)sc->sc_common + qoffset);
 	ip->CommHeaderAddress = htole32(sc->sc_common_seg.ds_addr +
 	    ((caddr_t)sc->sc_queues - (caddr_t)sc->sc_common));
 	memset(sc->sc_queues, 0, sizeof(struct aac_queue_table));
@@ -699,8 +699,8 @@
 		}
 		if (rsize != sizeof(mir)) {
 			aprint_error("%s: container info response wrong size "
-			    "(%d should be %d)\n",
-			    sc->sc_dv.dv_xname, rsize, sizeof(mir));
+			    "(%u should be %u)\n",
+			    sc->sc_dv.dv_xname, (unsigned) rsize, (unsigned)
sizeof(mir));
 			continue;
 		}
 
@@ -997,7 +997,7 @@
 	fib->Header.StructType = AAC_FIBTYPE_TFIB;
 	fib->Header.Size = htole16(sizeof(*fib) + datasize);
 	fib->Header.SenderSize = htole16(sizeof(*fib));
-	fib->Header.SenderFibAddress = 0; /* htole32((u_int32_t)fib);	* XXX */
+	fib->Header.SenderFibAddress = 0; /* Not needed */
 	fib->Header.ReceiverFibAddress = htole32(fibpa);
 
 	/*
@@ -1171,7 +1171,7 @@
 	AAC_DPRINTF(AAC_D_QUEUE, ("aac_ccb_submit(%p, %p) ", sc, ac));
 
 	/* Fix up the address values. */
-	ac->ac_fib->Header.SenderFibAddress = htole32((u_int32_t)ac->ac_fib);
+	ac->ac_fib->Header.SenderFibAddress = 0; /* Not needed */
 	ac->ac_fib->Header.ReceiverFibAddress = htole32(ac->ac_fibphys);
 
 	/* Save a pointer to the command for speedy reverse-lookup. */
@@ -1297,8 +1297,7 @@
 
 	/* Fetch the entry. */
 	*fib_size = le32toh((sc->sc_qentries[queue] + ci)->aq_fib_size);
-	*fib_addr = (void *)(intptr_t) le32toh((struct aac_fib *)
-	    (sc->sc_qentries[queue] + ci)->aq_fib_addr);
+	*fib_addr = 0; /* XXX Not needed? */
 
 	/* Update consumer index. */
 	sc->sc_queues->qt_qindex[queue][AAC_CONSUMER_INDEX] = ci + 1;

-- 
D'Arcy J.M. Cain <darcy@NetBSD.org>
http://www.NetBSD.org/