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

2021-03-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar 25 03:44:25 UTC 2021

Modified Files:
src/sys/arch/sandpoint/stand/altboot: rge.c

Log Message:
Fix tftp boot with RTL8169/8110.

When sending frame shorter than 60 octets, we add trailing \0's to
payload to construct 60-octet frame.

rge.c rev 1.4--1.7 did this tail-padding on buffer provided by caller,
which results in memory corruption if buffer is shorter than 60 bytes.

Instead, allocate temporary buffer on stack, and work on it.

This bug affects tftp_getnextblock() compiled by GCC8 and later, by
which stack layout has drastically changed. However, even with GCC7,
if tftp.c is compiled with -O0, the bug becomes tangible.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/rge.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/altboot/rge.c
diff -u src/sys/arch/sandpoint/stand/altboot/rge.c:1.7 src/sys/arch/sandpoint/stand/altboot/rge.c:1.8
--- src/sys/arch/sandpoint/stand/altboot/rge.c:1.7	Tue Dec 25 17:07:06 2012
+++ src/sys/arch/sandpoint/stand/altboot/rge.c	Thu Mar 25 03:44:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rge.c,v 1.7 2012/12/25 17:07:06 phx Exp $ */
+/* $NetBSD: rge.c,v 1.8 2021/03/25 03:44:25 rin Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -235,11 +235,15 @@ rge_send(void *dev, char *buf, unsigned 
 	struct local *l = dev;
 	volatile struct desc *txd;
 	unsigned loop, ret;
+	char tmp[60];
 
 	ret = len;
+	/* RTL does not stretch <60 Tx frame */
 	if (len < 60) {
+		memcpy(tmp, buf, len);
+		buf = tmp;
 		memset(buf + len, 0, 60 - len);
-		len = 60; /* RTL does not stretch <60 Tx frame */
+		len = 60;
 	}
 	wbinv(buf, len);
 	txd = &l->txd[l->tx];



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

2021-03-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Mar 24 02:53:16 UTC 2021

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile

Log Message:
Remove "lib" directory for cleandir.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/altboot/Makefile

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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.17 src/sys/arch/sandpoint/stand/altboot/Makefile:1.18
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.17	Sat Apr  8 19:53:22 2017
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Wed Mar 24 02:53:16 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2017/04/08 19:53:22 christos Exp $
+#	$NetBSD: Makefile,v 1.18 2021/03/24 02:53:16 rin Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -51,6 +51,11 @@ SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=		${SALIB}
 
+cleandir distclean: .WAIT cleanlibdir
+
+cleanlibdir:
+	-rm -rf lib
+
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 	${_MKTARGET_LINK}
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \



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

2021-03-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Mar 23 07:21:41 UTC 2021

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

Log Message:
Make this compile with -DDEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.32 src/sys/arch/sandpoint/stand/altboot/main.c:1.33
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.32	Tue Mar 23 07:21:15 2021
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Tue Mar 23 07:21:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.32 2021/03/23 07:21:15 rin Exp $ */
+/* $NetBSD: main.c,v 1.33 2021/03/23 07:21:40 rin Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -40,6 +40,10 @@
 
 #include "globals.h"
 
+#ifdef DEBUG
+int debug = 1;
+#endif
+
 static const struct bootarg {
 	const char *name;
 	int value;



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

2021-03-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Mar 23 07:21:16 UTC 2021

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

Log Message:
Make sure not to run kernel if fdloadfile() fails;
it returns *non-zero* value on error.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.31 src/sys/arch/sandpoint/stand/altboot/main.c:1.32
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.31	Wed Jun 26 22:04:12 2019
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Tue Mar 23 07:21:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.31 2019/06/26 22:04:12 christos Exp $ */
+/* $NetBSD: main.c,v 1.32 2021/03/23 07:21:15 rin Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -345,7 +345,7 @@ main(int argc, char *argv[], char *boota
 
 		err = fdloadfile(fd, marks, LOAD_KERNEL);
 		close(fd);
-		if (err < 0)
+		if (err != 0)
 			continue;
 
 		printf("entry=%p, ssym=%p, esym=%p\n",



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

2017-08-03 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Aug  3 19:51:00 UTC 2017

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

Log Message:
This driver should also support Schneider & Koch SK-9821 v2.0, besides
Marvell SKnet.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/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/altboot/skg.c
diff -u src/sys/arch/sandpoint/stand/altboot/skg.c:1.4 src/sys/arch/sandpoint/stand/altboot/skg.c:1.5
--- src/sys/arch/sandpoint/stand/altboot/skg.c:1.4	Sun Oct 30 21:08:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/skg.c	Thu Aug  3 19:51:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: skg.c,v 1.4 2011/10/30 21:08:33 phx Exp $ */
+/* $NetBSD: skg.c,v 1.5 2017/08/03 19:51:00 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 Frank Wille.
@@ -193,6 +193,7 @@ skg_match(unsigned tag, void *data)
 
 	v = pcicfgread(tag, PCI_ID_REG);
 	switch (v) {
+	case PCI_DEVICE(0x1148, 0x4320):
 	case PCI_DEVICE(0x11ab, 0x4320):
 		return 1;
 	}



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

2017-08-03 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Aug  3 19:22:15 UTC 2017

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c siisata.c version

Log Message:
Some Synology network devices show vendor 0x1148 (Schneider & Koch) instead
of 0x11ab (Marvell). Detect both.
Improve spinning up of both disk drives on Synology DS20x by adding some
more delays (directly at the start and after powering up the second drive).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/siisata.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.38 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.39
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.38	Thu Aug  3 09:42:34 2017
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Aug  3 19:22:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.38 2017/08/03 09:42:34 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.39 2017/08/03 19:22:15 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -269,7 +269,8 @@ brdsetup(void)
 brdtype = BRD_KUROBOXT4;
 		}
 	}
-	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x11ab) {
+	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x1148
+	|| PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x11ab) {
 		/* SKnet/Marvell (sk) at dev 15 */
 		brdtype = BRD_SYNOLOGY;
 	}
@@ -873,8 +874,11 @@ synopcifix(struct brdprop *brd)
 		 * with several seconds delay, but no CPLD register to
 		 * monitor the power state. So all we can do is to
 		 * wait some more seconds during SATA-init.
+		 * Also wait some seconds now, to make sure the first
+		 * disk is ready after a cold start.
 		 */
 		sata_delay[1] = SYNO_DISK_DELAY;
+		delay(10 * 1024 * 1024);
 	}
 
   cpld_done:

Index: src/sys/arch/sandpoint/stand/altboot/siisata.c
diff -u src/sys/arch/sandpoint/stand/altboot/siisata.c:1.6 src/sys/arch/sandpoint/stand/altboot/siisata.c:1.7
--- src/sys/arch/sandpoint/stand/altboot/siisata.c:1.6	Wed Sep 30 14:14:32 2015
+++ src/sys/arch/sandpoint/stand/altboot/siisata.c	Thu Aug  3 19:22:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.6 2015/09/30 14:14:32 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.7 2017/08/03 19:22:15 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -125,6 +125,15 @@ siisata_init(unsigned tag, void *data)
 			if (l->presense[n] == 0) {
 DPRINTF(("port %d not present\n", n));
 continue;
+			} else {
+/*
+ * XXX perform_atareset() does not work
+ * when the drive is not completely spun up?
+ * So insert another delay here.
+ */
+printf("Waiting 15 seconds for port %d "
+"to spin up.\n", n);
+delay(15 * 1000 * 1000);
 			}
 		}
 		if (atachkpwr(l, n) != ATA_PWR_ACTIVE) {

Index: src/sys/arch/sandpoint/stand/altboot/version
diff -u src/sys/arch/sandpoint/stand/altboot/version:1.8 src/sys/arch/sandpoint/stand/altboot/version:1.9
--- src/sys/arch/sandpoint/stand/altboot/version:1.8	Wed Sep 30 14:14:32 2015
+++ src/sys/arch/sandpoint/stand/altboot/version	Thu Aug  3 19:22:15 2017
@@ -18,3 +18,5 @@
 	NIC.
 1.11:	Pass precise model information and flags with bootinfo.
 	Synology DS207/209 LED and 2nd disk power-up support.
+1.12:	Some more Synology DS20x fixes, to make sure both drives have been
+	spun up. Also detect PCI-vendor 0x1148 (S&K) as Synology.



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

2017-08-03 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Aug  3 09:42:34 UTC 2017

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

Log Message:
Fixed overflow in delay() for delays greater than 2 seconds.
Replaced u_long by uint32_t and u_quad by uint64_t whenever the exact
32- or 64-bit word is needed.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.37 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.38
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.37	Thu Oct 15 12:00:02 2015
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Aug  3 09:42:34 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.37 2015/10/15 12:00:02 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.38 2017/08/03 09:42:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@ static void send_iomega(int, int, int, i
 static inline uint32_t mfmsr(void);
 static inline void mtmsr(uint32_t);
 static inline uint32_t cputype(void);
-static inline u_quad_t mftb(void);
+static inline uint64_t mftb(void);
 static void init_uart(unsigned, unsigned, uint8_t);
 static void send_sat(char *);
 static unsigned mpc107memsize(void);
@@ -1012,7 +1012,7 @@ _rtt(void)
 satime_t
 getsecs(void)
 {
-	u_quad_t tb = mftb();
+	uint64_t tb = mftb();
 
 	return (tb / ticks_per_sec);
 }
@@ -1021,13 +1021,13 @@ getsecs(void)
  * Wait for about n microseconds (at least!).
  */
 void
-delay(u_int n)
+delay(unsigned n)
 {
-	u_quad_t tb;
-	u_long scratch, tbh, tbl;
+	uint64_t tb;
+	uint32_t scratch, tbh, tbl;
 
 	tb = mftb();
-	tb += (n * 1000 + ns_per_tick - 1) / ns_per_tick;
+	tb += ((uint64_t)n * 1000 + ns_per_tick - 1) / ns_per_tick;
 	tbh = tb >> 32;
 	tbl = tb;
 	asm volatile ("1: mftbu %0; cmpw %0,%1; blt 1b; bgt 2f; mftb %0; cmpw 0, %0,%2; blt 1b; 2:" : "=&r"(scratch) : "r"(tbh), "r"(tbl));
@@ -1113,11 +1113,11 @@ cputype(void)
 	return pvr >> 16;
 }
 
-static inline u_quad_t
+static inline uint64_t
 mftb(void)
 {
-	u_long scratch;
-	u_quad_t tb;
+	uint32_t scratch;
+	uint64_t tb;
 
 	asm ("1: mftbu %0; mftb %0+1; mftbu %1; cmpw %0,%1; bne 1b"
 	: "=r"(tb), "=r"(scratch));



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

2016-06-10 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Jun 11 06:40:24 UTC 2016

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

Log Message:
PR 51200 gets in libsa considered harmful: use kgets


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.27 src/sys/arch/sandpoint/stand/altboot/main.c:1.28
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.27	Wed Sep 30 14:14:32 2015
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sat Jun 11 06:40:24 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.27 2015/09/30 14:14:32 phx Exp $ */
+/* $NetBSD: main.c,v 1.28 2016/06/11 06:40:24 dholland Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -643,7 +643,7 @@ static int input_cmdline(char **argv, in
 
 	printf("\nbootargs> ");
 	cmdline = alloc(256);
-	gets(cmdline);
+	kgets(cmdline, 256);
 
 	return parse_cmdline(argv, maxargc, cmdline,
 	cmdline + strlen(cmdline));
@@ -686,7 +686,7 @@ findflash(void)
 
 	for (;;) {
 		printf("\nfind> ");
-		gets(buf);
+		kgets(buf, sizeof(buf));
 		if (tolower((unsigned)buf[0]) == 'x')
 			break;
 		for (i = 0, n = 0, c = 0; buf[i]; i++) {
@@ -744,7 +744,7 @@ sat_test(void)
 		}
 
 		printf("controller> ");
-		gets(buf);
+		kgets(buf, sizeof(buf));
 		if (buf[0] == '*' && buf[1] == 'X')
 			break;
 



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

2015-10-15 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Oct 15 12:00:02 UTC 2015

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

Log Message:
fix a board type check logic error that affected Linkstation and Kurobox (HG).
They were mistakenly recognized kurot4 type and ended up with kernel boot
failure.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.36 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.37
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.36	Wed Sep 30 14:14:32 2015
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Oct 15 12:00:02 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.36 2015/09/30 14:14:32 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.37 2015/10/15 12:00:02 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -260,10 +260,14 @@ brdsetup(void)
 	}
 	else if (PCI_CLASS(pcicfgread(dev11, PCI_CLASS_REG)) == PCI_CLASS_ETH) {
 		/* ADMtek AN985 (tlp) or RealTek 8169S (re) at dev 11 */
-		if (PCI_VENDOR(pcicfgread(dev12, PCI_ID_REG)) != 0x1095)
+		if (PCI_VENDOR(pcicfgread(dev11, PCI_ID_REG)) == 0x1317)
 			brdtype = BRD_KUROBOX;
-		else
-			brdtype = BRD_KUROBOXT4;
+		else if (PCI_VENDOR(pcicfgread(dev11, PCI_ID_REG)) == 0x10ec) {
+			if (PCI_PRODUCT(pcicfgread(dev12,PCI_ID_REG)) != 0x3512)
+brdtype = BRD_KUROBOX;
+			else
+brdtype = BRD_KUROBOXT4;
+		}
 	}
 	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x11ab) {
 		/* SKnet/Marvell (sk) at dev 15 */



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

2015-09-29 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Sep 29 15:12:53 UTC 2015

Modified Files:
src/sys/arch/sandpoint/stand/altboot: dsk.c globals.h

Log Message:
The disk's unittag is not equal to the channel, so we need an additional
unitchan entry to make lba_read() work in all cases.
The libsa-printf() does not seem to support 64-bit output, so cast the
block number to unsigned when printing an error message.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.17 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.18
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.17	Tue Aug  5 17:55:20 2014
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Tue Sep 29 15:12:52 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.17 2014/08/05 17:55:20 joerg Exp $ */
+/* $NetBSD: dsk.c,v 1.18 2015/09/29 15:12:52 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -125,6 +125,7 @@ disk_scan(void *drv)
 		}
 		d = &ldisk[ndrive];
 		d->dvops = l;
+		d->unitchan = n;
 		d->unittag = ndrive;
 		snprintf(d->xname, sizeof(d->xname), "wd%d", d->unittag);
 		set_xfermode(l, n);
@@ -404,7 +405,7 @@ lba_read(struct disk *d, int64_t bno, in
 	int error;
 
 	l = d->dvops;
-	n = d->unittag;
+	n = d->unitchan;
 	p = (uint16_t *)buf;
 	chan = &l->chan[n];
 	error = 0;
@@ -414,7 +415,8 @@ lba_read(struct disk *d, int64_t bno, in
 		(*issue)(chan, bno, rdcnt);
 		for (k = 0; k < rdcnt; k++) {
 			if (spinwait_unbusy(l, n, 1000, &err) == 0) {
-printf("%s blk %lld %s\n", d->xname, bno, err);
+printf("%s blk %u %s\n",
+   d->xname, (unsigned)bno, err);
 error = EIO;
 break;
 			}

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.19 src/sys/arch/sandpoint/stand/altboot/globals.h:1.20
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.19	Thu Apr 26 19:59:37 2012
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Tue Sep 29 15:12:52 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.19 2012/04/26 19:59:37 phx Exp $ */
+/* $NetBSD: globals.h,v 1.20 2015/09/29 15:12:52 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -172,6 +172,7 @@ NIF_DECL(stg);
 struct disk {
 	char xname[8];
 	void *dvops;
+	unsigned unitchan;
 	unsigned unittag;
 	uint16_t ident[128];
 	uint64_t nsect;



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

2014-08-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Aug  8 21:18:10 UTC 2014

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

Log Message:
Use __unreachable().


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.34 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.35
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.34	Tue Aug  5 17:55:20 2014
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Fri Aug  8 21:18:10 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.34 2014/08/05 17:55:20 joerg Exp $ */
+/* $NetBSD: brdsetup.c,v 1.35 2014/08/08 21:18:10 joerg Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -859,7 +859,7 @@ _rtt(void)
 		asm volatile ("sync; isync");
 		run(0, 0, 0, 0, (void *)0xFFF00100); /* reset entry */
 	}
-	/*NOTREACHED*/
+	__unreachable();
 }
 
 satime_t



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

2014-08-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Aug  5 17:55:20 UTC 2014

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c dev_net.c dsk.c main.c
nif.c

Log Message:
Don't use non-literal strings as format strings.
XXX Switch to strlcpy.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/dev_net.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/nif.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.33 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.34
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.33	Thu Nov  7 14:51:36 2013
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Tue Aug  5 17:55:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.33 2013/11/07 14:51:36 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.34 2014/08/05 17:55:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -319,11 +319,11 @@ brdsetup(void)
 	brdfixup();
 
 	bi_mem.memsize = mpc107memsize();
-	snprintf(bi_cons.devname, sizeof(bi_cons.devname), consname);
+	snprintf(bi_cons.devname, sizeof(bi_cons.devname), "%s", consname);
 	bi_cons.addr = consport;
 	bi_cons.speed = brdprop->consspeed;
 	bi_clk.ticks_per_sec = ticks_per_sec;
-	snprintf(bi_fam.name, sizeof(bi_fam.name), brdprop->family);
+	snprintf(bi_fam.name, sizeof(bi_fam.name), "%s", brdprop->family);
 }
 
 struct brdprop *

Index: src/sys/arch/sandpoint/stand/altboot/dev_net.c
diff -u src/sys/arch/sandpoint/stand/altboot/dev_net.c:1.2 src/sys/arch/sandpoint/stand/altboot/dev_net.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/dev_net.c:1.2	Sun Jul 17 20:54:46 2011
+++ src/sys/arch/sandpoint/stand/altboot/dev_net.c	Tue Aug  5 17:55:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: dev_net.c,v 1.2 2011/07/17 20:54:46 joerg Exp $ */
+/* $NetBSD: dev_net.c,v 1.3 2014/08/05 17:55:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@ net_open(struct open_file *f, ...)
 	}
 
 	if (file[0] != '\0') 
-		snprintf(bootfile, sizeof(bootfile), file);
+		snprintf(bootfile, sizeof(bootfile), "%s", file);
 	else if (bootfile[0] == '\0')
 		snprintf(bootfile, sizeof(bootfile), "netbsd");
 
@@ -83,7 +83,7 @@ net_open(struct open_file *f, ...)
 	&& (error = nfs_mount(netdev_sock, rootip, rootpath)) != 0)
 		goto bad;
 
-	snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), bootfile);
+	snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), "%s", bootfile);
 	f->f_devdata = &netdev_sock;
 	netdev_opens++;
 	return 0;

Index: src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.16 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.17
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.16	Thu Apr 26 19:59:37 2012
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Tue Aug  5 17:55:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.16 2012/04/26 19:59:37 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.17 2014/08/05 17:55:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -502,7 +502,7 @@ dsk_open(struct open_file *f, ...)
 	d->part = part;
 	f->f_devdata = d;
 
-	snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), name);
+	snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), "%s", name);
 	if (dlp->d_partitions[part].p_fstype == FS_BSDFFS) {
 		if ((error = ffsv2_open(name, f)) == 0) {
 			fs = &fs_ffsv2;

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.25 src/sys/arch/sandpoint/stand/altboot/main.c:1.26
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.25	Wed Mar 26 17:35:08 2014
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Tue Aug  5 17:55:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.25 2014/03/26 17:35:08 christos Exp $ */
+/* $NetBSD: main.c,v 1.26 2014/08/05 17:55:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -525,7 +525,7 @@ module_load(const char *kernel_path)
 		if (size < bm->bm_len)
 			printf("WARNING: couldn't load");
 		else {
-			snprintf(bi->kmod, sizeof(bi->kmod), bm->bm_kmod);
+			snprintf(bi->kmod, sizeof(bi->kmod), "%s", bm->bm_kmod);
 			bi->type = BI_MODULE_ELF;
 			bi->len = size;
 			bi->base = kmodloadp;

Index: src/sys/arch/sandpoint/stand/altboot/nif.c
diff -u src/sys/arch/sandpoint/stand/altboot/nif.c:1.5 src/sys/arch/sandpoint/stand/altboot/nif.c:1.6
--- src/sys/arch/sandpoint/stand/altboot/nif.c:1.5	Sat Mar 12 16:41:23 2011
+++ src/sys/arch/sandpoint/stand/altboot/nif.c	Tue Aug  5 17:55:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: nif.c,v 1.5 2011/03/12 16:41:23 phx Ex

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

2014-03-22 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Mar 22 18:54:28 UTC 2014

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

Log Message:
drop trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.23 src/sys/arch/sandpoint/stand/altboot/main.c:1.24
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.23	Sun Jan  5 21:10:50 2014
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sat Mar 22 18:54:28 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.23 2014/01/05 21:10:50 jakllsch Exp $ */
+/* $NetBSD: main.c,v 1.24 2014/03/22 18:54:28 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -430,8 +430,8 @@ module_add(const char *name)
 
 	bm = alloc(sizeof(struct boot_module) + strlen(name) + 1);
 	if (bm == NULL) {
-		printf("couldn't allocate module %s\n", name); 
-		return; 
+		printf("couldn't allocate module %s\n", name);
+		return;
 	}
 
 	bm->bm_kmod = (char *)(bm + 1);
@@ -451,12 +451,12 @@ module_add(const char *name)
 #define alignpg(x)	(((x)+PAGE_SIZE-1) & ~(PAGE_SIZE-1))
 
 void
-module_load(const char *kernel_path) 
+module_load(const char *kernel_path)
 {
 	struct boot_module *bm;
 	struct bi_modulelist_entry *bi;
 	struct stat st;
-	char *p; 
+	char *p;
 	int size, fd;
 
 	strcpy(module_base, kernel_path);
@@ -496,7 +496,7 @@ module_load(const char *kernel_path) 
 		}
 		bm->bm_len = (int)st.st_size;
 		close(fd);
-		size += sizeof(struct bi_modulelist_entry); 
+		size += sizeof(struct bi_modulelist_entry);
 	}
 	if (size == 0)
 		return;



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

2014-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jan  5 21:10:50 UTC 2014

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

Log Message:
sprinkle const


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.22 src/sys/arch/sandpoint/stand/altboot/main.c:1.23
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.22	Tue Dec 25 17:02:35 2012
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Jan  5 21:10:50 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.22 2012/12/25 17:02:35 phx Exp $ */
+/* $NetBSD: main.c,v 1.23 2014/01/05 21:10:50 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -88,8 +88,8 @@ char module_base[80];
 uint32_t kmodloadp;
 int modules_enabled = 0;
 
-void module_add(char *);
-void module_load(char *);
+void module_add(const char *);
+void module_load(const char *);
 int module_open(struct boot_module *);
 
 void main(int, char **, char *, char *);
@@ -421,7 +421,7 @@ bi_add(void *new, int type, int size)
 }
 
 void
-module_add(char *name)
+module_add(const char *name)
 {
 	struct boot_module *bm, *bmp;
 
@@ -451,7 +451,7 @@ module_add(char *name)
 #define alignpg(x)	(((x)+PAGE_SIZE-1) & ~(PAGE_SIZE-1))
 
 void
-module_load(char *kernel_path) 
+module_load(const char *kernel_path) 
 {
 	struct boot_module *bm;
 	struct bi_modulelist_entry *bi;



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

2014-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jan  5 21:09:33 UTC 2014

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

Log Message:
Drop duplicate and unused extern global variable.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/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/altboot/devopen.c
diff -u src/sys/arch/sandpoint/stand/altboot/devopen.c:1.2 src/sys/arch/sandpoint/stand/altboot/devopen.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/devopen.c:1.2	Sun Mar  6 18:22:13 2011
+++ src/sys/arch/sandpoint/stand/altboot/devopen.c	Sun Jan  5 21:09:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.2 2011/03/06 18:22:13 phx Exp $ */
+/* $NetBSD: devopen.c,v 1.3 2014/01/05 21:09:33 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -52,7 +52,6 @@ struct fs_ops fs_tftp  = FS_OPS(tftp);
 struct fs_ops fs_ffsv2 = FS_OPS(ffsv2);
 struct fs_ops fs_ffsv1 = FS_OPS(ffsv1);
 struct fs_ops fs_mem   = FS_OPS(mem);
-extern char *fsmod;
 
 static void parseunit(const char *, int *, int *, char **);
 



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

2013-11-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Nov  7 14:51:36 UTC 2013

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

Log Message:
shut off gcc 4.8 unused variable warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.32 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.33
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.32	Tue Dec 25 17:07:06 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Nov  7 14:51:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.32 2012/12/25 17:07:06 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.33 2013/11/07 14:51:36 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -446,6 +446,9 @@ encbrdfix(struct brdprop *brd)
 	val = pcicfgread(ac97, 0x3c) &~ 0xff;
 	val |= 5;
 	pcicfgwrite(ac97, 0x3c, val);
+
+	(void) pcicfgread(ide, 0x08);
+	(void) pcicfgread(pmgt, 0x08);
 }
 
 void



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

2013-09-15 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Sep 15 18:22:57 UTC 2013

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

Log Message:
New version can read the MAC address for QNAP systems from flash.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/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/altboot/version
diff -u src/sys/arch/sandpoint/stand/altboot/version:1.6 src/sys/arch/sandpoint/stand/altboot/version:1.7
--- src/sys/arch/sandpoint/stand/altboot/version:1.6	Sun Jan 22 13:08:17 2012
+++ src/sys/arch/sandpoint/stand/altboot/version	Sun Sep 15 18:22:57 2013
@@ -14,3 +14,5 @@
 1.9:	Support PATA drive configuration option. Wait until drives are
 ready after cold-start. Wake up drives from standby mode.
 A default command line can be saved to flash as initrd image.
+1.10:	Read correct MAC address from flash on QNAP-TS systems with re(4)
+	NIC.



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

2013-08-20 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Aug 21 06:44:02 UTC 2013

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile

Log Message:
Use 


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/altboot/Makefile

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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.12 src/sys/arch/sandpoint/stand/altboot/Makefile:1.13
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.12	Sun Oct 30 20:42:09 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Wed Aug 21 06:44:02 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.12 2011/10/30 20:42:09 phx Exp $
+#	$NetBSD: Makefile,v 1.13 2013/08/21 06:44:02 matt Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -19,6 +19,7 @@ CPPFLAGS+=	-nostdinc -I. -I${.OBJDIR} -I
 DBG=		-Os
 
 .include 
+.include 
 
 # XXX SHOULD NOT NEED TO DEFINE THESE!
 LIBCRT0=
@@ -32,14 +33,6 @@ BINMODE=	444
 RELOC=		100
 ENTRY=		_start
 
-.if !make(obj) && !make(clean) && !make(cleandir)
-.BEGIN:
-	@[ -h machine ] || ln -s ${S}/arch/${MACHINE}/include machine
-	@[ -h powerpc ] || ln -s ${S}/arch/powerpc/include powerpc
-.NOPATH: machine powerpc
-.endif
-CLEANFILES+= machine powerpc
-
 ### find out what to use for libkern
 KERN_AS=	library
 .include "${S}/lib/libkern/Makefile.inc"
@@ -62,6 +55,7 @@ vers.c: version
 	${${MKREPRO} == "yes" :?:-D} ${.CURDIR}/version "sandpoint"
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
+	${_MKTARGET_LINK}
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \
 	${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 	${OBJCOPY} -S -O binary ${PROG} ${PROG}.bin



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

2012-12-25 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Dec 25 17:07:07 UTC 2012

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

Log Message:
QNAP V200 boards have no EEPROM for the MAC address, so all devices default
to the same address (00:e0:4c:69:20:01).
Now we read the real MAC address from the flash ROM. It is stored at the
beginning of a 512-byte block in ASCII format. Some QNAP's have a broken
ext2 file system, so we cannot look for the file ETH0.MAC_ADDR therein,
but have to search the whole flash in 512-byte steps for candidates...


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/rge.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.31 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.32
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.31	Mon Apr 16 16:55:29 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Tue Dec 25 17:07:06 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.31 2012/04/16 16:55:29 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.32 2012/12/25 17:07:06 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -1254,6 +1254,41 @@ read_mac_string(uint8_t *mac, char *p)
 }
 
 /*
+ * Scan through the Flash memory and look for a string starting at 512 bytes
+ * block boundaries, matching the format: xx:xx:xx:xx:xx:xx, where "x"
+ * are hexadecimal digits.
+ * Read the first match as our MAC address.
+ * The start address of the search, p, *must* be dividable by 512!
+ * Return false when no suitable MAC string was found.
+ */
+static int
+find_mac_string(uint8_t *mac, char *p)
+{
+	int i;
+
+	for (;;) {
+		for (i = 0; i < 3 * 6; i += 3) {
+			if (!isxdigit((unsigned)p[i]) ||
+			!isxdigit((unsigned)p[i + 1]))
+break;
+			if ((i < 5 && p[i + 2] != ':') ||
+			(i >= 5 && p[i + 2] != '\0'))
+break;
+		}
+		if (i >= 6) {
+			/* found a valid MAC address */
+			read_mac_string(mac, p);
+			return 1;
+		}
+		if (p >= (char *)0xfe00)
+			break;
+		p += 0x200;
+	}
+	return 0;
+}
+
+
+/*
  * For cost saving reasons some NAS boxes lack SEEPROM for NIC's
  * ethernet address and keep it in their Flash memory instead.
  */
@@ -1272,6 +1307,10 @@ read_mac_from_flash(uint8_t *mac)
 	case BRD_DLINKDSM:
 		read_mac_string(mac, (char *)0xfff0ff80);
 		return;
+	case BRD_QNAPTS:
+		if (find_mac_string(mac, (char *)0xfff0))
+			return;
+		break;
 	default:
 		printf("Warning: This board has no known method defined "
 		"to determine its MAC address!\n");

Index: src/sys/arch/sandpoint/stand/altboot/rge.c
diff -u src/sys/arch/sandpoint/stand/altboot/rge.c:1.6 src/sys/arch/sandpoint/stand/altboot/rge.c:1.7
--- src/sys/arch/sandpoint/stand/altboot/rge.c:1.6	Sun Oct 30 21:08:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/rge.c	Tue Dec 25 17:07:06 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: rge.c,v 1.6 2011/10/30 21:08:33 phx Exp $ */
+/* $NetBSD: rge.c,v 1.7 2012/12/25 17:07:06 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -102,6 +102,9 @@ struct desc {
 #define	 RCR_AM		(1U << 2)	/* accept multicast frame */
 #define	 RCR_APM	(1U << 1)	/* accept unicast frame */
 #define	 RCR_AAP	(1U << 0)	/* promiscuous */
+#define RGE_EECMD	0x50		/* EEPROM command register */
+#define  EECMD_LOCK	0x00
+#define  EECMD_UNLOCK	0xc0
 #define RGE_PHYAR	0x60		/* PHY access */
 #define RGE_PHYSR	0x6c		/* PHY status */
 #define RGE_RMS		0xda		/* Rx maximum frame size */
@@ -146,7 +149,8 @@ rge_init(unsigned tag, void *data)
 	unsigned val;
 	struct local *l;
 	struct desc *txd, *rxd;
-	uint8_t *en = data;
+	uint32_t reg;
+	uint8_t *en;
 
 	l = ALLOC(struct local, 256);	/* desc alignment */
 	memset(l, 0, sizeof(struct local));
@@ -158,14 +162,27 @@ rge_init(unsigned tag, void *data)
 	} while (val & CR_RESET);
 
 	mii_initphy(l);
-
 	en = data;
-	en[0] = CSR_READ_1(l, RGE_IDR0);
-	en[1] = CSR_READ_1(l, RGE_IDR1);
-	en[2] = CSR_READ_1(l, RGE_IDR2);
-	en[3] = CSR_READ_1(l, RGE_IDR3);
-	en[4] = CSR_READ_1(l, RGE_IDR4);
-	en[5] = CSR_READ_1(l, RGE_IDR5);
+
+	if (brdtype == BRD_QNAPTS) {
+		/* read the MAC from flash and write it into the ID-Regs */
+		read_mac_from_flash(en);
+
+		CSR_WRITE_1(l, RGE_EECMD, EECMD_UNLOCK);
+		reg = en[0] | (en[1] << 8) | (en[2] << 16) | (en[3] << 24);
+		CSR_WRITE_4(l, RGE_IDR0, reg);
+		reg = en[4] | (en[5] << 8);
+		CSR_WRITE_4(l, RGE_IDR4, reg);
+		CSR_WRITE_1(l, RGE_EECMD, EECMD_LOCK);
+	} else {
+		/* pretent the ID-Regs have the correct address */
+		en[0] = CSR_READ_1(l, RGE_IDR0);
+		en[1] = CSR_READ_1(l, RGE_IDR1);
+		en[2] = CSR_READ_1(l, RGE_IDR2);
+		en[3] = CSR_READ_1(l, RGE_IDR3);
+		en[4] = CSR_READ_1(l, RGE_IDR4);
+		en[5] = CSR_READ_1(l, RGE_IDR5);
+	}
 
 	printf("MAC 

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

2012-12-25 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Dec 25 17:02:35 UTC 2012

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

Log Message:
Add a DEBUG function to search the Flash for byte-streams, as U-Boot usually
doesn't offer a search function.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.21 src/sys/arch/sandpoint/stand/altboot/main.c:1.22
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.21	Mon May 21 21:34:16 2012
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Tue Dec 25 17:02:35 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.21 2012/05/21 21:34:16 dsl Exp $ */
+/* $NetBSD: main.c,v 1.22 2012/12/25 17:02:35 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -111,6 +111,7 @@ static int parse_cmdline(char **, int, c
 static int is_space(char);
 #ifdef DEBUG
 static void sat_test(void);
+static void findflash(void);
 #endif
 
 #define	BNAME_DEFAULT "wd0:"
@@ -236,12 +237,21 @@ main(int argc, char *argv[], char *boota
 			n / 100);
 		if (tstchar()) {
 #ifdef DEBUG
-			if (toupper(getchar()) == 'C') {
+			unsigned c;
+
+			c = toupper(getchar());
+			if (c == 'C') {
 /* controller test terminal */
 sat_test();
 n = 200;
 continue;
 			}
+			else if (c == 'F') {
+/* find strings in Flash ROM */
+findflash();
+n = 200;
+continue;
+			}
 #else
 			(void)getchar();
 #endif
@@ -665,6 +675,40 @@ is_space(char c)
 
 #ifdef DEBUG
 static void
+findflash(void)
+{
+	char buf[256];
+	int i, n;
+	unsigned char c, *p;
+
+	for (;;) {
+		printf("\nfind> ");
+		gets(buf);
+		if (tolower((unsigned)buf[0]) == 'x')
+			break;
+		for (i = 0, n = 0, c = 0; buf[i]; i++) {
+			c <<= 4;
+			c |= hex2nibble(buf[i]);
+			if (i & 1)
+buf[n++] = c;
+		}
+		printf("Searching for:");
+		for (i = 0; i < n; i++)
+			printf(" %02x", buf[i]);
+		printf("\n");
+		for (p = (unsigned char *)0xff00;
+		 p <= (unsigned char *)(0x-n); p++) {
+			for (i = 0; i < n; i++) {
+if (p[i] != buf[i])
+	break;
+			}
+			if (i >= n)
+printf("Found at %08x\n", (unsigned)p);
+		}
+	}
+}
+
+static void
 sat_test(void)
 {
 	char buf[1024];



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

2012-04-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Apr 27 00:35:43 UTC 2012

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

Log Message:
Comment improvement. altboot(8) is now aware of the disk removal
for mirrored drive configuration.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.19 src/sys/arch/sandpoint/stand/altboot/main.c:1.20
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.19	Thu Apr 26 19:59:37 2012
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Fri Apr 27 00:35:43 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.19 2012/04/26 19:59:37 phx Exp $ */
+/* $NetBSD: main.c,v 1.20 2012/04/27 00:35:43 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -272,11 +272,11 @@ main(int argc, char *argv[], char *boota
 			break;	/* break on first unknown string */
 	}
 
+	/*
+	 * If no device name is given, we construct a list of drives
+	 * which have valid disklabels.
+	 */
 	if (n >= argc) {
-		/*
-		 * If no device name is given we construct a list of drives
-		 * which have valid disklabels.
-		 */
 		n = 0;
 		argc = 0;
 		argv = alloc(MAX_UNITS * (sizeof(char *) + sizeof("wdN:")));
@@ -295,6 +295,7 @@ main(int argc, char *argv[], char *boota
 		}
 	}
 
+	/* try to boot off kernel from the drive list */
 	while (n < argc) {
 		bname = argv[n++];
 



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

2012-04-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Apr 26 19:59:37 UTC 2012

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot dsk.c globals.h
main.c

Log Message:
Multiple boot devices and/or paths may be specified, which are booted one
after another until success. When no boot device is specified altboot tries
to boot from all disk devices with a valid NetBSD disklabel, starting with
unit 0.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/arch/sandpoint/stand/altboot/README.altboot
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/stand/altboot/globals.h \
src/sys/arch/sandpoint/stand/altboot/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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.10 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.11
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.10	Tue Apr 24 14:56:07 2012
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Thu Apr 26 19:59:36 2012
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.10 2012/04/24 14:56:07 nisimura Exp $
+$NetBSD: README.altboot,v 1.11 2012/04/26 19:59:36 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -61,11 +61,11 @@ that the original U-Boot/PPCboot still r
 as a functional extension for them.
 
 In case the firmware was crippled by the vendor so that it only boots
-Linux U-Boot images (D-Link), you can still use altboot by uploading
-altboot.img instead of the Linux kernel.
+Linux U-Boot images (D-Link, Synology 2007), you can still use altboot by
+overwriting the Linux kernel with altboot.img.
 
 Altboot passes the following bootinfo records to the NetBSD/sandpoint
-kernel.
+kernel:
 - processor clock tick value driving MPC8241/8245.
 - serial console selection.
 - booted kernel filename and which device it was fetched from.
@@ -104,7 +104,12 @@ restarts itself. Mainly useful for altbo
 Multiple arguments may be specified at once, although not all combinations
 make sense. The format of an altboot command line is:
 
-  [[ ...] :[]]
+  [[ ...] :[] ...]
+
+Multiple boot devices and/or paths may be specified, which are booted one
+after another until success. When no boot device is specified altboot tries
+to boot from all disk devices with a valid NetBSD disklabel, starting with
+unit 0.
 
 The following device names are supported:
 - tftp			boot from TFTP (address retrieved by DHCP)

Index: src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.15 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.16
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.15	Mon Apr  9 12:40:55 2012
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Thu Apr 26 19:59:37 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.15 2012/04/09 12:40:55 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.16 2012/04/26 19:59:37 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -83,7 +83,6 @@ static void issue48(struct dvata_chan *,
 static void issue28(struct dvata_chan *, int64_t, int);
 static struct disk *lookup_disk(int);
 
-#define MAX_UNITS 8
 static struct disk ldisk[MAX_UNITS];
 
 int
@@ -462,7 +461,18 @@ static struct disk *
 lookup_disk(int unit)
 {
 
-	return &ldisk[unit];
+	return (unit >= 0 && unit < MAX_UNITS) ? &ldisk[unit] : NULL;
+}
+
+int
+dlabel_valid(int unit)
+{
+	struct disk *dsk;
+
+	dsk = lookup_disk(unit);
+	if (dsk == NULL)
+		return NULL;
+	return dsk->dlabel != NULL;
 }
 
 int
@@ -487,10 +497,10 @@ dsk_open(struct open_file *f, ...)
 
 	if ((d = lookup_disk(unit)) == NULL)
 		return ENXIO;
-	f->f_devdata = d;
 	if ((dlp = d->dlabel) == NULL || part >= dlp->d_npartitions)
 		return ENXIO;
 	d->part = part;
+	f->f_devdata = d;
 
 	snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), name);
 	if (dlp->d_partitions[part].p_fstype == FS_BSDFFS) {

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.18 src/sys/arch/sandpoint/stand/altboot/globals.h:1.19
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.18	Mon Apr 16 16:55:29 2012
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Thu Apr 26 19:59:37 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.18 2012/04/16 16:55:29 phx Exp $ */
+/* $NetBSD: globals.h,v 1.19 2012/04/26 19:59:37 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -167,8 +167,23 @@ NIF_DECL(skg);
 NIF_DECL(stg);
 
 /* DSK support */
-int dskdv_init(void *);
+#define MAX_UNITS 4
+
+struct disk {
+	char xname[8];
+	void *dvops;
+	unsigned unittag;
+	uint16_t ident[128];
+	uint64_t nsect;
+	uint64_t first;
+	void *dlabel;
+	int part;
+	void *fsops;
+	int (*lba_read

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

2012-04-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Apr 24 14:56:07 UTC 2012

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
Add KURO-BOX/T4 vendor custom U-Boot version message.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/altboot/README.altboot

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.9 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.10
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.9	Sat Jan 14 22:36:54 2012
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Tue Apr 24 14:56:07 2012
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.9 2012/01/14 22:36:54 phx Exp $
+$NetBSD: README.altboot,v 1.10 2012/04/24 14:56:07 nisimura Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -48,6 +48,10 @@ Altboot is known working on at least the
 
PPCBoot 2.0.0-A9 (Feb 13 2006 - 14:56:11)
 
+- KURO-BOX/T4 vendor custom U-Boot
+
+   U-Boot 2009.06-BUFFALO-svn1376 (Jul 11 2009 - 04:11:01) KURO-NAS/T4
+
 The standard use of altboot is to invoke it with a short script from
 U-Boot/PPCboot, where the altboot.bin image is stored in an unoccupied 128KB
 section of the target's HW NOR flash.  Combined with standard



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

2012-04-16 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr 16 16:55:29 UTC 2012

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

Log Message:
Improved Synology CS/RS support: watch power-state of all SATA drives before
initializing them, configure drive LEDs to reflect SATA activity.
Configure drives on all ATA PCI devices, not only on the first one.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/altboot/globals.h \
src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.30 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.31
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.30	Mon Apr  9 14:02:04 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Apr 16 16:55:29 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.30 2012/04/09 14:02:04 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.31 2012/04/16 16:55:29 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -46,6 +46,7 @@
 void xxx ## setup(struct brdprop *); \
 void xxx ## brdfix(struct brdprop *); \
 void xxx ## pcifix(struct brdprop *); \
+void xxx ## launch(struct brdprop *); \
 void xxx ## reset(void)
 
 BRD_DECL(mot);
@@ -119,28 +120,28 @@ static struct brdprop brdlist[] = {
 	BRD_SANDPOINTX3,
 	0,
 	"com", 0x3f8, 115200,
-	motsetup, motbrdfix, motpcifix, NULL },
+	motsetup, motbrdfix, motpcifix, NULL, NULL },
 {
 	"encpp1",
 	"EnCore PP1",
 	BRD_ENCOREPP1,
 	0,
 	"com", 0x3f8, 115200,
-	encsetup, encbrdfix, encpcifix, NULL },
+	encsetup, encbrdfix, encpcifix, NULL, NULL },
 {
 	"kurobox",
 	"KuroBox",
 	BRD_KUROBOX,
 	0,
 	"eumb", 0x4600, 57600,
-	kurosetup, kurobrdfix, NULL, kuroreset },
+	kurosetup, kurobrdfix, NULL, NULL, kuroreset },
 {
 	"synology",
-	"Synology DS",
+	"Synology CS/DS/RS",
 	BRD_SYNOLOGY,
 	0,
 	"eumb", 0x4500, 115200,
-	synosetup, synobrdfix, NULL, synoreset },
+	synosetup, synobrdfix, synopcifix, synolaunch, synoreset },
 {
 	"qnap",
 	"QNAP TS",
@@ -148,42 +149,42 @@ static struct brdprop brdlist[] = {
 	33164691,	/* Linux source says 3300, but the Synology  */
 			/* clock value delivers a much better precision. */
 	"eumb", 0x4500, 115200,
-	NULL, qnapbrdfix, NULL, qnapreset },
+	NULL, qnapbrdfix, NULL, NULL, qnapreset },
 {
 	"iomega",
 	"IOMEGA StorCenter G2",
 	BRD_STORCENTER,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, iomegabrdfix, NULL, iomegareset },
+	NULL, iomegabrdfix, NULL, NULL, iomegareset },
 {
 	"dlink",
 	"D-Link DSM-G600",
 	BRD_DLINKDSM,
 	3300,
 	"eumb", 0x4500, 9600,
-	NULL, dlinkbrdfix, NULL, NULL },
+	NULL, dlinkbrdfix, NULL, NULL, NULL },
 {
 	"nhnas",
 	"Netronix NH-230/231",
 	BRD_NH230NAS,
 	3300,
 	"eumb", 0x4500, 9600,
-	NULL, nhnasbrdfix, NULL, nhnasreset },
+	NULL, nhnasbrdfix, NULL, NULL, nhnasreset },
 {
 	"kurot4",
 	"KuroBox/T4",
 	BRD_KUROBOXT4,
 	32768000,
 	"eumb", 0x4600, 57600,
-	NULL, kurot4brdfix, NULL, NULL },
+	NULL, kurot4brdfix, NULL, NULL, NULL },
 {
 	"unknown",
 	"Unknown board",
 	BRD_UNKNOWN,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, NULL, NULL, NULL }, /* must be the last */
+	NULL, NULL, NULL, NULL, NULL }, /* must be the last */
 };
 
 static struct brdprop *brdprop;
@@ -365,6 +366,15 @@ pcifixup()
 }
 
 void
+launchfixup()
+{
+
+	if (brdprop->launch == NULL)
+		return;
+	(*brdprop->launch)(brdprop);
+}
+
+void
 encsetup(struct brdprop *brd)
 {
 
@@ -707,6 +717,50 @@ synobrdfix(struct brdprop *brd)
 }
 
 void
+synopcifix(struct brdprop *brd)
+{
+	static const char csmodel[4][7] = {
+		"CS406e", "CS406", "RS406", "CS407e"
+	};
+	volatile uint8_t *cpld = (volatile uint8_t *)0xff00;
+	uint8_t pwrstate;
+
+	if (nata > 1) {
+		/*
+		 * CS/RS stations power-up their disks one after another.
+		 * We have to watch over the current power state in a CPLD
+		 * register, until all disks become available.
+		 */
+		printf("CPLD V1.%d for model %s\n", cpld[2] & 3,
+		csmodel[(cpld[2] & 0x0c) >> 2]);
+		cpld[0] = 0x00; /* all drive LEDs blinking yellow */
+		do {
+			delay(1000 * 1000);
+			pwrstate = cpld[1];
+			printf("Power state: %02x\r", pwrstate);
+		} while (pwrstate != 0xff);
+		putchar('\n');
+	}
+}
+
+void
+synolaunch(struct brdprop *brd)
+{
+	volatile uint8_t *cpld = (volatile uint8_t *)0xff00;
+	struct dkdev_ata *sata1, *sata2;
+
+	if (nata > 1) {
+		/* enable drive LEDs for active disk drives on CS/RS models */
+		sata1 = lata[0].drv;
+		sata2 = lata[1].drv;
+		cpld[0] = (sata1->presense[0] ? 0x80 : 0xc0) |
+		(sata1->presense[1] ? 0x20 : 0x30) |
+		(sata2->presense[0] ? 0x08 : 0x0c) |
+		(sata2->presense[1] ? 0x02 : 0x03);
+	}
+}
+
+void
 synoreset()
 {
 

Inde

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

2012-04-09 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Mon Apr  9 14:02:04 UTC 2012

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

Log Message:
The processor ExtClk value of Kurobox/T4 is comfirmed as 32768000.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.29 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.30
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.29	Mon Apr  9 13:26:37 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Apr  9 14:02:04 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.29 2012/04/09 13:26:37 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.30 2012/04/09 14:02:04 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -174,9 +174,9 @@ static struct brdprop brdlist[] = {
 	"kurot4",
 	"KuroBox/T4",
 	BRD_KUROBOXT4,
-	0,
+	32768000,
 	"eumb", 0x4600, 57600,
-	kurot4setup, kurot4brdfix, NULL, NULL },
+	NULL, kurot4brdfix, NULL, NULL },
 {
 	"unknown",
 	"Unknown board",
@@ -776,16 +776,6 @@ nhnasreset()
 }
 
 void
-kurot4setup(struct brdprop *brd)
-{
-
-	if (PCI_VENDOR(pcicfgread(pcimaketag(0, 11, 0), PCI_ID_REG)) == 0x10ec)
-		brd->extclk = 32768000; /* decr 2457600Hz */
-	else
-		brd->extclk = 32521333; /* decr 2439100Hz */
-}
-
-void
 kurot4brdfix(struct brdprop *brd)
 {
 



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

2012-04-09 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Mon Apr  9 12:40:56 UTC 2012

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

Log Message:
Refactor disklabel decode logic.  RAIDFRAME case needs more attention
as it's not certain whether a general solution.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.14 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.15
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.14	Sun Jan 22 13:16:54 2012
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Mon Apr  9 12:40:55 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.14 2012/01/22 13:16:54 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.15 2012/04/09 12:40:55 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -77,6 +77,7 @@ static void drive_ident(struct disk *, c
 static char *mkident(char *, int);
 static void set_xfermode(struct dkdev_ata *, int);
 static void decode_dlabel(struct disk *, char *);
+static struct disklabel *search_dmagic(char *);
 static int lba_read(struct disk *, int64_t, int, void *);
 static void issue48(struct dvata_chan *, int64_t, int);
 static void issue28(struct dvata_chan *, int64_t, int);
@@ -306,7 +307,6 @@ decode_dlabel(struct disk *d, char *iobu
 struct mbr_partition *mp, *bsdp;
 	struct disklabel *dlp;
 	struct partition *pp;
-	char *dp;
 	int i, first, rf_offset;
 
 	bsdp = NULL;
@@ -324,39 +324,26 @@ decode_dlabel(struct disk *d, char *iobu
 	rf_offset = 0;
 	first = (bsdp) ? bswap32(bsdp->mbrp_start) : 0;
 	(*d->lba_read)(d, first + LABELSECTOR, 1, iobuf);
-	dp = iobuf /* + LABELOFFSET */;
-	for (i = 0; i < 512 - sizeof(struct disklabel); i++, dp += 4) {
-		dlp = (struct disklabel *)dp;
-		if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC) {
-			if (dlp->d_partitions[0].p_fstype == FS_RAID) {
-printf("%s%c: raid\n", d->xname, i + 'a');
-snprintf(d->xname, sizeof(d->xname), "raid.");
-rf_offset = dlp->d_partitions[0].p_offset +
-RF_PROTECTED_SECTORS;
-(*d->lba_read)(d, rf_offset + LABELSECTOR, 1,
-iobuf);
-dp = iobuf /* + LABELOFFSET */;
-for (i = 0; i < 512 - sizeof(struct disklabel); i++, dp += 4) {
-	dlp = (struct disklabel *)dp;
-	if (dlp->d_magic == DISKMAGIC &&
-	dlp->d_magic2 == DISKMAGIC)
-		goto found;
-}
-			} else	/* Not RAID */
-goto found;
-		}
+	dlp = search_dmagic(iobuf);
+	if (dlp == NULL)
+		goto notfound;
+	if (dlp->d_partitions[0].p_fstype == FS_RAID) {
+		printf("%s%c: raid\n", d->xname, 0 + 'a');
+		snprintf(d->xname, sizeof(d->xname), "raid.");
+		rf_offset
+		= dlp->d_partitions[0].p_offset + RF_PROTECTED_SECTORS;
+		(*d->lba_read)(d, rf_offset + LABELSECTOR, 1, iobuf);
+		dlp = search_dmagic(iobuf);
+		if (dlp == NULL)
+			goto notfound;
 	}
-	d->dlabel = NULL;
-	printf("%s: no disklabel\n", d->xname);
-	return;
-  found:
 	for (i = 0; i < dlp->d_npartitions; i += 1) {
 		const char *type;
 		pp = &dlp->d_partitions[i];
 		pp->p_offset += rf_offset;
 		type = NULL;
 		switch (pp->p_fstype) {
-		case FS_SWAP: /* swap */
+		case FS_SWAP:
 			type = "swap";
 			break;
 		case FS_BSDFFS:
@@ -372,6 +359,25 @@ decode_dlabel(struct disk *d, char *iobu
 	}
 	d->dlabel = allocaligned(sizeof(struct disklabel), 4);
 	memcpy(d->dlabel, dlp, sizeof(struct disklabel));
+	return;
+  notfound:
+	d->dlabel = NULL;
+	printf("%s: no disklabel\n", d->xname);
+	return;
+}
+
+struct disklabel *
+search_dmagic(char *dp)
+{
+	int i;
+	struct disklabel *dlp;
+
+	for (i = 0; i < 512 - sizeof(struct disklabel); i += 4, dp += 4) {
+		dlp = (struct disklabel *)dp;
+		if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC)
+			return dlp;
+	}
+	return NULL;
 }
 
 static void



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

2012-04-08 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Apr  8 10:38:34 UTC 2012

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

Log Message:
Add an entry for Terastation TGL miconv2 satellite processor which
features a more complex protocol than Linkstation/Kurobox.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.27 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.28
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.27	Sat Jan 14 22:36:54 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Apr  8 10:38:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.27 2012/01/14 22:36:54 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.28 2012/04/08 10:38:34 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -56,6 +56,7 @@ BRD_DECL(qnap);
 BRD_DECL(iomega);
 BRD_DECL(dlink);
 BRD_DECL(nhnas);
+BRD_DECL(kurot4);
 
 static void brdfixup(void);
 static void setup(void);
@@ -170,6 +171,13 @@ static struct brdprop brdlist[] = {
 	"eumb", 0x4500, 9600,
 	NULL, nhnasbrdfix, NULL, nhnasreset },
 {
+	"miconv2",
+	"KuroBox/T4",
+	BRD_KUROBOXT4,
+	0,
+	"eumb", 0x4600, 57600,
+	kurot4setup, kurot4brdfix, NULL, NULL },
+{
 	"unknown",
 	"Unknown board",
 	BRD_UNKNOWN,
@@ -207,7 +215,7 @@ brdsetup(void)
 	char *consname;
 	int consport;
 	uint32_t extclk;
-	unsigned pchb, pcib, dev11, dev13, dev15, dev16, val;
+	unsigned pchb, pcib, dev11, dev12, dev13, dev15, dev16, val;
 	extern struct btinfo_memory bi_mem;
 	extern struct btinfo_console bi_cons;
 	extern struct btinfo_clock bi_clk;
@@ -229,6 +237,7 @@ brdsetup(void)
 	busclock = 0;
 
 	dev11 = pcimaketag(0, 11, 0);
+	dev12 = pcimaketag(0, 12, 0);
 	dev13 = pcimaketag(0, 13, 0);
 	dev15 = pcimaketag(0, 15, 0);
 	dev16 = pcimaketag(0, 16, 0);
@@ -243,7 +252,10 @@ brdsetup(void)
 	}
 	else if (PCI_CLASS(pcicfgread(dev11, PCI_CLASS_REG)) == PCI_CLASS_ETH) {
 		/* ADMtek AN985 (tlp) or RealTek 8169S (re) at dev 11 */
-		brdtype = BRD_KUROBOX;
+		if (PCI_VENDOR(pcicfgread(dev12, PCI_ID_REG)) != 0x1095)
+			brdtype = BRD_KUROBOX;
+		else
+			brdtype = BRD_KUROBOXT4;
 	}
 	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x11ab) {
 		/* SKnet/Marvell (sk) at dev 15 */
@@ -764,6 +776,23 @@ nhnasreset()
 }
 
 void
+kurot4setup(struct brdprop *brd)
+{
+
+	if (PCI_VENDOR(pcicfgread(pcimaketag(0, 11, 0), PCI_ID_REG)) == 0x10ec)
+		brd->extclk = 32768000; /* decr 2457600Hz */
+	else
+		brd->extclk = 32521333; /* decr 2439100Hz */
+}
+
+void
+kurot4brdfix(struct brdprop *brd)
+{
+
+	init_uart(uart2base, 38400, LCR_8BITS | LCR_PEVEN);
+}
+
+void
 _rtt(void)
 {
 	uint32_t msr;

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.16 src/sys/arch/sandpoint/stand/altboot/globals.h:1.17
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.16	Sun Jan 22 13:08:16 2012
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Apr  8 10:38:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.16 2012/01/22 13:08:16 phx Exp $ */
+/* $NetBSD: globals.h,v 1.17 2012/04/08 10:38:34 nisimura Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -22,6 +22,7 @@ extern int brdtype;
 #define BRD_STORCENTER		103
 #define BRD_DLINKDSM		104
 #define BRD_NH230NAS		105
+#define BRD_KUROBOXT4		106
 #define BRD_UNKNOWN		-1
 
 struct brdprop {



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

2012-01-22 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jan 22 13:16:54 UTC 2012

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

Log Message:
Cleanup in perform_atareset().


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.13 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.14
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.13	Sun Jan 22 13:08:16 2012
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Sun Jan 22 13:16:54 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.13 2012/01/22 13:08:16 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.14 2012/01/22 13:16:54 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -179,19 +179,14 @@ int
 perform_atareset(struct dkdev_ata *l, int n)
 {
 	struct dvata_chan *chan = &l->chan[n];
-//	int retries;
 
-//	for (retries = 0; retries < 10; retries++) {
-		CSR_WRITE_1(chan->ctl, ATA_DREQ);
-		delay(10);
-		CSR_WRITE_1(chan->ctl, ATA_SRST|ATA_DREQ);
-		delay(10);
-		CSR_WRITE_1(chan->ctl, ATA_DREQ);
-//		if (spinwait_unbusy(l, n, 1000/*250*/, NULL) != 0)
-//			return 1;
-//		delay(1000 * 1000);
-//	}
-	return spinwait_unbusy(l, n, 1000/*250*/, NULL);
+	CSR_WRITE_1(chan->ctl, ATA_DREQ);
+	delay(10);
+	CSR_WRITE_1(chan->ctl, ATA_SRST|ATA_DREQ);
+	delay(10);
+	CSR_WRITE_1(chan->ctl, ATA_DREQ);
+
+	return spinwait_unbusy(l, n, 1000, NULL);
 }
 
 /* clear idle and standby timers to spin up the drive */



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

2012-01-22 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jan 22 13:08:17 UTC 2012

Modified Files:
src/sys/arch/sandpoint/stand/altboot: dsk.c globals.h main.c pciide.c
siisata.c version

Log Message:
Support PATA drive configuration option (ide:N[N...]).
Wait until drives are ready after cold-start.
Wake up drives from standby mode.
A default command line can be saved to flash as initrd image.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/altboot/pciide.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/siisata.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.12 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.13
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.12	Thu Jan 19 07:38:05 2012
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Sun Jan 22 13:08:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.12 2012/01/19 07:38:05 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.13 2012/01/22 13:08:16 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -179,34 +179,46 @@ int
 perform_atareset(struct dkdev_ata *l, int n)
 {
 	struct dvata_chan *chan = &l->chan[n];
+//	int retries;
 
-	CSR_WRITE_1(chan->ctl, ATA_DREQ);
-	delay(10);
-	CSR_WRITE_1(chan->ctl, ATA_SRST|ATA_DREQ);
-	delay(10);
-	CSR_WRITE_1(chan->ctl, ATA_DREQ);
+//	for (retries = 0; retries < 10; retries++) {
+		CSR_WRITE_1(chan->ctl, ATA_DREQ);
+		delay(10);
+		CSR_WRITE_1(chan->ctl, ATA_SRST|ATA_DREQ);
+		delay(10);
+		CSR_WRITE_1(chan->ctl, ATA_DREQ);
+//		if (spinwait_unbusy(l, n, 1000/*250*/, NULL) != 0)
+//			return 1;
+//		delay(1000 * 1000);
+//	}
+	return spinwait_unbusy(l, n, 1000/*250*/, NULL);
+}
+
+/* clear idle and standby timers to spin up the drive */
+void
+wakeup_drive(struct dkdev_ata *l, int n)
+{
+	struct dvata_chan *chan = &l->chan[n];
 
-	return spinwait_unbusy(l, n, 250, NULL);
+	CSR_WRITE_1(chan->cmd + _NSECT, 0);
+	CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_IDLE);
+	(void)CSR_READ_1(chan->alt);
+	delay(10 * 1000);
+	CSR_WRITE_1(chan->cmd + _NSECT, 0);
+	CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_STANDBY);
+	(void)CSR_READ_1(chan->alt);
+	delay(10 * 1000);
 }
 
 int
-satapresense(struct dkdev_ata *l, int n)
+atachkpwr(struct dkdev_ata *l, int n)
 {
-#define VND_CH(n) (((n&02)<<8)+((n&01)<<7))
-#define VND_SC(n) (0x100+VND_CH(n))
-#define VND_SS(n) (0x104+VND_CH(n))
-
-	uint32_t sc = l->bar[5] + VND_SC(n);
-	uint32_t ss = l->bar[5] + VND_SS(n);
-	unsigned val;
-
-	val = (00 << 4) | (03 << 8);	/* any speed, no pwrmgt */
-	CSR_WRITE_4(sc, val | 01);	/* perform init */
-	delay(50 * 1000);
-	CSR_WRITE_4(sc, val);
-	delay(50 * 1000);	
-	val = CSR_READ_4(ss);		/* has completed */
-	return ((val & 03) == 03);	/* active drive found */
+	struct dvata_chan *chan = &l->chan[n];
+
+	CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_CHKPWR);
+	(void)CSR_READ_1(chan->alt);
+	delay(10 * 1000);
+	return CSR_READ_1(chan->cmd + _NSECT);
 }
 
 static int

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.15 src/sys/arch/sandpoint/stand/altboot/globals.h:1.16
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.15	Sat Jan  7 19:57:49 2012
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Jan 22 13:08:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.15 2012/01/07 19:57:49 phx Exp $ */
+/* $NetBSD: globals.h,v 1.16 2012/01/22 13:08:16 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -42,6 +42,7 @@ extern uint32_t cpuclock, busclock;
 
 /* board specific support code */
 struct brdprop *brd_lookup(int);
+int get_drive_config(int);
 int tstchar(void);
 #ifdef DEBUG
 void sat_write(char *, int);
@@ -177,16 +178,23 @@ DSK_DECL(siisata);
 #define ATA_STS_DRDY		0x40
 #define ATA_STS_ERR 		0x01
 /* command */
+#define ATA_CMD_CHKPWR		0xe5
 #define ATA_CMD_IDENT		0xec
+#define ATA_CMD_IDLE		0xe3
 #define ATA_CMD_READ		0x20
 #define ATA_CMD_READ_EXT	0x24
 #define ATA_CMD_SETF		0xef
+#define ATA_CMD_STANDBY		0xe2
 /* device */
 #define ATA_DEV_LBA		0xe0
 #define ATA_DEV_OBS		0x90
 /* control */
 #define ATA_DREQ		0x08
 #define ATA_SRST		0x04
+/* power state */
+#define ATA_PWR_ACTIVE		0xff
+#define ATA_PWR_IDLE		0x80
+#define ATA_PWR_STANDBY		0x00
 
 #define ATA_XFER		0x03
 #define XFER_PIO4		0x0c
@@ -229,4 +237,5 @@ struct disk {
 
 int spinwait_unbusy(struct dkdev_ata *, int, int, const char **);
 int perform_atareset(struct dkdev_ata *, int);
-int satapresense(struct dkdev_ata *, int);
+void wakeup_drive(struct dkdev_ata *, int);
+int atachkpwr(struc

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

2012-01-14 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jan 14 22:36:54 UTC 2012

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

Log Message:
Netronics is spelled Netronix.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/README.altboot
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sandpoint/stand/altboot/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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.8 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.9
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.8	Sat Jan 14 20:16:53 2012
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Sat Jan 14 22:36:54 2012
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.8 2012/01/14 20:16:53 phx Exp $
+$NetBSD: README.altboot,v 1.9 2012/01/14 22:36:54 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -44,7 +44,7 @@ Altboot is known working on at least the
 
U-Boot 1.0.0 (Sep  2 2005 - 14:49:11)
 
-- Netronics NH230/231 and compatible with restricted vendor custom PPCboot
+- Allnet 6250 and compatible with restricted vendor custom PPCboot
 
PPCBoot 2.0.0-A9 (Feb 13 2006 - 14:56:11)
 

Index: src/sys/arch/sandpoint/stand/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.26 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.27
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.26	Sat Jan 14 20:03:11 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Jan 14 22:36:54 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.26 2012/01/14 20:03:11 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.27 2012/01/14 22:36:54 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -164,7 +164,7 @@ static struct brdprop brdlist[] = {
 	NULL, dlinkbrdfix, NULL, NULL },
 {
 	"nhnas",
-	"Netronics NH230/231",
+	"Netronix NH-230/231",
 	BRD_NH230NAS,
 	3300,
 	"eumb", 0x4500, 9600,



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

2012-01-14 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jan 14 20:16:53 UTC 2012

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
Add NH230 PPCboot version.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/README.altboot

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.7 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.8
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.7	Sun Jan  1 14:16:41 2012
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Sat Jan 14 20:16:53 2012
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.7 2012/01/01 14:16:41 phx Exp $
+$NetBSD: README.altboot,v 1.8 2012/01/14 20:16:53 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -44,6 +44,10 @@ Altboot is known working on at least the
 
U-Boot 1.0.0 (Sep  2 2005 - 14:49:11)
 
+- Netronics NH230/231 and compatible with restricted vendor custom PPCboot
+
+   PPCBoot 2.0.0-A9 (Feb 13 2006 - 14:56:11)
+
 The standard use of altboot is to invoke it with a short script from
 U-Boot/PPCboot, where the altboot.bin image is stored in an unoccupied 128KB
 section of the target's HW NOR flash.  Combined with standard



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

2012-01-14 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jan 14 20:03:12 UTC 2012

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c entry.S

Log Message:
Add 0x7000 BAT-mapping for NH230/231.
NH23x: Initialize LEDs on startup (status off, to indicate the bootloader
is running). Hardware reset routine.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/entry.S

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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.25 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.26
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.25	Sun Jan  8 14:53:54 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Jan 14 20:03:11 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.25 2012/01/08 14:53:54 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.26 2012/01/14 20:03:11 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,6 +57,60 @@ BRD_DECL(iomega);
 BRD_DECL(dlink);
 BRD_DECL(nhnas);
 
+static void brdfixup(void);
+static void setup(void);
+static void send_iomega(int, int, int, int, int, int);
+static inline uint32_t mfmsr(void);
+static inline void mtmsr(uint32_t);
+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 *);
+static unsigned mpc107memsize(void);
+
+/* UART registers */
+#define RBR		0
+#define THR		0
+#define DLB		0
+#define DMB		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  LSR_THRE	0x20
+#define  LSR_DRDY	0x01
+#define DCR		0x11
+#define UART_READ(base, r)	in8(base + (r))
+#define UART_WRITE(base, r, v)	out8(base + (r), (v))
+
+/* MPC106 and MPC824x PCI bridge memory configuration */
+#define MPC106_MEMSTARTADDR1	0x80
+#define MPC106_EXTMEMSTARTADDR1	0x88
+#define MPC106_MEMENDADDR1	0x90
+#define MPC106_EXTMEMENDADDR1	0x98
+#define MPC106_MEMEN		0xa0
+
+/* Iomega StorCenter MC68HC908 microcontroller data packet */
+#define IOMEGA_POWER		0
+#define IOMEGA_LED		1
+#define IOMEGA_FLASH_RATE	2
+#define IOMEGA_FAN		3
+#define IOMEGA_HIGH_TEMP	4
+#define IOMEGA_LOW_TEMP		5
+#define IOMEGA_ID		6
+#define IOMEGA_CHECKSUM		7
+#define IOMEGA_PACKETSIZE	8
+
+/* NH230/231 GPIO */
+#define NHGPIO_WRITE(x)		*((uint8_t *)0x7000) = x
+
 static struct brdprop brdlist[] = {
 {
 	"sandpoint",
@@ -78,7 +132,7 @@ static struct brdprop brdlist[] = {
 	BRD_KUROBOX,
 	0,
 	"eumb", 0x4600, 57600,
-	kurosetup, kurobrdfix, NULL, NULL },
+	kurosetup, kurobrdfix, NULL, kuroreset },
 {
 	"synology",
 	"Synology DS",
@@ -114,7 +168,7 @@ static struct brdprop brdlist[] = {
 	BRD_NH230NAS,
 	3300,
 	"eumb", 0x4500, 9600,
-	NULL, nhnasbrdfix, NULL, NULL },
+	NULL, nhnasbrdfix, NULL, nhnasreset },
 {
 	"unknown",
 	"Unknown board",
@@ -124,63 +178,14 @@ static struct brdprop brdlist[] = {
 	NULL, NULL, NULL, NULL }, /* must be the last */
 };
 
-/* MPC106 and MPC824x PCI bridge memory configuration */
-#define MPC106_MEMSTARTADDR1	0x80
-#define MPC106_EXTMEMSTARTADDR1	0x88
-#define MPC106_MEMENDADDR1	0x90
-#define MPC106_EXTMEMENDADDR1	0x98
-#define MPC106_MEMEN		0xa0
-
-/* Iomega StorCenter MC68HC908 microcontroller data packet */
-#define IOMEGA_POWER		0
-#define IOMEGA_LED		1
-#define IOMEGA_FLASH_RATE	2
-#define IOMEGA_FAN		3
-#define IOMEGA_HIGH_TEMP	4
-#define IOMEGA_LOW_TEMP		5
-#define IOMEGA_ID		6
-#define IOMEGA_CHECKSUM		7
-#define IOMEGA_PACKETSIZE	8
-
 static struct brdprop *brdprop;
 static uint32_t ticks_per_sec, ns_per_tick;
 
-static void brdfixup(void);
-static void setup(void);
-static void send_iomega(int, int, int, int, int, int);
-static inline uint32_t mfmsr(void);
-static inline void mtmsr(uint32_t);
-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 *);
-static unsigned mpc107memsize(void);
-
 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 */
-#define RBR		0
-#define THR		0
-#define DLB		0
-#define DMB		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  LSR_THRE	0x20
-#define  LSR_DRDY	0x01
-#define DCR		0x11
-#define UART_READ(base, r)	in8(base + (r))
-#define UART_WRITE(base, r, v)	out8(base + (r),

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

2012-01-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jan  8 14:53:54 UTC 2012

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

Log Message:
Set the extclk for NH230 to 3300Hz.
Prepare a synosetup() function which should set a different extclk for
the 400MHz models, as soon as we find a method to check for them.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.24 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.25
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.24	Sat Jan  7 19:57:49 2012
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Jan  8 14:53:54 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.24 2012/01/07 19:57:49 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.25 2012/01/08 14:53:54 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -76,17 +76,16 @@ static struct brdprop brdlist[] = {
 	"kurobox",
 	"KuroBox",
 	BRD_KUROBOX,
-	32768000,
+	0,
 	"eumb", 0x4600, 57600,
 	kurosetup, kurobrdfix, NULL, NULL },
 {
 	"synology",
 	"Synology DS",
 	BRD_SYNOLOGY,
-	33164691,	/* from Synology/Linux source*/
-			/* XXX should be 33165343 for the CS-406 */
+	0,
 	"eumb", 0x4500, 115200,
-	NULL, synobrdfix, NULL, synoreset },
+	synosetup, synobrdfix, NULL, synoreset },
 {
 	"qnap",
 	"QNAP TS",
@@ -113,7 +112,7 @@ static struct brdprop brdlist[] = {
 	"nhnas",
 	"Netronics NH230/231",
 	BRD_NH230NAS,
-	0,
+	3300,
 	"eumb", 0x4500, 9600,
 	NULL, nhnasbrdfix, NULL, NULL },
 {
@@ -664,6 +663,16 @@ kurobrdfix(struct brdprop *brd)
 }
 
 void
+synosetup(struct brdprop *brd)
+{
+
+	if (1) /* 200 and 266MHz models */
+		brd->extclk = 33164691; /* from Synology/Linux source */
+	else   /* 400MHz models XXX how to check? */
+		brd->extclk = 33165343;
+}
+
+void
 synobrdfix(struct brdprop *brd)
 {
 



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

2012-01-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Jan  7 19:57:49 UTC 2012

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

Log Message:
NH230 PPCBoot configures the memory boundary registers for 128MB, although
the board has only 64MB. Fix that.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.23 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.24
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.23	Sat Nov 12 23:52:54 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Jan  7 19:57:49 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.23 2011/11/12 23:52:54 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.24 2012/01/07 19:57:49 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -125,6 +125,13 @@ static struct brdprop brdlist[] = {
 	NULL, NULL, NULL, NULL }, /* must be the last */
 };
 
+/* MPC106 and MPC824x PCI bridge memory configuration */
+#define MPC106_MEMSTARTADDR1	0x80
+#define MPC106_EXTMEMSTARTADDR1	0x88
+#define MPC106_MEMENDADDR1	0x90
+#define MPC106_EXTMEMENDADDR1	0x98
+#define MPC106_MEMEN		0xa0
+
 /* Iomega StorCenter MC68HC908 microcontroller data packet */
 #define IOMEGA_POWER		0
 #define IOMEGA_LED		1
@@ -148,6 +155,7 @@ 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 *);
+static unsigned mpc107memsize(void);
 
 const unsigned dcache_line_size = 32;		/* 32B linesize */
 const unsigned dcache_range_size = 4 * 1024;	/* 16KB / 4-way */
@@ -1002,8 +1010,49 @@ tstchar(void)
 	return (UART_READ(uart1base, LSR) & LSR_DRDY) != 0;
 }
 
-unsigned
-mpc107memsize()
+#define SAR_MASK 0x0ff0
+#define SAR_SHIFT20
+#define EAR_MASK 0x3000
+#define EAR_SHIFT28
+#define AR(v, s) v) & SAR_MASK) >> SAR_SHIFT) << (s))
+#define XR(v, s) v) & EAR_MASK) >> EAR_SHIFT) << (s))
+static void
+set_mem_bounds(unsigned tag, unsigned bk_en, ...)
+{
+	unsigned mbst, mbxst, mben, mbxen;
+	unsigned start, end;
+	va_list ap;
+	int i, sh;
+
+	va_start(ap, bk_en);
+	mbst = mbxst = mben = mbxen = 0;
+
+	for (i = 0; i < 4; i++) {
+		if ((bk_en & (1U << i)) != 0) {
+			start = va_arg(ap, unsigned);
+			end = va_arg(ap, unsigned);
+		} else {
+			start = 0x3ff0;
+			end = 0x3fff;
+		}
+		sh = i << 3;
+		mbst |= AR(start, sh);
+		mbxst |= XR(start, sh);
+		mben |= AR(end, sh);
+		mbxen |= XR(end, sh);
+	}
+	va_end(ap);
+
+	pcicfgwrite(tag, MPC106_MEMSTARTADDR1, mbst);
+	pcicfgwrite(tag, MPC106_EXTMEMSTARTADDR1, mbxst);
+	pcicfgwrite(tag, MPC106_MEMENDADDR1, mben);
+	pcicfgwrite(tag, MPC106_EXTMEMENDADDR1,	mbxen);
+	pcicfgwrite(tag, MPC106_MEMEN,
+	(pcicfgread(tag, MPC106_MEMEN) & ~0xff) | (bk_en & 0xff));
+}
+
+static unsigned
+mpc107memsize(void)
 {
 	unsigned bankn, end, n, tag, val;
 
@@ -1011,37 +1060,13 @@ mpc107memsize()
 
 	if (brdtype == BRD_ENCOREPP1) {
 		/* the brd's PPCBOOT looks to have erroneous values */
-		unsigned tbl[] = {
-#define MPC106_MEMSTARTADDR1	0x80
-#define MPC106_EXTMEMSTARTADDR1	0x88
-#define MPC106_MEMENDADDR1	0x90
-#define MPC106_EXTMEMENDADDR1	0x98
-#define MPC106_MEMEN		0xa0
-#define	BK0_S	0x
-#define	BK0_E	(128 << 20) - 1
-#define BK1_S	0x3ff0
-#define BK1_E	0x3fff
-#define BK2_S	0x3ff0
-#define BK2_E	0x3fff
-#define BK3_S	0x3ff0
-#define BK3_E	0x3fff
-#define AR(v, s) v) & SAR_MASK) >> SAR_SHIFT) << (s))
-#define XR(v, s) v) & EAR_MASK) >> EAR_SHIFT) << (s))
-#define SAR_MASK 0x0ff0
-#define SAR_SHIFT20
-#define EAR_MASK 0x3000
-#define EAR_SHIFT28
-		AR(BK0_S, 0) | AR(BK1_S, 8) | AR(BK2_S, 16) | AR(BK3_S, 24),
-		XR(BK0_S, 0) | XR(BK1_S, 8) | XR(BK2_S, 16) | XR(BK3_S, 24),
-		AR(BK0_E, 0) | AR(BK1_E, 8) | AR(BK2_E, 16) | AR(BK3_E, 24),
-		XR(BK0_E, 0) | XR(BK1_E, 8) | XR(BK2_E, 16) | XR(BK3_E, 24),
-		};
-		tag = pcimaketag(0, 0, 0);
-		pcicfgwrite(tag, MPC106_MEMSTARTADDR1, tbl[0]);
-		pcicfgwrite(tag, MPC106_EXTMEMSTARTADDR1, tbl[1]);
-		pcicfgwrite(tag, MPC106_MEMENDADDR1, tbl[2]);
-		pcicfgwrite(tag, MPC106_EXTMEMENDADDR1,	tbl[3]);
-		pcicfgwrite(tag, MPC106_MEMEN, 1);
+		set_mem_bounds(tag, 1, 0x, (128 << 20) - 1);
+	} else if (brdtype == BRD_NH230NAS) {
+		/*
+		 * PPCBoot sets the end address to 0x7ff, although the
+		 * board has just 64MB (0x3ff).
+		 */
+		set_mem_bounds(tag, 1, 0x, 0x03ff);
 	}
 
 	bankn = 0;
@@ -1051,7 +1076,7 @@ mpc107memsize()
 			break;
 		bankn = n;
 	}
-	bankn = bankn * 8;
+	bankn <<= 3;
 
 	val = pcicfgread(tag, MPC106_EXTMEMENDADDR1);
 	end =  ((val >> bankn) & 0x03) << 28;

Index: src/sys/

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

2012-01-01 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jan  1 18:25:03 UTC 2012

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

Log Message:
Handle devices with two network interfaces (e.g. a DSM-G600 with stge(4)
and ath(4)).


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.15 src/sys/arch/sandpoint/stand/altboot/main.c:1.16
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.15	Sun Nov  6 20:20:57 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Jan  1 18:25:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.15 2011/11/06 20:20:57 phx Exp $ */
+/* $NetBSD: main.c,v 1.16 2012/01/01 18:25:03 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@ extern char bootprog_name[], bootprog_re
 extern char newaltboot[], newaltboot_end[];
 
 struct pcidev lata[2];
-struct pcidev lnif[1];
+struct pcidev lnif[2];
 struct pcidev lusb[3];
 int nata, nnif, nusb;
 
@@ -137,7 +137,7 @@ main(int argc, char *argv[], char *boota
 		nata = pcilookup(PCI_CLASS_MISCSTORAGE, lata, 2);
 	if (nata == 0)
 		nata = pcilookup(PCI_CLASS_SCSI, lata, 2);
-	nnif = pcilookup(PCI_CLASS_ETH, lnif, 1);
+	nnif = pcilookup(PCI_CLASS_ETH, lnif, 2);
 	nusb = pcilookup(PCI_CLASS_USB, lusb, 3);
 
 #ifdef DEBUG
@@ -153,10 +153,10 @@ main(int argc, char *argv[], char *boota
 	}
 	if (nnif == 0)
 		printf("no NET found\n");
-	else {
+	else for (n = 0; n < nnif; n++) {
 		int b, d, f, bdf, pvd;
-		bdf = lnif[0].bdf;
-		pvd = lnif[0].pvd;
+		bdf = lnif[n].bdf;
+		pvd = lnif[n].pvd;
 		pcidecomposetag(bdf, &b, &d, &f);
 		printf("%04x.%04x NET %02d:%02d:%02d\n",
 		PCI_VENDOR(pvd), PCI_PRODUCT(pvd), b, d, f);
@@ -176,11 +176,18 @@ main(int argc, char *argv[], char *boota
 	pcisetup();
 	pcifixup();
 
-	if (dskdv_init(&lata[0]) == 0
-	|| (nata == 2 && dskdv_init(&lata[1]) == 0))
+	/* intialize a disk driver */
+	for (n = 0; n < nata; n++)
+		if (dskdv_init(&lata[n]) != 0)
+			break;
+	if (n >= nata)
 		printf("IDE/SATA device driver was not found\n");
 
-	if (netif_init(&lnif[0]) == 0)
+	/* initialize a network interface */
+	for (n = 0; n < nnif; n++)
+		if (netif_init(&lnif[n]) != 0)
+			break;
+	if (n >= nnif)
 		printf("no NET device driver was found\n");
 
 	/*



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

2012-01-01 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Jan  1 14:16:41 UTC 2012

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
Add Iomega StorCenter.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/README.altboot

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.6 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.7
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.6	Sun Nov 13 16:22:18 2011
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Sun Jan  1 14:16:41 2012
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.6 2011/11/13 16:22:18 phx Exp $
+$NetBSD: README.altboot,v 1.7 2012/01/01 14:16:41 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -19,8 +19,8 @@ NetBSD kernels.
 
 Altboot is known working on at least these models:
 
-- KuroBox or LinkStation with a popular U-Boot as the replacement of
-  vendor proprietary
+- KuroBox or LinkStation with a popular U-Boot as replacement of
+  the vendor's proprietary one
 
U-Boot 1.1.4 LiSt 2.1.0 (Sep 21 2006 - 00:22:56) LinkStation / KuroBox
 
@@ -40,6 +40,10 @@ Altboot is known working on at least the
 
U-Boot 1.1.2 (Aug 28 2005 - 13:37:25) QNAP System, Inc.
 
+- Iomega StorCenter with vendor custom U-Boot
+
+   U-Boot 1.0.0 (Sep  2 2005 - 14:49:11)
+
 The standard use of altboot is to invoke it with a short script from
 U-Boot/PPCboot, where the altboot.bin image is stored in an unoccupied 128KB
 section of the target's HW NOR flash.  Combined with standard
@@ -52,7 +56,7 @@ In case the firmware was crippled by the
 Linux U-Boot images (D-Link), you can still use altboot by uploading
 altboot.img instead of the Linux kernel.
 
-Altboot hands the following bootinfo records to the NetBSD/sandpoint
+Altboot passes the following bootinfo records to the NetBSD/sandpoint
 kernel.
 - processor clock tick value driving MPC8241/8245.
 - serial console selection.



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

2011-11-13 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Nov 13 16:22:18 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
Add DS-106j.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/README.altboot

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.5 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.6
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.5	Thu Jun  2 16:41:32 2011
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Sun Nov 13 16:22:18 2011
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.5 2011/06/02 16:41:32 phx Exp $
+$NetBSD: README.altboot,v 1.6 2011/11/13 16:22:18 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -28,7 +28,7 @@ Altboot is known working on at least the
 
PPCBoot 2.0.0 (Mar  1 2005 - 15:31:41)
 
-- Synology 207, 407e with vendor custom PPCboot
+- Synology 106j, 207, 407e with vendor custom PPCboot
 
PPCBoot 2.0.0 (Jan 30 2007 - xx:xx:xx)
 



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

2011-11-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Nov 13 00:06:54 UTC 2011

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

Log Message:
Make the chipfix() functions return void instead of int, as the return
value is useless. Suggested by nisimura.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/stand/altboot/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/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.10 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.11
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.10	Sat Nov 12 16:56:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Sun Nov 13 00:06:54 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.10 2011/11/12 16:56:12 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.11 2011/11/13 00:06:54 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -35,14 +35,14 @@
 
 #include "globals.h"
 
-static int cmdidefix(struct dkdev_ata *);
-static int apoidefix(struct dkdev_ata *);
-static int iteidefix(struct dkdev_ata *);
+static void cmdidefix(struct dkdev_ata *);
+static void apoidefix(struct dkdev_ata *);
+static void iteidefix(struct dkdev_ata *);
 
 static uint32_t pciiobase = PCI_XIOBASE;
 
 struct myops {
-	int (*chipfix)(struct dkdev_ata *);
+	void (*chipfix)(struct dkdev_ata *);
 	int (*presense)(struct dkdev_ata *, int);
 };
 static struct myops defaultops = { NULL, NULL };
@@ -93,8 +93,7 @@ pciide_init(unsigned tag, void *data)
 
 	/* chipset specific fixes */
 	if (myops->chipfix)
-		if (!(*myops->chipfix)(l))
-			return NULL;
+		(*myops->chipfix)(l);
 
 	val = pcicfgread(tag, PCI_CLASS_REG);
 	native = PCI_CLASS(val) != PCI_CLASS_IDE ||
@@ -142,7 +141,7 @@ pciide_init(unsigned tag, void *data)
 	return l;
 }
 
-static int
+static void
 cmdidefix(struct dkdev_ata *l)
 {
 	unsigned v;
@@ -155,11 +154,9 @@ cmdidefix(struct dkdev_ata *l)
 	pcicfgwrite(l->tag, 0xa4, (v & ~0x) | 0x328a);
 	v = pcicfgread(l->tag, 0xb4);
 	pcicfgwrite(l->tag, 0xb4, (v & ~0x) | 0x328a);
-
-	return 1;
 }
 
-static int
+static void
 apoidefix(struct dkdev_ata *l)
 {
 	unsigned v;
@@ -167,11 +164,9 @@ apoidefix(struct dkdev_ata *l)
 	/* enable primary and secondary channel */
 	v = pcicfgread(l->tag, 0x40) & ~0x03;
 	pcicfgwrite(l->tag, 0x40, v | 0x03);
-
-	return 1;
 }
 
-static int
+static void
 iteidefix(struct dkdev_ata *l)
 {
 	unsigned v;
@@ -183,6 +178,4 @@ iteidefix(struct dkdev_ata *l)
 	/* i/o configuration, enable channels, cables, IORDY */
 	v = pcicfgread(l->tag, 0x40);
 	pcicfgwrite(l->tag, 0x40, (v & ~0xff) | 0x36a0f3);
-
-	return 1;
 }



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

2011-11-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Nov 12 23:52:54 UTC 2011

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

Log Message:
Improved Iomega microcontroller support. Bumped version to 1.8.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.22 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.23
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.22	Mon Nov  7 21:11:55 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Nov 12 23:52:54 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.22 2011/11/07 21:11:55 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.23 2011/11/12 23:52:54 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -141,7 +141,7 @@ static uint32_t ticks_per_sec, ns_per_ti
 
 static void brdfixup(void);
 static void setup(void);
-static int send_iomega(int, int, int, int, int, int);
+static void send_iomega(int, int, int, int, int, int);
 static inline uint32_t mfmsr(void);
 static inline void mtmsr(uint32_t);
 static inline uint32_t cputype(void);
@@ -694,15 +694,15 @@ iomegabrdfix(struct brdprop *brd)
 {
 
 	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
-	/* LED flashing blue, fan auto, turn on at 60C, turn off at 50C */
-	(void)send_iomega('b', 'd', 2, 'a', 60, 50);
+	/* LED flashing blue, fan auto, turn on at 50C, turn off at 45C */
+	send_iomega('b', 'd', 2, 'a', 50, 45);
 }
 
 void
 iomegareset()
 {
 
-	(void)send_iomega('g', 0, 0, 0, 0, 0);
+	send_iomega('g', 0, 0, 0, 0, 0);
 	/*NOTREACHED*/
 }
 
@@ -901,7 +901,7 @@ iomega_debug(const char *txt, uint8_t bu
 }
 #endif /* DEBUG */
 
-static int
+static void
 send_iomega(int power, int led, int rate, int fan, int high, int low)
 {
 	uint8_t buf[IOMEGA_PACKETSIZE];
@@ -923,7 +923,7 @@ send_iomega(int power, int led, int rate
 	 */
 	do {
 		putchar(0);
-		delay(25000);
+		delay(5);
 	} while (!tstchar());
 
 	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
@@ -935,18 +935,12 @@ send_iomega(int power, int led, int rate
 #endif
 
 	/* send command */
-	if (power >= 0)
-		buf[IOMEGA_POWER] = power;
-	if (led >= 0)
-		buf[IOMEGA_LED] = led;
-	if (rate >= 0)
-		buf[IOMEGA_FLASH_RATE] = rate;
-	if (fan >= 0)
-		buf[IOMEGA_FAN] = fan;
-	if (high >= 0)
-		buf[IOMEGA_HIGH_TEMP] = high;
-	if (low >= 0)
-		buf[IOMEGA_LOW_TEMP] = low;
+	buf[IOMEGA_POWER] = power;
+	buf[IOMEGA_LED] = led;
+	buf[IOMEGA_FLASH_RATE] = rate;
+	buf[IOMEGA_FAN] = fan;
+	buf[IOMEGA_HIGH_TEMP] = high;
+	buf[IOMEGA_LOW_TEMP] = low;
 	buf[IOMEGA_ID] = 7;	/* host id */
 	buf[IOMEGA_CHECKSUM] = (buf[IOMEGA_POWER] + buf[IOMEGA_LED] +
 	buf[IOMEGA_FLASH_RATE] + buf[IOMEGA_FAN] +
@@ -963,12 +957,15 @@ send_iomega(int power, int led, int rate
 	/* receive the reply */
 	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
 		buf[i] = getchar();
-
-	uart1base = savedbase;
 #ifdef DEBUG
+	uart1base = savedbase;
 	iomega_debug("68HC908 reply", buf);
+	uart1base = uart2base;
 #endif
-	return buf[0] != '#';  /* error? */
+
+	if (buf[0] == '#')
+		goto again;  /* try again on error */
+	uart1base = savedbase;
 }
 
 void

Index: src/sys/arch/sandpoint/stand/altboot/version
diff -u src/sys/arch/sandpoint/stand/altboot/version:1.4 src/sys/arch/sandpoint/stand/altboot/version:1.5
--- src/sys/arch/sandpoint/stand/altboot/version:1.4	Sun Mar 13 15:23:43 2011
+++ src/sys/arch/sandpoint/stand/altboot/version	Sat Nov 12 23:52:54 2011
@@ -9,3 +9,5 @@
 1.7:	ST1023/IP1000A driver, load kernels from memory (mem:), possibility
 	to replace altboot with a new version while running, interactive
 	mode, default boot path is now wd0:netbsd in multiuser mode
+1.8:	Iomega support, IT821x & VT6410 IDE support, fixed interrupt
+	issue, exception handler and sat-controller test mode (DEBUG)



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

2011-11-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Nov 12 16:56:12 UTC 2011

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

Log Message:
Add support for IT821x IDE.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.10 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.11
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.10	Tue Nov  1 16:32:57 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Sat Nov 12 16:56:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.10 2011/11/01 16:32:57 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.11 2011/11/12 16:56:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -186,7 +186,7 @@ perform_atareset(struct dkdev_ata *l, in
 	delay(10);
 	CSR_WRITE_1(chan->ctl, ATA_DREQ);
 
-	return spinwait_unbusy(l, n, 150, NULL);
+	return spinwait_unbusy(l, n, 250, NULL);
 }
 
 int

Index: src/sys/arch/sandpoint/stand/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.9 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.10
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.9	Wed Nov  2 04:10:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Sat Nov 12 16:56:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.9 2011/11/02 04:10:33 nisimura Exp $ */
+/* $NetBSD: pciide.c,v 1.10 2011/11/12 16:56:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
 
 static int cmdidefix(struct dkdev_ata *);
 static int apoidefix(struct dkdev_ata *);
+static int iteidefix(struct dkdev_ata *);
 
 static uint32_t pciiobase = PCI_XIOBASE;
 
@@ -47,6 +48,7 @@ struct myops {
 static struct myops defaultops = { NULL, NULL };
 static struct myops cmdideops = { cmdidefix, NULL };
 static struct myops apoideops = { apoidefix, NULL };
+static struct myops iteideops = { iteidefix, NULL };
 static struct myops *myops;
 
 int
@@ -65,6 +67,8 @@ pciide_match(unsigned tag, void *data)
 		myops = &apoideops;
 		return 1;
 	case PCI_DEVICE(0x1283, 0x8211): /* ITE 8211 IDE */
+		myops = &iteideops;
+		return 1;
 	case PCI_DEVICE(0x10ad, 0x0105): /* Symphony Labs 82C105 IDE */
 	case PCI_DEVICE(0x10b8, 0x5229): /* ALi IDE */
 	case PCI_DEVICE(0x1191, 0x0008): /* ACARD ATP865 */
@@ -127,10 +131,10 @@ pciide_init(unsigned tag, void *data)
 	for (n = 0; n < 2; n++) {
 		if (myops->presense && (*myops->presense)(l, n) == 0)
 			l->presense[n] = 0; /* found not exist */
-		else {
+		else
 			/* check to see whether soft reset works */
 			l->presense[n] = perform_atareset(l, n);
-		}
+
 		if (l->presense[n])
 			printf("channel %d present\n", n);
 	}
@@ -166,3 +170,19 @@ apoidefix(struct dkdev_ata *l)
 
 	return 1;
 }
+
+static int
+iteidefix(struct dkdev_ata *l)
+{
+	unsigned v;
+
+	/* set PCI mode and 66Mhz reference clock, disable IT8212 RAID */
+	v = pcicfgread(l->tag, 0x50);
+	pcicfgwrite(l->tag, 0x50, v & ~0x83);
+
+	/* i/o configuration, enable channels, cables, IORDY */
+	v = pcicfgread(l->tag, 0x40);
+	pcicfgwrite(l->tag, 0x40, (v & ~0xff) | 0x36a0f3);
+
+	return 1;
+}



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

2011-11-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Nov  7 21:11:56 UTC 2011

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

Log Message:
Fixed Iomega microcontroller support. Implemented Iomega reboot function.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.21 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.22
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.21	Sun Nov  6 20:20:57 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Nov  7 21:11:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.21 2011/11/06 20:20:57 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.22 2011/11/07 21:11:55 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@ static struct brdprop brdlist[] = {
 	BRD_STORCENTER,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, iomegabrdfix, NULL, NULL },
+	NULL, iomegabrdfix, NULL, iomegareset },
 {
 	"dlink",
 	"D-Link DSM-G600",
@@ -141,7 +141,7 @@ static uint32_t ticks_per_sec, ns_per_ti
 
 static void brdfixup(void);
 static void setup(void);
-static int send_iomega(int, int, int, int, int, int, uint8_t *);
+static int send_iomega(int, int, int, int, int, int);
 static inline uint32_t mfmsr(void);
 static inline void mtmsr(uint32_t);
 static inline uint32_t cputype(void);
@@ -694,8 +694,16 @@ iomegabrdfix(struct brdprop *brd)
 {
 
 	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
-	/* illuminate LEDs */
-	if (0) (void)send_iomega('b', 'd', 2, 'a', 60, 50, NULL);
+	/* LED flashing blue, fan auto, turn on at 60C, turn off at 50C */
+	(void)send_iomega('b', 'd', 2, 'a', 60, 50);
+}
+
+void
+iomegareset()
+{
+
+	(void)send_iomega('g', 0, 0, 0, 0, 0);
+	/*NOTREACHED*/
 }
 
 void
@@ -880,44 +888,87 @@ send_sat(char *msg)
 	uart1base = savedbase;
 }
 
+#ifdef DEBUG
+static void
+iomega_debug(const char *txt, uint8_t buf[])
+{
+	int i;
+
+	printf("%s:", txt);
+	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
+		printf(" %02x", buf[i]);
+	putchar('\n');
+}
+#endif /* DEBUG */
+
 static int
-send_iomega(int power, int led, int rate, int fan, int high, int low,
-uint8_t *st)
+send_iomega(int power, int led, int rate, int fan, int high, int low)
 {
-	unsigned i, savedbase;
-	static uint8_t cur_state[IOMEGA_PACKETSIZE];
 	uint8_t buf[IOMEGA_PACKETSIZE];
+	unsigned i, savedbase;
 
-	buf[IOMEGA_POWER] =
-	power >= 0 ? power : cur_state[IOMEGA_POWER];
-	buf[IOMEGA_LED] =
-	led >= 0 ? led : cur_state[IOMEGA_LED];
-	buf[IOMEGA_FLASH_RATE] =
-	rate >= 0 ? rate : cur_state[IOMEGA_FLASH_RATE];
-	buf[IOMEGA_FAN] =
-	fan >= 0 ? fan : cur_state[IOMEGA_FAN];
-	buf[IOMEGA_HIGH_TEMP] =
-	high >= 0 ? high : cur_state[IOMEGA_HIGH_TEMP];
-	buf[IOMEGA_LOW_TEMP] =
-	low >= 0 ? low : cur_state[IOMEGA_LOW_TEMP];
+	savedbase = uart1base;
+	uart1base = uart2base;
+
+	/* first flush the receive buffer */
+  again:
+	while (tstchar())
+		(void)getchar();
+	delay(2);
+	if (tstchar())
+		goto again;
+	/*
+	 * Now synchronize the transmitter by sending 0x00
+	 * until we receive a status reply.
+	 */
+	do {
+		putchar(0);
+		delay(25000);
+	} while (!tstchar());
+
+	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
+		buf[i] = getchar();
+#ifdef DEBUG
+	uart1base = savedbase;
+	iomega_debug("68HC908 status", buf);
+	uart1base = uart2base;
+#endif
+
+	/* send command */
+	if (power >= 0)
+		buf[IOMEGA_POWER] = power;
+	if (led >= 0)
+		buf[IOMEGA_LED] = led;
+	if (rate >= 0)
+		buf[IOMEGA_FLASH_RATE] = rate;
+	if (fan >= 0)
+		buf[IOMEGA_FAN] = fan;
+	if (high >= 0)
+		buf[IOMEGA_HIGH_TEMP] = high;
+	if (low >= 0)
+		buf[IOMEGA_LOW_TEMP] = low;
 	buf[IOMEGA_ID] = 7;	/* host id */
 	buf[IOMEGA_CHECKSUM] = (buf[IOMEGA_POWER] + buf[IOMEGA_LED] +
 	buf[IOMEGA_FLASH_RATE] + buf[IOMEGA_FAN] +
 	buf[IOMEGA_HIGH_TEMP] + buf[IOMEGA_LOW_TEMP] +
 	buf[IOMEGA_ID]) & 0x7f;
-
-	savedbase = uart1base;
+#ifdef DEBUG
+	uart1base = savedbase;
+	iomega_debug("G2 sending", buf);
 	uart1base = uart2base;
+#endif
 	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
 		putchar(buf[i]);
+
+	/* receive the reply */
 	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
 		buf[i] = getchar();
-	uart1base = savedbase;
-	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
-		printf("%02x", buf[i]);
-	printf("\n");
 
-	return 0;
+	uart1base = savedbase;
+#ifdef DEBUG
+	iomega_debug("68HC908 reply", buf);
+#endif
+	return buf[0] != '#';  /* error? */
 }
 
 void



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

2011-11-06 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Nov  6 20:20:57 UTC 2011

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

Log Message:
Added a test terminal for communicating with the satellite microcontroller.
When compiled with DEBUG option it can be entered by typing 'C'.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.20 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.21
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.20	Tue Nov  1 16:32:57 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Nov  6 20:20:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.20 2011/11/01 16:32:57 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.21 2011/11/06 20:20:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -695,7 +695,7 @@ iomegabrdfix(struct brdprop *brd)
 
 	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
 	/* illuminate LEDs */
-	(void)send_iomega('b', 'd', 2, 'a', 60, 50, NULL);
+	if (0) (void)send_iomega('b', 'd', 2, 'a', 60, 50, NULL);
 }
 
 void
@@ -950,6 +950,7 @@ getchar(void)
 int
 tstchar(void)
 {
+
 	return (UART_READ(uart1base, LSR) & LSR_DRDY) != 0;
 }
 
@@ -1101,3 +1102,35 @@ read_mac_from_flash(uint8_t *mac)
 	/* set to 00:00:00:00:00:00 in case of error */
 	memset(mac, 0, 6);
 }
+
+#ifdef DEBUG
+void
+sat_write(char *p, int len)
+{
+	unsigned savedbase;
+
+	savedbase = uart1base;
+	uart1base = uart2base;
+	while (len--)
+		putchar(*p++);
+	uart1base = savedbase;
+}
+
+int
+sat_getch(void)
+{
+	unsigned lsr;
+
+	do {
+		lsr = UART_READ(uart2base, LSR);
+	} while ((lsr & LSR_DRDY) == 0);
+	return UART_READ(uart2base, RBR);
+}
+
+int
+sat_tstch(void)
+{
+
+	return (UART_READ(uart2base, LSR) & LSR_DRDY) != 0;
+}
+#endif /* DEBUG */

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.13 src/sys/arch/sandpoint/stand/altboot/globals.h:1.14
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.13	Sun Oct 30 21:08:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Nov  6 20:20:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.13 2011/10/30 21:08:33 phx Exp $ */
+/* $NetBSD: globals.h,v 1.14 2011/11/06 20:20:57 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -43,6 +43,11 @@ extern uint32_t cpuclock, busclock;
 /* board specific support code */
 struct brdprop *brd_lookup(int);
 int tstchar(void);
+#ifdef DEBUG
+void sat_write(char *, int);
+int sat_getch(void);
+int sat_tstch(void);
+#endif
 unsigned mpc107memsize(void);
 void read_mac_from_flash(uint8_t *);
 

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.14 src/sys/arch/sandpoint/stand/altboot/main.c:1.15
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.14	Mon Apr 25 18:29:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Nov  6 20:20:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.14 2011/04/25 18:29:33 phx Exp $ */
+/* $NetBSD: main.c,v 1.15 2011/11/06 20:20:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -106,6 +106,9 @@ static int check_bootname(char *);
 static int input_cmdline(char **, int);
 static int parse_cmdline(char **, int, char *, char *);
 static int is_space(char);
+#ifdef DEBUG
+static void sat_test(void);
+#endif
 
 #define	BNAME_DEFAULT "wd0:"
 #define MAX_ARGS 10
@@ -206,7 +209,17 @@ main(int argc, char *argv[], char *boota
 			printf("Hit any key to enter interactive mode: %d\r",
 			n / 100);
 		if (tstchar()) {
+#ifdef DEBUG
+			if (toupper(getchar()) == 'C') {
+/* controller test terminal */
+sat_test();
+n = 200;
+continue;
+			}
+#else
 			(void)getchar();
+#endif
+			/* enter command line */
 			argv = new_argv;
 			argc = input_cmdline(argv, MAX_ARGS);
 			break;
@@ -617,5 +630,60 @@ parse_cmdline(char **argv, int maxargc, 
 static int
 is_space(char c)
 {
+
 	return c > '\0' && c <= ' ';
 }
+
+#ifdef DEBUG
+static void
+sat_test(void)
+{
+	char buf[1024];
+	int i, j, n, pos;
+	unsigned char c;
+
+	putchar('\n');
+	for (;;) {
+		do {
+			for (pos = 0; pos < 1024 && sat_tstch() != 0; pos++)
+buf[pos] = sat_getch();
+			if (pos > 1023)
+break;
+			delay(10);
+		} while (sat_tstch());
+
+		for (i = 0; i < pos; i += 16) {
+			if ((n = i + 16) > pos)
+n = pos;
+			for (j = 0; j < n; j++)
+printf("%02x ", (unsigned)buf[i + j]);
+			for (; j < 16; j++)
+printf("   ");
+			putchar('\"');
+			for (j = 0; j < n; j++) {
+c = buf[i + j];
+putchar((c >= 0x20 && c <= 0x7e)

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

2011-11-01 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Nov  2 04:10:33 UTC 2011

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

Log Message:
VIA 82C586A/B 82C686A/B SouthBridges share PCI ID 0x1066-0571.
They are distinguishable by looking at PCI-ISA bridge PCI ID and
revision number.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/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/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.8 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.9
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.8	Tue Nov  1 16:32:57 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Wed Nov  2 04:10:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.8 2011/11/01 16:32:57 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.9 2011/11/02 04:10:33 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@ pciide_match(unsigned tag, void *data)
 	case PCI_DEVICE(0x1095, 0x0680): /* SiI 0680 IDE */
 		myops = &cmdideops;
 		return 1;
-	case PCI_DEVICE(0x1106, 0x0571): /* VIA 82C586A IDE */
+	case PCI_DEVICE(0x1106, 0x0571): /* VIA 82C586A/B/686A/B IDE */
 	case PCI_DEVICE(0x1106, 0x1571): /* VIA 82C586 IDE */
 	case PCI_DEVICE(0x1106, 0x3164): /* VIA VT6410 RAID IDE */
 		myops = &apoideops;



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

2011-11-01 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Nov  1 16:32:57 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c dsk.c pciide.c

Log Message:
The Apollo family of IDE interface chips has both channels disabled by
default, so we have to enable them in a new chipfix function. Also move
the channel enable code for the 82C686B from encpcifix() to pciide.c.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.19 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.20
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.19	Sun Oct 30 21:08:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Tue Nov  1 16:32:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.19 2011/10/30 21:08:33 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.20 2011/11/01 16:32:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -454,25 +454,20 @@ encpcifix(struct brdprop *brd)
 	/*
 	 *  IDE fixup 
 	 * - "native mode" (ide 0x09)
-	 * - use primary only (ide 0x40)
 	 */
+
 	/* ide: 0x09 - programming interface; 1000'SsPp */
 	val = pcicfgread(ide, 0x08) & 0x00ff;
 	pcicfgwrite(ide, 0x08, val | (0x8f << 8));
 
 	/* ide: 0x10-20 - leave them PCI memory space assigned */
-
-	/* ide: 0x40 - use primary only */
-	val = pcicfgread(ide, 0x40) &~ 03;
-	val |= 02;
-	pcicfgwrite(ide, 0x40, val);
 #else
 	/*
 	 *  IDE fixup 
 	 * - "compatiblity mode" (ide 0x09)
-	 * - use primary only (ide 0x40)
 	 * - remove PCI pin assignment (ide 0x3d)
 	 */
+
 	/* ide: 0x09 - programming interface; 1000'SsPp */
 	val = pcicfgread(ide, 0x08) & 0x00ff;
 	val |= (0x8a << 8);
@@ -480,22 +475,17 @@ encpcifix(struct brdprop *brd)
 
 	/* ide: 0x10-20 */
 	/*
-	experiment shows writing ide: 0x09 changes these
-	register behaviour. The pcicfgwrite() above writes
-	0x8a at ide: 0x09 to make sure legacy IDE.  Then
-	reading BAR0-3 is to return value 0s even though
-	pcisetup() has written range assignments.  Value
-	overwrite makes no effect. Having 0x8f for native
-	PCIIDE doesn't change register values and brings no
-	weirdness.
+	 * experiment shows writing ide: 0x09 changes these
+	 * register behaviour. The pcicfgwrite() above writes
+	 * 0x8a at ide: 0x09 to make sure legacy IDE.  Then
+	 * reading BAR0-3 is to return value 0s even though
+	 * pcisetup() has written range assignments.  Value
+	 * overwrite makes no effect. Having 0x8f for native
+	 * PCIIDE doesn't change register values and brings no
+	 * weirdness.
 	 */
 
-	/* ide: 0x40 - use primary only */
-	val = pcicfgread(ide, 0x40) &~ 03;
-	val |= 02;
-	pcicfgwrite(ide, 0x40, val);
-
-		/* ide: 0x3d/3c - turn off PCI pin */
+	/* ide: 0x3d/3c - turn off PCI pin */
 	val = pcicfgread(ide, 0x3c) & 0x00ff;
 	pcicfgwrite(ide, 0x3c, val);
 #endif

Index: src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.9 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.10
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.9	Sun Oct 30 21:08:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Tue Nov  1 16:32:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.9 2011/10/30 21:08:33 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.10 2011/11/01 16:32:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -102,6 +102,8 @@ dskdv_init(void *self)
 	return 0;
   found:
 	pci->drv = (*dv->init)(tag, NULL);
+	if (pci->drv == NULL)
+		return 0;
 	disk_scan(pci->drv);
 	return 1;
 }

Index: src/sys/arch/sandpoint/stand/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.7 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.8
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.7	Mon Apr 25 18:30:18 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Tue Nov  1 16:32:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.7 2011/04/25 18:30:18 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.8 2011/11/01 16:32:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
 #include "globals.h"
 
 static int cmdidefix(struct dkdev_ata *);
+static int apoidefix(struct dkdev_ata *);
 
 static uint32_t pciiobase = PCI_XIOBASE;
 
@@ -45,6 +46,7 @@ struct myops {
 };
 static struct myops defaultops = { NULL, NULL };
 static struct myops cmdideops = { cmdidefix, NULL };
+static struct myops apoideops = { apoidefix, NULL };
 static struct myops *myops;
 
 int
@@ -57,9 +59,12 @@ pciide_match(unsigned tag, void *data)
 	case PCI_DEVICE(0x1095, 0x0680): /* SiI 0680 IDE */
 		myops = &cmdideops;
 		return 1;
-	case PCI_DEVICE(0x1283, 0x8211): /* I

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

2011-10-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Oct 30 21:08:33 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c dsk.c entry.S fxp.c
globals.h nvt.c rge.c skg.c stg.c vge.c

Log Message:
Added in8() and out8() to access a byte with reorder-protection.
Use it in all drivers instead of (volatile uint8_t *).


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/entry.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/fxp.c \
src/sys/arch/sandpoint/stand/altboot/nvt.c \
src/sys/arch/sandpoint/stand/altboot/vge.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/rge.c \
src/sys/arch/sandpoint/stand/altboot/stg.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.18 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.19
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.18	Sun May 29 18:06:45 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Oct 30 21:08:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.18 2011/05/29 18:06:45 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.19 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -172,8 +172,8 @@ unsigned uart2base;	/* optional satellit
 #define  LSR_THRE	0x20
 #define  LSR_DRDY	0x01
 #define DCR		0x11
-#define UART_READ(base, r)	*(volatile char *)(base + (r))
-#define UART_WRITE(base, r, v)	*(volatile char *)(base + (r)) = (v)
+#define UART_READ(base, r)	in8(base + (r))
+#define UART_WRITE(base, r, v)	out8(base + (r), (v))
 
 void brdsetup(void);	/* called by entry.S */
 

Index: src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.8 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.9
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.8	Sun Jul 17 20:54:46 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Sun Oct 30 21:08:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.8 2011/07/17 20:54:46 joerg Exp $ */
+/* $NetBSD: dsk.c,v 1.9 2011/10/30 21:08:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -56,8 +56,8 @@
  */
 #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 CSR_READ_1(r)		in8(r)
+#define CSR_WRITE_1(r,v)	out8(r,v)
 
 struct dskdv {
 	char *name;

Index: src/sys/arch/sandpoint/stand/altboot/entry.S
diff -u src/sys/arch/sandpoint/stand/altboot/entry.S:1.4 src/sys/arch/sandpoint/stand/altboot/entry.S:1.5
--- src/sys/arch/sandpoint/stand/altboot/entry.S:1.4	Sun Oct 30 20:42:09 2011
+++ src/sys/arch/sandpoint/stand/altboot/entry.S	Sun Oct 30 21:08:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.4 2011/10/30 20:42:09 phx Exp $ */
+/* $NetBSD: entry.S,v 1.5 2011/10/30 21:08:33 phx Exp $ */
 
 #include 
 #include 
@@ -207,6 +207,20 @@ syncicache:
 	.globl	newaltboot_end
 newaltboot_end:
 
+
+/* 8-bit i/o access */
+	.globl	out8
+out8:
+	stb	4,0(3)
+	eieio
+	blr
+
+	.globl	in8
+in8:
+	lbz	3,0(3)
+	eieio
+	blr
+
 /*
  * reverse endian access to mimic outw/outl/inw/inl
  */

Index: src/sys/arch/sandpoint/stand/altboot/fxp.c
diff -u src/sys/arch/sandpoint/stand/altboot/fxp.c:1.2 src/sys/arch/sandpoint/stand/altboot/fxp.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/fxp.c:1.2	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/fxp.c	Sun Oct 30 21:08:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: fxp.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: fxp.c,v 1.3 2011/10/30 21:08:33 phx Exp $ */
 
 /*
  * most of the following code was imported from dev/ic/i82557.c; the
@@ -86,8 +86,8 @@
  * - no vtophys() translation, vaddr_t == paddr_t. 
  * - PIPT writeback cache aware.
  */
-#define CSR_WRITE_1(l, r, v)	*(volatile uint8_t *)((l)->iobase+(r)) = (v)
-#define CSR_READ_1(l, r)	*(volatile uint8_t *)((l)->iobase+(r))
+#define CSR_WRITE_1(l, r, v)	out8((l)->iobase+(r), (v))
+#define CSR_READ_1(l, r)	in8((l)->iobase+(r))
 #define CSR_WRITE_2(l, r, v)	out16rb((l)->iobase+(r), (v))
 #define CSR_READ_2(l, r)	in16rb((l)->iobase+(r))
 #define CSR_WRITE_4(l, r, v) 	out32rb((l)->iobase+(r), (v))
Index: src/sys/arch/sandpoint/stand/altboot/nvt.c
diff -u src/sys/arch/sandpoint/stand/altboot/nvt.c:1.2 src/sys/arch/sandpoint/stand/altboot/nvt.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/nvt.c:1.2	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/nvt.c	Sun Oct 30 21:08:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nvt.c,v

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

2011-10-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Oct 30 20:42:09 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile entry.S
Added Files:
src/sys/arch/sandpoint/stand/altboot: exception.c

Log Message:
Make sure to disable interrupts, as U-Boot may call us with interrupts
enabled, causing quite unpleasant effects (e.g. by decrementer interrupts).

When DEBUG is defined, an exception handler will be installed, which reports
about all exceptions while altboot is running, including register dump and
stack frame backtrace.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/altboot/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/entry.S
cvs rdiff -u -r0 -r1.1 src/sys/arch/sandpoint/stand/altboot/exception.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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.11 src/sys/arch/sandpoint/stand/altboot/Makefile:1.12
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.11	Wed May 25 19:26:21 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Sun Oct 30 20:42:09 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.11 2011/05/25 19:26:21 phx Exp $
+#	$NetBSD: Makefile,v 1.12 2011/10/30 20:42:09 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -8,7 +8,7 @@ NOMAN=		# defined
 SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c memfs.c
 SRCS+=		nif.c fxp.c tlp.c rge.c skg.c stg.c
 SRCS+=		dsk.c pciide.c siisata.c
-SRCS+=		vers.c
+SRCS+=		exception.c vers.c
 CLEANFILES+=	vers.c ${PROG} ${PROG}.bin ${PROG}.img
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith

Index: src/sys/arch/sandpoint/stand/altboot/entry.S
diff -u src/sys/arch/sandpoint/stand/altboot/entry.S:1.3 src/sys/arch/sandpoint/stand/altboot/entry.S:1.4
--- src/sys/arch/sandpoint/stand/altboot/entry.S:1.3	Sun Mar 13 15:23:43 2011
+++ src/sys/arch/sandpoint/stand/altboot/entry.S	Sun Oct 30 20:42:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.3 2011/03/13 15:23:43 phx Exp $ */
+/* $NetBSD: entry.S,v 1.4 2011/10/30 20:42:09 phx Exp $ */
 
 #include 
 #include 
@@ -20,13 +20,20 @@ _start:
 	mr	28,6
 	mr	29,7
 
+	/* Disable interrupts and everything except the MMU. */
+	mfmsr	3
+	andi.	3,3,PSL_DR|PSL_IR
+	mtmsr	3
+	isync
+
 	/*
 	 * U-Boot/PPCBoot forgets to flush the cache when using the "bootm"
 	 * command, so we have to do that now.
 	 */
 	lis	11,_start@ha
 	addi	11,11,_start@l
-	andi.	11,11,~31@l
+	li	10,-32
+	and	11,11,10
 	lis	12,(_edata+31)@ha
 	addi	12,12,(_edata+31)@l
 	bl	syncicache
@@ -41,8 +48,8 @@ _start:
 	mfmsr	0
 	andi.	0,0,PSL_DR
 	beq	2f
-	lis	5, 0xfec0@ha	/* CONFIG_ADDR of PCI */
-	lis	6, 0xfee0@ha	/* CONFIG_DATA of PCI */
+	lis	5,0xfec0@ha		/* CONFIG_ADDR of PCI */
+	lis	6,0xfee0@ha		/* CONFIG_DATA of PCI */
 	mfspr	3,SPR_DBAT0U
 	mfspr	4,SPR_DBAT0L
 	bl	dbat_sanity_check
@@ -104,13 +111,18 @@ _start:
 	b	5b
 
 6:
-	/* prepare stack at +1MB from _start. */
-	lis	1,_start@h
-	ori	1,1,_start@l
-	addis	1,1,0x10
-	addi	1,1,-4
+	/* prepare stack at +1MB from _start, 16-byte aligned */
+	lis	1,_start@ha
+	addi	1,1,_start@l
+	addis	1,1,0x10@ha
+	li	10,-16
+	and	1,1,10
+	stw	0,0(1)
 
 	bl	brdsetup
+#ifdef DEBUG
+	bl	init_vectors
+#endif
 	mr	3,30
 	mr	4,31
 	mr	5,28
@@ -152,7 +164,7 @@ dbat_sanity_check:
  */
 	.globl	run
 run:
-	mtctr	7 	/* hat trick jump to entry point */
+	mtctr	7			/* hat trick jump to entry point */
 	bctr
 
 /*
@@ -198,38 +210,115 @@ newaltboot_end:
 /*
  * reverse endian access to mimic outw/outl/inw/inl
  */
-	.globl out16rb
-	.globl iohtole16
+	.globl	out16rb
+	.globl	iohtole16
 out16rb:
 iohtole16:
 	sthbrx	4,0,3
 	eieio
 	blr 
 
-	.globl out32rb
-	.globl iohtole32
+	.globl	out32rb
+	.globl	iohtole32
 out32rb:
 iohtole32:
 	stwbrx	4,0,3
 	eieio
 	blr
 
-	.global in16rb
-	.global iole16toh
+	.globl	in16rb
+	.globl	iole16toh
 in16rb:
 iole16toh:
 	lhbrx	3,0,3
 	eieio
 	blr
 
-	.global in32rb
-	.global iole32toh
+	.globl	in32rb
+	.globl	iole32toh
 in32rb:
 iole32toh:
 	lwbrx	3,0,3
 	eieio
 	blr
 
+#ifdef DEBUG
+	/*
+	 * Call an exception handler, which prints out all information
+	 * about the type of exception, cpu registers, stack frame
+	 * backtrace, etc.
+	 * Use a new stack at 0x2000 and make room for 32 GPRs, and 15
+	 * special registers. The layout will be:
+	 * 0x00: link area
+	 * 0x10: R0
+	 * ...
+	 * 0x8c: R31
+	 * 0x90: CR, XER, LR, CTR
+	 * 0xa0: SRR0, SRR1, DAR, DSISR
+	 * 0xb0: DMISS, DCMP, HASH1, HASH2
+	 * 0xc0: IMISS, ICMP, RPA
+	 *
+	 */
+	.globl	trap
+trap:
+	mtsprg1	1
+	mfmsr	1
+	andis.	1,1,PSL_TGPR@h
+	beq	1f
+	andi.	1,1,0x		/* make sure TGPR is disabled */
+	mtmsr	1
+	isync
+	mtsprg1	1			/* and save the real r1 again */
+1:	li	1,0x2000-16-(32*4+15*4)
+	stmw	2,24(1)			/* save r2..r31 */
+	stw	0,16(1)			/* 

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

2011-06-20 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Jun 20 19:48:05 UTC 2011

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

Log Message:
Add support for booting from RAID 1.
Note, that the RAID partition must be the first partition of the disk.
Reviewed by phx@.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.6 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.7
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.6	Wed Jun  8 18:06:02 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Mon Jun 20 19:48:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.6 2011/06/08 18:06:02 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.7 2011/06/20 19:48:05 jdc Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -43,6 +43,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -296,7 +298,7 @@
 	struct disklabel *dlp;
 	struct partition *pp;
 	char *dp;
-	int i, first;
+	int i, first, rf_offset;
 
 	bsdp = NULL;
 	(*d->lba_read)(d, 0, 1, iobuf);
@@ -310,24 +312,39 @@
 		}
 	}
   skip:
+	rf_offset = 0;
 	first = (bsdp) ? bswap32(bsdp->mbrp_start) : 0;
 	(*d->lba_read)(d, first + LABELSECTOR, 1, iobuf);
 	dp = iobuf /* + LABELOFFSET */;
 	for (i = 0; i < 512 - sizeof(struct disklabel); i++, dp += 4) {
 		dlp = (struct disklabel *)dp;
 		if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC) {
-			goto found;
+			if (dlp->d_partitions[0].p_fstype == FS_RAID) {
+printf("%s%c: raid\n", d->xname, i + 'a');
+snprintf(d->xname, sizeof(d->xname), "raid.");
+rf_offset = dlp->d_partitions[0].p_offset +
+RF_PROTECTED_SECTORS;
+(*d->lba_read)(d, rf_offset + LABELSECTOR, 1,
+iobuf);
+dp = iobuf /* + LABELOFFSET */;
+for (i = 0; i < 512 - sizeof(struct disklabel); i++, dp += 4) {
+	dlp = (struct disklabel *)dp;
+	if (dlp->d_magic == DISKMAGIC &&
+	dlp->d_magic2 == DISKMAGIC)
+		goto found;
+}
+			} else	/* Not RAID */
+goto found;
 		}
 	}
 	d->dlabel = NULL;
 	printf("%s: no disklabel\n", d->xname);
 	return;
   found:
-	d->dlabel = allocaligned(sizeof(struct disklabel), 4);
-	memcpy(d->dlabel, dlp, sizeof(struct disklabel));
 	for (i = 0; i < dlp->d_npartitions; i += 1) {
 		const char *type;
 		pp = &dlp->d_partitions[i];
+		pp->p_offset += rf_offset;
 		type = NULL;
 		switch (pp->p_fstype) {
 		case FS_SWAP: /* swap */
@@ -341,8 +358,11 @@
 			break;
 		}
 		if (type != NULL)
-			printf("%s%c: %s\n", d->xname, i + 'a', type);
+			printf("%s%c: %s\t(%u)\n", d->xname, i + 'a', type,
+			pp->p_offset);
 	}
+	d->dlabel = allocaligned(sizeof(struct disklabel), 4);
+	memcpy(d->dlabel, dlp, sizeof(struct disklabel));
 }
 
 static void



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

2011-06-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Jun  8 18:06:02 UTC 2011

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

Log Message:
Support disk units from multiple IDE/SATA PCI controllers.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.5 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.6
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.5	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Wed Jun  8 18:06:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.5 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: dsk.c,v 1.6 2011/06/08 18:06:02 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
 };
 static int ndskdv = sizeof(ldskdv)/sizeof(ldskdv[0]);
 
-static int disk_scan(void *);
+static void disk_scan(void *);
 static int probe_drive(struct dkdev_ata *, int);
 static void drive_ident(struct disk *, char *);
 static char *mkident(char *, int);
@@ -80,7 +80,8 @@
 static void issue28(struct dvata_chan *, int64_t, int);
 static struct disk *lookup_disk(int);
 
-static struct disk ldisk[4];
+#define MAX_UNITS 8
+static struct disk ldisk[MAX_UNITS];
 
 int
 dskdv_init(void *self)
@@ -103,15 +104,15 @@
 	return 1;
 }
 
-static int
+static void
 disk_scan(void *drv)
 {
 	struct dkdev_ata *l = drv;
 	struct disk *d;
-	int n, ndrive;
+	static int ndrive = 0;
+	int n;
 
-	ndrive = 0;
-	for (n = 0; n < 4; n++) {
+	for (n = 0; n < 4 && ndrive < MAX_UNITS; n++) {
 		if (l->presense[n] == 0)
 			continue;
 		if (probe_drive(l, n) == 0) {
@@ -127,7 +128,6 @@
 		decode_dlabel(d, l->iobuf);
 		ndrive += 1;
 	}
-	return ndrive;
 }
 
 int



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

2011-06-02 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Jun  2 16:41:32 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
Add PPCBoot version from DS-207 and CS-407e.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/README.altboot

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.4 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.5
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.4	Tue Apr 19 14:12:54 2011
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Thu Jun  2 16:41:32 2011
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.4 2011/04/19 14:12:54 phx Exp $
+$NetBSD: README.altboot,v 1.5 2011/06/02 16:41:32 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -28,6 +28,10 @@
 
PPCBoot 2.0.0 (Mar  1 2005 - 15:31:41)
 
+- Synology 207, 407e with vendor custom PPCboot
+
+   PPCBoot 2.0.0 (Jan 30 2007 - xx:xx:xx)
+
 - D-Link DSM-G600 with heavily restricted vendor custom U-Boot
 
U-Boot 0.2.0 (May 26 2005 - 19:38:32)



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

2011-05-30 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon May 30 19:48:12 UTC 2011

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

Log Message:
When a drive is present, retry ATA-reset for a maximum of 10 seconds, until
successful.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/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/altboot/siisata.c
diff -u src/sys/arch/sandpoint/stand/altboot/siisata.c:1.3 src/sys/arch/sandpoint/stand/altboot/siisata.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/siisata.c:1.3	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/siisata.c	Mon May 30 19:48:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.3 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: siisata.c,v 1.4 2011/05/30 19:48:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
 siisata_init(unsigned tag, void *data)
 {
 	unsigned idreg;
-	int nchan, n;
+	int n, nchan, retries;
 	struct dkdev_ata *l;
 
 	l = alloc(sizeof(struct dkdev_ata));
@@ -99,15 +99,22 @@
 	pcicfgwrite(tag, 0x80, 0x00);
 	pcicfgwrite(tag, 0x84, 0x00);
 
-	for (n = 0; n < nchan; n++) {
+	for (n = 0, retries = 0; n < nchan; n++) {
+		l->presense[n] = 0;
+
 		if (satapresense(l, n)) {
 			/* drive present, now check whether soft reset works */
-			if (perform_atareset(l, n)) {
-DPRINTF(("port %d device present\n", n));
-l->presense[n] = 1;
+			while (retries++ < 10) {
+if (perform_atareset(l, n)) {
+	DPRINTF(("port %d device present\n", n));
+	l->presense[n] = 1;
+	break;
+}
+/* give the drive another second to spin up */
+if (retries < 10)
+	delay(1000 * 1000);
 			}
-		} else
-			l->presense[n] = 0;
+		}
 	}
 	return l;
 }



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

2011-05-29 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun May 29 18:06:45 UTC 2011

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

Log Message:
When PPCBoot supports the SKnet interface it will configure it to automatically
byte-reverse all descriptors by setting a vendor-specific bit in PCI config
space. We have to clear that bit to make sure our driver can send and
receive.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.17 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.18
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.17	Tue Apr 26 08:08:39 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun May 29 18:06:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.17 2011/04/26 08:08:39 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.18 2011/05/29 18:06:45 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -125,11 +125,23 @@
 	NULL, NULL, NULL, NULL }, /* must be the last */
 };
 
+/* Iomega StorCenter MC68HC908 microcontroller data packet */
+#define IOMEGA_POWER		0
+#define IOMEGA_LED		1
+#define IOMEGA_FLASH_RATE	2
+#define IOMEGA_FAN		3
+#define IOMEGA_HIGH_TEMP	4
+#define IOMEGA_LOW_TEMP		5
+#define IOMEGA_ID		6
+#define IOMEGA_CHECKSUM		7
+#define IOMEGA_PACKETSIZE	8
+
 static struct brdprop *brdprop;
 static uint32_t ticks_per_sec, ns_per_tick;
 
 static void brdfixup(void);
 static void setup(void);
+static int send_iomega(int, int, int, int, int, int, uint8_t *);
 static inline uint32_t mfmsr(void);
 static inline void mtmsr(uint32_t);
 static inline uint32_t cputype(void);
@@ -693,6 +705,7 @@
 
 	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
 	/* illuminate LEDs */
+	(void)send_iomega('b', 'd', 2, 'a', 60, 50, NULL);
 }
 
 void
@@ -877,6 +890,46 @@
 	uart1base = savedbase;
 }
 
+static int
+send_iomega(int power, int led, int rate, int fan, int high, int low,
+uint8_t *st)
+{
+	unsigned i, savedbase;
+	static uint8_t cur_state[IOMEGA_PACKETSIZE];
+	uint8_t buf[IOMEGA_PACKETSIZE];
+
+	buf[IOMEGA_POWER] =
+	power >= 0 ? power : cur_state[IOMEGA_POWER];
+	buf[IOMEGA_LED] =
+	led >= 0 ? led : cur_state[IOMEGA_LED];
+	buf[IOMEGA_FLASH_RATE] =
+	rate >= 0 ? rate : cur_state[IOMEGA_FLASH_RATE];
+	buf[IOMEGA_FAN] =
+	fan >= 0 ? fan : cur_state[IOMEGA_FAN];
+	buf[IOMEGA_HIGH_TEMP] =
+	high >= 0 ? high : cur_state[IOMEGA_HIGH_TEMP];
+	buf[IOMEGA_LOW_TEMP] =
+	low >= 0 ? low : cur_state[IOMEGA_LOW_TEMP];
+	buf[IOMEGA_ID] = 7;	/* host id */
+	buf[IOMEGA_CHECKSUM] = (buf[IOMEGA_POWER] + buf[IOMEGA_LED] +
+	buf[IOMEGA_FLASH_RATE] + buf[IOMEGA_FAN] +
+	buf[IOMEGA_HIGH_TEMP] + buf[IOMEGA_LOW_TEMP] +
+	buf[IOMEGA_ID]) & 0x7f;
+
+	savedbase = uart1base;
+	uart1base = uart2base;
+	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
+		putchar(buf[i]);
+	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
+		buf[i] = getchar();
+	uart1base = savedbase;
+	for (i = 0; i < IOMEGA_PACKETSIZE; i++)
+		printf("%02x", buf[i]);
+	printf("\n");
+
+	return 0;
+}
+
 void
 putchar(int c)
 {

Index: src/sys/arch/sandpoint/stand/altboot/skg.c
diff -u src/sys/arch/sandpoint/stand/altboot/skg.c:1.2 src/sys/arch/sandpoint/stand/altboot/skg.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/skg.c:1.2	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/skg.c	Sun May 29 18:06:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: skg.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: skg.c,v 1.3 2011/05/29 18:06:45 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 Frank Wille.
@@ -212,6 +212,10 @@
 	memset(l, 0, sizeof(struct local));
 	l->csr = DEVTOV(pcicfgread(tag, 0x10)); /* use mem space */
 
+	/* make sure the descriptor bytes are not reversed */
+	i = pcicfgread(tag, 0x44);
+	pcicfgwrite(tag, 0x44, i & ~4);
+
 	/* reset the chip */
 	CSR_WRITE_2(l, SK_CSR, CSR_SW_RESET);
 	CSR_WRITE_2(l, SK_CSR, CSR_MASTER_RESET);



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

2011-05-25 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed May 25 19:26:21 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile
Removed Files:
src/sys/arch/sandpoint/stand/altboot: printf.c

Log Message:
Use printf() from libsa.
Ok by nisimura@.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/stand/altboot/Makefile
cvs rdiff -u -r1.4 -r0 src/sys/arch/sandpoint/stand/altboot/printf.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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.10 src/sys/arch/sandpoint/stand/altboot/Makefile:1.11
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.10	Sun Mar  6 18:22:13 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Wed May 25 19:26:21 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.10 2011/03/06 18:22:13 phx Exp $
+#	$NetBSD: Makefile,v 1.11 2011/05/25 19:26:21 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -8,11 +8,11 @@
 SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c memfs.c
 SRCS+=		nif.c fxp.c tlp.c rge.c skg.c stg.c
 SRCS+=		dsk.c pciide.c siisata.c
-SRCS+=		printf.c vers.c
+SRCS+=		vers.c
 CLEANFILES+=	vers.c ${PROG} ${PROG}.bin ${PROG}.img
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
-CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
+CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP -DLIBSA_PRINTF_WIDTH_SUPPORT
 #CPPFLAGS+=	-DCONSNAME=\"com\" -DCONSPORT=0x3f8 -DCONSSPEED=115200
 #CPPFLAGS+=	-DCONSNAME=\"eumb\" -DCONSPORT=0x4600 -DCONSSPEED=57600
 CPPFLAGS+=	-nostdinc -I. -I${.OBJDIR} -I${S}



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

2011-04-29 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Apr 29 22:21:36 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: rge.c

Log Message:
When we stretch a short frame to 60 bytes in rge_send() do not return 60,
but the original frame size.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/rge.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/altboot/rge.c
diff -u src/sys/arch/sandpoint/stand/altboot/rge.c:1.4 src/sys/arch/sandpoint/stand/altboot/rge.c:1.5
--- src/sys/arch/sandpoint/stand/altboot/rge.c:1.4	Mon Apr  4 16:41:34 2011
+++ src/sys/arch/sandpoint/stand/altboot/rge.c	Fri Apr 29 22:21:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rge.c,v 1.4 2011/04/04 16:41:34 phx Exp $ */
+/* $NetBSD: rge.c,v 1.5 2011/04/29 22:21:36 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -217,8 +217,9 @@
 {
 	struct local *l = dev;
 	volatile struct desc *txd;
-	unsigned loop;
+	unsigned loop, ret;
 
+	ret = len;
 	if (len < 60) {
 		memset(buf + len, 0, 60 - len);
 		len = 60; /* RTL does not stretch <60 Tx frame */
@@ -241,7 +242,7 @@
 	return -1;
   done:
 	l->tx ^= 1;
-	return len;
+	return ret;
 }
 
 int



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

2011-04-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 26 08:08:40 UTC 2011

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

Log Message:
Priority of QNAP board detection was still too high. It should be lowest,
because a Realtek chip at pci device 15 is used on several boards. Now
NH230/All6250 detection should work again.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.16 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.17
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.16	Mon Apr 25 18:28:47 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Tue Apr 26 08:08:39 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.16 2011/04/25 18:28:47 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.17 2011/04/26 08:08:39 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -229,11 +229,6 @@
 		/* VIA 6410 (viaide) at dev 13 */
 		brdtype = BRD_STORCENTER;
 	}
-	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x8086
-	|| PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x10ec) {
-		/* Intel (wm) or RealTek (re) at dev 15 */
-		brdtype = BRD_QNAPTS;
-	}
 	else if (PCI_VENDOR(pcicfgread(dev16, PCI_ID_REG)) == 0x1191) {
 		/* ACARD ATP865 (acardide) at dev 16 */
 		brdtype = BRD_DLINKDSM;
@@ -243,6 +238,11 @@
 		/* ITE (iteide) or SiI (satalink) at dev 16 */
 		brdtype = BRD_NH230NAS;
 	}
+	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x8086
+	|| PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x10ec) {
+		/* Intel (wm) or RealTek (re) at dev 15 */
+		brdtype = BRD_QNAPTS;
+	}
 
 	brdprop = brd_lookup(brdtype);
 



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

2011-04-25 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr 25 18:30:18 UTC 2011

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

Log Message:
Add VIA VT6410 vendor/product IDs (StorCenter).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/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/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.6 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.7
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.6	Tue Apr 19 17:49:38 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Mon Apr 25 18:30:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.6 2011/04/19 17:49:38 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.7 2011/04/25 18:30:18 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,6 +59,7 @@
 		return 1;
 	case PCI_DEVICE(0x1283, 0x8211): /* ITE 8211 IDE */
 	case PCI_DEVICE(0x1106, 0x1571): /* VIA 82C586 IDE */
+	case PCI_DEVICE(0x1106, 0x3164): /* VIA VT6410 */
 	case PCI_DEVICE(0x10ad, 0x0105): /* Symphony Labs 82C105 IDE */
 	case PCI_DEVICE(0x10b8, 0x5229): /* ALi IDE */
 	case PCI_DEVICE(0x1191, 0x0008): /* ACARD ATP865 */



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

2011-04-25 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr 25 18:29:33 UTC 2011

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

Log Message:
Also scan for PCI_CLASS_RAID, when looking for disk devices.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.13 src/sys/arch/sandpoint/stand/altboot/main.c:1.14
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.13	Sun Mar 20 02:07:05 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Mon Apr 25 18:29:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.13 2011/03/20 02:07:05 phx Exp $ */
+/* $NetBSD: main.c,v 1.14 2011/04/25 18:29:33 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -129,6 +129,8 @@
 
 	nata = pcilookup(PCI_CLASS_IDE, lata, 2);
 	if (nata == 0)
+		nata = pcilookup(PCI_CLASS_RAID, lata, 2);
+	if (nata == 0)
 		nata = pcilookup(PCI_CLASS_MISCSTORAGE, lata, 2);
 	if (nata == 0)
 		nata = pcilookup(PCI_CLASS_SCSI, lata, 2);



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

2011-04-25 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr 25 18:28:47 UTC 2011

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

Log Message:
Detect StorCenter before QNAP, otherwise the Realtek NIC will mis-detect as
StorCenter boards as QNAP.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.15 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.16
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.15	Sun Apr 17 13:09:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Apr 25 18:28:47 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.15 2011/04/17 13:09:30 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.16 2011/04/25 18:28:47 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -225,15 +225,15 @@
 		/* SKnet/Marvell (sk) at dev 15 */
 		brdtype = BRD_SYNOLOGY;
 	}
+	else if (PCI_VENDOR(pcicfgread(dev13, PCI_ID_REG)) == 0x1106) {
+		/* VIA 6410 (viaide) at dev 13 */
+		brdtype = BRD_STORCENTER;
+	}
 	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x8086
 	|| PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x10ec) {
 		/* Intel (wm) or RealTek (re) at dev 15 */
 		brdtype = BRD_QNAPTS;
 	}
-	else if (PCI_VENDOR(pcicfgread(dev13, PCI_ID_REG)) == 0x1106) {
-		/* VIA 6410 (viaide) at dev 13 */
-		brdtype = BRD_STORCENTER;
-	}
 	else if (PCI_VENDOR(pcicfgread(dev16, PCI_ID_REG)) == 0x1191) {
 		/* ACARD ATP865 (acardide) at dev 16 */
 		brdtype = BRD_DLINKDSM;



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

2011-04-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 19 17:49:38 UTC 2011

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

Log Message:
Some DSM-G600 use a Acard ATP865A instead of ATP865. Added its product id.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/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/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.5 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.6
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.5	Thu Mar 10 21:11:49 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Tue Apr 19 17:49:38 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.5 2011/03/10 21:11:49 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.6 2011/04/19 17:49:38 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,6 +62,7 @@
 	case PCI_DEVICE(0x10ad, 0x0105): /* Symphony Labs 82C105 IDE */
 	case PCI_DEVICE(0x10b8, 0x5229): /* ALi IDE */
 	case PCI_DEVICE(0x1191, 0x0008): /* ACARD ATP865 */
+	case PCI_DEVICE(0x1191, 0x0009): /* ACARD ATP865A */
 		myops = &defaultops;
 		return 1;
 	}



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

2011-04-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Apr 19 14:12:54 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
Added a detailed description of altboot command line and boot arguments.


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

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.3 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.4
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.3	Fri Apr  8 08:29:07 2011
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Tue Apr 19 14:12:54 2011
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.3 2011/04/08 08:29:07 phx Exp $
+$NetBSD: README.altboot,v 1.4 2011/04/19 14:12:54 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -58,4 +58,47 @@
 - product family indication.
 - preloaded kernel module names (under development).
 
+When no arguments are given, altboot defaults to boot a kernel called
+"netbsd" from the root partition of the first disk in multiuser mode.
+
+Boot arguments may be passed in three ways:
+- On the command line, directly after the "go 0x100" command.
+- From the U-Boot "bootargs" environment variable, when started by "bootm".
+- By entering the interactive mode.
+
+The following boot arguments are recognized:
+- multi			boot into multiuser
+- auto			boot into multiuser
+- single		boot into singleuser
+- ask			ask for boot device
+- ddb			drop into the kernel debugger
+- userconf		change configured devices
+
+The following boot flags are recognized:
+- norm			boot normally
+- quiet			boot quietly
+- verb			boot verbosely
+- silent		boot silently
+- debug			boot with debug output
+
+Additionally the special argument "altboot" is recognized, which replaces
+the actually running altboot program with the loaded binary file and
+restarts itself. Mainly useful for altboot testing.
+
+Multiple arguments may be specified at once, although not all combinations
+make sense. The format of an altboot command line is:
+
+  [[ ...] :[]]
+
+The following device names are supported:
+- tftp			boot from TFTP (address retrieved by DHCP)
+- nfs			boot from NFS (address retrieved by DHCP)
+- wd[N[P]]		boot from disk N, partition P, defaults to wd0a
+- mem			boot from memory
+
+For tftp and nfs the bootfile is determined by DHCP, when missing.
+For wd it defaults to "netbsd".
+For mem the bootfile is actually a hexadecimal address to load from and
+is mandatory.
+
  ### ### ###



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

2011-04-17 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Apr 17 13:09:30 UTC 2011

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

Log Message:
DSM-G600 has a 33.000 MHz oscillator on board.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.14 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.15
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.14	Wed Apr 13 18:32:21 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Apr 17 13:09:30 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.14 2011/04/13 18:32:21 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.15 2011/04/17 13:09:30 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -106,7 +106,7 @@
 	"dlink",
 	"D-Link DSM-G600",
 	BRD_DLINKDSM,
-	0,
+	3300,
 	"eumb", 0x4500, 9600,
 	NULL, dlinkbrdfix, NULL, NULL },
 {



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

2011-04-13 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Apr 13 18:32:21 UTC 2011

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

Log Message:
ExtClk for QNAP should be the same as for Synology's 266MHz systems.
This seems logical, as both boards are very similar, and the clock precision
is ok now.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.13 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.14
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.13	Sat Apr  9 19:56:20 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Wed Apr 13 18:32:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.13 2011/04/09 19:56:20 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.14 2011/04/13 18:32:21 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -83,15 +83,16 @@
 	"synology",
 	"Synology DS",
 	BRD_SYNOLOGY,
-	33164691,	/* from Synology/Linux source */
-	/* 33168000,		XXX better precision? */
+	33164691,	/* from Synology/Linux source*/
+			/* XXX should be 33165343 for the CS-406 */
 	"eumb", 0x4500, 115200,
 	NULL, synobrdfix, NULL, synoreset },
 {
 	"qnap",
 	"QNAP TS",
 	BRD_QNAPTS,
-	0,
+	33164691,	/* Linux source says 3300, but the Synology  */
+			/* clock value delivers a much better precision. */
 	"eumb", 0x4500, 115200,
 	NULL, qnapbrdfix, NULL, qnapreset },
 {



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

2011-04-09 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Apr  9 19:56:20 UTC 2011

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

Log Message:
Set D-Link DSM-G600 power LED to solid green on start.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.12 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.13
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.12	Sat Mar 26 17:55:05 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Apr  9 19:56:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.12 2011/03/26 17:55:05 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.13 2011/04/09 19:56:20 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -699,7 +699,8 @@
 {
 
 	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
-	/* illuminate LEDs */
+	send_sat("SYN\n");
+	send_sat("ZWO\n");	/* power LED solid on */
 }
 
 void



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

2011-04-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Apr  8 08:29:07 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot

Log Message:
QNAP support.
Note about the D-Link firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/README.altboot

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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.2 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.3
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.2	Sun Mar 13 15:23:43 2011
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Fri Apr  8 08:29:07 2011
@@ -1,11 +1,11 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.2 2011/03/13 15:23:43 phx Exp $
+$NetBSD: README.altboot,v 1.3 2011/04/08 08:29:07 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
 irons out and rectifies erroneously configured HW by product
-bootloaders and prepares a sane runtime better suited for booting
+bootloaders and prepares a sane runtime, better suited for booting
 NetBSD kernels.
 
 - provides the foundation of a fast NetBSD porting cycle with functionalities
@@ -17,8 +17,10 @@
   targets to make it possible having common NetBSD kernels for them.
 - builds and hands a bootinfo list to the NetBSD kernel.
 
-Altboot is known working on at least three models.
-- KuroBox with a popular U-Boot as the replacement of vendor proprietary
+Altboot is known working on at least these models:
+
+- KuroBox or LinkStation with a popular U-Boot as the replacement of
+  vendor proprietary
 
U-Boot 1.1.4 LiSt 2.1.0 (Sep 21 2006 - 00:22:56) LinkStation / KuroBox
 
@@ -30,14 +32,22 @@
 
U-Boot 0.2.0 (May 26 2005 - 19:38:32)
 
+- QNAP TS-101 (V200) with vendor custom U-Boot
+
+   U-Boot 1.1.2 (Aug 28 2005 - 13:37:25) QNAP System, Inc.
+
 The standard use of altboot is to invoke it with a short script from
-U-Boot/PPCboot, where the altboot image is stored in an unoccupied 128KB
+U-Boot/PPCboot, where the altboot.bin image is stored in an unoccupied 128KB
 section of the target's HW NOR flash.  Combined with standard
 U-Boot/PPCboot functions, it is possible to boot a NetBSD kernel off
 it right after power-on, without the help of manual intervention.  Note
 that the original U-Boot/PPCboot still remains useful and altboot works
 as a functional extension for them.
 
+In case the firmware was crippled by the vendor so that it only boots
+Linux U-Boot images (D-Link), you can still use altboot by uploading
+altboot.img instead of the Linux kernel.
+
 Altboot hands the following bootinfo records to the NetBSD/sandpoint
 kernel.
 - processor clock tick value driving MPC8241/8245.



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

2011-04-04 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Apr  4 16:41:34 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: rge.c

Log Message:
Make sure a frame is at least 60 bytes, as Realtek does not automatically
expand small frames.
Patch suggested by nisimura@.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/rge.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/altboot/rge.c
diff -u src/sys/arch/sandpoint/stand/altboot/rge.c:1.3 src/sys/arch/sandpoint/stand/altboot/rge.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/rge.c:1.3	Sun Mar 27 19:09:43 2011
+++ src/sys/arch/sandpoint/stand/altboot/rge.c	Mon Apr  4 16:41:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rge.c,v 1.3 2011/03/27 19:09:43 phx Exp $ */
+/* $NetBSD: rge.c,v 1.4 2011/04/04 16:41:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -219,6 +219,10 @@
 	volatile struct desc *txd;
 	unsigned loop;
 
+	if (len < 60) {
+		memset(buf + len, 0, 60 - len);
+		len = 60; /* RTL does not stretch <60 Tx frame */
+	}
 	wbinv(buf, len);
 	txd = &l->txd[l->tx];
 	txd->xd2 = htole32(VTOPHYS(buf));



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

2011-03-27 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 27 19:09:43 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: rge.c

Log Message:
Fixed PHY access.
Support 8169SC/8110SC (as found on QNAP V200 boards).
Make frame receiving work (FRAMELEN <-> FRAMESIZE).
Driver works now, but not the first time after cold start.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/rge.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/altboot/rge.c
diff -u src/sys/arch/sandpoint/stand/altboot/rge.c:1.2 src/sys/arch/sandpoint/stand/altboot/rge.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/rge.c:1.2	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/rge.c	Sun Mar 27 19:09:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rge.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: rge.c,v 1.3 2011/03/27 19:09:43 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -133,6 +133,7 @@
 
 	v = pcicfgread(tag, PCI_ID_REG);
 	switch (v) {
+	case PCI_DEVICE(0x10ec, 0x8167):
 	case PCI_DEVICE(0x10ec, 0x8169):
 		return 1;
 	}
@@ -199,7 +200,7 @@
 	l->rcr = (07 << 13) | (07 << 8) | RCR_APM;
 	CSR_WRITE_1(l, RGE_CR, CR_TXEN | CR_RXEN);
 	CSR_WRITE_1(l, RGE_ETTHR, 0x3f);
-	CSR_WRITE_2(l, RGE_RMS, FRAMELEN);
+	CSR_WRITE_2(l, RGE_RMS, FRAMESIZE);
 	CSR_WRITE_4(l, RGE_TCR, l->tcr);
 	CSR_WRITE_4(l, RGE_RCR, l->rcr);
 	CSR_WRITE_4(l, RGE_TNPDS, VTOPHYS(txd));
@@ -208,7 +209,6 @@
 	CSR_WRITE_4(l, RGE_RDSAR + 4, 0); 
 	CSR_WRITE_2(l, RGE_ISR, ~0);
 	CSR_WRITE_2(l, RGE_IMR, 0);
-
 	return l;
 }
 
@@ -287,15 +287,16 @@
 static int
 mii_read(struct local *l, int phy, int reg)
 {
-	unsigned v, loop;
+	unsigned v;
 
 	v = reg << 16;
 	CSR_WRITE_4(l, RGE_PHYAR, v);
-	loop = 100;
+	DELAY(1000);
 	do {
+		DELAY(100);
 		v = CSR_READ_4(l, RGE_PHYAR);
 	} while ((v & (1U << 31)) == 0); /* wait for 0 -> 1 */
-	return v;
+	return v & 0x;
 }
 
 static void
@@ -305,7 +306,9 @@
 
 	v = (reg << 16) | (data & 0x) | (1U << 31);
 	CSR_WRITE_4(l, RGE_PHYAR, v);
+	DELAY(1000);
 	do {
+		DELAY(100);
 		v = CSR_READ_4(l, RGE_PHYAR);
 	} while (v & (1U << 31)); /* wait for 1 -> 0 */
 }
@@ -337,17 +340,9 @@
 static void
 mii_initphy(struct local *l)
 {
-	int phy, ctl, sts, bound;
+	int bound, ctl, phy, sts;
 
-	for (phy = 0; phy < 32; phy++) {
-		ctl = mii_read(l, phy, MII_BMCR);
-		sts = mii_read(l, phy, MII_BMSR);
-		if (ctl != 0x && sts != 0x)
-			goto found;
-	}
-	printf("MII: no PHY found\n");
-	return;
-  found:
+	phy = 7;	/* internal rgephy, always at 7 */
 	ctl = mii_read(l, phy, MII_BMCR);
 	mii_write(l, phy, MII_BMCR, ctl | BMCR_RESET);
 	bound = 100;



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

2011-03-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 26 17:55:05 UTC 2011

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

Log Message:
QNAP support. Detect wm(4) based V1.02 and re(4) based V200 boards.
That should include all TS-101 and TS-201 models.
Add reset-code and LED-illumination code for the QNAP PIC, which listens
on the second UART with 19200 bps.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/altboot/brdsetup.c \
src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.11 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.12
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.11	Sun Mar 13 01:56:21 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Mar 26 17:55:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.11 2011/03/13 01:56:21 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.12 2011/03/26 17:55:05 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -89,14 +89,14 @@
 	NULL, synobrdfix, NULL, synoreset },
 {
 	"qnap",
-	"QNAP TS-101",
-	BRD_QNAPTS101,
+	"QNAP TS",
+	BRD_QNAPTS,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, qnapbrdfix, NULL, NULL },
+	NULL, qnapbrdfix, NULL, qnapreset },
 {
 	"iomega",
-	"IOMEGA StorCenter",
+	"IOMEGA StorCenter G2",
 	BRD_STORCENTER,
 	0,
 	"eumb", 0x4500, 115200,
@@ -224,9 +224,10 @@
 		/* SKnet/Marvell (sk) at dev 15 */
 		brdtype = BRD_SYNOLOGY;
 	}
-	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x8086) {
-		/* Intel (wm) at dev 15 */
-		brdtype = BRD_QNAPTS101;
+	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x8086
+	|| PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x10ec) {
+		/* Intel (wm) or RealTek (re) at dev 15 */
+		brdtype = BRD_QNAPTS;
 	}
 	else if (PCI_VENDOR(pcicfgread(dev13, PCI_ID_REG)) == 0x1106) {
 		/* VIA 6410 (viaide) at dev 13 */
@@ -237,7 +238,7 @@
 		brdtype = BRD_DLINKDSM;
 	}
 	else if (PCI_VENDOR(pcicfgread(dev16, PCI_ID_REG)) == 0x1283
-		   || PCI_VENDOR(pcicfgread(dev16, PCI_ID_REG)) == 0x1095) {
+	|| PCI_VENDOR(pcicfgread(dev16, PCI_ID_REG)) == 0x1095) {
 		/* ITE (iteide) or SiI (satalink) at dev 16 */
 		brdtype = BRD_NH230NAS;
 	}
@@ -672,7 +673,17 @@
 qnapbrdfix(struct brdprop *brd)
 {
 
-	/* illuminate LEDs */
+	init_uart(uart2base, 19200, LCR_8BITS | LCR_PNONE);
+	/* beep, status LED red */
+	send_sat("PW");
+}
+
+void
+qnapreset()
+{
+
+	send_sat("f");
+	/*NOTREACHED*/
 }
 
 void
Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.11 src/sys/arch/sandpoint/stand/altboot/globals.h:1.12
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.11	Sun Mar 13 01:56:21 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sat Mar 26 17:55:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.11 2011/03/13 01:56:21 phx Exp $ */
+/* $NetBSD: globals.h,v 1.12 2011/03/26 17:55:05 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -17,7 +17,7 @@
 #define BRD_SANDPOINTX3		3
 #define BRD_ENCOREPP1		10
 #define BRD_KUROBOX		100
-#define BRD_QNAPTS101		101
+#define BRD_QNAPTS		101
 #define BRD_SYNOLOGY		102
 #define BRD_STORCENTER		103
 #define BRD_DLINKDSM		104



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

2011-03-19 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 20 02:07:05 UTC 2011

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

Log Message:
The DSM-G600 U-Boot is so restricted that there is no possibility to pass
any bootargs. So we will just do the default multiuser boot from wd0: when
altboot was started together with a Linux initrd image.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.12 src/sys/arch/sandpoint/stand/altboot/main.c:1.13
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.12	Sun Mar 13 15:23:43 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Mar 20 02:07:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.12 2011/03/13 15:23:43 phx Exp $ */
+/* $NetBSD: main.c,v 1.13 2011/03/20 02:07:05 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -184,10 +184,18 @@
 	 * "bootm".
 	 */
 	if (argc > MAX_ARGS) {
-		/* parse Linux bootargs */
-		argv = new_argv;
-		argc = parse_cmdline(argv, MAX_ARGS, bootargs_start,
-		bootargs_end);
+		if (argv != NULL) {
+			/*
+			 * initrd image was loaded: assume extremely
+			 * restricted firmware and boot default
+			 */
+			argc = 0;
+		} else {
+			/* parse standard Linux bootargs */
+			argc = parse_cmdline(new_argv, MAX_ARGS,
+			bootargs_start, bootargs_end);
+			argv = new_argv;
+		}
 	}
 
 	/* wait 2s for user to enter interactive mode */



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

2011-03-13 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 13 15:23:43 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: README.altboot entry.S main.c
version

Log Message:
With the new boot argument "altboot" the program can replace itself with a
new binary while running.
The default boot path was changed from nfs: to wd0:.
Bumped altboot version to 1.7.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/README.altboot
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/entry.S
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/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/altboot/README.altboot
diff -u src/sys/arch/sandpoint/stand/altboot/README.altboot:1.1 src/sys/arch/sandpoint/stand/altboot/README.altboot:1.2
--- src/sys/arch/sandpoint/stand/altboot/README.altboot:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/README.altboot	Sun Mar 13 15:23:43 2011
@@ -1,6 +1,6 @@
 /// notes about altboot ///
 
-$NetBSD: README.altboot,v 1.1 2011/01/23 01:05:30 nisimura Exp $
+$NetBSD: README.altboot,v 1.2 2011/03/13 15:23:43 phx Exp $
 
 Altboot is a functional bridge to fill the gap between a NAS product
 custom bootloader and the NetBSD kernel startup environment.  Altboot
@@ -17,7 +17,7 @@
   targets to make it possible having common NetBSD kernels for them.
 - builds and hands a bootinfo list to the NetBSD kernel.
 
-Altboot is known working on two models.
+Altboot is known working on at least three models.
 - KuroBox with a popular U-Boot as the replacement of vendor proprietary
 
U-Boot 1.1.4 LiSt 2.1.0 (Sep 21 2006 - 00:22:56) LinkStation / KuroBox
@@ -26,6 +26,10 @@
 
PPCBoot 2.0.0 (Mar  1 2005 - 15:31:41)
 
+- D-Link DSM-G600 with heavily restricted vendor custom U-Boot
+
+   U-Boot 0.2.0 (May 26 2005 - 19:38:32)
+
 The standard use of altboot is to invoke it with a short script from
 U-Boot/PPCboot, where the altboot image is stored in an unoccupied 128KB
 section of the target's HW NOR flash.  Combined with standard
@@ -45,4 +49,3 @@
 - preloaded kernel module names (under development).
 
  ### ### ###
-

Index: src/sys/arch/sandpoint/stand/altboot/entry.S
diff -u src/sys/arch/sandpoint/stand/altboot/entry.S:1.2 src/sys/arch/sandpoint/stand/altboot/entry.S:1.3
--- src/sys/arch/sandpoint/stand/altboot/entry.S:1.2	Sat Feb 26 20:11:24 2011
+++ src/sys/arch/sandpoint/stand/altboot/entry.S	Sun Mar 13 15:23:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.2 2011/02/26 20:11:24 phx Exp $ */
+/* $NetBSD: entry.S,v 1.3 2011/03/13 15:23:43 phx Exp $ */
 
 #include 
 #include 
@@ -24,25 +24,12 @@
 	 * U-Boot/PPCBoot forgets to flush the cache when using the "bootm"
 	 * command, so we have to do that now.
 	 */
-	lis	3,_start@ha
-	addi	3,3,_start@l
-	andi.	3,3,~31@l
-	lis	4,(_edata+31)@ha
-	addi	4,4,(_edata+31)@l
-	mr	5,3
-10:
-	dcbst	0,5
-	addi	5,5,32
-	cmplw	5,4
-	ble	10b
-	sync
-11:
-	icbi	0,3
-	addi	3,3,32
-	cmplw	3,4
-	ble	11b
-	sync
-	isync
+	lis	11,_start@ha
+	addi	11,11,_start@l
+	andi.	11,11,~31@l
+	lis	12,(_edata+31)@ha
+	addi	12,12,(_edata+31)@l
+	bl	syncicache
 
 	mfspr	11,SPR_HID0
 	andi.	0,11,HID0_DCE
@@ -169,6 +156,46 @@
 	bctr
 
 /*
+ * newaltboot(argc, argv, altboot_base, altboot_len)
+ * To be executed in a safe memory region. Copies the new altboot from
+ * altboot_base to 0x100 and starts it there.
+ */
+	.globl	newaltboot
+newaltboot:
+	lis	7,0x100@h
+	mr	11,7
+	subi	7,7,4
+	subi	5,5,4
+	add	12,11,6
+	addi	6,6,3
+	srawi	6,6,2
+	mtctr	6
+1:	lwzu	8,4(5)
+	stwu	8,4(7)
+	bdnz+	1b
+	mtctr	11
+	addi	12,12,31
+	bl	syncicache
+	bctr
+syncicache:
+/* r11=start, r12=end, r10=scratch */
+	mr	10,11
+2:	dcbst	0,10
+	addi	10,10,32
+	cmplw	10,12
+	ble	2b
+	sync
+3:	icbi	0,11
+	addi	11,11,32
+	cmplw	11,12
+	ble	3b
+	sync
+	isync
+	blr
+	.globl	newaltboot_end
+newaltboot_end:
+
+/*
  * reverse endian access to mimic outw/outl/inw/inl
  */
 	.globl out16rb

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.11 src/sys/arch/sandpoint/stand/altboot/main.c:1.12
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.11	Sun Mar 13 01:56:21 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Mar 13 15:23:43 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.11 2011/03/13 01:56:21 phx Exp $ */
+/* $NetBSD: main.c,v 1.12 2011/03/13 15:23:43 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -54,7 +54,8 @@
 	{ "quiet",	AB_QUIET },
 	{ "verb",	AB_VERBOSE },
 	{ "silent",	AB_SILENT },
-	{ "debug",	AB_DEBUG }
+	{ "debug",	AB_DEBUG },
+	{ "altboot",	-1 }
 };
 
 void *bootinfo; /* low memory reserved to pass bootinfo structures */
@@ -89,7 +90,9 @@
 int module_open(struct boot_module *);
 

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

2011-03-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar 13 01:56:22 UTC 2011

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

Log Message:
Enter interactive mode, when a key is pressed within two seconds.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sandpoint/stand/altboot/brdsetup.c \
src/sys/arch/sandpoint/stand/altboot/globals.h \
src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.10 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.11
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.10	Sat Mar 12 16:41:23 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Mar 13 01:56:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.10 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.11 2011/03/13 01:56:21 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -141,6 +141,7 @@
 
 unsigned uart1base;	/* console */
 unsigned uart2base;	/* optional satellite processor */
+#define RBR		0
 #define THR		0
 #define DLB		0
 #define DMB		1
@@ -156,6 +157,7 @@
 #define  MCR_DTR	0x01
 #define LSR		5
 #define  LSR_THRE	0x20
+#define  LSR_DRDY	0x01
 #define DCR		0x11
 #define UART_READ(base, r)	*(volatile char *)(base + (r))
 #define UART_WRITE(base, r, v)	*(volatile char *)(base + (r)) = (v)
@@ -663,7 +665,7 @@
 {
 
 	send_sat("C");
-	/*NOTRECHED*/
+	/*NOTREACHED*/
 }
 
 void
@@ -878,6 +880,23 @@
 		UART_WRITE(uart1base, THR, c);
 }
 
+int
+getchar(void)
+{
+	unsigned lsr;
+
+	do {
+		lsr = UART_READ(uart1base, LSR);
+	} while ((lsr & LSR_DRDY) == 0);
+	return UART_READ(uart1base, RBR);
+}
+
+int
+tstchar(void)
+{
+	return (UART_READ(uart1base, LSR) & LSR_DRDY) != 0;
+}
+
 unsigned
 mpc107memsize()
 {
Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.10 src/sys/arch/sandpoint/stand/altboot/globals.h:1.11
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.10	Sat Mar 12 16:41:23 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Mar 13 01:56:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.10 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: globals.h,v 1.11 2011/03/13 01:56:21 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -42,6 +42,7 @@
 
 /* board specific support code */
 struct brdprop *brd_lookup(int);
+int tstchar(void);
 unsigned mpc107memsize(void);
 void read_mac_from_flash(uint8_t *);
 
Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.10 src/sys/arch/sandpoint/stand/altboot/main.c:1.11
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.10	Sat Mar 12 16:41:23 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Mar 13 01:56:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.10 2011/03/12 16:41:23 phx Exp $ */
+/* $NetBSD: main.c,v 1.11 2011/03/13 01:56:21 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -100,6 +100,7 @@
 uint32_t busclock, cpuclock;
 
 static int check_bootname(char *);
+static int input_cmdline(char **, int);
 static int parse_cmdline(char **, int, char *, char *);
 static int is_space(char);
 
@@ -185,6 +186,21 @@
 		bootargs_end);
 	}
 
+	/* wait 2s for user to enter interactive mode */
+	for (n = 200; n >= 0; n--) {
+		if (n % 100 == 0)
+			printf("Hit any key to enter interactive mode: %d\r",
+			n / 100);
+		if (tstchar()) {
+			(void)getchar();
+			argv = new_argv;
+			argc = input_cmdline(argv, MAX_ARGS);
+			break;
+		}
+		delay(1);
+	}
+	putchar('\n');
+
 	howto = RB_AUTOBOOT;		/* default is autoboot = 0 */
 
 	/* get boot options and determine bootname */
@@ -537,6 +553,18 @@
 	return 0;
 }
 
+static int input_cmdline(char **argv, int maxargc)
+{
+	char *cmdline;
+
+	printf("\nbootargs> ");
+	cmdline = alloc(256);
+	gets(cmdline);
+
+	return parse_cmdline(argv, maxargc, cmdline,
+	cmdline + strlen(cmdline));
+}
+
 static int
 parse_cmdline(char **argv, int maxargc, char *p, char *end)
 {



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

2011-03-12 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Mar 12 16:41:23 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c globals.h main.c nif.c
stg.c

Log Message:
Introduced an optional shutdown function for all network interfaces.
This is needed to stop a NIF and make it return to a known state. A running
NIF may cause all sorts of bad effects, like for example making it impossible
to reboot a board without a hardware-reset function.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/altboot/brdsetup.c \
src/sys/arch/sandpoint/stand/altboot/globals.h \
src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/nif.c \
src/sys/arch/sandpoint/stand/altboot/stg.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.9 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.10
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.9	Fri Mar 11 17:46:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sat Mar 12 16:41:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.9 2011/03/11 17:46:30 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.10 2011/03/12 16:41:23 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,6 +31,7 @@
 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -128,6 +129,8 @@
 
 static void brdfixup(void);
 static void setup(void);
+static inline uint32_t mfmsr(void);
+static inline void mtmsr(uint32_t);
 static inline uint32_t cputype(void);
 static inline u_quad_t mftb(void);
 static void init_uart(unsigned, unsigned, uint8_t);
@@ -252,7 +255,7 @@
 			busclock = (extclk *
 			pci_to_memclk[(val >> 19) & 0x1f] + 10) / 10;
 			/* PLLRATIO from HID1 */
-			__asm ("mfspr %0,1009" : "=r"(val));
+			asm volatile ("mfspr %0,1009" : "=r"(val));
 			cpuclock = ((uint64_t)busclock *
 			mem_to_cpuclk[val >> 27] + 10) / 10;
 		} else
@@ -696,11 +699,23 @@
 void
 _rtt(void)
 {
+	uint32_t msr;
+
+	netif_shutdown_all();
 
 	if (brdprop->reset != NULL)
 		(*brdprop->reset)();
-	else
+	else {
+		msr = mfmsr();
+		msr &= ~PSL_EE;
+		mtmsr(msr);
+		asm volatile ("sync; isync");
+		asm volatile("mtspr %0,%1" : : "K"(81), "r"(0));
+		msr &= ~(PSL_ME | PSL_DR | PSL_IR);
+		mtmsr(msr);
+		asm volatile ("sync; isync");
 		run(0, 0, 0, 0, (void *)0xFFF00100); /* reset entry */
+	}
 	/*NOTREACHED*/
 }
 
@@ -785,11 +800,26 @@
 }
 
 static inline uint32_t
+mfmsr(void)
+{
+	uint32_t msr;
+
+	asm volatile ("mfmsr %0" : "=r"(msr));
+	return msr;
+}
+
+static inline void
+mtmsr(uint32_t msr)
+{
+	asm volatile ("mtmsr %0" : : "r"(msr));
+}
+
+static inline uint32_t
 cputype(void)
 {
 	uint32_t pvr;
 
-	__asm volatile ("mfpvr %0" : "=r"(pvr));
+	asm volatile ("mfpvr %0" : "=r"(pvr));
 	return pvr >> 16;
 }
 
@@ -801,7 +831,7 @@
 
 	asm ("1: mftbu %0; mftb %0+1; mftbu %1; cmpw %0,%1; bne 1b"
 	: "=r"(tb), "=r"(scratch));
-	return (tb);
+	return tb;
 }
 
 static void
Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.9 src/sys/arch/sandpoint/stand/altboot/globals.h:1.10
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.9	Thu Mar 10 21:11:49 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sat Mar 12 16:41:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.9 2011/03/10 21:11:49 phx Exp $ */
+/* $NetBSD: globals.h,v 1.10 2011/03/12 16:41:23 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -133,6 +133,7 @@
 int net_strategy(void *, int, daddr_t, size_t, void *, size_t *);
 
 int netif_init(void *);
+void netif_shutdown_all(void);
 int netif_open(void *); 
 int netif_close(int); 
 
@@ -140,7 +141,8 @@
 int xxx ## _match(unsigned, void *); \
 void * xxx ## _init(unsigned, void *); \
 int xxx ## _send(void *, char *, unsigned); \
-int xxx ## _recv(void *, char *, unsigned, unsigned)
+int xxx ## _recv(void *, char *, unsigned, unsigned); \
+void xxx ## _shutdown(void *)
 
 NIF_DECL(fxp);
 NIF_DECL(tlp);
Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.9 src/sys/arch/sandpoint/stand/altboot/main.c:1.10
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.9	Sun Mar  6 18:22:13 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sat Mar 12 16:41:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.9 2011/03/06 18:22:13 phx Exp $ */
+/* $NetBSD: main.c,v 1.10 2011/03/12 16:41:23 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -250,6 +250,8 @@
 			btinfo_modulelist_size);
 	}
 
+	netif_shutdown_all();
+
 	__syncicache((void *)marks[MARK_ENTRY],
 	(u_int)marks[MARK_SYM] - (u_int)marks[MARK_ENTRY]);
 

Index: src/sys/arch/sandpoint/stand/altboot/nif.c
diff -u src/sys/arch/sandpoint/stand/alt

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

2011-03-11 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Fri Mar 11 17:46:30 UTC 2011

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

Log Message:
Some code cleanup, suggested by nisimura@.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/stg.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.8 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.9
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.8	Thu Mar 10 21:11:49 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Fri Mar 11 17:46:30 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.8 2011/03/10 21:11:49 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.9 2011/03/11 17:46:30 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -969,27 +969,29 @@
 }
 
 /*
- * For cost saving reasons some NAS boxes are missing the ROM for the
- * NIC's ethernet address and keep it in their Flash memory.
+ * For cost saving reasons some NAS boxes lack SEEPROM for NIC's
+ * ethernet address and keep it in their Flash memory instead.
  */
 void
 read_mac_from_flash(uint8_t *mac)
 {
 	uint8_t *p;
 
-	if (brdtype == BRD_SYNOLOGY) {
+	switch (brdtype) {
+	case BRD_SYNOLOGY:
 		p = redboot_fis_lookup("vendor");
-		if (p != NULL) {
-			memcpy(mac, p, 6);
-			return;
-		}
-	} else if (brdtype == BRD_DLINKDSM) {
+		if (p == NULL)
+			break;
+		memcpy(mac, p, 6);
+		return;
+	case BRD_DLINKDSM:
 		read_mac_string(mac, (char *)0xfff0ff80);
 		return;
-	}
-	else
+	default:
 		printf("Warning: This board has no known method defined "
 		"to determine its MAC address!\n");
+		break;
+	}
 
 	/* set to 00:00:00:00:00:00 in case of error */
 	memset(mac, 0, 6);

Index: src/sys/arch/sandpoint/stand/altboot/stg.c
diff -u src/sys/arch/sandpoint/stand/altboot/stg.c:1.3 src/sys/arch/sandpoint/stand/altboot/stg.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/stg.c:1.3	Thu Mar 10 21:11:50 2011
+++ src/sys/arch/sandpoint/stand/altboot/stg.c	Fri Mar 11 17:46:30 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: stg.c,v 1.3 2011/03/10 21:11:50 phx Exp $ */
+/* $NetBSD: stg.c,v 1.4 2011/03/11 17:46:30 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -55,12 +55,13 @@
 	uint64_t xd0, xd1, xd2, dummy;
 };
 #define T1_EMPTY		(1U << 31)	/* no Tx frame available */
-#define T1_NOALIGN		(03 << 16)	/* allow any Tx alignment */
+#define T1_NOALIGN		(3U << 16)	/* allow any Tx alignment */
 #define T1_CNTSHIFT		24		/* Tx fragment count */
-#define T2_LENSHIFT		48		/* Tx frame length */
+#define T2_LENSHIFT		48		/* Tx fragment length */
 #define R1_DONE			(1U << 31)	/* desc has a Rx frame */
 #define R1_FL_MASK		0x		/* Rx frame length */
 #define R1_ER_MASK		0x3f	/* Rx error indication */
+#define R2_LENSHIFT		48		/* Rx fragment length */
 
 #define STGE_DMACtrl		0x00
 #define  DMAC_RxDMAPollNow	(1U << 4)
@@ -161,6 +162,10 @@
 	uint8_t *en;
 	unsigned i;
 	uint32_t macctl, reg;
+	static uint8_t bad[2][6] = {
+		{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+		{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
+	};
 
 	l = ALLOC(struct local, 32);		/* desc alignment */
 	memset(l, 0, sizeof(struct local));
@@ -187,20 +192,10 @@
 
 	/* read ethernet address */
 	en = data;
-	if (PCI_PRODUCT(pcicfgread(tag, PCI_ID_REG)) != 0x1023) {
-		/* read from station address registers when not ST1023 */
-		en[0] = CSR_READ_2(l, STGE_StationAddress0) & 0xff;
-		en[1] = CSR_READ_2(l, STGE_StationAddress0) >> 8;
-		en[2] = CSR_READ_2(l, STGE_StationAddress1) & 0xff;
-		en[3] = CSR_READ_2(l, STGE_StationAddress1) >> 8;
-		en[4] = CSR_READ_2(l, STGE_StationAddress2) & 0xff;
-		en[5] = CSR_READ_2(l, STGE_StationAddress2) >> 8;
-	} else {
-		/* ST1023: read the address from the serial EEPROM */
-		static uint8_t bad[2][6] = {
-			{ 0x00,0x00,0x00,0x00,0x00,0x00 },
-			{ 0xff,0xff,0xff,0xff,0xff,0xff }
-		};
+	for (i = 0; i < 6; i++)
+		en[i] = CSR_READ_1(l, STGE_StationAddress0 + i);
+
+	if (memcmp(en, bad[0], 6) == 0 || memcmp(en, bad[1], 6) == 0) {
 		uint16_t addr[3];
 
 		for (i = 0; i < 3; i++) {
@@ -223,6 +218,7 @@
 		for (i = 0; i < 6; i++)
 			CSR_WRITE_1(l, STGE_StationAddress0 + i, en[i]);
 	}
+
 	printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
 	en[0], en[1], en[2], en[3], en[4], en[5]);
 
@@ -237,10 +233,10 @@
 	txd[1].xd1 = htole64(T1_EMPTY);
 	rxd = &l->rxd[0];
 	rxd[0].xd0 = htole64(VTOPHYS(&rxd[1]));
-	rxd[0].xd2 = htole64((uint64_t)VTOPHYS(l->rxstore[0]) |
+	rxd[0].xd2 = htole64(VTOPHYS(l->rxstore[0]) |
 	((uint64_t)FRAMESIZE << 48));
 	rxd[1].xd0 = htole64(VTOPHYS(&rxd[0]));
-	rxd[1].xd2 = htole64((uint64_t)VTOPHYS(l->rxstore[1]) |
+	rxd[1].xd2 = htole64(VTOPHYS(l->rxstore[1]) |
 	((uint64_t)FRAMESIZE << 48));
 	wbinv(l, sizeof(struct local));
 



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

2011-03-10 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Mar 10 21:11:50 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c globals.h pci.c
pciide.c stg.c

Log Message:
Make sure the device class is IDE (class 0, subclass 1), before checking
the PCI interface for native/legacy mode. Different subclasses are always
assumed being in native mode. That makes the Acard IDE controller work.

New macros for PCI interface, revision and class.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/pci.c \
src/sys/arch/sandpoint/stand/altboot/pciide.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/stg.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.7 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.8
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.7	Sun Mar  6 18:22:13 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Mar 10 21:11:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.7 2011/03/06 18:22:13 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.8 2011/03/10 21:11:49 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
 		/* VIA 686B southbridge at dev 22 */
 		brdtype = BRD_ENCOREPP1;
 	}
-	else if ((pcicfgread(dev11, PCI_CLASS_REG) >> 16) == PCI_CLASS_ETH) {
+	else if (PCI_CLASS(pcicfgread(dev11, PCI_CLASS_REG)) == PCI_CLASS_ETH) {
 		/* ADMtek AN985 (tlp) or RealTek 8169S (re) at dev 11 */
 		brdtype = BRD_KUROBOX;
 	}

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.8 src/sys/arch/sandpoint/stand/altboot/globals.h:1.9
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.8	Sun Mar  6 18:22:13 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Thu Mar 10 21:11:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.8 2011/03/06 18:22:13 phx Exp $ */
+/* $NetBSD: globals.h,v 1.9 2011/03/10 21:11:49 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -80,12 +80,16 @@
 void  pcicfgwrite(unsigned, int, unsigned);
 
 #define PCI_ID_REG			0x00
-#define PCI_COMMAND_STATUS_REG		0x04
 #define  PCI_VENDOR(id)			((id) & 0x)
 #define  PCI_PRODUCT(id)		(((id) >> 16) & 0x)
 #define  PCI_VENDOR_INVALID		0x
 #define  PCI_DEVICE(v,p)		((v) | ((p) << 16))
+#define PCI_COMMAND_STATUS_REG		0x04
 #define PCI_CLASS_REG			0x08
+#define  PCI_CLASS(v)			(((v) >> 16) & 0x)
+#define  PCI_SUBCLASS(v)		(((v) >> 16) & 0xff)
+#define  PCI_INTERFACE(v)		(((v) & 0xff00) >> 8)
+#define  PCI_REVISION(v)		((v) & 0xff)
 #define  PCI_CLASS_PPB			0x0604
 #define  PCI_CLASS_ETH			0x0200
 #define  PCI_CLASS_SCSI			0x0100

Index: src/sys/arch/sandpoint/stand/altboot/pci.c
diff -u src/sys/arch/sandpoint/stand/altboot/pci.c:1.4 src/sys/arch/sandpoint/stand/altboot/pci.c:1.5
--- src/sys/arch/sandpoint/stand/altboot/pci.c:1.4	Mon Feb 14 06:21:29 2011
+++ src/sys/arch/sandpoint/stand/altboot/pci.c	Thu Mar 10 21:11:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.c,v 1.4 2011/02/14 06:21:29 nisimura Exp $ */
+/* $NetBSD: pci.c,v 1.5 2011/03/10 21:11:49 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -190,25 +190,26 @@
 	/* 0x00 */
 #ifdef DEBUG
 	printf("%02d:%02d:%02d:", bus, dev, func);
-	val = cfgread(bus, dev, func, 0x00);
+	val = cfgread(bus, dev, func, PCI_ID_REG);
 	printf(" chip %04x.%04x", val & 0x, val>>16);
 	val = cfgread(bus, dev, func, 0x2c);
 	printf(" card %04x.%04x", val & 0x, val>>16);
-	val = cfgread(bus, dev, func, 0x08);
+	val = cfgread(bus, dev, func, PCI_CLASS_REG);
 	printf(" rev %02x class %02x.%02x.%02x",
-		val & 0xff, (val>>24), (val>>16) & 0xff, (val>>8) & 0xff);
-	val = cfgread(bus, dev, func, 0x0c);
+	PCI_REVISION(val), (val>>24), (val>>16) & 0xff,
+	PCI_INTERFACE(val));
+	val = cfgread(bus, dev, func, PCI_BHLC_REG);
 	printf(" hdr %02x\n", (val>>16) & 0xff);
 #endif
 
 	/* 0x04 */
-	val = cfgread(bus, dev, func, 0x04);
+	val = cfgread(bus, dev, func, PCI_COMMAND_STATUS_REG);
 	val |= 0x0107; /* enable IO,MEM,MASTER,SERR */
 	cfgwrite(bus, dev, func, 0x04, val);
 
 	/* 0x0c */
 	val = 0x80 << 8 | 0x08 /* 32B cache line */;
-	cfgwrite(bus, dev, func, 0x0c, val);
+	cfgwrite(bus, dev, func, PCI_BHLC_REG, val);
 
 	/* 0x3c */
 	val = cfgread(bus, dev, func, 0x3c) & ~0xff;
@@ -217,13 +218,13 @@
 
 	/* 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)
+	if (PCI_CLASS(val) == PCI_CLASS_IDE && (PCI_INTERFACE(val) & 0x05) == 0)
 		return 0;
 
 	memassign(bus, dev, func);
 
 	/* descending toward PCI-PCI bridge

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

2011-03-09 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Mar  9 20:35:56 UTC 2011

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

Log Message:
Check the PCI-interface for legacy/native mode, not the PCI-revision.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/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/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.3 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.3	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Wed Mar  9 20:35:56 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.3 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: pciide.c,v 1.4 2011/03/09 20:35:56 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
 	l->tag = tag;
 
 	val = pcicfgread(tag, PCI_CLASS_REG);
-	native = val & 03;
+	native = ((val >> 8) & 05) != 0;
 	if (native) {
 		/* native, use BAR 01234 */
 		l->bar[0] = pciiobase + (pcicfgread(tag, 0x10) &~ 01);



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

2011-03-08 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Tue Mar  8 19:00:39 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: stg.c

Log Message:
Driver seems to work now. Successfully booted a kernel via BOOTP and NFS on
an ST1023-compatible IC+ IP1000A chip.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/stg.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/altboot/stg.c
diff -u src/sys/arch/sandpoint/stand/altboot/stg.c:1.1 src/sys/arch/sandpoint/stand/altboot/stg.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/stg.c:1.1	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/stg.c	Tue Mar  8 19:00:38 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: stg.c,v 1.1 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: stg.c,v 1.2 2011/03/08 19:00:38 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -52,17 +52,15 @@
 #define ALLOC(T,A)		(T *)allocaligned(sizeof(T),(A))
 
 struct desc {
-	uint64_t xd0, xd1, xd2;
+	uint64_t xd0, xd1, xd2, dummy;
 };
-/* xd1 */
-#define RXLEN(x)		((x) & 0x)
-#define RXERRORMASK		0x3fLL
-#define TXNOALIGN		(1ULL << 16)
-#define TXFRAGCOUNT(x)		(((uint64_t)((x) & 0xf)) << 48)
-#define DONE			(1ULL << 31)
-/* xd2 */
-#define FRAGADDR(x)		((uint64_t)(x))
-#define FRAGLEN(x)		(((uint64_t)((x) & 0x)) << 48)
+#define T1_EMPTY		(1U << 31)	/* no Tx frame available */
+#define T1_NOALIGN		(03 << 16)	/* allow any Tx alignment */
+#define T1_CNTSHIFT		24		/* Tx fragment count */
+#define T2_LENSHIFT		48		/* Tx frame length */
+#define R1_DONE			(1U << 31)	/* desc has a Rx frame */
+#define R1_FL_MASK		0x		/* Rx frame length */
+#define R1_ER_MASK		0x3f	/* Rx error indication */
 
 #define STGE_DMACtrl		0x00
 #define  DMAC_RxDMAComplete	(1U << 3)
@@ -73,6 +71,7 @@
 #define STGE_TFDListPtrHi	0x14
 #define STGE_RFDListPtrLo	0x1c
 #define STGE_RFDListPtrHi	0x20
+#define STGE_DebugCtrl		0x2c
 #define STGE_AsicCtrl		0x30
 #define  AC_PhyMedia		(1U << 7)
 #define  AC_GlobalReset		(1U << 16)
@@ -93,6 +92,8 @@
 #define  EC_EepromBusy		(1U << 15)
 #define STGE_IntEnable		0x5c
 #define STGE_MACCtrl		0x6c
+#define  MC_DuplexSelect	(1U << 5)
+#define  MC_StatisticsDisable	(1U << 22)
 #define  MC_TxEnable		(1U << 24)
 #define  MC_RxEnable		(1U << 27)
 #define STGE_PhyCtrl		0x76
@@ -110,18 +111,17 @@
 #define STGE_StationAddress0	0x78
 #define STGE_StationAddress1	0x7a
 #define STGE_StationAddress2	0x7c
+#define STGE_MaxFrameSize	0x84
+#define STGE_ReceiveMode	0x88
+#define  RM_ReceiveUnicast	(1U << 0)
+#define  RM_ReceiveMulticast	(1U << 1)
+#define  RM_ReceiveBroadcast	(1U << 2)
+#define  RM_ReceiveAllFrames	(1U << 3)
+#define  RM_ReceiveMulticastHash (1U << 4)
+#define  RM_ReceiveIPMulticast	(1U << 5)
 
 #define STGE_EEPROM_SA0		0x10
 
-#define MII_PSSR		0x11	/* MAKPHY status register */
-#define  PSSR_DUPLEX		0x2000	/* FDX */
-#define  PSSR_RESOLVED		0x0800	/* speed and duplex resolved */
-#define  PSSR_LINK		0x0400  /* link indication */
-#define  PSSR_SPEED(x)		(((x) >> 14) & 0x3)
-#define  SPEED10		0
-#define  SPEED100		1
-#define  SPEED1000 		2
-
 #define FRAMESIZE	1536
 
 struct local {
@@ -162,7 +162,7 @@
 	struct desc *txd, *rxd;
 	uint8_t *en;
 	unsigned i;
-	uint32_t reg;
+	uint32_t macctl, reg;
 
 	l = ALLOC(struct local, 32);		/* desc alignment */
 	memset(l, 0, sizeof(struct local));
@@ -231,6 +231,43 @@
 	DPRINTF(("PHY %d (%04x.%04x)\n", l->phy,
 	mii_read(l, l->phy, 2), mii_read(l, l->phy, 3)));
 
+	/* setup descriptors */
+	txd = &l->txd[0];
+	txd[0].xd0 = htole64(VTOPHYS(&txd[1]));
+	txd[0].xd1 = htole64(T1_EMPTY);
+	txd[1].xd0 = htole64(VTOPHYS(&txd[0]));
+	txd[1].xd1 = htole64(T1_EMPTY);
+	rxd = &l->rxd[0];
+	rxd[0].xd0 = htole64(VTOPHYS(&rxd[1]));
+	rxd[0].xd2 = htole64((uint64_t)VTOPHYS(l->rxstore[0]) |
+	((uint64_t)FRAMESIZE << 48));
+	rxd[1].xd0 = htole64(VTOPHYS(&rxd[0]));
+	rxd[1].xd2 = htole64((uint64_t)VTOPHYS(l->rxstore[1]) |
+	((uint64_t)FRAMESIZE << 48));
+	wbinv(l, sizeof(struct local));
+
+	CSR_WRITE_2(l, STGE_IntEnable, 0);
+	CSR_WRITE_2(l, STGE_ReceiveMode, RM_ReceiveUnicast |
+	RM_ReceiveBroadcast | RM_ReceiveAllFrames | RM_ReceiveMulticast);
+	CSR_WRITE_4(l, STGE_TFDListPtrHi, 0);
+	CSR_WRITE_4(l, STGE_TFDListPtrLo, VTOPHYS(txd));
+	CSR_WRITE_4(l, STGE_RFDListPtrHi, 0);
+	CSR_WRITE_4(l, STGE_RFDListPtrLo, VTOPHYS(rxd));
+	CSR_WRITE_2(l, STGE_MaxFrameSize, FRAMESIZE);
+	CSR_WRITE_4(l, STGE_MACCtrl, 0);	/* do IFSSelect(0) first */
+	macctl = MC_StatisticsDisable | MC_TxEnable | MC_RxEnable;
+
+	if ((pcicfgread(tag, PCI_CLASS_REG) & 0xff) >= 6) {
+		/* some workarounds for revisions >= 6 */
+		CSR_WRITE_2(l, STGE_DebugCtrl,
+		CSR_READ_2(l, STGE_DebugCtrl) | 0x0200);
+		CSR_WRITE_2(l, STGE_DebugCtrl,
+		CSR_READ_2(l, STGE_DebugCtrl) | 0x0010);
+		CSR_WRITE_2(l, STGE_DebugCtrl,
+		CSR_READ_2(l, STGE_DebugCtrl) | 0x0020);
+	}
+
+	/* auto ne

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

2011-03-07 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Mon Mar  7 22:18:46 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: printf.c

Log Message:
mkdigit() didn't work with values which have bit 31 set (>=0x8000).
Do not cast to (int).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/printf.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/altboot/printf.c
diff -u src/sys/arch/sandpoint/stand/altboot/printf.c:1.3 src/sys/arch/sandpoint/stand/altboot/printf.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/printf.c:1.3	Sun Jan 23 02:08:24 2011
+++ src/sys/arch/sandpoint/stand/altboot/printf.c	Mon Mar  7 22:18:46 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: printf.c,v 1.3 2011/01/23 02:08:24 nisimura Exp $ */
+/* $NetBSD: printf.c,v 1.4 2011/03/07 22:18:46 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -255,7 +255,7 @@
 	t = ptmp;
 	*t++ = '\0';
 	do {
-		int d = (int)llval % base;
+		int d = llval % base;
 		*t++ = hexdigit[d];
 		llval /= base;
 	} while (llval != 0 && ++n < sizeof(ptmp));



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

2011-03-06 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar  6 20:36:29 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: nif.c

Log Message:
Renamed "stg" to "stge" as in the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/nif.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/altboot/nif.c
diff -u src/sys/arch/sandpoint/stand/altboot/nif.c:1.3 src/sys/arch/sandpoint/stand/altboot/nif.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/nif.c:1.3	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/nif.c	Sun Mar  6 20:36:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nif.c,v 1.3 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: nif.c,v 1.4 2011/03/06 20:36:29 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -54,11 +54,11 @@
 static struct iodesc netdesc;
 
 static struct nifdv lnifdv[] = {
-	{ "fxp", fxp_match, fxp_init, fxp_send, fxp_recv },
-	{ "tlp", tlp_match, tlp_init, tlp_send, tlp_recv },
-	{ "re",  rge_match, rge_init, rge_send, rge_recv },
-	{ "sk",  skg_match, skg_init, skg_send, skg_recv },
-	{ "stg", stg_match, stg_init, stg_send, stg_recv },
+	{ "fxp",  fxp_match, fxp_init, fxp_send, fxp_recv },
+	{ "tlp",  tlp_match, tlp_init, tlp_send, tlp_recv },
+	{ "re",   rge_match, rge_init, rge_send, rge_recv },
+	{ "sk",   skg_match, skg_init, skg_send, skg_recv },
+	{ "stge", stg_match, stg_init, stg_send, stg_recv },
 };
 static int nnifdv = sizeof(lnifdv)/sizeof(lnifdv[0]);
 



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

2011-03-06 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar  6 18:22:13 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile brdsetup.c devopen.c
globals.h main.c
Added Files:
src/sys/arch/sandpoint/stand/altboot: memfs.c memfs.h

Log Message:
Suport for loading a kernel from memory (RAM, ROM or Flash).
The boot file path should look like "mem:", where  is
the start address, in hex notation, of the file in memory.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sandpoint/stand/altboot/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/devopen.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sandpoint/stand/altboot/memfs.c \
src/sys/arch/sandpoint/stand/altboot/memfs.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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.9 src/sys/arch/sandpoint/stand/altboot/Makefile:1.10
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.9	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Sun Mar  6 18:22:13 2011
@@ -1,12 +1,13 @@
-#	$NetBSD: Makefile,v 1.9 2011/03/06 13:55:12 phx Exp $
+#	$NetBSD: Makefile,v 1.10 2011/03/06 18:22:13 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
 PROG=		altboot
 FILES+=		${PROG}.bin ${PROG}.img
 NOMAN=		# defined
-SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c
-SRCS+=		fxp.c tlp.c rge.c skg.c stg.c dsk.c pciide.c siisata.c
+SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c memfs.c
+SRCS+=		nif.c fxp.c tlp.c rge.c skg.c stg.c
+SRCS+=		dsk.c pciide.c siisata.c
 SRCS+=		printf.c vers.c
 CLEANFILES+=	vers.c ${PROG} ${PROG}.bin ${PROG}.img
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple

Index: src/sys/arch/sandpoint/stand/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.6 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.7
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.6	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Mar  6 18:22:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.6 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.7 2011/03/06 18:22:13 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -959,20 +959,13 @@
 	return NULL;
 }
 
-static uint8_t hex2nibble(char c)
-{
-	if (c >= 'a')
-		c &= ~0x20;
-	return c > '9' ? c - 'A' + 10 : c - '0';
-}
-
 static void
 read_mac_string(uint8_t *mac, char *p)
 {
 	int i;
 
 	for (i = 0; i < 6; i++, p += 3)
-		*mac++ = (hex2nibble(p[0]) << 4) | hex2nibble(p[1]);
+		*mac++ = read_hex(p);
 }
 
 /*

Index: src/sys/arch/sandpoint/stand/altboot/devopen.c
diff -u src/sys/arch/sandpoint/stand/altboot/devopen.c:1.1 src/sys/arch/sandpoint/stand/altboot/devopen.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/devopen.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/devopen.c	Sun Mar  6 18:22:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: devopen.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: devopen.c,v 1.2 2011/03/06 18:22:13 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 #include 
 
 #include "globals.h"
+#include "memfs.h"
 
 struct devsw devnet = { "net", net_strategy, net_open, net_close, noioctl };
 struct devsw devdsk = { "dsk", dsk_strategy, dsk_open, dsk_close, noioctl };
@@ -50,6 +51,7 @@
 struct fs_ops fs_tftp  = FS_OPS(tftp);
 struct fs_ops fs_ffsv2 = FS_OPS(ffsv2);
 struct fs_ops fs_ffsv1 = FS_OPS(ffsv1);
+struct fs_ops fs_mem   = FS_OPS(mem);
 extern char *fsmod;
 
 static void parseunit(const char *, int *, int *, char **);
@@ -64,6 +66,13 @@
 	if (of->f_flags != F_READ)
 		return EPERM;
 
+	if (strncmp("mem:", name, 4) == 0) {
+		of->f_dev = NULL;
+		of->f_flags |= F_NODEV;
+		file_system[0] = fs_mem;
+		*file = (char *)&name[4];
+		return 0;		/* MEM */
+	}
 	if (strncmp("net:", name, 4) == 0 || strncmp("nfs:", name, 4) == 0) {
 		of->f_dev = &devnet;
 		if ((error = net_open(of, &name[4], "nfs")) != 0)

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.7 src/sys/arch/sandpoint/stand/altboot/globals.h:1.8
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.7	Sun Mar  6 13:55:12 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Mar  6 18:22:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.7 2011/03/06 13:55:12 phx Exp $ */
+/* $NetBSD: globals.h,v 1.8 2011/03/06 18:22:13 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -117,6 +117,9 @@
 void _wbinv(uint32_t, uint32_t);
 void _inv(uint32_t, uint32_t);
 
+/* parsing */
+uint32_t read_hex(const

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

2011-03-06 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sun Mar  6 13:55:12 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile brdsetup.c dsk.c
globals.h main.c nif.c pciide.c siisata.c
Added Files:
src/sys/arch/sandpoint/stand/altboot: stg.c

Log Message:
New experimental driver for SundanceIT ST1023 / IP1000+ NICs.
PHY initialization, media select and MAC address are working, but I found no
way to make the chip transmit any frame yet (although it clears the DONE flag).

Moved DSK_DECL to globals.h, where NIF_DECL already was.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sandpoint/stand/altboot/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/nif.c \
src/sys/arch/sandpoint/stand/altboot/pciide.c \
src/sys/arch/sandpoint/stand/altboot/siisata.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sandpoint/stand/altboot/stg.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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.8 src/sys/arch/sandpoint/stand/altboot/Makefile:1.9
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.8	Sat Feb 26 20:11:24 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Sun Mar  6 13:55:12 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2011/02/26 20:11:24 phx Exp $
+#	$NetBSD: Makefile,v 1.9 2011/03/06 13:55:12 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -6,8 +6,8 @@
 FILES+=		${PROG}.bin ${PROG}.img
 NOMAN=		# defined
 SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c
-SRCS+=		fxp.c tlp.c rge.c skg.c dsk.c pciide.c siisata.c printf.c
-SRCS+=		vers.c
+SRCS+=		fxp.c tlp.c rge.c skg.c stg.c dsk.c pciide.c siisata.c
+SRCS+=		printf.c vers.c
 CLEANFILES+=	vers.c ${PROG} ${PROG}.bin ${PROG}.img
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith

Index: src/sys/arch/sandpoint/stand/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.5 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.6
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.5	Mon Feb 14 06:21:29 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Mar  6 13:55:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.5 2011/02/14 06:21:29 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.6 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -959,6 +959,22 @@
 	return NULL;
 }
 
+static uint8_t hex2nibble(char c)
+{
+	if (c >= 'a')
+		c &= ~0x20;
+	return c > '9' ? c - 'A' + 10 : c - '0';
+}
+
+static void
+read_mac_string(uint8_t *mac, char *p)
+{
+	int i;
+
+	for (i = 0; i < 6; i++, p += 3)
+		*mac++ = (hex2nibble(p[0]) << 4) | hex2nibble(p[1]);
+}
+
 /*
  * For cost saving reasons some NAS boxes are missing the ROM for the
  * NIC's ethernet address and keep it in their Flash memory.
@@ -974,7 +990,11 @@
 			memcpy(mac, p, 6);
 			return;
 		}
-	} else
+	} else if (brdtype == BRD_DLINKDSM) {
+		read_mac_string(mac, (char *)0xfff0ff80);
+		return;
+	}
+	else
 		printf("Warning: This board has no known method defined "
 		"to determine its MAC address!\n");
 

Index: src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.4 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.5
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.4	Thu Feb 10 13:38:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Sun Mar  6 13:55:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.5 2011/03/06 13:55:12 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -57,13 +57,6 @@
 #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 *);

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.6 src/sys/arch/sandpoint/stand/altboot/globals.h:1.7
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.6	Mon Feb 14 06:21:29 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Mar  6 13:55:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.6 2011/02/14 06:21:29 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.7 2011/03/06 13:55:12 phx Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -88,6 +88,7 @@
 #define PCI_CLASS_REG			0x08
 #define  PCI_CLA

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

2011-02-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Sat Feb 26 20:11:24 UTC 2011

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

Log Message:
Build altboot.img, which fakes a Linux kernel module, loadable with "bootm",
for extremely stripped U-Boot firmware. Arguments are passed through the
"bootargs" environment variable, which is detected automatically when
using bootm.
The startup code also fixes a bug in bootm, which doesn't flush the cache
before running the image.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sandpoint/stand/altboot/Makefile
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/entry.S
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.7 src/sys/arch/sandpoint/stand/altboot/Makefile:1.8
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.7	Fri Jan 28 22:15:36 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Sat Feb 26 20:11:24 2011
@@ -1,14 +1,14 @@
-#	$NetBSD: Makefile,v 1.7 2011/01/28 22:15:36 phx Exp $
+#	$NetBSD: Makefile,v 1.8 2011/02/26 20:11:24 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
 PROG=		altboot
-FILES+=		${PROG}.bin
+FILES+=		${PROG}.bin ${PROG}.img
 NOMAN=		# defined
 SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c
 SRCS+=		fxp.c tlp.c rge.c skg.c dsk.c pciide.c siisata.c printf.c
 SRCS+=		vers.c
-CLEANFILES+=	vers.c ${PROG} ${PROG}.bin
+CLEANFILES+=	vers.c ${PROG} ${PROG}.bin ${PROG}.img
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
@@ -63,6 +63,8 @@
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \
 	${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
-	${OBJCOPY} -S -O binary ${.TARGET} ${.TARGET}.bin
+	${OBJCOPY} -S -O binary ${PROG} ${PROG}.bin
+	${TOOL_MKUBOOTIMAGE} -A powerpc -T kernel -C none -O linux \
+	-a 0x${RELOC} -n ${PROG} ${PROG}.bin ${PROG}.img
 
 .include 

Index: src/sys/arch/sandpoint/stand/altboot/entry.S
diff -u src/sys/arch/sandpoint/stand/altboot/entry.S:1.1 src/sys/arch/sandpoint/stand/altboot/entry.S:1.2
--- src/sys/arch/sandpoint/stand/altboot/entry.S:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/entry.S	Sat Feb 26 20:11:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: entry.S,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: entry.S,v 1.2 2011/02/26 20:11:24 phx Exp $ */
 
 #include 
 #include 
@@ -9,8 +9,41 @@
 	.text
 	.globl _start
 _start:
+	/*
+	 * Save possible argc and argv values from the firmware, usually
+	 * passed in r3 and r4.
+	 * When started with "bootm", as a Linux kernel module, r6 and r7
+	 * point to the start and end address of the bootargs.
+	 */
 	mr	30,3
 	mr	31,4
+	mr	28,6
+	mr	29,7
+
+	/*
+	 * U-Boot/PPCBoot forgets to flush the cache when using the "bootm"
+	 * command, so we have to do that now.
+	 */
+	lis	3,_start@ha
+	addi	3,3,_start@l
+	andi.	3,3,~31@l
+	lis	4,(_edata+31)@ha
+	addi	4,4,(_edata+31)@l
+	mr	5,3
+10:
+	dcbst	0,5
+	addi	5,5,32
+	cmplw	5,4
+	ble	10b
+	sync
+11:
+	icbi	0,3
+	addi	3,3,32
+	cmplw	3,4
+	ble	11b
+	sync
+	isync
+
 	mfspr	11,SPR_HID0
 	andi.	0,11,HID0_DCE
 	ori	11,11,HID0_ICE
@@ -93,6 +126,8 @@
 	bl	brdsetup
 	mr	3,30
 	mr	4,31
+	mr	5,28
+	mr	6,29
 	bl	main
 
 hang:	b	hang

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.6 src/sys/arch/sandpoint/stand/altboot/main.c:1.7
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.6	Thu Feb 10 13:38:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sat Feb 26 20:11:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.6 2011/02/10 13:38:08 nisimura Exp $ */
+/* $NetBSD: main.c,v 1.7 2011/02/26 20:11:24 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
 void module_load(char *);
 int module_open(struct boot_module *);
 
-void main(int, char **);
+void main(int, char **, char *, char *);
 extern char bootprog_name[], bootprog_rev[];
 
 struct pcidev lata[2];
@@ -100,13 +100,18 @@
 uint32_t busclock, cpuclock;
 
 static int check_bootname(char *);
+static int parse_cmdline(char **, int, char *, char *);
+static int is_space(char);
+
 #define	BNAME_DEFAULT "nfs:"
+#define MAX_ARGS 10
 
 void
-main(int argc, char *argv[])
+main(int argc, char *argv[], char *bootargs_start, char *bootargs_end)
 {
 	struct brdprop *brdprop;
 	unsigned long marks[MARK_MAX];
+	char *new_argv[MAX_ARGS];
 	int n, i, fd, howto;
 	char *bname;
 
@@ -166,6 +171,18 @@
 	if (netif_init(&lnif[0]) == 0)
 		printf("no NET device driver was found\n");
 
+	/*
+	 * When arg

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

2011-02-13 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Mon Feb 14 06:21:29 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c globals.h pci.c

Log Message:
- add preliminary Netronics NH230 and NH231 supports.
- assign PCI configuration register 0x3c with IDSEL value by PCI framework,
  eliminating most of pcifixup() logic in simple NASes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/pci.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.4 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.5
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.4	Thu Feb 10 13:38:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Feb 14 06:21:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.5 2011/02/14 06:21:29 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -54,6 +54,7 @@
 BRD_DECL(qnap);
 BRD_DECL(iomega);
 BRD_DECL(dlink);
+BRD_DECL(nhnas);
 
 static struct brdprop brdlist[] = {
 {
@@ -62,21 +63,21 @@
 	BRD_SANDPOINTX3,
 	0,
 	"com", 0x3f8, 115200,
-	motsetup, motbrdfix, motpcifix },
+	motsetup, motbrdfix, motpcifix, NULL },
 {
 	"encpp1",
 	"EnCore PP1",
 	BRD_ENCOREPP1,
 	0,
 	"com", 0x3f8, 115200,
-	encsetup, encbrdfix, encpcifix },
+	encsetup, encbrdfix, encpcifix, NULL },
 {
 	"kurobox",
 	"KuroBox",
 	BRD_KUROBOX,
 	32768000,
 	"eumb", 0x4600, 57600,
-	kurosetup, kurobrdfix, kuropcifix },
+	kurosetup, kurobrdfix, NULL, NULL },
 {
 	"synology",
 	"Synology DS",
@@ -84,35 +85,42 @@
 	33164691,	/* from Synology/Linux source */
 	/* 33168000,		XXX better precision? */
 	"eumb", 0x4500, 115200,
-	synosetup, synobrdfix, synopcifix, synoreset },
+	NULL, synobrdfix, NULL, synoreset },
 {
 	"qnap",
 	"QNAP TS-101",
 	BRD_QNAPTS101,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, NULL, qnappcifix },
+	NULL, qnapbrdfix, NULL, NULL },
 {
 	"iomega",
 	"IOMEGA StorCenter",
 	BRD_STORCENTER,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, iomegabrdfix, iomegapcifix },
+	NULL, iomegabrdfix, NULL, NULL },
 {
 	"dlink",
 	"D-Link DSM-G600",
 	BRD_DLINKDSM,
 	0,
 	"eumb", 0x4500, 9600,
-	NULL, dlinkbrdfix, dlinkpcifix },
+	NULL, dlinkbrdfix, NULL, NULL },
+{
+	"nhnas",
+	"Netronics NH230/231",
+	BRD_NH230NAS,
+	0,
+	"eumb", 0x4500, 9600,
+	NULL, nhnasbrdfix, NULL, NULL },
 {
 	"unknown",
 	"Unknown board",
 	BRD_UNKNOWN,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, NULL, NULL }, /* must be the last */
+	NULL, NULL, NULL, NULL }, /* must be the last */
 };
 
 static struct brdprop *brdprop;
@@ -169,7 +177,7 @@
 	char *consname;
 	int consport;
 	uint32_t extclk;
-	unsigned pchb, pcib, val;
+	unsigned pchb, pcib, dev11, dev13, dev15, dev16, val;
 	extern struct btinfo_memory bi_mem;
 	extern struct btinfo_console bi_cons;
 	extern struct btinfo_clock bi_clk;
@@ -190,33 +198,44 @@
 	extclk = EXT_CLK_FREQ;	/* usually 33MHz */
 	busclock = 0;
 
+	dev11 = pcimaketag(0, 11, 0);
+	dev13 = pcimaketag(0, 13, 0);
+	dev15 = pcimaketag(0, 15, 0);
+	dev16 = pcimaketag(0, 16, 0);
+
 	if (pcifinddev(0x10ad, 0x0565, &pcib) == 0) {
+		/* WinBond 553 southbridge at dev 11 */
 		brdtype = BRD_SANDPOINTX3;
 	}
 	else if (pcifinddev(0x1106, 0x0686, &pcib) == 0) {
+		/* VIA 686B southbridge at dev 22 */
 		brdtype = BRD_ENCOREPP1;
 	}
-	else if ((pcicfgread(pcimaketag(0, 11, 0), PCI_CLASS_REG) >> 16) ==
-	PCI_CLASS_ETH) {
-		/* tlp (ADMtek AN985) or re (RealTek 8169S) at dev 11 */
+	else if ((pcicfgread(dev11, PCI_CLASS_REG) >> 16) == PCI_CLASS_ETH) {
+		/* ADMtek AN985 (tlp) or RealTek 8169S (re) at dev 11 */
 		brdtype = BRD_KUROBOX;
 	}
-	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
-	0x11ab) {/* PCI_VENDOR_MARVELL */
+	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x11ab) {
+		/* SKnet/Marvell (sk) at dev 15 */
 		brdtype = BRD_SYNOLOGY;
 	}
-	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 15, 0), PCI_ID_REG)) ==
-	0x8086) {/* PCI_VENDOR_INTEL */
+	else if (PCI_VENDOR(pcicfgread(dev15, PCI_ID_REG)) == 0x8086) {
+		/* Intel (wm) at dev 15 */
 		brdtype = BRD_QNAPTS101;
 	}
-	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 13, 0), PCI_ID_REG)) ==
-	0x1106) {/* PCI_VENDOR_VIA */
+	else if (PCI_VENDOR(pcicfgread(dev13, PCI_ID_REG)) == 0x1106) {
+		/* VIA 6410 (viaide) at dev 13 */
 		brdtype = BRD_STORCENTER;
 	}
-	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 16, 0), PCI_ID_REG)) ==
-	0x1191) {/* PCI_VENDOR_ACARD */
+	else if (PCI_VENDOR(pcicfgread(dev16, PCI_ID_REG)) == 0x1191) {
+		/* ACARD ATP865 (acardide) at dev 16 */
 		brdtype = BRD_DLINK

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

2011-02-10 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Feb 10 13:38:08 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c dsk.c globals.h main.c
nif.c pci.c

Log Message:
- some rework for PCI device enumeration.
- allow dual IDE/SATA devices.
- fix a typo of D-Link #define.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/brdsetup.c \
src/sys/arch/sandpoint/stand/altboot/dsk.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/main.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/nif.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/pci.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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.3 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.3	Tue Feb  8 00:33:05 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Thu Feb 10 13:38:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.3 2011/02/08 00:33:05 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.4 2011/02/10 13:38:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -101,8 +101,8 @@
 	NULL, iomegabrdfix, iomegapcifix },
 {
 	"dlink",
-	"D-Link GSM-G600",
-	BRD_DLINKGSM,
+	"D-Link DSM-G600",
+	BRD_DLINKDSM,
 	0,
 	"eumb", 0x4500, 9600,
 	NULL, dlinkbrdfix, dlinkpcifix },
@@ -215,7 +215,7 @@
 	}
 	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 16, 0), PCI_ID_REG)) ==
 	0x1191) {/* PCI_VENDOR_ACARD */
-		brdtype = BRD_DLINKGSM;
+		brdtype = BRD_DLINKDSM;
 	}
 
 	brdprop = brd_lookup(brdtype);
@@ -406,12 +406,12 @@
 void
 motpcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, pcib, steer, val;
+	unsigned ide, net, pcib, steer, val;
 	int line;
 
 	pcib = pcimaketag(0, 11, 0);
 	ide  = pcimaketag(0, 11, 1);
-	nic  = pcimaketag(0, 15, 0);
+	net  = pcimaketag(0, 15, 0);
 
 	/*
 	 *  WinBond PIRQ 
@@ -492,21 +492,21 @@
 	 *  fxp fixup 
 	 * - use PCI pin A line 15 (fxp 0x3d/3c)
 	 */
-	val = pcicfgread(nic, 0x3c) & 0x;
-	pcidecomposetag(nic, NULL, &line, NULL);
+	val = pcicfgread(net, 0x3c) & 0x;
+	pcidecomposetag(net, NULL, &line, NULL);
 	val |= (('A' - '@') << 8) | line;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
 encpcifix(struct brdprop *brd)
 {
-	unsigned ide, irq, nic, pcib, steer, val;
+	unsigned ide, irq, net, pcib, steer, val;
 
 #define	STEER(v, b) (((v) & (b)) ? "edge" : "level")
 	pcib = pcimaketag(0, 22, 0);
 	ide  = pcimaketag(0, 22, 1);
-	nic  = pcimaketag(0, 25, 0);
+	net  = pcimaketag(0, 25, 0);
 
 	/*
 	 *  VIA PIRQ 
@@ -603,9 +603,9 @@
 	 * - use PCI pin A line 25 (fxp 0x3d/3c)
 	 */
 	/* 0x3d/3c - PCI pin/line */
-	val = pcicfgread(nic, 0x3c) & 0x;
+	val = pcicfgread(net, 0x3c) & 0x;
 	val |= (('A' - '@') << 8) | 25;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -630,17 +630,17 @@
 void
 kuropcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	nic = pcimaketag(0, 11, 0);
-	val = pcicfgread(nic, 0x3c) & 0xff00;
+	net = pcimaketag(0, 11, 0);
+	val = pcicfgread(net, 0x3c) & 0xff00;
 	val |= 11;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 
-	ide = pcimaketag(0, 12, 0);
-	val = pcicfgread(ide, 0x3c) & 0xff00;
+	dsk = pcimaketag(0, 12, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xff00;
 	val |= 12;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xff00;
@@ -677,12 +677,12 @@
 void
 synopcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	ide = pcimaketag(0, 13, 0);
-	val = pcicfgread(ide, 0x3c) & 0xff00;
+	dsk = pcimaketag(0, 13, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xff00;
 	val |= 13;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xff00;
@@ -699,10 +699,10 @@
 	val |= 14;
 	pcicfgwrite(usb, 0x3c, val);
 
-	nic = pcimaketag(0, 15, 0);
-	val = pcicfgread(nic, 0x3c) & 0xff00;
+	net = pcimaketag(0, 15, 0);
+	val = pcicfgread(net, 0x3c) & 0xff00;
 	val |= 15;
-	pcicfgwrite(nic, 0x3c, val);
+	pcicfgwrite(net, 0x3c, val);
 }
 
 void
@@ -716,12 +716,12 @@
 void
 qnappcifix(struct brdprop *brd)
 {
-	unsigned ide, nic, usb, val;
+	unsigned dsk, net, usb, val;
 
-	ide = pcimaketag(0, 13, 0);
-	val = pcicfgread(ide, 0x3c) & 0xff00;
+	dsk = pcimaketag(0, 13, 0);
+	val = pcicfgread(dsk, 0x3c) & 0xff00;
 	val |= 13;
-	pcicfgwrite(ide, 0x3c, val);
+	pcicfgwrite(dsk, 0x3c, val);
 
 	usb = pcimaketag(0, 14, 0);
 	val = pcicfgread(usb, 0x3c) & 0xfff

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

2011-02-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Feb  8 00:33:05 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: brdsetup.c globals.h pciide.c

Log Message:
- add preliminary code to support D-Link DSM-G600 rev.B NAS.
- it features 9600bps console, Moto MCU on the 2nd DUART channel,
  ACARD ATP865 PCIIDE and IP Plus IP1000A GbE.  It has MiniPCI
  slot.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.2 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.2	Mon Feb  7 12:45:21 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Tue Feb  8 00:33:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.2 2011/02/07 12:45:21 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.3 2011/02/08 00:33:05 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -53,6 +53,7 @@
 BRD_DECL(syno);
 BRD_DECL(qnap);
 BRD_DECL(iomega);
+BRD_DECL(dlink);
 
 static struct brdprop brdlist[] = {
 {
@@ -99,6 +100,13 @@
 	"eumb", 0x4500, 115200,
 	NULL, iomegabrdfix, iomegapcifix },
 {
+	"dlink",
+	"D-Link GSM-G600",
+	BRD_DLINKGSM,
+	0,
+	"eumb", 0x4500, 9600,
+	NULL, dlinkbrdfix, dlinkpcifix },
+{
 	"unknown",
 	"Unknown board",
 	BRD_UNKNOWN,
@@ -205,6 +213,10 @@
 	0x1106) {/* PCI_VENDOR_VIA */
 		brdtype = BRD_STORCENTER;
 	}
+	else if (PCI_VENDOR(pcicfgread(pcimaketag(0, 16, 0), PCI_ID_REG)) ==
+	0x1191) {/* PCI_VENDOR_ACARD */
+		brdtype = BRD_DLINKGSM;
+	}
 
 	brdprop = brd_lookup(brdtype);
 
@@ -771,6 +783,44 @@
 }
 
 void
+dlinkbrdfix(struct brdprop *brd)
+{
+
+	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
+}
+
+void
+dlinkpcifix(struct brdprop *brd)
+{
+	unsigned usb, nic, ide, 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);
+
+	ide = pcimaketag(0, 16, 0);
+	val = pcicfgread(ide, 0x3c) & 0xff00;
+	val |= 16;
+	pcicfgwrite(ide, 0x3c, val);
+}
+
+void
 _rtt(void)
 {
 

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.3 src/sys/arch/sandpoint/stand/altboot/globals.h:1.4
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.3	Thu Jan 27 17:38:04 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Tue Feb  8 00:33:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.3 2011/01/27 17:38:04 phx Exp $ */
+/* $NetBSD: globals.h,v 1.4 2011/02/08 00:33:05 nisimura Exp $ */
 
 #ifdef DEBUG
 #define	DPRINTF(x)	printf x
@@ -20,6 +20,7 @@
 #define BRD_QNAPTS101		101
 #define BRD_SYNOLOGY		102
 #define BRD_STORCENTER		103
+#define BRD_DLINKGSM		104
 #define BRD_UNKNOWN		-1
 
 struct brdprop {

Index: src/sys/arch/sandpoint/stand/altboot/pciide.c
diff -u src/sys/arch/sandpoint/stand/altboot/pciide.c:1.1 src/sys/arch/sandpoint/stand/altboot/pciide.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/pciide.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/pciide.c	Tue Feb  8 00:33:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pciide.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: pciide.c,v 1.2 2011/02/08 00:33:05 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 };
 static int cmdidefix(struct dkdev_ata *);
 static struct myops cmdideops = { cmdidefix, NULL };
-static struct myops *myops = &cmdideops;
+static struct myops *myops;
 
 int pciide_match(unsigned, void *);
 void *pciide_init(unsigned, void *);
@@ -56,10 +56,13 @@
 	v = pcicfgread(tag, PCI_ID_REG);
 	switch (v) {
 	case PCI_DEVICE(0x1095, 0x0680): /* SiI 0680 IDE */
+		myops = &cmdideops;
+		return 1;
 	case PCI_DEVICE(0x1283, 0x8211): /* ITE 8211 IDE */
 	case PCI_DEVICE(0x1106, 0x1571): /* VIA 82C586 IDE */
 	case PCI_DEVICE(0x10ad, 0x0105): /* Symphony Labs 82C105 IDE */
 	case PCI_DEVICE(0x10b8, 0x5229): /* ALi IDE */
+	case PCI_DEVICE(0x1191, 0x0008): /* ACARD ATP865 */
 		return 1;
 	}
 	return 0;



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

2011-02-07 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Mon Feb  7 12:45:21 UTC 2011

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

Log Message:
add IOMEGA StorCenter fixup codes.  Need more change as the satellite
microcontroller protocol is defined in 8-byte fixed length sequence.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/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/altboot/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.1 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Mon Feb  7 12:45:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: brdsetup.c,v 1.2 2011/02/07 12:45:21 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,6 +52,7 @@
 BRD_DECL(kuro);
 BRD_DECL(syno);
 BRD_DECL(qnap);
+BRD_DECL(iomega);
 
 static struct brdprop brdlist[] = {
 {
@@ -92,11 +93,11 @@
 	NULL, NULL, qnappcifix },
 {
 	"iomega",
-	"IOMEGA Storcenter",
+	"IOMEGA StorCenter",
 	BRD_STORCENTER,
 	0,
 	"eumb", 0x4500, 115200,
-	NULL, NULL, NULL },
+	NULL, iomegabrdfix, iomegapcifix },
 {
 	"unknown",
 	"Unknown board",
@@ -693,6 +694,14 @@
 }
 
 void
+synoreset()
+{
+
+	send_sat("C");
+	/*NOTRECHED*/
+}
+
+void
 qnappcifix(struct brdprop *brd)
 {
 	unsigned ide, nic, usb, val;
@@ -724,11 +733,41 @@
 }
 
 void
-synoreset()
+iomegabrdfix(struct brdprop *brd)
 {
 
-	send_sat("C");
-	/*NOTRECHED*/
+	init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
+}
+
+void
+iomegapcifix(struct brdprop *brd)
+{
+	unsigned ide, nic, usb, val;
+
+	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);
 }
 
 void



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

2011-01-27 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Jan 27 17:38:05 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: dsk.c fxp.c globals.h main.c
nvt.c pci.c rge.c siisata.c sip.c skg.c sme.c vge.c wm.c

Log Message:
Debugging output is only visible when DEBUG is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/dsk.c \
src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/fxp.c \
src/sys/arch/sandpoint/stand/altboot/nvt.c \
src/sys/arch/sandpoint/stand/altboot/pci.c \
src/sys/arch/sandpoint/stand/altboot/rge.c \
src/sys/arch/sandpoint/stand/altboot/siisata.c \
src/sys/arch/sandpoint/stand/altboot/sip.c \
src/sys/arch/sandpoint/stand/altboot/skg.c \
src/sys/arch/sandpoint/stand/altboot/sme.c \
src/sys/arch/sandpoint/stand/altboot/vge.c \
src/sys/arch/sandpoint/stand/altboot/wm.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.2 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.2	Sun Jan 23 01:32:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Thu Jan 27 17:38:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.3 2011/01/27 17:38:04 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -239,12 +239,10 @@
 	uint64_t huge;
 
 	p = (uint16_t *)ident;
-#if 1
-printf("[49]%04x [82]%04x [83]%04x [84]%04x "
-	   "[85]%04x [86]%04x [87]%04x [88]%04x\n",
-		p[49], p[82], p[83], p[84],
-		p[85], p[86], p[87], p[88]);
-#endif
+	DPRINTF(("[49]%04x [82]%04x [83]%04x [84]%04x "
+	   "[85]%04x [86]%04x [87]%04x [88]%04x\n",
+	p[49], p[82], p[83], p[84],
+	p[85], p[86], p[87], p[88]));
 	huge = 0;
 	printf("%s: ", d->xname);
 	printf("<%s> ", mkident((char *)ident + 54, 40));
@@ -332,7 +330,6 @@
   found:
 	d->dlabel = allocaligned(sizeof(struct disklabel), 4);
 	memcpy(d->dlabel, dlp, sizeof(struct disklabel));
-#if 1
 	for (i = 0; i < dlp->d_npartitions; i += 1) {
 		const char *type;
 		pp = &dlp->d_partitions[i];
@@ -351,7 +348,6 @@
 		if (type != NULL)
 			printf("%s%c: %s\n", d->xname, i + 'a', type);
 	}
-#endif
 }
 
 static void
@@ -480,9 +476,6 @@
 	}
 	return ENXIO;
   found:
-#if 0
-printf("dsk_open found %s\n", fsmod);
-#endif
 	d->fsops = fs;
 	f->f_devdata = d;
 
@@ -512,9 +505,6 @@
 	struct disklabel *dlp;
 	int64_t bno;
 
-#if 0
-printf("%s %lld %d\n", d->xname, dblk, size);
-#endif
 	if (size == 0)
 		return 0;
 	if (rw != F_READ)
Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.2 src/sys/arch/sandpoint/stand/altboot/globals.h:1.3
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.2	Sun Jan 23 01:32:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Thu Jan 27 17:38:04 2011
@@ -1,4 +1,10 @@
-/* $NetBSD: globals.h,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.3 2011/01/27 17:38:04 phx Exp $ */
+
+#ifdef DEBUG
+#define	DPRINTF(x)	printf x
+#else
+#define	DPRINTF(x)
+#endif
 
 /* clock feed */
 #ifndef EXT_CLK_FREQ

Index: src/sys/arch/sandpoint/stand/altboot/fxp.c
diff -u src/sys/arch/sandpoint/stand/altboot/fxp.c:1.1 src/sys/arch/sandpoint/stand/altboot/fxp.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/fxp.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/fxp.c	Thu Jan 27 17:38:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: fxp.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: fxp.c,v 1.2 2011/01/27 17:38:04 phx Exp $ */
 
 /*
  * most of the following code was imported from dev/ic/i82557.c; the
@@ -132,7 +132,9 @@
 static void autosize_eeprom(struct local *);
 static int read_eeprom(struct local *, int);
 static void fxp_scb_wait(struct local *);
+#ifdef DEBUG
 static int fxp_mdi_read(struct local *, int, int);
+#endif
 
 /*
  * Template for default configuration parameters.
@@ -208,8 +210,8 @@
 	printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x, ",
 		en[0], en[1], en[2], en[3], en[4], en[5]);
 
-	printf("PHY %d (%04x.%04x)\n", fxp_mdi_read(sc, 1, 18),
-	   fxp_mdi_read(sc, 1, 2), fxp_mdi_read(sc, 1, 3));
+	DPRINTF(("PHY %d (%04x.%04x)\n", fxp_mdi_read(sc, 1, 18),
+	   fxp_mdi_read(sc, 1, 2), fxp_mdi_read(sc, 1, 3)));
 
 	/* 
 	 * Initialize base of CBL and RFA memory. Loading with zero
@@ -505,6 +507,7 @@
 		printf("SCB timeout\n");
 }
 
+#ifdef DEBUG
 static int
 fxp_mdi_read(struct local *sc, int phy, int reg)
 {
@@ -523,3 +526,4 @@
 
 	return (value & 0x);
 }
+#endif
Index: src/sys/arch/sandpoint/stand/altboot/nvt.c
diff -u src/sys/arch/sandpoint/stand/altboot/nvt.c:1.1 src/sys/arch/sandpoin

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

2011-01-27 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Thu Jan 27 16:13:51 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile

Log Message:
Some cleanup. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sandpoint/stand/altboot/Makefile

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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.5 src/sys/arch/sandpoint/stand/altboot/Makefile:1.6
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.5	Thu Jan 27 04:54:40 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Thu Jan 27 16:13:51 2011
@@ -1,12 +1,13 @@
-#	$NetBSD: Makefile,v 1.5 2011/01/27 04:54:40 nisimura Exp $
+#	$NetBSD: Makefile,v 1.6 2011/01/27 16:13:51 phx Exp $
 
 S=		${.CURDIR}/../../../..
 
 PROG=		altboot
 NOMAN=		# defined
-SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c \
-		fxp.c tlp.c rge.c skg.c dsk.c pciide.c siisata.c printf.c
-CLEANFILES+=	vers.c vers.o ${PROG} ${PROG}.bin
+SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c
+SRCS+=		fxp.c tlp.c rge.c skg.c dsk.c pciide.c siisata.c printf.c
+SRCS+=		vers.c
+CLEANFILES+=	vers.c ${PROG} ${PROG}.bin
 CFLAGS+=	-Wall -Wno-main -ffreestanding -msoft-float -mmultiple
 CFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
@@ -53,17 +54,14 @@
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=		${SALIB}
 
-${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
+.PHONY: vers.c
+vers.c: version
 	${HOST_SH} ${S}/conf/newvers_stand.sh -K \
-	${${MKREPRO} == "yes" :?:-D} ${.CURDIR}/version sandpoint
-	${CC} -c vers.c
+	${${MKREPRO} == "yes" :?:-D} ${.CURDIR}/version "sandpoint"
+
+${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \
-	${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBKERN}
+	${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
 	${OBJCOPY} -S -O binary ${.TARGET} ${.TARGET}.bin
 
 .include 
-
-cleandir distclean: .WAIT cleanlibdir
-
-cleanlibdir:
-	-rm -rf lib



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

2011-01-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Jan 27 04:54:40 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile

Log Message:
remove an excess echo line accidentally creeped in.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sandpoint/stand/altboot/Makefile

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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.4 src/sys/arch/sandpoint/stand/altboot/Makefile:1.5
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.4	Thu Jan 27 04:32:49 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Thu Jan 27 04:54:40 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2011/01/27 04:32:49 nisimura Exp $
+#	$NetBSD: Makefile,v 1.5 2011/01/27 04:54:40 nisimura Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -54,7 +54,6 @@
 LIBSA=		${SALIB}
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
-	echo ${OBJS}
 	${HOST_SH} ${S}/conf/newvers_stand.sh -K \
 	${${MKREPRO} == "yes" :?:-D} ${.CURDIR}/version sandpoint
 	${CC} -c vers.c



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

2011-01-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Jan 27 04:32:49 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile

Log Message:
arrange vers.c generation to honour MKREPRO for global build control.


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

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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.3 src/sys/arch/sandpoint/stand/altboot/Makefile:1.4
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.3	Wed Jan 26 13:36:49 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Thu Jan 27 04:32:49 2011
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.3 2011/01/26 13:36:49 nisimura Exp $
+#	$NetBSD: Makefile,v 1.4 2011/01/27 04:32:49 nisimura Exp $
 
 S=		${.CURDIR}/../../../..
 
 PROG=		altboot
+NOMAN=		# defined
 SRCS=		entry.S main.c brdsetup.c pci.c devopen.c dev_net.c nif.c \
 		fxp.c tlp.c rge.c skg.c dsk.c pciide.c siisata.c printf.c
 CLEANFILES+=	vers.c vers.o ${PROG} ${PROG}.bin
@@ -14,20 +15,20 @@
 CPPFLAGS+=	-nostdinc -I. -I${.OBJDIR} -I${S}
 DBG=		-Os
 
+.include 
+
 # XXX SHOULD NOT NEED TO DEFINE THESE!
 LIBCRT0=
 LIBC=
 LIBCRTBEGIN=
 LIBCRTEND=
 
-NOMAN=		# defined
 STRIPFLAG=
 BINMODE=	444
 
 RELOC=		100
 ENTRY=		_start
 
-
 .if !make(obj) && !make(clean) && !make(cleandir)
 .BEGIN:
 	@[ -h machine ] || ln -s ${S}/arch/${MACHINE}/include machine
@@ -53,7 +54,9 @@
 LIBSA=		${SALIB}
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
-	${HOST_SH} ${S}/conf/newvers_stand.sh -KD ${.CURDIR}/version sandpoint
+	echo ${OBJS}
+	${HOST_SH} ${S}/conf/newvers_stand.sh -K \
+	${${MKREPRO} == "yes" :?:-D} ${.CURDIR}/version sandpoint
 	${CC} -c vers.c
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \
 	${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBKERN}



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

2011-01-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Jan 26 13:36:49 UTC 2011

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

Log Message:
one more twist to complete newvers_stand.sh transition. Include timestamp
in banner.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/stand/altboot/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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.2 src/sys/arch/sandpoint/stand/altboot/Makefile:1.3
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.2	Sun Jan 23 07:41:38 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Wed Jan 26 13:36:49 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2011/01/23 07:41:38 nisimura Exp $
+#	$NetBSD: Makefile,v 1.3 2011/01/26 13:36:49 nisimura Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -53,7 +53,7 @@
 LIBSA=		${SALIB}
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
-	${HOST_SH} ${S}/conf/newvers_stand.sh -K ${.CURDIR}/version "sandpoint"
+	${HOST_SH} ${S}/conf/newvers_stand.sh -KD ${.CURDIR}/version sandpoint
 	${CC} -c vers.c
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \
 	${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBKERN}

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.3 src/sys/arch/sandpoint/stand/altboot/main.c:1.4
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.3	Wed Jan 26 13:13:25 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Wed Jan 26 13:36:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.3 2011/01/26 13:13:25 phx Exp $ */
+/* $NetBSD: main.c,v 1.4 2011/01/26 13:36:49 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@
 int module_open(struct boot_module *);
 
 void main(int, char **);
-extern char bootprog_name[], bootprog_rev[], bootprog_maker[], bootprog_date[];
+extern char bootprog_name[], bootprog_rev[];
 
 int brdtype;
 uint32_t busclock, cpuclock;



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

2011-01-26 Thread Frank Wille
Module Name:src
Committed By:   phx
Date:   Wed Jan 26 13:13:25 UTC 2011

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

Log Message:
bootprog_maker and bootprog_date are missing since we switched to the
MI newvers_stand.sh script. Remove the refering information line.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/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/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.2 src/sys/arch/sandpoint/stand/altboot/main.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.2	Sun Jan 23 07:41:38 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Wed Jan 26 13:13:25 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.2 2011/01/23 07:41:38 nisimura Exp $ */
+/* $NetBSD: main.c,v 1.3 2011/01/26 13:13:25 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -110,10 +110,9 @@
 
 	printf("\n");
 	printf(">> %s altboot, revision %s\n", bootprog_name, bootprog_rev);
-	printf(">> (%s, %s)\n", bootprog_maker, bootprog_date);
 
 	brdprop = brd_lookup(brdtype);
-	printf("%s, cpu %u MHz, bus %u MHz, %dMB SDRAM\n", brdprop->verbose,
+	printf(">> %s, cpu %u MHz, bus %u MHz, %dMB SDRAM\n", brdprop->verbose,
 	cpuclock / 100, busclock / 100, bi_mem.memsize >> 20);
 
 	n = pcilookup(PCI_CLASS_IDE, lata, sizeof(lata)/sizeof(lata[0]));



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

2011-01-22 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Jan 23 07:41:38 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: Makefile main.c version
Removed Files:
src/sys/arch/sandpoint/stand/altboot: newvers.sh

Log Message:
switch to use newvers_stand.sh as suggested by joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/Makefile \
src/sys/arch/sandpoint/stand/altboot/main.c \
src/sys/arch/sandpoint/stand/altboot/version
cvs rdiff -u -r1.1 -r0 src/sys/arch/sandpoint/stand/altboot/newvers.sh

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/altboot/Makefile
diff -u src/sys/arch/sandpoint/stand/altboot/Makefile:1.1 src/sys/arch/sandpoint/stand/altboot/Makefile:1.2
--- src/sys/arch/sandpoint/stand/altboot/Makefile:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/Makefile	Sun Jan 23 07:41:38 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2011/01/23 01:05:30 nisimura Exp $
+#	$NetBSD: Makefile,v 1.2 2011/01/23 07:41:38 nisimura Exp $
 
 S=		${.CURDIR}/../../../..
 
@@ -53,7 +53,7 @@
 LIBSA=		${SALIB}
 
 ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
-	${HOST_SH} ${.CURDIR}/newvers.sh ${.CURDIR}/version
+	${HOST_SH} ${S}/conf/newvers_stand.sh -K ${.CURDIR}/version "sandpoint"
 	${CC} -c vers.c
 	${LD} -N -Ttext ${RELOC} -Bstatic -e ${ENTRY} -o ${PROG} \
 	${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBKERN}
Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.1 src/sys/arch/sandpoint/stand/altboot/main.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Jan 23 07:41:38 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: main.c,v 1.2 2011/01/23 07:41:38 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@
 int module_open(struct boot_module *);
 
 void main(int, char **);
-extern char bootprog_rev[], bootprog_maker[], bootprog_date[];
+extern char bootprog_name[], bootprog_rev[], bootprog_maker[], bootprog_date[];
 
 int brdtype;
 uint32_t busclock, cpuclock;
@@ -109,7 +109,7 @@
 	void *dev;
 
 	printf("\n");
-	printf(">> NetBSD/sandpoint Boot, Revision %s\n", bootprog_rev);
+	printf(">> %s altboot, revision %s\n", bootprog_name, bootprog_rev);
 	printf(">> (%s, %s)\n", bootprog_maker, bootprog_date);
 
 	brdprop = brd_lookup(brdtype);
Index: src/sys/arch/sandpoint/stand/altboot/version
diff -u src/sys/arch/sandpoint/stand/altboot/version:1.1 src/sys/arch/sandpoint/stand/altboot/version:1.2
--- src/sys/arch/sandpoint/stand/altboot/version:1.1	Sun Jan 23 01:32:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/version	Sun Jan 23 07:41:38 2011
@@ -1,7 +1,7 @@
-1.0	initial version
-1.1	PCI autoconf for multiple NIC device drivers
-1.2	Synology-DS support, Marvell-Yukon driver, fixed aligned alloc
-1.3	allow to have boot options, brdsetup.c cleanup to make brdtype
+1.0:	initial version
+1.1:	PCI autoconf for multiple NIC device drivers
+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
-1.5	altboot is the new name as this is capable of handling net & dsk.
+1.4:	load kernels from local disk
+1.5:	altboot is the new name as this is capable of handling net & dsk.



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

2011-01-22 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Jan 23 02:08:24 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: printf.c

Log Message:
fix a failure in the sign extension consideration.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/stand/altboot/printf.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/altboot/printf.c
diff -u src/sys/arch/sandpoint/stand/altboot/printf.c:1.2 src/sys/arch/sandpoint/stand/altboot/printf.c:1.3
--- src/sys/arch/sandpoint/stand/altboot/printf.c:1.2	Sun Jan 23 01:32:08 2011
+++ src/sys/arch/sandpoint/stand/altboot/printf.c	Sun Jan 23 02:08:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: printf.c,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
+/* $NetBSD: printf.c,v 1.3 2011/01/23 02:08:24 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -96,7 +96,8 @@
 	int length, fmax, fmin, leading;
 	int leftjust, llflag;
 	char fill, sign;
-	long long v;
+	long long d;
+	unsigned long long v;
 
 	outcnt = 0;
 	while ((i = *fmt++) != '\0') {
@@ -160,39 +161,39 @@
 
 		case 'd':
 			if (llflag)
-v = va_arg(ap, long long);
+d = va_arg(ap, long long);
 			else
-v = va_arg(ap, int);
-			if (v < 0) {
-sign = '-' ; v = -v;
+d = va_arg(ap, int);
+			if (d < 0) {
+sign = '-' ; d = -d;
 			}
-			mkdigit((unsigned long long)v, 10, str);
+			mkdigit((unsigned long long)d, 10, str);
 			break;
 
 		case 'u':
 			if (llflag)
-v = va_arg(ap, long long);
+v = va_arg(ap, unsigned long long);
 			else
-v = va_arg(ap, int);
-			mkdigit((unsigned long long)v, 10, str);
+v = va_arg(ap, unsigned int);
+			mkdigit(v, 10, str);
 			break;
 
 		case 'o':
 			if (llflag)
-v = va_arg(ap, long long);
+v = va_arg(ap, unsigned long long);
 			else
-v = va_arg(ap, int);
-			mkdigit((unsigned long long)v, 8, str);
+v = va_arg(ap, unsigned int);
+			mkdigit(v, 8, str);
 			fmax = 0;
 			break;
 
 		case 'X':
 		case 'x':
 			if (llflag)
-v = va_arg(ap, long long);
+v = va_arg(ap, unsigned long long);
 			else
-v = va_arg(ap, int);
-			mkdigit((unsigned long long)v, 16, str);
+v = va_arg(ap, unsigned int);
+			mkdigit(v, 16, str);
 			fmax = 0;
 			break;
 



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

2011-01-22 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Sun Jan 23 01:32:08 UTC 2011

Modified Files:
src/sys/arch/sandpoint/stand/altboot: dsk.c globals.h printf.c
Added Files:
src/sys/arch/sandpoint/stand/altboot: newvers.sh version

Log Message:
- add "ll" modifier to printf.
- be more conscious about int type propagation.
- add missing version and newvers.sh


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/dsk.c \
src/sys/arch/sandpoint/stand/altboot/globals.h \
src/sys/arch/sandpoint/stand/altboot/printf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sandpoint/stand/altboot/newvers.sh \
src/sys/arch/sandpoint/stand/altboot/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/altboot/dsk.c
diff -u src/sys/arch/sandpoint/stand/altboot/dsk.c:1.1 src/sys/arch/sandpoint/stand/altboot/dsk.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/dsk.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c	Sun Jan 23 01:32:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dsk.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: dsk.c,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -82,9 +82,9 @@
 static char *mkident(char *, int);
 static void set_xfermode(struct dkdev_ata *, int);
 static void decode_dlabel(struct disk *, char *);
-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 int lba_read(struct disk *, int64_t, int, void *);
+static void issue48(struct dvata_chan *, int64_t, int);
+static void issue28(struct dvata_chan *, int64_t, int);
 static struct disk *lookup_disk(int);
 
 static struct disk ldisk[4];
@@ -368,11 +368,11 @@
 }
 
 static int
-lba_read(struct disk *d, uint64_t bno, uint32_t bcnt, void *buf)
+lba_read(struct disk *d, int64_t bno, int bcnt, void *buf)
 {
 	struct dkdev_ata *l;
 	struct dvata_chan *chan;
-	void (*issue)(struct dvata_chan *, uint64_t, uint32_t);
+	void (*issue)(struct dvata_chan *, int64_t, int);
 	int n, rdcnt, i, k;
 	uint16_t *p;
 	const char *err;
@@ -389,8 +389,7 @@
 		(*issue)(chan, bno, rdcnt);
 		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);
+printf("%s blk %lld %s\n", d->xname, bno, err);
 error = EIO;
 break;
 			}
@@ -406,7 +405,7 @@
 }
 
 static void
-issue48(struct dvata_chan *chan, uint64_t bno, uint32_t nblk)
+issue48(struct dvata_chan *chan, int64_t bno, int nblk)
 {
 
 	CSR_WRITE_1(chan->cmd + _NSECT, 0); /* always less than 256 */
@@ -422,7 +421,7 @@
 }
 
 static void
-issue28(struct dvata_chan *chan, uint64_t bno, uint32_t nblk)
+issue28(struct dvata_chan *chan, int64_t bno, int nblk)
 {
 
 	CSR_WRITE_1(chan->cmd + _NSECT, nblk);
@@ -511,10 +510,10 @@
 {
 	struct disk *d = devdata;
 	struct disklabel *dlp;
-	uint64_t bno;
+	int64_t bno;
 
 #if 0
-printf("%s %d %d\n", d->xname, (int)dblk, size);
+printf("%s %lld %d\n", d->xname, dblk, size);
 #endif
 	if (size == 0)
 		return 0;
Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.1 src/sys/arch/sandpoint/stand/altboot/globals.h:1.2
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Jan 23 01:32:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: globals.h,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
 
 /* clock feed */
 #ifndef EXT_CLK_FREQ
@@ -186,7 +186,7 @@
 	void *dlabel;
 	int part;
 	void *fsops;
-	int (*lba_read)(struct disk *, uint64_t, uint32_t, void *);
+	int (*lba_read)(struct disk *, int64_t, int, void *);
 };
 
 int spinwait_unbusy(struct dkdev_ata *, int, int, const char **);
Index: src/sys/arch/sandpoint/stand/altboot/printf.c
diff -u src/sys/arch/sandpoint/stand/altboot/printf.c:1.1 src/sys/arch/sandpoint/stand/altboot/printf.c:1.2
--- src/sys/arch/sandpoint/stand/altboot/printf.c:1.1	Sun Jan 23 01:05:30 2011
+++ src/sys/arch/sandpoint/stand/altboot/printf.c	Sun Jan 23 01:32:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: printf.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */
+/* $NetBSD: printf.c,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define MAXSTR	80
 
 static int _doprnt(void (*)(int), const char *, va_list);
-static void pr_int(unsigned long, int, char *);
+static void mkdigit(unsigned long long, int, char *);
 static void sputchar(int);
 
 static char *sbuf, *ebuf;
@@ -89,22 +89,14 @@
 }
 
 static int
-_doprnt(func, fmt, ap)
-	void (*func)(int);	/* Function to put a character */
-	const char *fmt;	/* Format string for p