CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-21 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sat Jan 22 00:32:42 UTC 2011

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

Log Message:
- make sure to wait for BUSY bit goes down prior to each 512B block
read from xfer register, or corrupted datum may be retrieved.  Uncovered
by corrected PIO READ_CMD value.
- remove redundant register assignments to set transfer mode.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/netboot/dsk.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.7 src/sys/arch/sandpoint/stand/netboot/dsk.c:1.8
--- src/sys/arch/sandpoint/stand/netboot/dsk.c:1.7	Tue Jan 11 07:01:21 2011
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Sat Jan 22 00:32:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.7 2011/01/11 07:01:21 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.8 2011/01/22 00:32:41 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -154,7 +154,9 @@
 	(void)CSR_READ_1(chan-alt);
 
 	sts = CSR_READ_1(chan-cmd + _STS);
-	while (milli--  0  sts != 0xff  (sts  ATA_STS_BUSY)) {
+	while (milli--  0
+	 sts != 0xff
+	 (sts  (ATA_STS_BUSY|ATA_STS_DRDY)) != ATA_STS_DRDY) {
 		delay(1000);
 		sts = CSR_READ_1(chan-cmd + _STS);
 	}
@@ -166,6 +168,8 @@
 		msg = returned ERR;
 	else if (sts  ATA_STS_BUSY)
 		msg = remains BUSY;
+	else if ((sts  ATA_STS_DRDY) == 0)
+		msg = no DRDY;
 
 	if (err != NULL)
 		*err = msg;
@@ -251,10 +255,10 @@
 		huge = p[60] | (p[61]  16);
 	}
 	if ((p[83]  0xc000) == 0x4000  (p[83]  (1  10))) {
+		printf(LBA48 );
 		huge = p[100] | (p[101]  16);
 		huge |= (uint64_t)p[102]  32;
 		huge |= (uint64_t)p[103]  48;
-		printf(LBA48 );
 	}
 	huge = (1 + 10);
 	printf(%d MB\n, (int)huge);
@@ -357,10 +361,7 @@
 
 	CSR_WRITE_1(chan-cmd + _FEA, ATA_XFER);
 	CSR_WRITE_1(chan-cmd + _NSECT, XFER_PIO0);
-	CSR_WRITE_1(chan-cmd + _LBAL, 0);
-	CSR_WRITE_1(chan-cmd + _LBAM, 0);
-	CSR_WRITE_1(chan-cmd + _LBAH, 0);
-	CSR_WRITE_1(chan-cmd + _DEV, ATA_DEV_OBS);
+	CSR_WRITE_1(chan-cmd + _DEV, ATA_DEV_OBS); /* ??? */
 	CSR_WRITE_1(chan-cmd + _CMD, ATA_CMD_SETF);
 
 	spinwait_unbusy(l, n, 1000, NULL);
@@ -372,7 +373,7 @@
 	struct dkdev_ata *l;
 	struct dvata_chan *chan;
 	void (*issue)(struct dvata_chan *, uint64_t, uint32_t);
-	int n, rdcnt, i;
+	int n, rdcnt, i, k;
 	uint16_t *p;
 	const char *err;
 	int error;
@@ -386,16 +387,20 @@
 		issue = (bno  (1ULL28)) ? 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;
-		}
-		for (i = 0; i  rdcnt * 512; i += 2) {
-			/* arrives in native order */
-			*p++ = *(uint16_t *)(chan-cmd + _DAT);
+		for (k = 0; k  rdcnt; k++) {
+			if (spinwait_unbusy(l, n, 1000, err) == 0) {
+printf(%s blk %d %s\n,
+   d-xname, (int)bno, err);
+error = EIO;
+break;
+			}
+			for (i = 0; i  512; i += 2) {
+/* arrives in native order */
+*p++ = *(uint16_t *)(chan-cmd + _DAT);
+			}
+			/* clear irq if any */
+			(void)CSR_READ_1(chan-cmd + _STS);
 		}
-		(void)CSR_READ_1(chan-cmd + _STS);
 	}
 	return error;
 }
@@ -404,7 +409,7 @@
 issue48(struct dvata_chan *chan, uint64_t bno, uint32_t nblk)
 {
 
-	CSR_WRITE_1(chan-cmd + _NSECT, 0);
+	CSR_WRITE_1(chan-cmd + _NSECT, 0); /* always less than 256 */
 	CSR_WRITE_1(chan-cmd + _LBAL, (bno  24)  0xff);
 	CSR_WRITE_1(chan-cmd + _LBAM, (bno  32)  0xff);
 	CSR_WRITE_1(chan-cmd + _LBAH, (bno  40)  0xff);



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-13 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Jan 13 21:54:15 UTC 2011

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

Log Message:
Configure transfer mode registers to PIO mode. It seems to work without, but
just to be on the safe side.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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/siisata.c
diff -u src/sys/arch/sandpoint/stand/netboot/siisata.c:1.14 src/sys/arch/sandpoint/stand/netboot/siisata.c:1.15
--- src/sys/arch/sandpoint/stand/netboot/siisata.c:1.14	Mon Jan 10 20:13:47 2011
+++ src/sys/arch/sandpoint/stand/netboot/siisata.c	Thu Jan 13 21:54:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.14 2011/01/10 20:13:47 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.15 2011/01/13 21:54:14 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
 void *
 siisata_init(unsigned tag, void *data)
 {
-	unsigned val;
+	unsigned idreg;
 	int nchan, n;
 	struct dkdev_ata *l;
 
@@ -67,6 +67,7 @@
 	l-iobuf = allocaligned(512, 16);
 	l-tag = tag;
 
+	idreg = pcicfgread(tag, PCI_ID_REG);
 	l-bar[0] = pciiobase + (pcicfgread(tag, 0x10) ~ 01);
 	l-bar[1] = pciiobase + (pcicfgread(tag, 0x14) ~ 01);
 	l-bar[2] = pciiobase + (pcicfgread(tag, 0x18) ~ 01);
@@ -74,8 +75,7 @@
 	l-bar[4] = pciiobase + (pcicfgread(tag, 0x20) ~ 01);
 	l-bar[5] = pcicfgread(tag, 0x24) ~ 0x3ff;
 
-	val = pcicfgread(tag, PCI_ID_REG);
-	if ((PCI_PRODUCT(val)  0xf) == 0x2) {
+	if ((PCI_PRODUCT(idreg)  0xf) == 0x2) {
 		/* 3112/3512 */
 		l-chan[0].cmd = l-bar[0];
 		l-chan[0].ctl = l-chan[0].alt = l-bar[1] | 02;
@@ -98,6 +98,10 @@
 		nchan = 4;
 	}
 
+	/* configure PIO transfer mode */
+	pcicfgwrite(tag, 0x80, 0x00);
+	pcicfgwrite(tag, 0x84, 0x00);
+
 	for (n = 0; n  nchan; n++) {
 		if (satapresense(l, n)) {
 			/* drive present, now check whether soft reset works */



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Jan 11 08:04:15 UTC 2011

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

Log Message:
add MODULAR loading facility. Disabled for now 'til it gets ready to use.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sandpoint/stand/netboot/main.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/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.37 src/sys/arch/sandpoint/stand/netboot/main.c:1.38
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.37	Mon Jan 10 20:16:42 2011
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Tue Jan 11 08:04:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.37 2011/01/10 20:16:42 phx Exp $ */
+/* $NetBSD: main.c,v 1.38 2011/01/11 08:04:14 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -71,6 +71,22 @@
 struct btinfo_bootpath bi_path;
 struct btinfo_rootdevice bi_rdev;
 struct btinfo_net bi_net;
+struct btinfo_modulelist *btinfo_modulelist;
+size_t btinfo_modulelist_size;
+
+struct boot_module {
+	char *bm_kmod;
+	ssize_t bm_len;
+	struct boot_module *bm_next;
+};
+struct boot_module *boot_modules;
+char module_base[80];
+uint32_t kmodloadp;
+int modules_enabled = 0;
+
+void module_add(char *);
+void module_load(char *);
+int module_open(struct boot_module *);
 
 void main(int, char **);
 extern char bootprog_rev[], bootprog_maker[], bootprog_date[];
@@ -171,10 +187,15 @@
 	marks[MARK_START] = 0;
 	if (fdloadfile(fd, marks, LOAD_KERNEL)  0)
 		goto loadfail;
+	close(fd);
+
+	printf(entry=%p, ssym=%p, esym=%p\n,
+	(void *)marks[MARK_ENTRY],
+	(void *)marks[MARK_SYM],
+	(void *)marks[MARK_END]);
 
 	bootinfo = (void *)0x4000;
 	bi_init(bootinfo);
-
 	bi_add(bi_cons, BTINFO_CONSOLE, sizeof(bi_cons));
 	bi_add(bi_mem, BTINFO_MEMORY, sizeof(bi_mem));
 	bi_add(bi_clk, BTINFO_CLOCK, sizeof(bi_clk));
@@ -186,10 +207,17 @@
 		bi_add(bi_net, BTINFO_NET, sizeof(bi_net));
 	}
 
-	printf(entry=%p, ssym=%p, esym=%p\n,
-	(void *)marks[MARK_ENTRY],
-	(void *)marks[MARK_SYM],
-	(void *)marks[MARK_END]);
+	if (modules_enabled) {
+		module_add(fsmod);
+		if (fsmod2 != NULL  strcmp(fsmod, fsmod2) != 0)
+		module_add(fsmod2);
+		kmodloadp = marks[MARK_END];
+		btinfo_modulelist = NULL;
+		module_load(bname);
+		if (btinfo_modulelist != NULL  btinfo_modulelist-num  0)
+			bi_add(btinfo_modulelist, BTINFO_MODULELIST,
+			btinfo_modulelist_size);
+	}
 
 	__syncicache((void *)marks[MARK_ENTRY],
 	(u_int)marks[MARK_SYM] - (u_int)marks[MARK_ENTRY]);
@@ -234,6 +262,137 @@
 	bi_next += size;
 }
 
+void
+module_add(char *name)
+{
+	struct boot_module *bm, *bmp;
+
+	while (*name == ' ' || *name == '\t')
+		++name;
+
+	bm = alloc(sizeof(struct boot_module) + strlen(name) + 1);
+	if (bm == NULL) {
+		printf(couldn't allocate module %s\n, name); 
+		return; 
+	}
+
+	bm-bm_kmod = (char *)(bm + 1);
+	bm-bm_len = -1;
+	bm-bm_next = NULL;
+	strcpy(bm-bm_kmod, name);
+	if ((bmp = boot_modules) == NULL)
+		boot_modules = bm;
+	else {
+		while (bmp-bm_next != NULL)
+			bmp = bmp-bm_next;
+		bmp-bm_next = bm;
+	}
+}
+
+#define PAGE_SIZE	4096
+#define alignpg(x)	(((x)+PAGE_SIZE-1)  ~(PAGE_SIZE-1))
+
+void
+module_load(char *kernel_path) 
+{
+	struct boot_module *bm;
+	struct bi_modulelist_entry *bi;
+	struct stat st;
+	char *p; 
+	int size, fd;
+
+	strcpy(module_base, kernel_path);
+	if ((p = strchr(module_base, ':')) == NULL)
+		return; /* eeh?! */
+	p += 1;
+	size = sizeof(module_base) - (p - module_base);
+
+	if (netbsd_version / 100 % 100 == 99) {
+		/* -current */
+		snprintf(p, size,
+		/stand/sandpoint/%d.%d.%d/modules,
+		netbsd_version / 1,
+		netbsd_version / 100 % 100,
+		netbsd_version / 100 % 100);
+	}
+	 else if (netbsd_version != 0) {
+		/* release */
+		snprintf(p, size,
+		/stand/sandpoint/%d.%d/modules,
+		netbsd_version / 1,
+		netbsd_version / 100 % 100);
+	}
+
+	/*
+	 * 1st pass; determine module existence
+	 */
+	size = 0;
+	for (bm = boot_modules; bm != NULL; bm = bm-bm_next) {
+		fd = module_open(bm);
+		if (fd == -1)
+			continue;
+		if (fstat(fd, st) == -1 || st.st_size == -1) {
+			printf(WARNING: couldn't stat %s\n, bm-bm_kmod);
+			close(fd);
+			continue;
+		}
+		bm-bm_len = (int)st.st_size;
+		close(fd);
+		size += sizeof(struct bi_modulelist_entry); 
+	}
+	if (size == 0)
+		return;
+
+	size += sizeof(struct btinfo_modulelist);
+	btinfo_modulelist = alloc(size);
+	if (btinfo_modulelist == NULL) {
+		printf(WARNING: couldn't allocate module list\n);
+		return;
+	}
+	btinfo_modulelist_size = size;
+	btinfo_modulelist-num = 0;
+
+	/*
+	 * 2nd pass; load modules into memory
+	 */
+	kmodloadp = alignpg(kmodloadp);
+	bi = (struct bi_modulelist_entry *)(btinfo_modulelist + 1);
+	for (bm = boot_modules; bm != NULL; bm = bm-bm_next) {
+		if 

CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Jan 11 08:19:34 UTC 2011

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

Log Message:
move module load address printf() to show the correct value.  Still
some more work.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sandpoint/stand/netboot/main.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/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.38 src/sys/arch/sandpoint/stand/netboot/main.c:1.39
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.38	Tue Jan 11 08:04:14 2011
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Tue Jan 11 08:19:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.38 2011/01/11 08:04:14 nisimura Exp $ */
+/* $NetBSD: main.c,v 1.39 2011/01/11 08:19:34 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -371,9 +371,9 @@
 			bi-len = size;
 			bi-base = kmodloadp;
 			btinfo_modulelist-num += 1;
+			printf(loaded at 0x%08x size 0x%x, kmodloadp, size);
 			kmodloadp += alignpg(size);
 			bi += 1;
-			printf(loaded at 0x%08x size 0x%x, kmodloadp, size);
 		}
 		printf(\n);
 		close(fd);



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Jan 11 09:45:25 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/netboot: kse.c nvt.c pcn.c sip.c sme.c
wm.c

Log Message:
always have even numbered descriptors to avoid ones belong to Tx/Rx
share the same cacheline even for 32B cacheline CPU. These six are
provisional code stocks and untested.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/netboot/kse.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/stand/netboot/nvt.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/netboot/pcn.c \
src/sys/arch/sandpoint/stand/netboot/sip.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/netboot/sme.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/netboot/wm.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/kse.c
diff -u src/sys/arch/sandpoint/stand/netboot/kse.c:1.4 src/sys/arch/sandpoint/stand/netboot/kse.c:1.5
--- src/sys/arch/sandpoint/stand/netboot/kse.c:1.4	Sun May  2 13:36:30 2010
+++ src/sys/arch/sandpoint/stand/netboot/kse.c	Tue Jan 11 09:45:25 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: kse.c,v 1.4 2010/05/02 13:36:30 phx Exp $ */
+/* $NetBSD: kse.c,v 1.5 2011/01/11 09:45:25 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -100,10 +100,10 @@
 #define FRAMESIZE	1536
 
 struct local {
-	struct desc txd;
+	struct desc txd[2];
 	struct desc rxd[2];
 	uint8_t rxstore[2][FRAMESIZE];
-	unsigned csr, rx;
+	unsigned csr, tx, rx;
 };
 
 static void mii_dealan(struct local *, unsigned);
@@ -162,7 +162,7 @@
 		printf(\n);
 	}
 
-	txd = l-txd;
+	txd = l-txd[0];
 	rxd = l-rxd[0];
 	rxd[0].xd0 = htole32(R0_OWN);
 	rxd[0].xd1 = htole32(FRAMESIZE);
@@ -172,7 +172,7 @@
 	rxd[1].xd1 = htole32(R1_RER | FRAMESIZE);
 	rxd[1].xd2 = htole32(VTOPHYS(l-rxstore[1]));
 	rxd[1].xd3 = htole32(VTOPHYS(rxd[0]));
-	l-rx = 0;
+	l-tx = l-rx = 0;
 
 	CSR_WRITE_4(l, TDLB, VTOPHYS(txd));
 	CSR_WRITE_4(l, RDLB, VTOPHYS(rxd));
@@ -191,7 +191,7 @@
 	unsigned txstat, loop;
 
 	wbinv(buf, len);
-	txd = l-txd;
+	txd = l-txd[l-tx];
 	txd-xd2 = htole32(VTOPHYS(buf));
 	txd-xd1 = htole32(T1_FS | T1_LS | (len  T1_TBS_MASK));
 	txd-xd0 = htole32(T0_OWN);
@@ -208,6 +208,7 @@
 	printf(xmit failed\n);
 	return -1;
   done:
+	l-tx ^= 1;
 	return len;
 }
 

Index: src/sys/arch/sandpoint/stand/netboot/nvt.c
diff -u src/sys/arch/sandpoint/stand/netboot/nvt.c:1.18 src/sys/arch/sandpoint/stand/netboot/nvt.c:1.19
--- src/sys/arch/sandpoint/stand/netboot/nvt.c:1.18	Sun May  2 13:36:30 2010
+++ src/sys/arch/sandpoint/stand/netboot/nvt.c	Tue Jan 11 09:45:25 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nvt.c,v 1.18 2010/05/02 13:36:30 phx Exp $ */
+/* $NetBSD: nvt.c,v 1.19 2011/01/11 09:45:25 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -139,10 +139,10 @@
 #define FRAMESIZE	1536
 
 struct local {
-	struct desc txd;
+	struct desc txd[2];
 	struct desc rxd[2];
 	uint8_t rxstore[2][FRAMESIZE];
-	unsigned csr, rx;
+	unsigned csr, tx, rx;
 	unsigned phy, bmsr, anlpar;
 	unsigned ctl0;
 };
@@ -210,7 +210,7 @@
 		printf(-FDX);
 	printf(\n);
 
-	txd = l-txd;
+	txd = l-txd[0];
 	rxd = l-rxd[0];
 	rxd[0].xd0 = htole32(R0_OWN);
 	rxd[0].xd1 = htole32(FRAMESIZE  16);
@@ -221,7 +221,7 @@
 	rxd[1].xd2 = htole32(FRAMESIZE  16);
 	rxd[1].xd3 = htole32(VTOPHYS(rxd[0]));
 	wbinv(l, sizeof(struct local));
-	l-rx = 0;
+	l-tx = l-rx = 0;
 
 	/* enable transmitter and receiver */
 	l-ctl0 = CTL0_TXON | CTL0_RXON | CTL0_START;
@@ -250,7 +250,7 @@
 	if (len  60)
 		len = 60; /* needs to stretch to ETHER_MIN_LEN - 4 */
 	wbinv(buf, len);
-	txd = l-txd;
+	txd = l-txd[l-tx];
 	txd-xd3 = htole32(txd);
 	txd-xd2 = htole32(VTOPHYS(buf));
 	txd-xd1 = htole32(T1_STP | T1_EDP | len);
@@ -267,6 +267,7 @@
 	printf(xmit failed\n);
 	return -1;
   done:
+	l-tx ^= 1;
 	return len;
 }
 

Index: src/sys/arch/sandpoint/stand/netboot/pcn.c
diff -u src/sys/arch/sandpoint/stand/netboot/pcn.c:1.17 src/sys/arch/sandpoint/stand/netboot/pcn.c:1.18
--- src/sys/arch/sandpoint/stand/netboot/pcn.c:1.17	Sun May  2 13:36:30 2010
+++ src/sys/arch/sandpoint/stand/netboot/pcn.c	Tue Jan 11 09:45:25 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pcn.c,v 1.17 2010/05/02 13:36:30 phx Exp $ */
+/* $NetBSD: pcn.c,v 1.18 2011/01/11 09:45:25 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -116,10 +116,10 @@
 #define FRAMESIZE	1536
 
 struct local {
-	struct desc txd;
+	struct desc txd[2];
 	struct desc rxd[2];
 	uint8_t rxstore[2][FRAMESIZE];
-	unsigned csr, rx;
+	unsigned csr, tx, rx;
 	unsigned phy, bmsr, anlpar;
 };
 
@@ -179,13 +179,13 @@
 		printf(-FDX);
 	printf(\n);
 
-	txd = l-txd;
+	txd = l-txd[0];
 	rxd = l-rxd[0];
 	rxd[0].xd0 = htole32(VTOPHYS(l-rxstore[0]));
 	rxd[0].xd1 = htole32(R1_OWN | R1_ONES | FRAMESIZE);
 	rxd[1].xd0 = htole32(VTOPHYS(l-rxstore[1]));
 	rxd[1].xd1 = 

CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-11 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Jan 11 10:10:48 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/netboot: kse.c nvt.c pcn.c sip.c sme.c
wm.c

Log Message:
make sure to have 32B aligned descriptor array.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/netboot/kse.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sandpoint/stand/netboot/nvt.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/stand/netboot/pcn.c \
src/sys/arch/sandpoint/stand/netboot/sip.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/netboot/sme.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/netboot/wm.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/kse.c
diff -u src/sys/arch/sandpoint/stand/netboot/kse.c:1.5 src/sys/arch/sandpoint/stand/netboot/kse.c:1.6
--- src/sys/arch/sandpoint/stand/netboot/kse.c:1.5	Tue Jan 11 09:45:25 2011
+++ src/sys/arch/sandpoint/stand/netboot/kse.c	Tue Jan 11 10:10:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: kse.c,v 1.5 2011/01/11 09:45:25 nisimura Exp $ */
+/* $NetBSD: kse.c,v 1.6 2011/01/11 10:10:48 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
 	unsigned i, val, fdx;
 	uint8_t *en;
 
-	l = ALLOC(struct local, sizeof(struct desc)); /* desc alignment */
+	l = ALLOC(struct local, 32); /* desc alignment */
 	memset(l, 0, sizeof(struct local));
 	l-csr = DEVTOV(pcicfgread(tag, 0x10));
 

Index: src/sys/arch/sandpoint/stand/netboot/nvt.c
diff -u src/sys/arch/sandpoint/stand/netboot/nvt.c:1.19 src/sys/arch/sandpoint/stand/netboot/nvt.c:1.20
--- src/sys/arch/sandpoint/stand/netboot/nvt.c:1.19	Tue Jan 11 09:45:25 2011
+++ src/sys/arch/sandpoint/stand/netboot/nvt.c	Tue Jan 11 10:10:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nvt.c,v 1.19 2011/01/11 09:45:25 nisimura Exp $ */
+/* $NetBSD: nvt.c,v 1.20 2011/01/11 10:10:48 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -175,7 +175,7 @@
 	struct desc *txd, *rxd;
 	uint8_t *en;
 
-	l = ALLOC(struct local, sizeof(struct desc)); /* desc alignment */
+	l = ALLOC(struct local, 32); /* desc alignment */
 	memset(l, 0, sizeof(struct local));
 	l-csr = ~01  DEVTOV(pcicfgread(tag, 0x10)); /* use IO space */
 

Index: src/sys/arch/sandpoint/stand/netboot/pcn.c
diff -u src/sys/arch/sandpoint/stand/netboot/pcn.c:1.18 src/sys/arch/sandpoint/stand/netboot/pcn.c:1.19
--- src/sys/arch/sandpoint/stand/netboot/pcn.c:1.18	Tue Jan 11 09:45:25 2011
+++ src/sys/arch/sandpoint/stand/netboot/pcn.c	Tue Jan 11 10:10:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pcn.c,v 1.18 2011/01/11 09:45:25 nisimura Exp $ */
+/* $NetBSD: pcn.c,v 1.19 2011/01/11 10:10:48 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -149,7 +149,7 @@
 	uint8_t *en;
 	struct pcninit initblock, *ib;
 
-	l = ALLOC(struct local, sizeof(struct desc)); /* desc alignment */
+	l = ALLOC(struct local, 32); /* desc alignment */
 	memset(l, 0, sizeof(struct local));
 	l-csr = DEVTOV(pcicfgread(tag, 0x14)); /* use mem space */
 
Index: src/sys/arch/sandpoint/stand/netboot/sip.c
diff -u src/sys/arch/sandpoint/stand/netboot/sip.c:1.18 src/sys/arch/sandpoint/stand/netboot/sip.c:1.19
--- src/sys/arch/sandpoint/stand/netboot/sip.c:1.18	Tue Jan 11 09:45:25 2011
+++ src/sys/arch/sandpoint/stand/netboot/sip.c	Tue Jan 11 10:10:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: sip.c,v 1.18 2011/01/11 09:45:25 nisimura Exp $ */
+/* $NetBSD: sip.c,v 1.19 2011/01/11 10:10:48 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
 	if (PCI_DEVICE(0x100b, 0x0020) != val)
 		return NULL;
 
-	l = ALLOC(struct local, sizeof(struct desc)); /* desc alignment */
+	l = ALLOC(struct local, 32); /* desc alignment */
 	memset(l, 0, sizeof(struct local));
 	l-csr = DEVTOV(pcicfgread(tag, 0x14)); /* use mem space */
 

Index: src/sys/arch/sandpoint/stand/netboot/sme.c
diff -u src/sys/arch/sandpoint/stand/netboot/sme.c:1.4 src/sys/arch/sandpoint/stand/netboot/sme.c:1.5
--- src/sys/arch/sandpoint/stand/netboot/sme.c:1.4	Tue Jan 11 09:45:25 2011
+++ src/sys/arch/sandpoint/stand/netboot/sme.c	Tue Jan 11 10:10:48 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: sme.c,v 1.4 2011/01/11 09:45:25 nisimura Exp $ */
+/* $NetBSD: sme.c,v 1.5 2011/01/11 10:10:48 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
 	unsigned mac32, mac16, val, fdx;
 	uint8_t *en;
 
-	l = ALLOC(struct local, sizeof(struct desc)); /* desc alignment */
+	l = ALLOC(struct local, 32); /* desc alignment */
 	memset(l, 0, sizeof(struct local));
 	l-csr = DEVTOV(pcicfgread(tag, 0x1c)); /* BAR3 mem space, LE */
 	l-phy = 1; /* 9420 internal PHY */

Index: src/sys/arch/sandpoint/stand/netboot/wm.c
diff -u src/sys/arch/sandpoint/stand/netboot/wm.c:1.12 src/sys/arch/sandpoint/stand/netboot/wm.c:1.13
--- 

CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 10 18:35:50 UTC 2011

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

Log Message:
Try to detect Iomega Storcenter board (untested).


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/stand/netboot/brdsetup.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.21 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.22
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.21	Sat Jun 26 21:45:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Mon Jan 10 18:35:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.21 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.22 2011/01/10 18:35:49 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -200,6 +200,10 @@
 	0x8086) {/* PCI_VENDOR_INTEL */
 		brdtype = BRD_QNAPTS101;
 	}
+	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 13, 0), PCI_ID_REG)) ==
+	0x1106) {/* PCI_VENDOR_VIA */
+		brdtype = BRD_STORCENTER;
+	}
 
 	brdprop = brd_lookup(brdtype);
 
@@ -261,6 +265,7 @@
 static void
 setup()
 {
+
 	if (brdprop-setup == NULL)
 		return;
 	(*brdprop-setup)(brdprop);
@@ -269,6 +274,7 @@
 static void
 brdfixup()
 {
+
 	if (brdprop-brdfix == NULL)
 		return;
 	(*brdprop-brdfix)(brdprop);
@@ -277,6 +283,7 @@
 void
 pcifixup()
 {
+
 	if (brdprop-pcifix == NULL)
 		return;
 	(*brdprop-pcifix)(brdprop);
@@ -285,6 +292,7 @@
 void
 encsetup(struct brdprop *brd)
 {
+
 #ifdef COSNAME
 	brd-consname = CONSNAME;
 #endif
@@ -358,6 +366,7 @@
 void
 motsetup(struct brdprop *brd)
 {
+
 #ifdef COSNAME
 	brd-consname = CONSNAME;
 #endif
@@ -372,6 +381,7 @@
 void
 motbrdfix(struct brdprop *brd)
 {
+
 /*
  * WinBond/Symphony Lab 83C553 with PC87308 SuperIO
  *
@@ -638,6 +648,7 @@
 void
 synosetup(struct brdprop *brd)
 {
+
 	/* nothing */
 }
 
@@ -723,6 +734,7 @@
 void
 _rtt(void)
 {
+
 	if (brdprop-reset != NULL)
 		(*brdprop-reset)();
 	else



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 10 20:13:47 UTC 2011

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

Log Message:
Make disk-booting work on Synology by using a PIO ATA-read command (0x20)
instead of the DMA read command (0xc8). This should work for all platforms.
Included the soft-reset in the siisata driver.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/stand/netboot/globals.h
cvs rdiff -u -r1.13 -r1.14 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/globals.h
diff -u src/sys/arch/sandpoint/stand/netboot/globals.h:1.18 src/sys/arch/sandpoint/stand/netboot/globals.h:1.19
--- src/sys/arch/sandpoint/stand/netboot/globals.h:1.18	Sat Jun 26 21:45:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/globals.h	Mon Jan 10 20:13:47 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.18 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: globals.h,v 1.19 2011/01/10 20:13:47 phx Exp $ */
 
 /* clock feed */
 #ifndef EXT_CLK_FREQ
@@ -135,24 +135,24 @@
 struct fs_ops *dsk_fsops(struct open_file *);
 
 /* status */
-#define ATA_STS_BUSY	0x80
-#define ATA_STS_DRDY	0x40
-#define ATA_STS_ERR 	0x01
+#define ATA_STS_BUSY		0x80
+#define ATA_STS_DRDY		0x40
+#define ATA_STS_ERR 		0x01
 /* command */
-#define ATA_CMD_IDENT	0xec
-#define ATA_CMD_READ	0xc8
-#define ATA_CMD_READ_EXT 0x24
-#define ATA_CMD_SETF	0xef
+#define ATA_CMD_IDENT		0xec
+#define ATA_CMD_READ		0x20
+#define ATA_CMD_READ_EXT	0x24
+#define ATA_CMD_SETF		0xef
 /* device */
-#define ATA_DEV_LBA	0xe0
-#define ATA_DEV_OBS	0x90
+#define ATA_DEV_LBA		0xe0
+#define ATA_DEV_OBS		0x90
 /* control */
-#define ATA_DREQ	0x08
-#define ATA_SRST	0x04
+#define ATA_DREQ		0x08
+#define ATA_SRST		0x04
 
-#define ATA_XFER	0x03
-#define XFER_PIO4	0x0c
-#define XFER_PIO0	0x08
+#define ATA_XFER		0x03
+#define XFER_PIO4		0x0c
+#define XFER_PIO0		0x08
 
 struct dvata_chan {
 	uint32_t cmd, ctl, alt, dma;

Index: src/sys/arch/sandpoint/stand/netboot/siisata.c
diff -u src/sys/arch/sandpoint/stand/netboot/siisata.c:1.13 src/sys/arch/sandpoint/stand/netboot/siisata.c:1.14
--- src/sys/arch/sandpoint/stand/netboot/siisata.c:1.13	Sun Aug  8 11:58:26 2010
+++ src/sys/arch/sandpoint/stand/netboot/siisata.c	Mon Jan 10 20:13:47 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.13 2010/08/08 11:58:26 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.14 2011/01/10 20:13:47 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -83,11 +83,10 @@
 		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 */
 		nchan = 2;
 	}
 	else {
-		/* 3114 */
+		/* 3114 - assume BA5 access is possible XXX */
 		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;
@@ -98,10 +97,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);
+		if (satapresense(l, n)) {
+			/* drive present, now check whether soft reset works */
+			if (perform_atareset(l, n)) {
+printf(port %d device present\n, n);
+l-presense[n] = 1;
+			}
+		} else
+			l-presense[n] = 0;
 	}
 	return l;
 }



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 10 20:14:52 UTC 2011

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

Log Message:
Do not crash, but use netbsd as default file name when missing.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/netboot/devopen.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/devopen.c
diff -u src/sys/arch/sandpoint/stand/netboot/devopen.c:1.11 src/sys/arch/sandpoint/stand/netboot/devopen.c:1.12
--- src/sys/arch/sandpoint/stand/netboot/devopen.c:1.11	Sat Jun 26 21:45:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/devopen.c	Mon Jan 10 20:14:52 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.11 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: devopen.c,v 1.12 2011/01/10 20:14:52 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -83,6 +83,8 @@
 	if (name[0] == 'w'  name[1] == 'd') {
 		parseunit(name[2], unit, part, file);
 		of-f_dev = devdsk;
+		if (*file == NULL || **file = ' ')
+			*file = netbsd;
 		if ((error = dsk_open(of, unit, part, *file)) != 0)
 			return error;
 		file_system[0] = *dsk_fsops(of);



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 10 20:16:42 UTC 2011

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

Log Message:
Accept wd[N[p]]: (with N=disk and p=partition) for specifying a disk drive.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sandpoint/stand/netboot/main.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/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.36 src/sys/arch/sandpoint/stand/netboot/main.c:1.37
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.36	Sun Jan  9 22:59:40 2011
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Mon Jan 10 20:16:42 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.36 2011/01/09 22:59:40 phx Exp $ */
+/* $NetBSD: main.c,v 1.37 2011/01/10 20:16:42 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -300,7 +300,7 @@
 	 * nfs:bootfile
 	 * tftp:
 	 * tftp:bootfile
-	 * wdN:bootfile
+	 * wd[N[P]]:bootfile
 	 *
 	 * net is a synonym of nfs.
 	 */
@@ -308,9 +308,14 @@
 		return 1;
 	if (strncmp(s, tftp:, 5) == 0)
 		return 1;
-	if (s[0] == 'w'  s[1] == 'd'
-	 s[2] = '0'  s[2] = '3'  s[3] == ':') {
-		return s[4] != '\0';
+	if (s[0] == 'w'  s[1] == 'd') {
+		s += 2;
+		if (*s != ':'  *s = '0'  *s = '3') {
+			++s;
+			if (*s != ':'  *s = 'a'  *s = 'p')
+++s;
+		}
+		return *s == ':';
 	}
 	return 0;
 }



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Jan 10 20:18:19 UTC 2011

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

Log Message:
Try to increase compatibility with all controllers when reading the status.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/netboot/dsk.c \
src/sys/arch/sandpoint/stand/netboot/version

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.5 src/sys/arch/sandpoint/stand/netboot/dsk.c:1.6
--- src/sys/arch/sandpoint/stand/netboot/dsk.c:1.5	Sun Aug  8 11:58:26 2010
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Mon Jan 10 20:18:19 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.5 2010/08/08 11:58:26 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.6 2011/01/10 20:18:19 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -142,11 +142,23 @@
 	int sts;
 	const char *msg;
 
+	/*
+	 * For best compatibility it is recommended to wait 400ns and
+	 * read the alternate status byte four times before the status
+	 * is valid.
+	 */
+	delay(1);
+	(void)CSR_READ_1(chan-alt);
+	(void)CSR_READ_1(chan-alt);
+	(void)CSR_READ_1(chan-alt);
+	(void)CSR_READ_1(chan-alt);
+
 	sts = CSR_READ_1(chan-cmd + _STS);
 	while (milli--  0  sts != 0xff  (sts  ATA_STS_BUSY)) {
 		delay(1000);
 		sts = CSR_READ_1(chan-cmd + _STS);
 	}
+
 	msg = NULL;
 	if (sts == 0xff)
 		msg = returned 0xff;
@@ -157,7 +169,7 @@
 
 	if (err != NULL)
 		*err = msg;
-	return (msg == NULL);
+	return msg == NULL;
 }
 
 int
Index: src/sys/arch/sandpoint/stand/netboot/version
diff -u src/sys/arch/sandpoint/stand/netboot/version:1.5 src/sys/arch/sandpoint/stand/netboot/version:1.6
--- src/sys/arch/sandpoint/stand/netboot/version:1.5	Thu May 20 20:18:51 2010
+++ src/sys/arch/sandpoint/stand/netboot/version	Mon Jan 10 20:18:19 2011
@@ -3,3 +3,4 @@
 1.2	Synology-DS support, Marvell-Yukon driver, fixed aligned alloc
 1.3	allow to have boot options, brdsetup.c cleanup to make brdtype
 	maintainance more confortable
+1.4	load kernels from local disk



CVS commit: src/sys/arch/sandpoint/stand/netboot

2011-01-09 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jan  9 22:59:41 UTC 2011

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

Log Message:
fixed message: is found - was found


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sandpoint/stand/netboot/main.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/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.35 src/sys/arch/sandpoint/stand/netboot/main.c:1.36
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.35	Sun Aug  8 11:54:45 2010
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Sun Jan  9 22:59:40 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.35 2010/08/08 11:54:45 phx Exp $ */
+/* $NetBSD: main.c,v 1.36 2011/01/09 22:59:40 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -133,13 +133,14 @@
 	pcifixup();
 
 	if (dskdv_init(dsk, dev) == 0 || disk_scan(dev) == 0)
-		printf(no IDE/SATA device driver is found\n);
+		printf(no IDE/SATA device driver was found\n);
 
 	if (netif_init(tag) == 0)
-		printf(no NIC device driver is found\n);
+		printf(no NIC device driver was found\n);
+
+	howto = RB_AUTOBOOT;		/* default is autoboot = 0 */
 
 	/* get boot options and determine bootname */
-	howto = RB_AUTOBOOT;
 	for (n = 1; n  argc; n++) {
 		for (i = 0; i  sizeof(bootargs) / sizeof(bootargs[0]); i++) {
 			if (strncasecmp(argv[n], bootargs[i].name,



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-08-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Aug  8 11:54:46 UTC 2010

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

Log Message:
Minor source cleanup. Suggested by Kiyohara.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/netboot/dsk.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sandpoint/stand/netboot/main.c
cvs rdiff -u -r1.11 -r1.12 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.3 src/sys/arch/sandpoint/stand/netboot/dsk.c:1.4
--- src/sys/arch/sandpoint/stand/netboot/dsk.c:1.3	Fri Jul 23 20:01:27 2010
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Sun Aug  8 11:54:45 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.3 2010/07/23 20:01:27 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.4 2010/08/08 11:54:45 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -365,6 +365,7 @@
 	const char *err;
 	int error;
 
+return EIO; /*@@@*/
 	l = d-dvops;
 	n = d-unittag;
 	p = (uint16_t *)buf;

Index: src/sys/arch/sandpoint/stand/netboot/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.34 src/sys/arch/sandpoint/stand/netboot/main.c:1.35
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.34	Sat Jun 26 21:45:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Sun Aug  8 11:54:45 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.34 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: main.c,v 1.35 2010/08/08 11:54:45 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -151,7 +151,7 @@
 		if (i = sizeof(bootargs) / sizeof(bootargs[0]))
 			break;	/* break on first unknown string */
 	}
-	if (n == argc)
+	if (n = argc)
 		bname = BNAME_DEFAULT;
 	else {
 		bname = argv[n];

Index: src/sys/arch/sandpoint/stand/netboot/siisata.c
diff -u src/sys/arch/sandpoint/stand/netboot/siisata.c:1.11 src/sys/arch/sandpoint/stand/netboot/siisata.c:1.12
--- src/sys/arch/sandpoint/stand/netboot/siisata.c:1.11	Fri Jul 23 20:04:52 2010
+++ src/sys/arch/sandpoint/stand/netboot/siisata.c	Sun Aug  8 11:54:46 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.11 2010/07/23 20:04:52 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.12 2010/08/08 11:54:46 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,9 +58,10 @@
 void *
 siisata_init(unsigned tag, void *data)
 {
-	unsigned val;
+	unsigned val, cls;
 	int nchan, n;
 	struct dkdev_ata *l;
+	static int ba5bccregs[] = { 0x40, 0x44, 0x240, 0x244 };
 
 	l = alloc(sizeof(struct dkdev_ata));
 	memset(l, 0, sizeof(struct dkdev_ata));
@@ -77,17 +78,24 @@
 	val = pcicfgread(tag, PCI_ID_REG);
 	if ((PCI_PRODUCT(val)  0xf) == 0x2) {
 		/* 3112/3512 */
+		/* reset BA5 indirect access enable */
+		val = pcicfgread(tag, 0x40);
+		pcicfgwrite(tag, 0x40, val  ~02);
+		/* reset everything, enable BA5 access */
+		pcicfgwrite(tag, 0x88, 0x100f3);
+		delay(50 * 1000);
+		pcicfgwrite(tag, 0x88, 0x1);
+		delay(50 * 1000);		
 		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 */
 		nchan = 2;
 	}
 	else {
-		/* 3114 */
+		/* 3114 - 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;
@@ -98,10 +106,40 @@
 		l-chan[3].ctl = l-chan[3].alt = (l-bar[5] + 0x2c8) | 02;
 		nchan = 4;
 	}
+
+	/* fixup cache line */
+	cls = (pcicfgread(tag, 0xc)  0xff)  2;
+	if (cls  224) {
+		cls = (pcicfgread(tag, 0xc)  0xff) | (2242);
+		pcicfgwrite(tag, 0xc, cls);
+		cls = 224;
+	} else if (cls  32)
+		cls = 32;
+	cls = (cls + 31) / 32;
+	for (n = 0; n  nchan; n++) {
+		val = in32rb(l-bar[5] + ba5bccregs[n]);
+		if ((val  0x7)  cls)
+			out32rb(l-bar[5] + ba5bccregs[n], (val  0x07) | cls);
+	}
+
+	/* detect presence */
 	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);
+
+	for (val=0; val0x100; val+=4) {
+		if ((val  0xf) == 0)
+			printf(0x%02x:,val);
+		printf( 0x%08x,pcicfgread(tag,val));
+		if ((val  0xf) == 0xc)
+			printf(\n);
+	}
 	return l;
 }



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-08-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Aug  8 11:58:26 UTC 2010

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

Log Message:
Erroneously committed test code. Reverted to previous revision.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/netboot/dsk.c
cvs rdiff -u -r1.12 -r1.13 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.4 src/sys/arch/sandpoint/stand/netboot/dsk.c:1.5
--- src/sys/arch/sandpoint/stand/netboot/dsk.c:1.4	Sun Aug  8 11:54:45 2010
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Sun Aug  8 11:58:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.4 2010/08/08 11:54:45 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.5 2010/08/08 11:58:26 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -365,7 +365,6 @@
 	const char *err;
 	int error;
 
-return EIO; /*@@@*/
 	l = d-dvops;
 	n = d-unittag;
 	p = (uint16_t *)buf;

Index: src/sys/arch/sandpoint/stand/netboot/siisata.c
diff -u src/sys/arch/sandpoint/stand/netboot/siisata.c:1.12 src/sys/arch/sandpoint/stand/netboot/siisata.c:1.13
--- src/sys/arch/sandpoint/stand/netboot/siisata.c:1.12	Sun Aug  8 11:54:46 2010
+++ src/sys/arch/sandpoint/stand/netboot/siisata.c	Sun Aug  8 11:58:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.12 2010/08/08 11:54:46 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.13 2010/08/08 11:58:26 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,10 +58,9 @@
 void *
 siisata_init(unsigned tag, void *data)
 {
-	unsigned val, cls;
+	unsigned val;
 	int nchan, n;
 	struct dkdev_ata *l;
-	static int ba5bccregs[] = { 0x40, 0x44, 0x240, 0x244 };
 
 	l = alloc(sizeof(struct dkdev_ata));
 	memset(l, 0, sizeof(struct dkdev_ata));
@@ -78,24 +77,17 @@
 	val = pcicfgread(tag, PCI_ID_REG);
 	if ((PCI_PRODUCT(val)  0xf) == 0x2) {
 		/* 3112/3512 */
-		/* reset BA5 indirect access enable */
-		val = pcicfgread(tag, 0x40);
-		pcicfgwrite(tag, 0x40, val  ~02);
-		/* reset everything, enable BA5 access */
-		pcicfgwrite(tag, 0x88, 0x100f3);
-		delay(50 * 1000);
-		pcicfgwrite(tag, 0x88, 0x1);
-		delay(50 * 1000);		
 		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 */
 		nchan = 2;
 	}
 	else {
-		/* 3114 - assume BA5 access is possible */
+		/* 3114 */
 		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;
@@ -106,40 +98,10 @@
 		l-chan[3].ctl = l-chan[3].alt = (l-bar[5] + 0x2c8) | 02;
 		nchan = 4;
 	}
-
-	/* fixup cache line */
-	cls = (pcicfgread(tag, 0xc)  0xff)  2;
-	if (cls  224) {
-		cls = (pcicfgread(tag, 0xc)  0xff) | (2242);
-		pcicfgwrite(tag, 0xc, cls);
-		cls = 224;
-	} else if (cls  32)
-		cls = 32;
-	cls = (cls + 31) / 32;
-	for (n = 0; n  nchan; n++) {
-		val = in32rb(l-bar[5] + ba5bccregs[n]);
-		if ((val  0x7)  cls)
-			out32rb(l-bar[5] + ba5bccregs[n], (val  0x07) | cls);
-	}
-
-	/* detect presence */
 	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);
-
-	for (val=0; val0x100; val+=4) {
-		if ((val  0xf) == 0)
-			printf(0x%02x:,val);
-		printf( 0x%08x,pcicfgread(tag,val));
-		if ((val  0xf) == 0xc)
-			printf(\n);
-	}
 	return l;
 }



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-07-23 Thread Frank Wille
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  (1ULL28)) ? 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; n6; 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 | 0xf3);
+	delay(50 * 1000);
+//	pcicfgwrite(tag, 0x88, val  0xc0);
+	pcicfgwrite(tag, 0x88, val  0x00);
+	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;
 }



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-07-23 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Jul 23 20:04:52 UTC 2010

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

Log Message:
Erroneously committed my test code. Reverted to 1.9.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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/siisata.c
diff -u src/sys/arch/sandpoint/stand/netboot/siisata.c:1.10 src/sys/arch/sandpoint/stand/netboot/siisata.c:1.11
--- src/sys/arch/sandpoint/stand/netboot/siisata.c:1.10	Fri Jul 23 20:01:27 2010
+++ src/sys/arch/sandpoint/stand/netboot/siisata.c	Fri Jul 23 20:04:52 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.10 2010/07/23 20:01:27 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.11 2010/07/23 20:04:52 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -35,11 +35,6 @@
 
 #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 *);
@@ -78,24 +73,17 @@
 	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; n6; 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 | 0xf3);
-	delay(50 * 1000);
-//	pcicfgwrite(tag, 0x88, val  0xc0);
-	pcicfgwrite(tag, 0x88, val  0x00);
-	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[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);
+		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 */
 		nchan = 2;
 	}
 	else {
@@ -110,16 +98,10 @@
 		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;
 }



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-07-17 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jul 17 14:15:34 UTC 2010

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

Log Message:
Code to set PCI cfg xfer mode registers of 0680A IDE, to make sure the
chip is in PIO mode.
Patch submitted by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/netboot/pciide.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/pciide.c
diff -u src/sys/arch/sandpoint/stand/netboot/pciide.c:1.8 src/sys/arch/sandpoint/stand/netboot/pciide.c:1.9
--- src/sys/arch/sandpoint/stand/netboot/pciide.c:1.8	Sat Jun 26 21:45:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/pciide.c	Sat Jul 17 14:15:34 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.8 2010/06/26 21:45:49 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.9 2010/07/17 14:15:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -41,7 +41,8 @@
 	int (*chipfix)(struct dkdev_ata *);
 	int (*presense)(struct dkdev_ata *, int);
 };
-static struct myops cmdideops = { NULL, NULL };
+static int cmdidefix(struct dkdev_ata *);
+static struct myops cmdideops = { cmdidefix, NULL };
 static struct myops *myops = cmdideops;
 
 int pciide_match(unsigned, void *);
@@ -76,9 +77,6 @@
 	l-iobuf = allocaligned(512, 16);
 	l-tag = tag;
 
-	if (myops-chipfix)
-		(*myops-chipfix)(l);
-
 	val = pcicfgread(tag, PCI_CLASS_REG);
 	native = val  03;
 	if (native) {
@@ -119,5 +117,27 @@
 		if (l-presense[n])
 			printf(channel %d present\n, n);
 	}
+
+	/* make sure to have PIO0 */
+	if (myops-chipfix)
+		(*myops-chipfix)(l);
+
 	return l;
 }
+
+static int
+cmdidefix(struct dkdev_ata *l)
+{
+	int v;
+
+	v = pcicfgread(l-tag, 0x80);
+	pcicfgwrite(l-tag, 0x80, (v  ~0xff) | 0x01);
+	v = pcicfgread(l-tag, 0x84);
+	pcicfgwrite(l-tag, 0x84, (v  ~0xff) | 0x01);
+	v = pcicfgread(l-tag, 0xa4);
+	pcicfgwrite(l-tag, 0xa4, (v  ~0x) | 0x328a);
+	v = pcicfgread(l-tag, 0xb4);
+	pcicfgwrite(l-tag, 0xb4, (v  ~0x) | 0x328a);
+
+	return 1;
+}



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-06-27 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jun 27 12:09:17 UTC 2010

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

Log Message:
Replaced test code for Synology SiI3512 with working KuroBox code again.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/netboot/dsk.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.1 src/sys/arch/sandpoint/stand/netboot/dsk.c:1.2
--- src/sys/arch/sandpoint/stand/netboot/dsk.c:1.1	Sat Jun 26 22:13:32 2010
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Sun Jun 27 12:09:17 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.1 2010/06/26 22:13:32 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.2 2010/06/27 12:09:17 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -82,7 +82,6 @@
 static char *mkident(char *, int);
 static void set_xfermode(struct dkdev_ata *, int);
 static void decode_dlabel(struct disk *, char *);
-static int sii_spinwait_irqack(struct dkdev_ata *, int);
 static int lba_read(struct disk *, uint64_t, uint32_t, void *);
 static void issue48(struct dvata_chan *, uint64_t, uint32_t);
 static void issue28(struct dvata_chan *, uint64_t, uint32_t);
@@ -356,35 +355,12 @@
 }
 
 static int
-sii_spinwait_irqack(struct dkdev_ata *l, int n)
-{
-/* 0x0a0, 0x0e0, 0x2a0, 0x2e0 */
-#define CNST_CH(n) (((n02)8)+((n01)6))
-#define CNST_TF(n) (0x0a0+CNST_CH(n))
-#define CNST_INT   (111)
-	struct dvata_chan *chan = l-chan[n];
-	uint32_t cnst = l-bar[5] + CNST_TF(n);
-	int loop, sts;
-
-	loop = 100;
-	do {
-		sts = CSR_READ_4(cnst);
-		if (sts  CNST_INT) {
-			sts = CSR_READ_1(chan-cmd + _STS);
-			return (sts  ATA_STS_ERR) == 0;
-		}
-		delay(1000);
-	} while (--loop  0);
-	return 0;
-}
-
-static int
 lba_read(struct disk *d, uint64_t bno, uint32_t bcnt, void *buf)
 {
 	struct dkdev_ata *l = d-dvops;
 	struct dvata_chan *chan;
 	void (*issue)(struct dvata_chan *, uint64_t, uint32_t);
-	uint32_t n, i, rdcnt;
+	uint32_t n, rdcnt;
 	uint16_t *p;
 	const char *err;
 	int error;
@@ -401,35 +377,14 @@
 		if (spinwait_unbusy(l, n, 1000, err) == 0) {
 			printf(%s blk %d %s\n, d-xname, (int)bno, err);
 			error = EIO;
-			goto skip;
 		}
-#if 1 /* XXX */
-		for (i = 0; i  rdcnt; i += 1) {
-			if (sii_spinwait_irqack(l, n) == 0) {
-printf(%s blk %d no xfer ack\n, d-xname, (int)bno);
-error = EIO;
-goto skip;
-			}
-			for (n = 0; n  512; n +=2) {
+		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);
 		}
-#else
-		i = 0;
-		if (sii_spinwait_irqack(l, n) == 0) {
-			printf(%s blk %d no xfer ack\n, d-xname, (int)bno);
-			error = EIO;
-			goto skip;
-		}
-		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);
-#endif
-  skip:
 		bno += rdcnt; bcnt -= rdcnt;
 	}
 	return error;
@@ -511,9 +466,7 @@
 	}
 	return ENXIO;
   found:
-#if 1
 printf(dsk_open found %s\n, fsmod);
-#endif
 	d-fsops = fs;
 	f-f_devdata = d;
 



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-06-27 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jun 27 12:09:41 UTC 2010

Removed Files:
src/sys/arch/sandpoint/stand/netboot: atawd.c

Log Message:
No longer needed. See dsk.c.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r0 src/sys/arch/sandpoint/stand/netboot/atawd.c

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



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-06-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jun 26 22:13:32 UTC 2010

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

Log Message:
- add IDE/SATA diskboot facility
known ok with KuroBox PCIIDE, need more debug on SiI3512 SATA
which fails reading sectors from a drive.

- now capable of TFTP loading

Code submitted by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/sandpoint/stand/netboot/dsk.c

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

Added files:

Index: src/sys/arch/sandpoint/stand/netboot/dsk.c
diff -u /dev/null src/sys/arch/sandpoint/stand/netboot/dsk.c:1.1
--- /dev/null	Sat Jun 26 22:13:32 2010
+++ src/sys/arch/sandpoint/stand/netboot/dsk.c	Sat Jun 26 22:13:32 2010
@@ -0,0 +1,570 @@
+/* $NetBSD: dsk.c,v 1.1 2010/06/26 22:13:32 phx Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tohru Nishimura.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * assumptions;
+ * - up to 4 IDE/SATA drives.
+ * - a single (master) drive in each IDE channel.
+ * - all drives are up and spinning.
+ */
+
+#include sys/types.h
+
+#include lib/libsa/stand.h
+#include lib/libsa/ufs.h
+
+#include sys/disklabel.h
+#include sys/bootblock.h
+
+#include machine/bootinfo.h
+#include machine/stdarg.h
+
+#include globals.h
+
+/*
+ * - no vtophys() translation, vaddr_t == paddr_t.
+ */
+#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)
+
+#define DSK_DECL(xxx) \
+int xxx ## _match(unsigned, void *); \
+void * xxx ## _init(unsigned, void *)
+
+DSK_DECL(pciide);
+DSK_DECL(siisata);
+
+struct dskdv {
+	char *name;
+	int (*match)(unsigned, void *);
+	void *(*init)(unsigned, void *);
+	void *priv;
+};
+
+static struct dskdv ldskdv[] = {
+	{ pciide, pciide_match, pciide_init, },
+	{ siisata, siisata_match, siisata_init, },
+};
+static int ndskdv = sizeof(ldskdv)/sizeof(ldskdv[0]);
+
+static int probe_drive(struct dkdev_ata *, int);
+static void drive_ident(struct disk *, char *);
+static char *mkident(char *, int);
+static void set_xfermode(struct dkdev_ata *, int);
+static void decode_dlabel(struct disk *, char *);
+static int sii_spinwait_irqack(struct dkdev_ata *, int);
+static int lba_read(struct disk *, uint64_t, uint32_t, void *);
+static void issue48(struct dvata_chan *, uint64_t, uint32_t);
+static void issue28(struct dvata_chan *, uint64_t, uint32_t);
+static struct disk *lookup_disk(int);
+
+static struct disk ldisk[4];
+
+int
+dskdv_init(unsigned tag, void **cookie)
+{
+	struct dskdv *dv;
+	int n;
+
+	for (n = 0; n  ndskdv; n++) {
+		dv = ldskdv[n];
+		if ((*dv-match)(tag, NULL)  0)
+			goto found;
+	}
+	return 0;
+  found:
+	dv-priv = (*dv-init)(tag, NULL);
+	*cookie = dv;
+	return 1;
+}
+
+int
+disk_scan(void *cookie)
+{
+	struct dskdv *dv = cookie;
+	struct dkdev_ata *l = dv-priv;
+	struct disk *d;
+	int n, ndrive;
+
+	ndrive = 0;
+	for (n = 0; n  4; n++) {
+		if (l-presense[n] == 0)
+			continue;
+		if (probe_drive(l, n) == 0) {
+			l-presense[n] = 0;
+			continue;
+		}
+		d = ldisk[ndrive];
+		d-dvops = l;
+		d-unittag = ndrive;
+		snprintf(d-xname, sizeof(d-xname), wd%d, d-unittag);
+		drive_ident(d, l-iobuf);
+		decode_dlabel(d, l-iobuf);
+		set_xfermode(l, n);
+		ndrive += 1;
+	}
+	return ndrive;
+}
+
+int
+spinwait_unbusy(struct dkdev_ata *l, int n, int milli, const char **err)
+{
+	struct dvata_chan *chan = l-chan[n];
+	int sts;
+	const char *msg;
+

CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-20 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu May 20 20:18:51 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: brdsetup.c globals.h main.c
version

Log Message:
brdsetup() cleanup by Toru Nishimura.
Put all board-relevant data into a structure.
A few modifications by myself to use the new structure for generating the
BTINFO_PRODFAMILY boot node.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/stand/netboot/brdsetup.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/netboot/globals.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sandpoint/stand/netboot/main.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/netboot/version

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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.18 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.19
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.18	Wed May 19 15:04:51 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Thu May 20 20:18:51 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.18 2010/05/19 15:04:51 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.19 2010/05/20 20:18:51 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -39,16 +39,82 @@
 
 #include globals.h
 
-const unsigned dcache_line_size = 32;		/* 32B linesize */
-const unsigned dcache_range_size = 4 * 1024;	/* 16KB / 4-way */
+#define BRD_DECL(xxx) \
+void xxx ## setup(struct brdprop *); \
+void xxx ## brdfix(struct brdprop *); \
+void xxx ## pcifix(struct brdprop *); \
+void xxx ## reset(void)
+
+BRD_DECL(enc);
+BRD_DECL(mot);
+BRD_DECL(kuro);
+BRD_DECL(syno);
+
+static struct brdprop brdlist[] = {
+{
+	sandpoint,
+	Sandpoint X3,
+	BRD_SANDPOINTX3,
+	0,
+	com, 0x3f8, 115200,
+	motsetup, NULL, motpcifix },
+{
+	encpp1,
+	EnCore PP1,
+	BRD_ENCOREPP1,
+	0,
+	com, 0x3f8, 115200,
+	encsetup, NULL, encpcifix },
+{
+	kurobox,
+	KuroBox,
+	BRD_KUROBOX,
+	32768000,
+	eumb, 0x4600, 57600,
+	kurosetup, kurobrdfix, kuropcifix },
+{
+	synology,
+	Synology DS,
+	BRD_SYNOLOGY,
+	33164691,	/* from Synology/Linux source */
+	/* 33168000,		XXX better precision? */
+	eumb, 0x4500, 115200,
+	synosetup, synobrdfix, synopcifix, synoreset },
+{
+	qnap,
+	QNAP TS-101,
+	BRD_QNAPTS101,
+	0,
+	eumb, 0x4500, 115200,
+	NULL, NULL, NULL },
+{
+	iomega,
+	IOMEGA Storcenter,
+	BRD_STORCENTER,
+	0,
+	eumb, 0x4500, 115200,
+	NULL, NULL, NULL },
+{
+	unknown,
+	Unknown board,
+	BRD_UNKNOWN,
+	0,
+	eumb, 0x4500, 115200,
+	NULL, NULL, NULL }, /* must be the last */
+};
 
+static struct brdprop *brdprop;
 static uint32_t ns_per_tick;
 
-void brdsetup(void);
-void setup_82C686B(void);
-void setup_83C553F(void);
-
+static void brdfixup(void);
+static void setup(void);
+static inline uint32_t cputype(void);
 static inline u_quad_t mftb(void);
+static void init_uart(unsigned, unsigned, uint8_t);
+static void send_sat(char *);
+
+const unsigned dcache_line_size = 32;		/* 32B linesize */
+const unsigned dcache_range_size = 4 * 1024;	/* 16KB / 4-way */
 
 unsigned uart1base;	/* console */
 unsigned uart2base;	/* optional satellite processor */
@@ -71,42 +137,7 @@
 #define UART_READ(base, r)	*(volatile char *)(base + (r))
 #define UART_WRITE(base, r, v)	*(volatile char *)(base + (r)) = (v)
 
-static __inline uint32_t
-cputype(void)
-{
-	uint32_t pvr;
-
-	__asm volatile (mfpvr %0 : =r(pvr));
-	return pvr  16;
-}
-
-static void
-init_uart(unsigned base, unsigned speed, uint8_t lcr)
-{
-	unsigned div;
-
-	div = busclock / speed / 16;
-	UART_WRITE(base, LCR, 0x80);		/* turn on DLAB bit */
-	UART_WRITE(base, FCR, 0x00);
-	UART_WRITE(base, DMB, div  8);	/* set speed */
-	UART_WRITE(base, DLB, div  0xff);
-	UART_WRITE(base, LCR, lcr);
-	UART_WRITE(base, FCR, 0x07);		/* FIFO on, TXRX FIFO reset */
-	UART_WRITE(base, IER, 0x00);		/* make sure INT disabled */
-}
-
-/* talk to satellite processor */
-static void
-send_sat(char *msg)
-{
-	unsigned savedbase;
-
-	savedbase = uart1base;
-	uart1base = uart2base;
-	while (*msg)
-		putchar(*msg++);
-	uart1base = savedbase;
-}
+void brdsetup(void);
 
 void
 brdsetup(void)
@@ -143,50 +174,32 @@
 
 	if (pcifinddev(0x10ad, 0x0565, pcib) == 0) {
 		brdtype = BRD_SANDPOINTX3;
-		setup_83C553F();
 	}
 	else if (pcifinddev(0x1106, 0x0686, pcib) == 0) {
 		brdtype = BRD_ENCOREPP1;
-		setup_82C686B();
 	}
 	else if ((pcicfgread(pcimaketag(0, 11, 0), PCI_CLASS_REG)  16) ==
 	PCI_CLASS_ETH) {
 		/* tlp (ADMtek AN985) or re (RealTek 8169S) at dev 11 */
 		brdtype = BRD_KUROBOX;
-		consname = eumb;
-		consport = 0x4600;
-		consspeed = 57600;
-		if (PCI_VENDOR(pcicfgread(pcimaketag(0, 11, 0), PCI_ID_REG))
-		== 0x10ec)
-			extclk = 32768000;  /* decr 2457600Hz */
-		else
-			extclk = 32521333;  /* decr 2439100Hz */
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 

CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed May 19 15:04:51 UTC 2010

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

Log Message:
Updated Synology extclk from latest Linux/Synology source.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/netboot/brdsetup.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.17 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.18
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.17	Tue May 18 14:32:38 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Wed May 19 15:04:51 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.17 2010/05/18 14:32:38 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.18 2010/05/19 15:04:51 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -168,7 +168,8 @@
 		consname = eumb;
 		consport = 0x4500;
 		consspeed = 115200;
-		extclk = 33164526;
+		extclk = 33164691;	/* from Synology/Linux source */
+		/* extclk = 33168000;	XXX better precision? */
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
 	0x8086) {/* PCI_VENDOR_INTEL */



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed May 19 15:05:58 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: Makefile entry.S main.c

Log Message:
Implemented support for boot arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/netboot/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/netboot/entry.S
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sandpoint/stand/netboot/main.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/Makefile
diff -u src/sys/arch/sandpoint/stand/netboot/Makefile:1.17 src/sys/arch/sandpoint/stand/netboot/Makefile:1.18
--- src/sys/arch/sandpoint/stand/netboot/Makefile:1.17	Mon May 17 17:50:08 2010
+++ src/sys/arch/sandpoint/stand/netboot/Makefile	Wed May 19 15:05:58 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2010/05/17 17:50:08 phx Exp $
+#	$NetBSD: Makefile,v 1.18 2010/05/19 15:05:58 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -11,7 +11,6 @@
 CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
 #CPPFLAGS+=	-DCONSNAME=\com\ -DCONSPORT=0x3f8 -DCONSSPEED=115200
 #CPPFLAGS+=	-DCONSNAME=\eumb\ -DCONSPORT=0x4600 -DCONSSPEED=57600
-#CPPFLAGS+=	-DSTART_DDB_SESSION
 CPPFLAGS+=	-nostdinc -I. -I${.OBJDIR} -I${S}
 DBG=		-Os
 

Index: src/sys/arch/sandpoint/stand/netboot/entry.S
diff -u src/sys/arch/sandpoint/stand/netboot/entry.S:1.6 src/sys/arch/sandpoint/stand/netboot/entry.S:1.7
--- src/sys/arch/sandpoint/stand/netboot/entry.S:1.6	Thu May 13 10:40:02 2010
+++ src/sys/arch/sandpoint/stand/netboot/entry.S	Wed May 19 15:05:58 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.6 2010/05/13 10:40:02 phx Exp $ */
+/* $NetBSD: entry.S,v 1.7 2010/05/19 15:05:58 phx Exp $ */
 
 #include powerpc/psl.h
 #include powerpc/spr.h
@@ -9,6 +9,8 @@
 	.text
 	.globl _start
 _start:
+	mr	30,3
+	mr	31,4
 	mfspr	11,SPR_HID0
 	andi.	0,11,HID0_DCE
 	ori	11,11,HID0_ICE
@@ -89,6 +91,8 @@
 	addi	1,1,-4
 
 	bl	brdsetup
+	mr	3,30
+	mr	4,31
 	bl	main
 
 hang:	b	hang

Index: src/sys/arch/sandpoint/stand/netboot/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.30 src/sys/arch/sandpoint/stand/netboot/main.c:1.31
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.30	Tue May 18 15:07:50 2010
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Wed May 19 15:05:58 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.30 2010/05/18 15:07:50 phx Exp $ */
+/* $NetBSD: main.c,v 1.31 2010/05/19 15:05:58 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -40,6 +40,23 @@
 
 #include globals.h
 
+static const struct bootarg {
+	const char *name;
+	int value;
+} bootargs[] = {
+	{ multi,	RB_AUTOBOOT },
+	{ auto,	RB_AUTOBOOT },
+	{ ask,	RB_ASKNAME },
+	{ single,	RB_SINGLE },
+	{ ddb,	RB_KDB },
+	{ userconf,	RB_USERCONF },
+	{ norm,	AB_NORMAL },
+	{ quiet,	AB_QUIET },
+	{ verb,	AB_VERBOSE },
+	{ silent,	AB_SILENT },
+	{ debug,	AB_DEBUG }
+};
+
 void *bootinfo; /* low memory reserved to pass bootinfo structures */
 int bi_size;	/* BOOTINFO_MAXSIZE */
 char *bi_next;
@@ -48,7 +65,7 @@
 char rootdev[4];	/* NIF nickname, filled by netif_init() */
 uint8_t en[6];		/* NIC macaddr, fill by netif_init() */
 
-void main(void);
+void main(int, char **);
 void bi_init(void *);
 void bi_add(void *, int, int);
 
@@ -62,7 +79,7 @@
 uint32_t busclock, cpuclock;
 
 void
-main(void)
+main(int argc, char *argv[])
 {
 	struct btinfo_memory bi_mem;
 	struct btinfo_console bi_cons;
@@ -73,7 +90,7 @@
 	unsigned long marks[MARK_MAX];
 	unsigned lata[1][2], lnif[1][2];
 	unsigned memsize, tag;
-	int b, d, f, fd, howto, n;
+	int b, d, f, fd, howto, i, n;
 
 	/* determine SDRAM size */
 	memsize = mpc107memsize();
@@ -143,10 +160,19 @@
 	if (fdloadfile(fd, marks, LOAD_KERNEL)  0)
 		goto loadfail;
 
-	howto = RB_SINGLE | AB_VERBOSE;
-#ifdef START_DDB_SESSION
-	howto |= RB_KDB;
-#endif
+	/* get boot mode and boot options */
+	howto = RB_AUTOBOOT;
+	for (n = 1; n  argc; n++) {
+		for (i = 0; i  sizeof(bootargs) / sizeof(bootargs[0]); i++) {
+			if (strncasecmp(argv[n], bootargs[i].name,
+			strlen(bootargs[i].name)) == 0) {
+howto |= bootargs[i].value;
+break;
+			}
+		}
+		if (i = sizeof(bootargs) / sizeof(bootargs[0]))
+			break;	/* break on first garbage argument */
+	}
 
 	bootinfo = (void *)0x4000;
 	bi_init(bootinfo);



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-18 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue May 18 10:41:30 UTC 2010

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

Log Message:
Synology PCI fixup, submitted by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/netboot/brdsetup.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.15 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.16
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.15	Mon May 17 17:48:59 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Tue May 18 10:41:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.15 2010/05/17 17:48:59 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.16 2010/05/18 10:41:30 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -126,9 +126,14 @@
 	uint32_t extclk;
 	unsigned pchb, pcib, val;
 
-	/* BAT to arrange address space */
-
-	/* EUMBBAR */
+	/*
+	 * CHRP specification Map-B BAT012 layout
+	 *   BAT0 - (256MB) SDRAM
+	 *   BAT1 8000- (256MB) PCI mem space
+	 *   BAT2 fc00- (64MB)  EUMB, PCI I/O space, misc devs, flash
+	 *
+	 * EUMBBAR is at fc00-.
+	 */
 	pchb = pcimaketag(0, 0, 0);
 	pcicfgwrite(pchb, 0x78, 0xfc00);
 
@@ -401,7 +406,7 @@
 	end |= ((val  bankn)  0xff)  20;
 	end |= 0xf;
 
-	return (end + 1); /* size of bankN SDRAM */
+	return (end + 1); /* assume the end address matches total amount */
 }
 
 /*
@@ -685,31 +690,58 @@
 		break;
 
 	case BRD_KUROBOX:
-		nic  = pcimaketag(0, 11, 0);
-		val = pcicfgread(nic, 0x3c)  0x;
-		val |= (('A' - '@')  8) | 11;
+		nic = pcimaketag(0, 11, 0);
+		val = pcicfgread(nic, 0x3c)  0xff00;
+		val |= 11;
 		pcicfgwrite(nic, 0x3c, val);
 
-		ide  = pcimaketag(0, 12, 0);
-		val = pcicfgread(ide, 0x3c)  0x;
-		val |= (('A' - '@')  8) | 12;
+		ide = pcimaketag(0, 12, 0);
+		val = pcicfgread(ide, 0x3c)  0xff00;
+		val |= 12;
 		pcicfgwrite(ide, 0x3c, val);
 
-		usb  = pcimaketag(0, 14, 0);
-		val = pcicfgread(usb, 0x3c)  0x;
-		val |= (('A' - '@')  8) | 14;
+		usb = pcimaketag(0, 14, 0);
+		val = pcicfgread(usb, 0x3c)  0xff00;
+		val |= 14;
 		pcicfgwrite(usb, 0x3c, val);
 
-		usb  = pcimaketag(0, 14, 1);
-		val = pcicfgread(usb, 0x3c)  0x;
-		val |= (('B' - '@')  8) | 14;
+		usb = pcimaketag(0, 14, 1);
+		val = pcicfgread(usb, 0x3c)  0xff00;
+		val |= 14;
 		pcicfgwrite(usb, 0x3c, val);
 
-		usb  = pcimaketag(0, 14, 2);
-		val = pcicfgread(usb, 0x3c)  0x;
-		val |= (('C' - '@')  8) | 14;
+		usb = pcimaketag(0, 14, 2);
+		val = pcicfgread(usb, 0x3c)  0xff00;
+		val |= 14;
 		pcicfgwrite(usb, 0x3c, val);
 		break;
+
+	case BRD_SYNOLOGY:
+		ide = pcimaketag(0, 13, 0);
+		val = pcicfgread(ide, 0x3c)  0xff00;
+		val |= 13;
+		pcicfgwrite(ide, 0x3c, val);
+
+		usb = pcimaketag(0, 14, 0);
+		val = pcicfgread(usb, 0x3c)  0xff00;
+		val |= 14;
+		pcicfgwrite(usb, 0x3c, val);
+
+		usb = pcimaketag(0, 14, 1);
+		val = pcicfgread(usb, 0x3c)  0xff00;
+		val |= 14;
+		pcicfgwrite(usb, 0x3c, val);
+
+		usb = pcimaketag(0, 14, 2);
+		val = pcicfgread(usb, 0x3c)  0xff00;
+		val |= 14;
+		pcicfgwrite(usb, 0x3c, val);
+
+		nic = pcimaketag(0, 15, 0);
+		val = pcicfgread(nic, 0x3c)  0xff00;
+		val |= 15;
+		pcicfgwrite(nic, 0x3c, val);
+		break;
 	}
 }
 



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-18 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue May 18 14:32:39 UTC 2010

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

Log Message:
Set Synology extclk from 33.33MHz to 33.164526MHz, which reduces the
error in the mftb timer from 5% to 0.002%.
The console port for QNAP and STORCENTER is 0x4500, not 0x4600.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/netboot/brdsetup.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.16 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.17
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.16	Tue May 18 10:41:30 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Tue May 18 14:32:38 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.16 2010/05/18 10:41:30 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.17 2010/05/18 14:32:38 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -168,19 +168,20 @@
 		consname = eumb;
 		consport = 0x4500;
 		consspeed = 115200;
+		extclk = 33164526;
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
 	0x8086) {/* PCI_VENDOR_INTEL */
 		brdtype = BRD_QNAPTS101;
 		consname = eumb;
-		consport = 0x4600;
+		consport = 0x4500;
 		consspeed = 115200;
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
 	0x10ec) {/* PCI_VENDOR_REALTEK */
 		brdtype = BRD_STORCENTER;
 		consname = eumb;
-		consport = 0x4600;
+		consport = 0x4500;
 		consspeed = 115200;
 	}
 



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-17 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon May 17 17:48:59 UTC 2010

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

Log Message:
Set correct extclk for KuroBox, which is not 33MHz.
Patch submitted by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sandpoint/stand/netboot/brdsetup.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.14 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.15
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.14	Sun May 16 11:27:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Mon May 17 17:48:59 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.14 2010/05/16 11:27:49 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.15 2010/05/17 17:48:59 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -151,6 +151,11 @@
 		consname = eumb;
 		consport = 0x4600;
 		consspeed = 57600;
+		if (PCI_VENDOR(pcicfgread(pcimaketag(0, 11, 0), PCI_ID_REG))
+		== 0x10ec)
+			extclk = 32768000;  /* decr 2457600Hz */
+		else
+			extclk = 32521333;  /* decr 2439100Hz */
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
 	0x11ab) {/* PCI_VENDOR_MARVELL */



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-17 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon May 17 17:50:08 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: Makefile globals.h

Log Message:
CPPFLAGS cleanup, submited by Toru Nishimura.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/netboot/Makefile
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/netboot/globals.h

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/Makefile
diff -u src/sys/arch/sandpoint/stand/netboot/Makefile:1.16 src/sys/arch/sandpoint/stand/netboot/Makefile:1.17
--- src/sys/arch/sandpoint/stand/netboot/Makefile:1.16	Sun May  2 13:31:14 2010
+++ src/sys/arch/sandpoint/stand/netboot/Makefile	Mon May 17 17:50:08 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.16 2010/05/02 13:31:14 phx Exp $
+#	$NetBSD: Makefile,v 1.17 2010/05/17 17:50:08 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -9,9 +9,8 @@
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
-CPPFLAGS+=	-DCONSNAME=\com\ -DCONSPORT=0x3f8 -DCONSSPEED=115200
+#CPPFLAGS+=	-DCONSNAME=\com\ -DCONSPORT=0x3f8 -DCONSSPEED=115200
 #CPPFLAGS+=	-DCONSNAME=\eumb\ -DCONSPORT=0x4600 -DCONSSPEED=57600
-#CPPFLAGS+=	-DTICKS_PER_SEC=(1/4)
 #CPPFLAGS+=	-DSTART_DDB_SESSION
 CPPFLAGS+=	-nostdinc -I. -I${.OBJDIR} -I${S}
 DBG=		-Os

Index: src/sys/arch/sandpoint/stand/netboot/globals.h
diff -u src/sys/arch/sandpoint/stand/netboot/globals.h:1.15 src/sys/arch/sandpoint/stand/netboot/globals.h:1.16
--- src/sys/arch/sandpoint/stand/netboot/globals.h:1.15	Sun May 16 11:27:49 2010
+++ src/sys/arch/sandpoint/stand/netboot/globals.h	Mon May 17 17:50:08 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.15 2010/05/16 11:27:49 phx Exp $ */
+/* $NetBSD: globals.h,v 1.16 2010/05/17 17:50:08 phx Exp $ */
 
 /* clock feed */
 #ifndef EXT_CLK_FREQ
@@ -16,6 +16,16 @@
 #define BRD_STORCENTER		103
 #define BRD_UNKNOWN		-1
 
+#ifndef CONSNAME
+#define CONSNAME com
+#endif
+#ifndef CONSPORT
+#define CONSPORT 0x3f8
+#endif
+#ifndef CONSSPEED
+#define CONSSPEED 115200
+#endif
+
 extern char *consname;
 extern int consport;
 extern int consspeed;



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-13 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu May 13 10:40:02 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: brdsetup.c dev_net.c entry.S
main.c pci.c

Log Message:
Patches by Toru Nishimura:
- set up DBATs for 8000-8fff and fc00-
- honour DHCP's filename field, use 'netbsd' when unspecified
- PCI-fixups for KuroBox
- determine PCIIDE programming mode for BAR assignment


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/netboot/brdsetup.c \
src/sys/arch/sandpoint/stand/netboot/pci.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/netboot/dev_net.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/netboot/entry.S
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sandpoint/stand/netboot/main.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.12 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.13
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.12	Wed May 12 18:33:09 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Thu May 13 10:40:02 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.12 2010/05/12 18:33:09 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.13 2010/05/13 10:40:02 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -274,7 +274,7 @@
 delay(u_int n)
 {
 	u_quad_t tb;
-	u_long tbh, tbl, scratch;
+	u_long scratch, tbh, tbl;
 
 	tb = mftb();
 	tb += (n * 1000 + ns_per_tick - 1) / ns_per_tick;
@@ -308,7 +308,7 @@
 void
 _inv(uint32_t adr, uint32_t siz)
 {
-	uint32_t off, bnd;
+	uint32_t bnd, off;
 
 	off = adr  (dcache_line_size - 1);
 	adr -= off;
@@ -342,7 +342,7 @@
 unsigned
 mpc107memsize()
 {
-	unsigned tag, val, n, bankn, end;
+	unsigned bankn, end, n, tag, val;
 
 	tag = pcimaketag(0, 0, 0);
 
@@ -411,7 +411,7 @@
 void
 setup_82C686B()
 {
-	unsigned pcib, ide, usb12, usb34, ac97, pmgt, val;
+	unsigned ac97, ide, pcib, pmgt, usb12, usb34, val;
 
 	pcib  = pcimaketag(0, 22, 0);
 	ide   = pcimaketag(0, 22, 1);
@@ -468,7 +468,7 @@
 setup_83C553F()
 {
 #if 0
-	unsigned pcib, ide, val;
+	unsigned ide, pcib, val;
 
 	pcib = pcimaketag(0, 11, 0);
 	ide  = pcimaketag(0, 11, 1);
@@ -478,7 +478,7 @@
 void
 pcifixup(void)
 {
-	unsigned pcib, ide, nic, val, steer, irq;
+	unsigned ide, irq, nic, pcib, steer, usb, val;
 	int line;
 
 	switch (brdtype) {
@@ -678,5 +678,32 @@
 		val |= (('A' - '@')  8) | 25;
 		pcicfgwrite(nic, 0x3c, val);
 		break;
+
+	case BRD_KUROBOX:
+		nic  = pcimaketag(0, 11, 0);
+		val = pcicfgread(nic, 0x3c)  0x;
+		val |= (('A' - '@')  8) | 11;
+		pcicfgwrite(nic, 0x3c, val);
+
+		ide  = pcimaketag(0, 12, 0);
+		val = pcicfgread(ide, 0x3c)  0x;
+		val |= (('A' - '@')  8) | 12;
+		pcicfgwrite(ide, 0x3c, val);
+
+		usb  = pcimaketag(0, 14, 0);
+		val = pcicfgread(usb, 0x3c)  0x;
+		val |= (('A' - '@')  8) | 14;
+		pcicfgwrite(usb, 0x3c, val);
+
+		usb  = pcimaketag(0, 14, 1);
+		val = pcicfgread(usb, 0x3c)  0x;
+		val |= (('B' - '@')  8) | 14;
+		pcicfgwrite(usb, 0x3c, val);
+
+		usb  = pcimaketag(0, 14, 2);
+		val = pcicfgread(usb, 0x3c)  0x;
+		val |= (('C' - '@')  8) | 14;
+		pcicfgwrite(usb, 0x3c, val);
+		break;
 	}
 }
Index: src/sys/arch/sandpoint/stand/netboot/pci.c
diff -u src/sys/arch/sandpoint/stand/netboot/pci.c:1.12 src/sys/arch/sandpoint/stand/netboot/pci.c:1.13
--- src/sys/arch/sandpoint/stand/netboot/pci.c:1.12	Fri Jun 12 00:24:33 2009
+++ src/sys/arch/sandpoint/stand/netboot/pci.c	Thu May 13 10:40:02 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.c,v 1.12 2009/06/12 00:24:33 nisimura Exp $ */
+/* $NetBSD: pci.c,v 1.13 2010/05/13 10:40:02 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -219,12 +219,11 @@
 	val = 0x80  8 | 0x08 /* 32B cache line */;
 	cfgwrite(bus, dev, func, 0x0c, val);
 
-#if 1
-/* skip IDE controller BAR assignment */
-val = cfgread(bus, dev, func, PCI_CLASS_REG);
-if ((val  16) == PCI_CLASS_IDE)
-	return 0;
-#endif
+	/* skip legacy mode IDE controller BAR assignment */
+	val = cfgread(bus, dev, func, PCI_CLASS_REG);
+	if ((val  16) == PCI_CLASS_IDE  ((val  8)  0x05) == 0)
+		return 0;
+
 	memassign(bus, dev, func);
 
 	/* descending toward PCI-PCI bridge */

Index: src/sys/arch/sandpoint/stand/netboot/dev_net.c
diff -u src/sys/arch/sandpoint/stand/netboot/dev_net.c:1.7 src/sys/arch/sandpoint/stand/netboot/dev_net.c:1.8
--- src/sys/arch/sandpoint/stand/netboot/dev_net.c:1.7	Mon Jan 12 09:41:59 2009
+++ src/sys/arch/sandpoint/stand/netboot/dev_net.c	Thu May 13 10:40:02 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: dev_net.c,v 1.7 2009/01/12 09:41:59 tsutsui Exp $ */
+/* $NetBSD: dev_net.c,v 1.8 2010/05/13 10:40:02 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -66,8 +66,8 @@
 			goto bad;
 		}
 
-		/* XXX always to use netbsd kernel filename */
-		

CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed May 12 18:33:09 UTC 2010

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

Log Message:
Typo: DHB should be DMB (most significant bye, not high byte).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/netboot/brdsetup.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.11 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.12
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.11	Sat May  8 19:41:07 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Wed May 12 18:33:09 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.11 2010/05/08 19:41:07 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.12 2010/05/12 18:33:09 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
 unsigned uart2base;	/* optional satellite processor */
 #define THR		0
 #define DLB		0
-#define DHB		1
+#define DMB		1
 #define IER		1
 #define FCR		2
 #define LCR		3
@@ -88,7 +88,7 @@
 	div = busclock / speed / 16;
 	UART_WRITE(base, LCR, 0x80);		/* turn on DLAB bit */
 	UART_WRITE(base, FCR, 0x00);
-	UART_WRITE(base, DHB, div  8);	/* set speed */
+	UART_WRITE(base, DMB, div  8);	/* set speed */
 	UART_WRITE(base, DLB, div  0xff);
 	UART_WRITE(base, LCR, lcr);
 	UART_WRITE(base, FCR, 0x07);		/* FIFO on, TXRX FIFO reset */



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat May  8 14:40:08 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: brdsetup.c globals.h main.c

Log Message:
Calculate busclock and cpuclock for 8245-based boards from PLL_CFG and HID1.
Print the clocks after netboot's welcome-message.
Make sure DUART-mode is enabled for eumb-systems.
Support for communication with the satellite processor via the 2nd UART.
Currently only KuroBox and Synology make use of it. Synology also resets the
board via its satellite.
Fixed console speed for KuroBox and QNAP (it is 115200).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/netboot/brdsetup.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/netboot/globals.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sandpoint/stand/netboot/main.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.9 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.10
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.9	Sun May  2 13:31:14 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Sat May  8 14:40:08 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.9 2010/05/02 13:31:14 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.10 2010/05/08 14:40:08 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,6 +31,8 @@
 
 #include sys/param.h
 
+#include powerpc/oea/spr.h
+
 #include lib/libsa/stand.h
 #include lib/libsa/net.h
 #include lib/libkern/libkern.h
@@ -40,30 +42,89 @@
 const unsigned dcache_line_size = 32;		/* 32B linesize */
 const unsigned dcache_range_size = 4 * 1024;	/* 16KB / 4-way */
 
+static uint32_t ns_per_tick;
+
 void brdsetup(void);
 void setup_82C686B(void);
 void setup_83C553F(void);
 
 static inline u_quad_t mftb(void);
 
-unsigned uartbase;
+unsigned uart1base;	/* console */
+unsigned uart2base;	/* optional satellite processor */
 #define THR		0
 #define DLB		0
-#define DMB		1
+#define DHB		1
 #define IER		1
 #define FCR		2
 #define LCR		3
+#define  LCR_DLAB	0x80
+#define  LCR_PEVEN	0x18
+#define  LCR_PNONE	0x00
+#define  LCR_8BITS	0x03
 #define MCR		4
+#define  MCR_RTS	0x02
+#define  MCR_DTR	0x01
 #define LSR		5
-#define DCR		11
-#define LSR_THRE	0x20
-#define UART_READ(r)		*(volatile char *)(uartbase + (r))
-#define UART_WRITE(r, v)	*(volatile char *)(uartbase + (r)) = (v)
+#define  LSR_THRE	0x20
+#define DCR		0x11
+#define UART_READ(base, r)	*(volatile char *)(base + (r))
+#define UART_WRITE(base, r, v)	*(volatile char *)(base + (r)) = (v)
+
+static __inline uint32_t
+cputype(void)
+{
+	uint32_t pvr;
+
+	__asm volatile (mfpvr %0 : =r(pvr));
+	return pvr  16;
+}
+
+static void
+init_uart(unsigned base, unsigned speed, uint8_t lcr)
+{
+	unsigned div;
+
+	div = busclock / speed / 16;
+	UART_WRITE(base, LCR, 0x80);		/* turn on DLAB bit */
+	UART_WRITE(base, FCR, 0x00);
+	UART_WRITE(base, DHB, div  8);	/* set speed */
+	UART_WRITE(base, DLB, div  0xff);
+	UART_WRITE(base, LCR, lcr);
+	UART_WRITE(base, FCR, 0x07);		/* FIFO on, TXRX FIFO reset */
+	UART_WRITE(base, IER, 0x00);		/* make sure INT disabled */
+}
+
+/* talk to satellite processor */
+static void
+send_sat(char *msg)
+{
+	unsigned savedbase;
+
+	savedbase = uart1base;
+	uart1base = uart2base;
+	while (*msg)
+		putchar(*msg++);
+	uart1base = savedbase;
+}
 
 void
 brdsetup(void)
 {
-	unsigned pchb, pcib, div;
+	static uint8_t pci_to_memclk[] = {
+		30, 30, 10, 10, 20, 10, 10, 10,
+		10, 20, 20, 15, 20, 15, 20, 30,
+		30, 40, 15, 40, 20, 25, 20, 40,
+		25, 20, 10, 20, 15, 15, 20, 00
+	};
+	static uint8_t mem_to_cpuclk[] = {
+		25, 30, 45, 20, 20, 00, 10, 30,
+		30, 20, 45, 30, 25, 35, 30, 35,
+		20, 25, 20, 30, 35, 40, 40, 20,
+		30, 25, 40, 30, 30, 25, 35, 00
+	};
+	uint32_t extclk;
+	unsigned pchb, pcib, val;
 
 	/* BAT to arrange address space */
 
@@ -72,6 +133,9 @@
 	pcicfgwrite(pchb, 0x78, 0xfc00);
 
 	brdtype = BRD_UNKNOWN;
+	extclk = EXT_CLK_FREQ;	/* usually 33MHz */
+	busclock = 0;
+
 	if (pcifinddev(0x10ad, 0x0565, pcib) == 0) {
 		brdtype = BRD_SANDPOINTX3;
 		setup_83C553F();
@@ -86,31 +150,7 @@
 		brdtype = BRD_KUROBOX;
 		consname = eumb;
 		consport = 0x4600;
-		consspeed = 57600;
-		if (pcifinddev(0x10ec, 0x8169, pcib) == 0) /* KURO-BOX/HG */
-			ticks_per_sec = 13300 / 4;
-
-		/* Stop Watchdog */
-		uartbase = 0xfc00 + 0x4500;
-		div = (ticks_per_sec * 4) / 9600 / 16;
-		UART_WRITE(DCR, 0x01);	/* 2 independent UART */
-		UART_WRITE(LCR, 0x80);	/* turn on DLAB bit */
-		UART_WRITE(FCR, 0x00);
-		UART_WRITE(DMB, div  8);
-		UART_WRITE(DLB, div  0xff);
-		UART_WRITE(LCR, 0x03 | 0x18);	/* 8 E 1 */
-		UART_WRITE(MCR, 0x03);		/* RTS DTR */
-		UART_WRITE(FCR, 0x07);		/* FIFO_EN | RXSR | TXSR */
-		UART_WRITE(IER, 0x00);		/* make sure INT disabled */
-		printf();
-	}
-	else if 

CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat May  8 15:26:54 UTC 2010

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

Log Message:
Print Kuro Box when detected. Print Unknown board when the hardware was
not identified.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sandpoint/stand/netboot/main.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/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.25 src/sys/arch/sandpoint/stand/netboot/main.c:1.26
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.25	Sat May  8 14:40:08 2010
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Sat May  8 15:26:54 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.25 2010/05/08 14:40:08 phx Exp $ */
+/* $NetBSD: main.c,v 1.26 2010/05/08 15:26:54 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -87,8 +87,12 @@
 		printf(Encore PP1); break;
 	case BRD_QNAPTS101:
 		printf(QNAP TS-101); break;
+	case BRD_KUROBOX:
+		printf(Kuro Box); break;
 	case BRD_SYNOLOGY:
 		printf(Synology DS); break;
+	default:
+		printf(Unknown board); break;
 	}
 	printf(, cpu %u MHz, bus %u MHz, %dMB SDRAM\n,
 	cpuclock / 100, busclock / 100, memsize  20);



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat May  8 19:41:07 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: brdsetup.c globals.h main.c

Log Message:
Support for IOMEGA Storcenter, by Toru Nishimura.
Kurobox console is 57600.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/stand/netboot/brdsetup.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/stand/netboot/globals.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sandpoint/stand/netboot/main.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.10 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.11
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.10	Sat May  8 14:40:08 2010
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Sat May  8 19:41:07 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.10 2010/05/08 14:40:08 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.11 2010/05/08 19:41:07 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -150,7 +150,7 @@
 		brdtype = BRD_KUROBOX;
 		consname = eumb;
 		consport = 0x4600;
-		consspeed = 115200;
+		consspeed = 57600;
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
 	0x11ab) {/* PCI_VENDOR_MARVELL */
@@ -166,6 +166,13 @@
 		consport = 0x4600;
 		consspeed = 115200;
 	}
+	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
+	0x10ec) {/* PCI_VENDOR_REALTEK */
+		brdtype = BRD_STORCENTER;
+		consname = eumb;
+		consport = 0x4600;
+		consspeed = 115200;
+	}
 
 	/* determine clock frequencies */
 	if (busclock == 0) {
@@ -205,6 +212,7 @@
 		send_sat(247);
 		break;
 	case BRD_QNAPTS101:
+	case BRD_STORCENTER:
 		init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
 		break;
 	}

Index: src/sys/arch/sandpoint/stand/netboot/globals.h
diff -u src/sys/arch/sandpoint/stand/netboot/globals.h:1.13 src/sys/arch/sandpoint/stand/netboot/globals.h:1.14
--- src/sys/arch/sandpoint/stand/netboot/globals.h:1.13	Sat May  8 14:40:08 2010
+++ src/sys/arch/sandpoint/stand/netboot/globals.h	Sat May  8 19:41:07 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.13 2010/05/08 14:40:08 phx Exp $ */
+/* $NetBSD: globals.h,v 1.14 2010/05/08 19:41:07 phx Exp $ */
 
 /* clock feed */
 #ifndef EXT_CLK_FREQ
@@ -13,6 +13,7 @@
 #define BRD_KUROBOX		100
 #define BRD_QNAPTS101		101
 #define BRD_SYNOLOGY		102
+#define BRD_STORCENTER		103
 #define BRD_UNKNOWN		-1
 
 extern char *consname;

Index: src/sys/arch/sandpoint/stand/netboot/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.26 src/sys/arch/sandpoint/stand/netboot/main.c:1.27
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.26	Sat May  8 15:26:54 2010
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Sat May  8 19:41:07 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.26 2010/05/08 15:26:54 phx Exp $ */
+/* $NetBSD: main.c,v 1.27 2010/05/08 19:41:07 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -91,6 +91,8 @@
 		printf(Kuro Box); break;
 	case BRD_SYNOLOGY:
 		printf(Synology DS); break;
+	case BRD_STORCENTER:
+		printf(IOMEGA StorCenter); break;
 	default:
 		printf(Unknown board); break;
 	}



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-03 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon May  3 18:55:09 UTC 2010

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

Log Message:
Fixed descriptor size (noticed by nisimura).
Using two TX descriptors. Might be better, although libsa seems to work with
one.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/netboot/skg.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/skg.c
diff -u src/sys/arch/sandpoint/stand/netboot/skg.c:1.1 src/sys/arch/sandpoint/stand/netboot/skg.c:1.2
--- src/sys/arch/sandpoint/stand/netboot/skg.c:1.1	Sun May  2 13:31:14 2010
+++ src/sys/arch/sandpoint/stand/netboot/skg.c	Mon May  3 18:55:09 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: skg.c,v 1.1 2010/05/02 13:31:14 phx Exp $ */
+/* $NetBSD: skg.c,v 1.2 2010/05/03 18:55:09 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 Frank Wille.
@@ -58,7 +58,7 @@
 
 struct desc {
 	uint32_t xd0, xd1, xd2, xd3, xd4;
-	uint32_t rsrvd[5];
+	uint32_t rsrvd[3];
 };
 #define CTL_LS			0x2000
 #define CTL_FS			0x4000
@@ -174,10 +174,10 @@
 #define FRAMESIZE	1536
 
 struct local {
-	struct desc txd;
+	struct desc txd[2];
 	struct desc rxd[2];
 	uint8_t rxstore[2][FRAMESIZE];
-	unsigned csr, rx, phy;
+	unsigned csr, rx, tx, phy;
 	uint16_t pssr, anlpar;
 };
 
@@ -208,7 +208,7 @@
 	unsigned i;
 	uint16_t reg;
 
-	l = ALLOC(struct local, 64);	/* desc alignment */
+	l = ALLOC(struct local, 32);	/* desc alignment */
 	memset(l, 0, sizeof(struct local));
 	l-csr = DEVTOV(pcicfgread(tag, 0x10)); /* use mem space */
 
@@ -288,14 +288,15 @@
 	/* setup descriptors and BMU */
 	CSR_WRITE_1(l, SK_TXAR1_COUNTERCTL, TXARCTL_ON|TXARCTL_FSYNC_ON);
 
-	txd = l-txd;
-	txd-xd1 = htole32(VTOPHYS(txd));
+	txd = l-txd[0];
+	txd[0].xd1 = htole32(VTOPHYS(txd[1]));
+	txd[1].xd1 = htole32(VTOPHYS(txd[0]));
 	rxd = l-rxd[0];
 	rxd[0].xd0 = htole32(FRAMESIZE|CTL_DEFOPC|CTL_LS|CTL_FS|CTL_OWN);
-	rxd[0].xd1 = htole32(rxd[1]);
+	rxd[0].xd1 = htole32(VTOPHYS(rxd[1]));
 	rxd[0].xd2 = htole32(VTOPHYS(l-rxstore[0]));
 	rxd[1].xd0 = htole32(FRAMESIZE|CTL_DEFOPC|CTL_LS|CTL_FS|CTL_OWN);
-	rxd[1].xd1 = htole32(rxd[0]);
+	rxd[1].xd1 = htole32(VTOPHYS(rxd[0]));
 	rxd[1].xd2 = htole32(VTOPHYS(l-rxstore[1]));
 	wbinv(l, sizeof(struct local));
 
@@ -332,7 +333,7 @@
 	unsigned loop;
 
 	wbinv(buf, len);
-	txd = l-txd;
+	txd = l-txd[l-tx];
 	txd-xd2 = htole32(VTOPHYS(buf));
 	txd-xd0 = htole32((len  FRAMEMASK)|CTL_DEFOPC|CTL_FS|CTL_LS|CTL_OWN);
 	wbinv(txd, sizeof(struct desc));
@@ -347,6 +348,7 @@
 	printf(xmit failed\n);
 	return -1;
   done:
+	l-tx ^= 1;
 	return len;
 }
 



CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-02 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun May  2 13:31:14 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: Makefile brdsetup.c globals.h
main.c nif.c
Added Files:
src/sys/arch/sandpoint/stand/netboot: skg.c

Log Message:
Add support for Qnap TS101 (untested) and Synology-DS boards.
Detect Synology SATAlink device (although still unused).
New skg driver for Marvell SKnet Yukon-lite based GbE, used on most DS boards.
As there is no documentation available, it was based on if_sk.c, with lots
of testing. Known problem: The MAC address on my DS-101g+ is always read
as 00:11:22:33:44:54, but sk(4) unfortunately has the same problem.
New allocaligned() function to replace non-working ALLOC() macros.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/netboot/Makefile
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/netboot/brdsetup.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/netboot/globals.h \
src/sys/arch/sandpoint/stand/netboot/nif.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/stand/netboot/main.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sandpoint/stand/netboot/skg.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/Makefile
diff -u src/sys/arch/sandpoint/stand/netboot/Makefile:1.15 src/sys/arch/sandpoint/stand/netboot/Makefile:1.16
--- src/sys/arch/sandpoint/stand/netboot/Makefile:1.15	Mon Jul 20 11:43:08 2009
+++ src/sys/arch/sandpoint/stand/netboot/Makefile	Sun May  2 13:31:14 2010
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.15 2009/07/20 11:43:08 nisimura Exp $
+#	$NetBSD: Makefile,v 1.16 2010/05/02 13:31:14 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
 PROG=		netboot
 SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c \
-		fxp.c tlp.c rge.c printf.c
+		fxp.c tlp.c rge.c skg.c printf.c
 CLEANFILES+=	vers.c vers.o ${PROG} ${PROG}.bin
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith

Index: src/sys/arch/sandpoint/stand/netboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.8 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.9
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.8	Fri Jul  3 10:31:19 2009
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Sun May  2 13:31:14 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.8 2009/07/03 10:31:19 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.9 2010/05/02 13:31:14 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -104,23 +104,29 @@
 		UART_WRITE(IER, 0x00);		/* make sure INT disabled */
 		printf();
 	}
+	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
+	0x8086) {/* PCI_VENDOR_INTEL */
+		brdtype = BRD_QNAPTS101;
+		consname = eumb;
+		consport = 0x4600;
+		consspeed = 57600;		/* XXX unverified */
+		ticks_per_sec = 13300 / 4;	/* TS-101 is 266MHz */
+	}
+	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
+	0x11ab) {/* PCI_VENDOR_MARVELL */
+		brdtype = BRD_SYNOLOGY;
+		consname = eumb;
+		consport = 0x4500;
+		consspeed = 115200;
+		/* XXX assume 133MHz bus clock, valid for 266MHz models */
+		ticks_per_sec = 13300 / 4;
+	}
 
 	/* now prepare serial console */
 	if (strcmp(consname, eumb) != 0)
 		uartbase = 0xfe00 + consport; /* 0x3f8, 0x2f8 */
-	else {
+	else
 		uartbase = 0xfc00 + consport; /* 0x4500, 0x4600 */
-		div = (ticks_per_sec * 4) / consspeed / 16;
-		UART_WRITE(DCR, 0x01);	/* 2 independent UART */
-		UART_WRITE(LCR, 0x80);	/* turn on DLAB bit */
-		UART_WRITE(FCR, 0x00);
-		UART_WRITE(DMB, div  8);
-		UART_WRITE(DLB, div  0xff); /* 0x36 when 115200...@100mhz */
-		UART_WRITE(LCR, 0x03);	/* 8 N 1 */
-		UART_WRITE(MCR, 0x03);	/* RTS DTR */
-		UART_WRITE(FCR, 0x07);	/* FIFO_EN | RXSR | TXSR */
-		UART_WRITE(IER, 0x00);	/* make sure INT disabled */
-	}
 }
 
 void

Index: src/sys/arch/sandpoint/stand/netboot/globals.h
diff -u src/sys/arch/sandpoint/stand/netboot/globals.h:1.11 src/sys/arch/sandpoint/stand/netboot/globals.h:1.12
--- src/sys/arch/sandpoint/stand/netboot/globals.h:1.11	Mon Jul 20 11:43:09 2009
+++ src/sys/arch/sandpoint/stand/netboot/globals.h	Sun May  2 13:31:14 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.11 2009/07/20 11:43:09 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.12 2010/05/02 13:31:14 phx Exp $ */
 
 /* clock feed */
 #ifndef TICKS_PER_SEC
@@ -12,6 +12,8 @@
 #define BRD_SANDPOINTX3		3
 #define BRD_ENCOREPP1		10
 #define BRD_KUROBOX		100
+#define BRD_QNAPTS101		101
+#define BRD_SYNOLOGY		102
 #define BRD_UNKNOWN		-1
 
 extern char *consname;
@@ -62,6 +64,7 @@
 #define  PCI_CLASS_IDE			0x0101
 #define  PCI_CLASS_RAID			0x0104
 #define  PCI_CLASS_SATA			0x0106
+#define  PCI_CLASS_MISCSTORAGE		0x0180
 #define PCI_BHLC_REG			0x0c
 #define  

CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-02 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun May  2 13:36:31 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: fxp.c kse.c nvt.c pcn.c rge.c
sip.c sme.c tlp.c vge.c wm.c

Log Message:
Fixed ALLOC() macro to allocate properly aligned memory.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/stand/netboot/fxp.c \
src/sys/arch/sandpoint/stand/netboot/wm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/netboot/kse.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/netboot/nvt.c \
src/sys/arch/sandpoint/stand/netboot/vge.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/netboot/pcn.c \
src/sys/arch/sandpoint/stand/netboot/rge.c \
src/sys/arch/sandpoint/stand/netboot/sip.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/netboot/sme.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sandpoint/stand/netboot/tlp.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/fxp.c
diff -u src/sys/arch/sandpoint/stand/netboot/fxp.c:1.10 src/sys/arch/sandpoint/stand/netboot/fxp.c:1.11
--- src/sys/arch/sandpoint/stand/netboot/fxp.c:1.10	Mon Jan 12 09:41:59 2009
+++ src/sys/arch/sandpoint/stand/netboot/fxp.c	Sun May  2 13:36:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fxp.c,v 1.10 2009/01/12 09:41:59 tsutsui Exp $ */
+/* $NetBSD: fxp.c,v 1.11 2010/05/02 13:36:30 phx Exp $ */
 
 /*
  * most of the following code was imported from dev/ic/i82557.c; the
@@ -97,7 +97,7 @@
 #define wbinv(adr, siz)		_wbinv(VTOPHYS(adr), (uint32_t)(siz))
 #define inv(adr, siz)		_inv(VTOPHYS(adr), (uint32_t)(siz))
 #define DELAY(n)		delay(n)
-#define ALLOC(T,A)	(T *)((unsigned)alloc(sizeof(T) + (A)) ~ ((A) - 1))
+#define ALLOC(T,A)		(T *)allocaligned(sizeof(T),(A))
 
 struct txdesc {
 	volatile uint16_t cb_status;
Index: src/sys/arch/sandpoint/stand/netboot/wm.c
diff -u src/sys/arch/sandpoint/stand/netboot/wm.c:1.10 src/sys/arch/sandpoint/stand/netboot/wm.c:1.11
--- src/sys/arch/sandpoint/stand/netboot/wm.c:1.10	Sun Jan 25 03:39:28 2009
+++ src/sys/arch/sandpoint/stand/netboot/wm.c	Sun May  2 13:36:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: wm.c,v 1.10 2009/01/25 03:39:28 nisimura Exp $ */
+/* $NetBSD: wm.c,v 1.11 2010/05/02 13:36:31 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
 #define wbinv(adr, siz)		_wbinv(VTOPHYS(adr), (uint32_t)(siz))
 #define inv(adr, siz)		_inv(VTOPHYS(adr), (uint32_t)(siz))
 #define DELAY(n)		delay(n)
-#define ALLOC(T,A)	(T *)((unsigned)alloc(sizeof(T) + (A)) ~ ((A) - 1))
+#define ALLOC(T,A)		(T *)allocaligned(sizeof(T),(A))
 
 struct tdesc {
 	uint32_t lo;	/* 31:0 */

Index: src/sys/arch/sandpoint/stand/netboot/kse.c
diff -u src/sys/arch/sandpoint/stand/netboot/kse.c:1.3 src/sys/arch/sandpoint/stand/netboot/kse.c:1.4
--- src/sys/arch/sandpoint/stand/netboot/kse.c:1.3	Sun Jan 25 03:39:28 2009
+++ src/sys/arch/sandpoint/stand/netboot/kse.c	Sun May  2 13:36:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: kse.c,v 1.3 2009/01/25 03:39:28 nisimura Exp $ */
+/* $NetBSD: kse.c,v 1.4 2010/05/02 13:36:30 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
 #define wbinv(adr, siz)		_wbinv(VTOPHYS(adr), (uint32_t)(siz))
 #define inv(adr, siz)		_inv(VTOPHYS(adr), (uint32_t)(siz))
 #define DELAY(n)		delay(n)
-#define ALLOC(T,A)	(T *)((unsigned)alloc(sizeof(T) + (A)) ~ ((A) - 1))
+#define ALLOC(T,A)		(T *)allocaligned(sizeof(T),(A))
 
 struct desc {
 	uint32_t xd0, xd1, xd2, xd3;

Index: src/sys/arch/sandpoint/stand/netboot/nvt.c
diff -u src/sys/arch/sandpoint/stand/netboot/nvt.c:1.17 src/sys/arch/sandpoint/stand/netboot/nvt.c:1.18
--- src/sys/arch/sandpoint/stand/netboot/nvt.c:1.17	Sun Jan 25 03:39:28 2009
+++ src/sys/arch/sandpoint/stand/netboot/nvt.c	Sun May  2 13:36:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: nvt.c,v 1.17 2009/01/25 03:39:28 nisimura Exp $ */
+/* $NetBSD: nvt.c,v 1.18 2010/05/02 13:36:30 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
 #define wbinv(adr, siz)		_wbinv(VTOPHYS(adr), (uint32_t)(siz))
 #define inv(adr, siz)		_inv(VTOPHYS(adr), (uint32_t)(siz))
 #define DELAY(n)		delay(n)
-#define ALLOC(T,A)	(T *)((unsigned)alloc(sizeof(T) + (A)) ~ ((A) - 1))
+#define ALLOC(T,A)		(T *)allocaligned(sizeof(T),(A))
 
 struct desc {
 	uint32_t xd0, xd1, xd2, xd3;
Index: src/sys/arch/sandpoint/stand/netboot/vge.c
diff -u src/sys/arch/sandpoint/stand/netboot/vge.c:1.17 src/sys/arch/sandpoint/stand/netboot/vge.c:1.18
--- src/sys/arch/sandpoint/stand/netboot/vge.c:1.17	Mon Jan 12 09:41:59 2009
+++ src/sys/arch/sandpoint/stand/netboot/vge.c	Sun May  2 13:36:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: vge.c,v 1.17 2009/01/12 09:41:59 tsutsui Exp $ */
+/* $NetBSD: vge.c,v 1.18 2010/05/02 13:36:31 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
 #define wbinv(adr, siz)		

CVS commit: src/sys/arch/sandpoint/stand/netboot

2010-05-02 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun May  2 14:27:07 UTC 2010

Modified Files:
src/sys/arch/sandpoint/stand/netboot: version

Log Message:
Bumped version, because of last changes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/netboot/version

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/version
diff -u src/sys/arch/sandpoint/stand/netboot/version:1.3 src/sys/arch/sandpoint/stand/netboot/version:1.4
--- src/sys/arch/sandpoint/stand/netboot/version:1.3	Tue Oct 30 00:30:14 2007
+++ src/sys/arch/sandpoint/stand/netboot/version	Sun May  2 14:27:07 2010
@@ -1,2 +1,3 @@
 1.0	initial version
 1.1	PCI autoconf for multiple NIC device drivers
+1.2	Synology-DS support, Marvell-Yukon driver, fixed aligned alloc



CVS commit: src/sys/arch/sandpoint/stand/netboot

2009-07-09 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Jul  9 15:39:28 UTC 2009

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

Log Message:
- show link speed and duplexity.
- fix an incomplete mod in mii_read().


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/stand/netboot/tlp.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/tlp.c
diff -u src/sys/arch/sandpoint/stand/netboot/tlp.c:1.23 src/sys/arch/sandpoint/stand/netboot/tlp.c:1.24
--- src/sys/arch/sandpoint/stand/netboot/tlp.c:1.23	Fri Jul  3 10:31:19 2009
+++ src/sys/arch/sandpoint/stand/netboot/tlp.c	Thu Jul  9 15:39:28 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tlp.c,v 1.23 2009/07/03 10:31:19 nisimura Exp $ */
+/* $NetBSD: tlp.c,v 1.24 2009/07/09 15:39:28 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -95,6 +95,7 @@
 #define  SROM_SR	(1U11)	/* SEEPROM select */
 #define PAR0_CSR25	0xa4		/* MAC 3:0 */
 #define PAR1_CSR26	0xa8		/* MAC 5:4 */
+#define AN_OMODE	0xfc		/* operation mode */
 
 #define FRAMESIZE	1536
 
@@ -127,9 +128,9 @@
 void *
 tlp_init(unsigned tag, void *data)
 {
-	unsigned val, i;
 	struct local *l;
 	struct desc *txd, *rxd;
+	unsigned i, val, fdx;
 	uint8_t *en;
 	
 	l = ALLOC(struct local, 2 * sizeof(struct desc)); /* desc alignment */
@@ -165,6 +166,15 @@
 	mii_initphy(l);
 	mii_dealan(l, 5);
 
+	val = CSR_READ(l, AN_OMODE);
+	if (val  (1U  29)) {
+		printf(%s, (val  (1U  31)) ? 100Mbps : 10Mbps);
+		fdx = !!(val  (1U  30));
+		if (fdx)
+			printf(-FDX);
+		printf(\n);
+	}
+
 	txd = l-txd[0];
 	txd[1].xd1 = htole32(T1_TER);
 	rxd = l-rxd[0];
@@ -302,7 +312,7 @@
 	for (i = 0; i  18; i++) {
 		CSR_WRITE(l, SPR_CSR9, MII_MIDIR);
 		DELAY(1);
-		rv = (data  1) | !!(CSR_READ(l, SPR_CSR9)  MII_MDI);
+		rv = (rv  1) | !!(CSR_READ(l, SPR_CSR9)  MII_MDI);
 		CSR_WRITE(l, SPR_CSR9, MII_MIDIR | MII_MDC);
 		DELAY(1);
 	}



CVS commit: src/sys/arch/sandpoint/stand/netboot

2009-07-03 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Jul  3 10:31:19 UTC 2009

Modified Files:
src/sys/arch/sandpoint/stand/netboot: brdsetup.c globals.h main.c tlp.c

Log Message:
- adapt KURBOX/HG arrangements, requested and tested by kiyohara.
- make tlp.c suited for ADMTek/Infineon AN983B/BX.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/netboot/brdsetup.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/netboot/globals.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sandpoint/stand/netboot/main.c \
src/sys/arch/sandpoint/stand/netboot/tlp.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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.7 src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.8
--- src/sys/arch/sandpoint/stand/netboot/brdsetup.c:1.7	Fri Jun 12 00:24:33 2009
+++ src/sys/arch/sandpoint/stand/netboot/brdsetup.c	Fri Jul  3 10:31:19 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.7 2009/06/12 00:24:33 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.8 2009/07/03 10:31:19 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -87,6 +87,22 @@
 		consname = eumb;
 		consport = 0x4600;
 		consspeed = 57600;
+		if (pcifinddev(0x10ec, 0x8169, pcib) == 0) /* KURO-BOX/HG */
+			ticks_per_sec = 13300 / 4;
+
+		/* Stop Watchdog */
+		uartbase = 0xfc00 + 0x4500;
+		div = (ticks_per_sec * 4) / 9600 / 16;
+		UART_WRITE(DCR, 0x01);	/* 2 independent UART */
+		UART_WRITE(LCR, 0x80);	/* turn on DLAB bit */
+		UART_WRITE(FCR, 0x00);
+		UART_WRITE(DMB, div  8);
+		UART_WRITE(DLB, div  0xff);
+		UART_WRITE(LCR, 0x03 | 0x18);	/* 8 E 1 */
+		UART_WRITE(MCR, 0x03);		/* RTS DTR */
+		UART_WRITE(FCR, 0x07);		/* FIFO_EN | RXSR | TXSR */
+		UART_WRITE(IER, 0x00);		/* make sure INT disabled */
+		printf();
 	}
 
 	/* now prepare serial console */
@@ -94,7 +110,7 @@
 		uartbase = 0xfe00 + consport; /* 0x3f8, 0x2f8 */
 	else {
 		uartbase = 0xfc00 + consport; /* 0x4500, 0x4600 */
-		div = (TICKS_PER_SEC * 4) / consspeed / 16;
+		div = (ticks_per_sec * 4) / consspeed / 16;
 		UART_WRITE(DCR, 0x01);	/* 2 independent UART */
 		UART_WRITE(LCR, 0x80);	/* turn on DLAB bit */
 		UART_WRITE(FCR, 0x00);

Index: src/sys/arch/sandpoint/stand/netboot/globals.h
diff -u src/sys/arch/sandpoint/stand/netboot/globals.h:1.9 src/sys/arch/sandpoint/stand/netboot/globals.h:1.10
--- src/sys/arch/sandpoint/stand/netboot/globals.h:1.9	Fri Jun 12 00:24:33 2009
+++ src/sys/arch/sandpoint/stand/netboot/globals.h	Fri Jul  3 10:31:19 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.9 2009/06/12 00:24:33 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.10 2009/07/03 10:31:19 nisimura Exp $ */
 
 /* clock feed */
 #ifndef TICKS_PER_SEC
@@ -17,6 +17,7 @@
 extern char *consname;
 extern int consport;
 extern int consspeed;
+extern int ticks_per_sec;
 
 unsigned mpc107memsize(void);
 

Index: src/sys/arch/sandpoint/stand/netboot/main.c
diff -u src/sys/arch/sandpoint/stand/netboot/main.c:1.22 src/sys/arch/sandpoint/stand/netboot/main.c:1.23
--- src/sys/arch/sandpoint/stand/netboot/main.c:1.22	Fri Jun 12 00:24:33 2009
+++ src/sys/arch/sandpoint/stand/netboot/main.c	Fri Jul  3 10:31:19 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.22 2009/06/12 00:24:33 nisimura Exp $ */
+/* $NetBSD: main.c,v 1.23 2009/07/03 10:31:19 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@
 char *consname = CONSNAME;
 int consport = CONSPORT;
 int consspeed = CONSSPEED;
+int ticks_per_sec = TICKS_PER_SEC;
 
 void
 main(void)
@@ -135,7 +136,7 @@
 	snprintf(bi_cons.devname, sizeof(bi_cons.devname), consname);
 	bi_cons.addr = consport;
 	bi_cons.speed = consspeed;
-	bi_clk.ticks_per_sec = TICKS_PER_SEC;
+	bi_clk.ticks_per_sec = ticks_per_sec;
 	snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), bootfile);
 	snprintf(bi_rdev.devname, sizeof(bi_rdev.devname), rootdev);
 	bi_rdev.cookie = tag; /* PCI tag for fxp netboot case */
Index: src/sys/arch/sandpoint/stand/netboot/tlp.c
diff -u src/sys/arch/sandpoint/stand/netboot/tlp.c:1.22 src/sys/arch/sandpoint/stand/netboot/tlp.c:1.23
--- src/sys/arch/sandpoint/stand/netboot/tlp.c:1.22	Sun Jan 25 03:39:28 2009
+++ src/sys/arch/sandpoint/stand/netboot/tlp.c	Fri Jul  3 10:31:19 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tlp.c,v 1.22 2009/01/25 03:39:28 nisimura Exp $ */
+/* $NetBSD: tlp.c,v 1.23 2009/07/03 10:31:19 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -41,13 +41,13 @@
 
 /*
  * - reverse endian access for CSR register.
- * - no vtophys() translation, vaddr_t == paddr_t. 
+ * - no vtophys() translation, vaddr_t == paddr_t.
  * - PIPT writeback cache aware.
  */
 #define CSR_READ(l, r)		in32rb((l)-csr+(r))
-#define CSR_WRITE(l, r, v) 	out32rb((l)-csr+(r), (v))
-#define VTOPHYS(va) 		(uint32_t)(va)