Module Name:    src
Committed By:   phx
Date:           Fri Jul 23 20:01:27 UTC 2010

Modified Files:
        src/sys/arch/sandpoint/stand/netboot: dsk.c siisata.c

Log Message:
Fixed error in loop counter variable for lba_read().
Patch by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/netboot/dsk.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/netboot/siisata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sandpoint/stand/netboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/netboot/dsk.c:1.2 src/sys/arch/sandpoint/stand/netboot/dsk.c:1.3
--- src/sys/arch/sandpoint/stand/netboot/dsk.c:1.2	Sun Jun 27 12:09:17 2010
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Fri Jul 23 20:01:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.2 2010/06/27 12:09:17 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.3 2010/07/23 20:01:27 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -357,10 +357,10 @@
 static int
 lba_read(struct disk *d, uint64_t bno, uint32_t bcnt, void *buf)
 {
-	struct dkdev_ata *l = d->dvops;
+	struct dkdev_ata *l;
 	struct dvata_chan *chan;
 	void (*issue)(struct dvata_chan *, uint64_t, uint32_t);
-	uint32_t n, rdcnt;
+	int n, rdcnt, i;
 	uint16_t *p;
 	const char *err;
 	int error;
@@ -370,22 +370,20 @@
 	p = (uint16_t *)buf;
 	chan = &l->chan[n];
 	error = 0;
-	while (bcnt > 0) {
+	for ( ; bcnt > 0; bno += rdcnt, bcnt -= rdcnt) {
 		issue = (bno < (1ULL<<28)) ? issue28 : issue48;
 		rdcnt = (bcnt > 255) ? 255 : bcnt;
 		(*issue)(chan, bno, rdcnt);
 		if (spinwait_unbusy(l, n, 1000, &err) == 0) {
 			printf("%s blk %d %s\n", d->xname, (int)bno, err);
 			error = EIO;
+			continue;
 		}
-		else {
-			for (n = 0; n < rdcnt * 512; n += 2) {
-				/* arrives in native order */
-				*p++ = *(uint16_t *)(chan->cmd + _DAT);
-			}
-			(void)CSR_READ_1(chan->cmd + _STS);
+		for (i = 0; i < rdcnt * 512; i += 2) {
+			/* arrives in native order */
+			*p++ = *(uint16_t *)(chan->cmd + _DAT);
 		}
-		bno += rdcnt; bcnt -= rdcnt;
+		(void)CSR_READ_1(chan->cmd + _STS);
 	}
 	return error;
 }
@@ -466,7 +464,9 @@
 	}
 	return ENXIO;
   found:
+#if 0
 printf("dsk_open found %s\n", fsmod);
+#endif
 	d->fsops = fs;
 	f->f_devdata = d;
 
@@ -520,4 +520,3 @@
 
 	return d->fsops;
 }
-

Index: src/sys/arch/sandpoint/stand/netboot/siisata.c
diff -u src/sys/arch/sandpoint/stand/netboot/siisata.c:1.9 src/sys/arch/sandpoint/stand/netboot/siisata.c:1.10
--- src/sys/arch/sandpoint/stand/netboot/siisata.c:1.9	Sat Jun 26 21:45:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/siisata.c	Fri Jul 23 20:01:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.9 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.10 2010/07/23 20:01:27 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -35,6 +35,11 @@
 
 #include "globals.h"
 
+//#define CSR_READ_4(r)		in32rb(r)
+//#define CSR_WRITE_4(r,v)	out32rb(r,v)
+//#define CSR_READ_1(r)		*(volatile uint8_t *)(r)
+//#define CSR_WRITE_1(r,v)	*(volatile uint8_t *)(r)=(v)
+
 static uint32_t pciiobase = PCI_XIOBASE;
 
 int siisata_match(unsigned, void *);
@@ -73,17 +78,24 @@
 	l->bar[3] = pciiobase + (pcicfgread(tag, 0x1c) &~ 01);
 	l->bar[4] = pciiobase + (pcicfgread(tag, 0x20) &~ 01);
 	l->bar[5] = pcicfgread(tag, 0x24) &~ 0x3ff;
+for (n=0; n<6; n++) printf("bar[%d]=0x%08x\n",n,(unsigned)l->bar[n]);
+	val = pcicfgread(tag, 0x88);
+//	pcicfgwrite(tag, 0x88, val | 0xc000f3);
+	pcicfgwrite(tag, 0x88, val | 0x0000f3);
+	delay(50 * 1000);
+//	pcicfgwrite(tag, 0x88, val & 0xc00000);
+	pcicfgwrite(tag, 0x88, val & 0x000000);
+	delay(50 * 1000);
 
 	val = pcicfgread(tag, PCI_ID_REG);
+	/* assume BA5 access is possible */
 	if ((PCI_PRODUCT(val) & 0xf) == 0x2) {
 		/* 3112/3512 */
-		l->chan[0].cmd = l->bar[0];
-		l->chan[0].ctl = l->chan[0].alt = l->bar[1] | 02;
-		l->chan[0].dma = l->bar[4] + 0x0;
-		l->chan[1].cmd = l->bar[2];
-		l->chan[1].ctl = l->chan[1].alt = l->bar[3] | 02;
-		l->chan[1].dma = l->bar[4] + 0x8;
-		/* assume BA5 access is possible */
+		l->chan[0].cmd = l->bar[5] + 0x080;
+		l->chan[0].ctl = l->chan[0].alt = (l->bar[5] + 0x088) | 02;
+		l->chan[1].cmd = l->bar[5] + 0x0c0;
+		l->chan[1].ctl = l->chan[1].alt = (l->bar[5] + 0x0c8) | 02;
+printf("3512! cmd=0x%08x ctl/alt=0x%08x\n",l->chan[0].cmd,l->chan[0].ctl);
 		nchan = 2;
 	}
 	else {
@@ -98,10 +110,16 @@
 		l->chan[3].ctl = l->chan[3].alt = (l->bar[5] + 0x2c8) | 02;
 		nchan = 4;
 	}
+
 	for (n = 0; n < nchan; n++) {
 		l->presense[n] = satapresense(l, n);
 		if (l->presense[n])
 			printf("port %d device present\n", n);
 	}
+
+	out32rb(l->bar[5] + 0xb4, 01);
+	out32rb(l->bar[5] + 0xf4, 01);
+	out32rb(l->bar[5] + 0xa4, 0x328a);
+	out32rb(l->bar[5] + 0xe4, 0x328a);
 	return l;
 }

Reply via email to