CVS commit: src/tests/modules

2012-04-19 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Fri Apr 20 05:41:26 UTC 2012

Modified Files:
src/tests/modules: t_abi_uvm.sh t_modload.sh

Log Message:
For now, skip module tests if modctl(8) fails either with EPERM or ENOSYS.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/modules/t_abi_uvm.sh
cvs rdiff -u -r1.12 -r1.13 src/tests/modules/t_modload.sh

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

Modified files:

Index: src/tests/modules/t_abi_uvm.sh
diff -u src/tests/modules/t_abi_uvm.sh:1.2 src/tests/modules/t_abi_uvm.sh:1.3
--- src/tests/modules/t_abi_uvm.sh:1.2	Tue Mar 20 05:50:11 2012
+++ src/tests/modules/t_abi_uvm.sh	Fri Apr 20 05:41:25 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_abi_uvm.sh,v 1.2 2012/03/20 05:50:11 jruoho Exp $
+# $NetBSD: t_abi_uvm.sh,v 1.3 2012/04/20 05:41:25 jruoho Exp $
 #
 # Copyright (c) 2012 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -32,11 +32,12 @@ PAGE_SIZE_head() {
 }
 PAGE_SIZE_body() {
 
-	# XXX: There should be a reliable way to detect MODULAR.
+	# XXX: Adjust when modctl(8) fails consistently.
 	#
-	sysctl machdep.xen > /dev/null 2>&1
+	$(atf_get_srcdir)/k_helper3 \
+		"%s/k_helper/k_helper.kmod" $(atf_get_srcdir)
 
-	if [ $? -eq 0 ]; then
+	if [ $? -eq 1 ] || [ $? -eq 78 ]; then
 		atf_skip "host does not support modules"
 	fi
 

Index: src/tests/modules/t_modload.sh
diff -u src/tests/modules/t_modload.sh:1.12 src/tests/modules/t_modload.sh:1.13
--- src/tests/modules/t_modload.sh:1.12	Sat Apr 14 02:46:17 2012
+++ src/tests/modules/t_modload.sh	Fri Apr 20 05:41:25 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_modload.sh,v 1.12 2012/04/14 02:46:17 pgoyette Exp $
+# $NetBSD: t_modload.sh,v 1.13 2012/04/20 05:41:25 jruoho Exp $
 #
 # Copyright (c) 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -42,7 +42,7 @@ plain_body() {
 	$(atf_get_srcdir)/k_helper3 \
 		"%s/k_helper/k_helper.kmod" $(atf_get_srcdir)
 
-	if [ $? -eq 78 ]; then
+	if [ $? -eq 1 ] || [ $? -eq 78 ]; then
 		atf_skip "host does not support modules"
 	fi
 
@@ -115,7 +115,7 @@ iflag_body() {
 	$(atf_get_srcdir)/k_helper3 \
 		"%s/k_helper/k_helper.kmod" $(atf_get_srcdir)
 
-	if [ $? -eq 78 ]; then
+	if [ $? -eq 1 ] || [ $? -eq 78 ]; then
 		atf_skip "host does not support modules"
 	fi
 
@@ -169,7 +169,7 @@ sflag_body() {
 	$(atf_get_srcdir)/k_helper3 \
 		"%s/k_helper/k_helper.kmod" $(atf_get_srcdir)
 
-	if [ $? -eq 78 ]; then
+	if [ $? -eq 1 ] || [ $? -eq 78 ]; then
 		atf_skip "host does not support modules"
 	fi
 



CVS commit: src/usr.bin/make

2012-04-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Apr 20 05:33:42 UTC 2012

Modified Files:
src/usr.bin/make: make.1 parse.c

Log Message:
Fix some typos in/around ParseGmakeExport.
Remove the suppresssion of duplicate entries in .MAKE.MAKEFILES


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/usr.bin/make/make.1
cvs rdiff -u -r1.182 -r1.183 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.202 src/usr.bin/make/make.1:1.203
--- src/usr.bin/make/make.1:1.202	Sun Apr  8 22:00:39 2012
+++ src/usr.bin/make/make.1	Fri Apr 20 05:33:41 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.202 2012/04/08 22:00:39 wiz Exp $
+.\"	$NetBSD: make.1,v 1.203 2012/04/20 05:33:41 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd March 31, 2012
+.Dd April 20, 2012
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -735,7 +735,6 @@ will look for.
 The list of makefiles read by
 .Nm ,
 which is useful for tracking dependencies.
-Each makefile is recorded only once, regardless of the number of times read.
 .It Va .MAKE.MODE
 Processed after reading all makefiles.
 Can affect the mode that

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.182 src/usr.bin/make/parse.c:1.183
--- src/usr.bin/make/parse.c:1.182	Sat Mar 31 00:12:24 2012
+++ src/usr.bin/make/parse.c	Fri Apr 20 05:33:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $	*/
+/*	$NetBSD: parse.c,v 1.183 2012/04/20 05:33:42 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.183 2012/04/20 05:33:42 sjg Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.183 2012/04/20 05:33:42 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2239,36 +2239,6 @@ ParseSetParseFile(const char *filename)
 free(dirname);
 }
 
-/*
- * Track the makefiles we read - so makefiles can
- * set dependencies on them.
- * Avoid adding anything more than once.
- */
-
-static void
-ParseTrackInput(const char *name)
-{
-char *old;
-char *fp = NULL;
-size_t name_len = strlen(name);
-
-old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
-if (old) {
-	/* does it contain name? */
-	for (; old != NULL; old = strchr(old, ' ')) {
-	if (*old == ' ')
-		old++;
-	if (memcmp(old, name, name_len) == 0
-		&& (old[name_len] == 0 || old[name_len] == ' '))
-		goto cleanup;
-	}
-}
-Var_Append (MAKE_MAKEFILES, name, VAR_GLOBAL);
- cleanup:
-if (fp) {
-	free(fp);
-}
-}
 
 
 /*-
@@ -2294,7 +2264,7 @@ Parse_SetInput(const char *name, int lin
 if (name == NULL)
 	name = curFile->fname;
 else
-	ParseTrackInput(name);
+	Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
 
 if (DEBUG(PARSE))
 	fprintf(debug_file, "Parse_SetInput: file %s, line %d, fd %d, nextbuf %p, arg %p\n",
@@ -2405,7 +2375,7 @@ ParseTraditionalInclude(char *line)
 }
 #endif
 
-#ifdef SYSVINCLUDE
+#ifdef GMAKEEXPORT
 /*-
  *-
  * ParseGmakeExport  --
@@ -2427,7 +2397,7 @@ ParseGmakeExport(char *line)
 char	  *value;
 
 if (DEBUG(PARSE)) {
-	fprintf(debug_file, "ParseTraditionalInclude: %s\n", variable);
+	fprintf(debug_file, "ParseGmakeExport: %s\n", variable);
 }
 
 /*
@@ -2441,13 +2411,12 @@ ParseGmakeExport(char *line)
 
 if (*value != '=') {
 	Parse_Error(PARSE_FATAL,
-		 "Variable/Value missing from \"include\"");
+		 "Variable/Value missing from \"export\"");
 	return;
 }
 
 /*
- * Substitute for any variables in the file name before trying to
- * find the thing.
+ * Expand the value before putting it in the environment.
  */
 value = Var_Subst(NULL, value, VAR_CMD, FALSE);
 setenv(variable, value, 1);
@@ -2908,7 +2877,7 @@ Parse_File(const char *name, int fd)
 		isspace((unsigned char) line[6]) &&
 		strchr(line, ':') == NULL) {
 		/*
-		 * It's an Gmake"export".
+		 * It's a Gmake "export".
 		 */
 		ParseGmakeExport(line);
 		continue;



CVS commit: src/tests/lib/librumphijack

2012-04-19 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Fri Apr 20 05:15:11 UTC 2012

Modified Files:
src/tests/lib/librumphijack: h_client.c

Log Message:
Close all file descriptors before trying to reason about the number of open
descriptors. Should fix the test failures reported on current users.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/librumphijack/h_client.c

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

Modified files:

Index: src/tests/lib/librumphijack/h_client.c
diff -u src/tests/lib/librumphijack/h_client.c:1.7 src/tests/lib/librumphijack/h_client.c:1.8
--- src/tests/lib/librumphijack/h_client.c:1.7	Tue Apr 17 09:23:21 2012
+++ src/tests/lib/librumphijack/h_client.c	Fri Apr 20 05:15:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_client.c,v 1.7 2012/04/17 09:23:21 jruoho Exp $	*/
+/*	$NetBSD: h_client.c,v 1.8 2012/04/20 05:15:11 jruoho Exp $	*/
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -115,12 +115,15 @@ main(int argc, char *argv[])
 
 		return EXIT_SUCCESS;
 	} else if (strcmp(argv[1], "fdoff8") == 0) {
+
+		(void)closefrom(0);
+
 		int fd;
 
-		do
+		do {
 			if ((fd = open("/dev/null", O_RDWR)) == -1)
 err(EXIT_FAILURE, "open1");
-		while (fd < 7);
+		} while (fd < 7);
 		fd = open("/dev/null", O_RDWR);
 		if (fd != -1 || errno != ENFILE)
 			errx(EXIT_FAILURE, "unexpected fd8 %d %d", fd, errno);



CVS commit: src/sys/ufs/ffs

2012-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 20 02:07:44 UTC 2012

Modified Files:
src/sys/ufs/ffs: fs.h

Log Message:
one more cast


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/ufs/ffs/fs.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/ufs/ffs/fs.h
diff -u src/sys/ufs/ffs/fs.h:1.57 src/sys/ufs/ffs/fs.h:1.58
--- src/sys/ufs/ffs/fs.h:1.57	Thu Apr 19 13:25:38 2012
+++ src/sys/ufs/ffs/fs.h	Thu Apr 19 22:07:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fs.h,v 1.57 2012/04/19 17:25:38 christos Exp $	*/
+/*	$NetBSD: fs.h,v 1.58 2012/04/20 02:07:43 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -710,7 +710,7 @@ struct ocg {
 #define	sblksize(fs, size, lbn) \
 	(((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
 	  ? (uint64_t)(fs)->fs_bsize \
-	  : (fragroundup(fs, blkoff(fs, (size)
+	  : (fragroundup(fs, blkoff(fs, (uint64_t)(size)
 
 
 /*



CVS commit: src/tests/lib/libc/gen

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Fri Apr 20 00:40:32 UTC 2012

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
ATF test for SIGBUS => BUS_ADRALN (invalid address alignment).

That one is tedious to test under x86: alignment exceptions are
not reported by this architecture unless you ask for them explicitely (by
setting the PSL_AC bit). The brokenness does not end there: %cr2 should
contain the address where the unaligned access occured, alas, it does not.

I am not aware of other architectures where this could happen. Still, my
knowledge is limited; if there is one, feel free to send me a mail and I
will update the test accordingly.

Adding insult to injury, this test can fail in various funny ways with VMs:
- under x86 QEMU, no trap() happens. As ring 3 code stays almost untouched by
QEMU VMM, I suppose the exception can only be triggered when the host
itself is capable of catching unaligned accesses.
- under Virtual Box with HVM support, i386 works fine, but amd64 fails with a
SIGILL (Illegal instruction) that happens right before entering the
signal handler. No idea why, and trying to debug it with gdb freezes the VM
(including ddb breaks).

Anyway, tested with:
- i386: P4 host, anita, Virtual Box HVM (Mac OS X)
- amd64: anita, Virtual Box HVM (Mac OS X)

XXX I would appreciate if someone could test it under a real amd64 host with
an up-to-date kernel, so I can reasonably assume that the culprit is
Virtual Box and not our amd64 port (my test machine being off line
I cannot do it myself). Results from other arches would be a plus too.

Initial issue reported by Nicolas Joly on port-amd64. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/gen/t_siginfo.c

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

Modified files:

Index: src/tests/lib/libc/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.14 src/tests/lib/libc/gen/t_siginfo.c:1.15
--- src/tests/lib/libc/gen/t_siginfo.c:1.14	Sun Mar 18 07:14:08 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Apr 20 00:40:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.14 2012/03/18 07:14:08 jruoho Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.15 2012/04/20 00:40:31 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -48,6 +48,9 @@
 #include 
 #endif
 
+/* for sigbus */
+char *addr;
+
 /* for sigchild */
 pid_t child;
 int code;
@@ -405,6 +408,70 @@ ATF_TC_BODY(sigsegv, tc)
 	atf_tc_fail("Test did not fault as expected");
 }
 
+static void
+sigbus_action(int signo, siginfo_t *info, void *ptr)
+{
+
+	sig_debug(signo, info, (ucontext_t *)ptr);
+
+	ATF_REQUIRE_EQ(info->si_signo, SIGBUS);
+	ATF_REQUIRE_EQ(info->si_errno, 0);
+	ATF_REQUIRE_EQ(info->si_code, BUS_ADRALN);
+
+	if (strcmp(atf_config_get("atf_arch"), "i386") == 0 ||
+	strcmp(atf_config_get("atf_arch"), "x86_64") == 0) {
+		atf_tc_expect_fail("x86 architecture does not correctly "
+		"report the address where the unaligned access occured");
+	}
+
+	ATF_REQUIRE_EQ(info->si_addr, (void *)addr);
+	atf_tc_pass();
+	/* NOTREACHED */
+}
+
+ATF_TC(sigbus_adraln);
+ATF_TC_HEAD(sigbus_adraln, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	"Checks that signal trampoline correctly calls SIGBUS handler "
+	"for invalid address alignment");
+}
+
+ATF_TC_BODY(sigbus_adraln, tc)
+{
+	struct sigaction sa;
+
+	sa.sa_flags = SA_SIGINFO;
+	sa.sa_sigaction = sigbus_action;
+	sigemptyset(&sa.sa_mask);
+	sigaction(SIGBUS, &sa, NULL);
+
+	/* Enable alignement checks for x86. 0x4 is PSL_AC. */
+#if defined(__i386__)
+	__asm__("pushf; orl $0x4, (%esp); popf");
+#elif defined(__amd64__)
+	__asm__("pushf; orl $0x4, (%rsp); popf");
+#endif
+
+	addr = calloc(2, sizeof(int));
+	ATF_REQUIRE(addr != NULL);
+
+	if (strcmp(atf_config_get("atf_arch"), "i386") == 0 ||
+	strcmp(atf_config_get("atf_arch"), "x86_64") == 0) {
+		if (system("cpuctl identify 0 | grep -q QEMU") == 0) {
+			atf_tc_expect_fail("QEMU fails to trap unaligned "
+			"accesses");
+		}
+	}
+
+	/* Force an unaligned access */
+	addr++;
+	ATF_REQUIRE_EQ(*(volatile int *)addr, 0);
+
+	atf_tc_fail("Test did not fault as expected");
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -415,6 +482,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, sigfpe_flt);
 	ATF_TP_ADD_TC(tp, sigfpe_int);
 	ATF_TP_ADD_TC(tp, sigsegv);
+	ATF_TP_ADD_TC(tp, sigbus_adraln);
 
 	return atf_no_error();
 }



CVS commit: src/sys/arch/powerpc/booke/dev

2012-04-19 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr 19 21:32:01 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Read maccfg1/maccfg2/ecntrl so we can preserve bits we don't change (like
GMII mode).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.10 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.11
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.10	Tue Feb 21 02:08:55 2012
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Thu Apr 19 21:32:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.11 2012/04/19 21:32:01 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.11 2012/04/19 21:32:01 matt Exp $");
 
 #include 
 #include 
@@ -592,6 +592,9 @@ pq3etsec_attach(device_t parent, device_
 
 	etsec_write(sc, ATTR, ATTR_DEFAULT);
 	etsec_write(sc, ATTRELI, ATTRELI_DEFAULT);
+	sc->sc_maccfg1 = etsec_read(sc, MACCFG1);
+	sc->sc_maccfg2 = etsec_read(sc, MACCFG2);
+	sc->sc_ecntrl = etsec_read(sc, ECNTRL);
 
 	sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
 



CVS commit: src/crypto/external/bsd/openssl/dist/crypto

2012-04-19 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Thu Apr 19 20:20:57 UTC 2012

Modified Files:
src/crypto/external/bsd/openssl/dist/crypto: mem.c
src/crypto/external/bsd/openssl/dist/crypto/asn1: a_d2i_fp.c
src/crypto/external/bsd/openssl/dist/crypto/buffer: buffer.c

Log Message:
pull in upstream SVN rev. 22439:
check for potentially exploitable overflows in asn1_d2i_read_bio
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
in CRYPTO_realloc_clean. (CVE-2012-2110)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/crypto/external/bsd/openssl/dist/crypto/mem.c
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/crypto/external/bsd/openssl/dist/crypto/asn1/a_d2i_fp.c
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/crypto/external/bsd/openssl/dist/crypto/buffer/buffer.c

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

Modified files:

Index: src/crypto/external/bsd/openssl/dist/crypto/mem.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/mem.c:1.1.1.2 src/crypto/external/bsd/openssl/dist/crypto/mem.c:1.2
--- src/crypto/external/bsd/openssl/dist/crypto/mem.c:1.1.1.2	Sun Jun  5 14:57:20 2011
+++ src/crypto/external/bsd/openssl/dist/crypto/mem.c	Thu Apr 19 20:20:57 2012
@@ -363,6 +363,10 @@ void *CRYPTO_realloc_clean(void *str, in
 
 	if (num <= 0) return NULL;
 
+	/* We don't support shrinking the buffer. Note the memcpy that copies
+	 * |old_len| bytes to the new buffer, below. */
+	if (num < old_len) return NULL;
+
 	if (realloc_debug_func != NULL)
 		realloc_debug_func(str, NULL, num, file, line, 0);
 	ret=malloc_ex_func(num,file,line);

Index: src/crypto/external/bsd/openssl/dist/crypto/asn1/a_d2i_fp.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/asn1/a_d2i_fp.c:1.1.1.1 src/crypto/external/bsd/openssl/dist/crypto/asn1/a_d2i_fp.c:1.2
--- src/crypto/external/bsd/openssl/dist/crypto/asn1/a_d2i_fp.c:1.1.1.1	Sun Jul 19 23:02:46 2009
+++ src/crypto/external/bsd/openssl/dist/crypto/asn1/a_d2i_fp.c	Thu Apr 19 20:20:56 2012
@@ -57,6 +57,7 @@
  */
 
 #include 
+#include 
 #include "cryptlib.h"
 #include 
 #include 
@@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU
 	BUF_MEM *b;
 	unsigned char *p;
 	int i;
-	int ret=-1;
 	ASN1_const_CTX c;
-	int want=HEADER_SIZE;
+	size_t want=HEADER_SIZE;
 	int eos=0;
-#if defined(__GNUC__) && defined(__ia64)
-	/* pathetic compiler bug in all known versions as of Nov. 2002 */
-	long off=0;
-#else
-	int off=0;
-#endif
-	int len=0;
+	size_t off=0;
+	size_t len=0;
 
 	b=BUF_MEM_new();
 	if (b == NULL)
@@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU
 			{
 			want-=(len-off);
 
-			if (!BUF_MEM_grow_clean(b,len+want))
+			if (len + want < len || !BUF_MEM_grow_clean(b,len+want))
 {
 ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
 goto err;
@@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU
 goto err;
 }
 			if (i > 0)
+{
+if (len+i < len)
+	{
+	ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
+	goto err;
+	}
 len+=i;
+}
 			}
 		/* else data already loaded */
 
@@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU
 			{
 			/* no data body so go round again */
 			eos++;
+			if (eos < 0)
+{
+ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG);
+goto err;
+}
 			want=HEADER_SIZE;
 			}
 		else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC))
@@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU
 		else 
 			{
 			/* suck in c.slen bytes of data */
-			want=(int)c.slen;
+			want=c.slen;
 			if (want > (len-off))
 {
 want-=(len-off);
+if (want > INT_MAX /* BIO_read takes an int length */ ||
+	len+want < len)
+		{
+		ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
+		goto err;
+		}
 if (!BUF_MEM_grow_clean(b,len+want))
 	{
 	ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
@@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU
 		ASN1_R_NOT_ENOUGH_DATA);
 		goto err;
 		}
+	/* This can't overflow because
+	 * |len+want| didn't overflow. */
 	len+=i;
-	want -= i;
+	want-=i;
 	}
 }
-			off+=(int)c.slen;
+			if (off + c.slen < off)
+{
+ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
+goto err;
+}
+			off+=c.slen;
 			if (eos <= 0)
 {
 break;
@@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU
 			}
 		}
 
+	if (off > INT_MAX)
+		{
+		ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
+		goto err;
+		}
+
 	*pb = b;
 	return off;
 err:
 	if (b != NULL) BUF_MEM_free(b);
-	return(ret);
+	return -1;
 	}

Index: src/crypto/external/bsd/openssl/dist/crypto/buffer/buffer.c
diff -u src/crypto/external/bsd/openssl/dist/crypto/buffer/buffer.c:1.1.1.2 src/crypto/external/bsd/openssl/dist/crypto/buffer/buffer.c:1.2
--- src/crypto/external/bsd/openssl/dist/crypto/buffer/buffer.c:1.1.1.2	Sun Jun  5

CVS commit: src

2012-04-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr 19 20:20:35 UTC 2012

Modified Files:
src/share/man/man4: hdaudio.4
src/sys/arch/i386/conf: ALL

Log Message:
Correct option name for hdaudio debugging.
Reported by Dave Tyson in PR 46357.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/share/man/man4/hdaudio.4
cvs rdiff -u -r1.337 -r1.338 src/sys/arch/i386/conf/ALL

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

Modified files:

Index: src/share/man/man4/hdaudio.4
diff -u src/share/man/man4/hdaudio.4:1.8 src/share/man/man4/hdaudio.4:1.9
--- src/share/man/man4/hdaudio.4:1.8	Sat Mar 17 11:11:00 2012
+++ src/share/man/man4/hdaudio.4	Thu Apr 19 20:20:35 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: hdaudio.4,v 1.8 2012/03/17 11:11:00 wiz Exp $
+.\"	$NetBSD: hdaudio.4,v 1.9 2012/04/19 20:20:35 wiz Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 28, 2010
+.Dd April 19, 2012
 .Dt HDAUDIO 4
 .Os
 .Sh NAME
@@ -39,7 +39,7 @@
 .Cd "audio* at audiobus?"
 .Pp
 .Cd "options HDAUDIO_DEBUG"
-.Cd "options HDAUDIO_AFG_DEBUG"
+.Cd "options HDAFG_DEBUG"
 .Sh DESCRIPTION
 The
 .Nm

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.337 src/sys/arch/i386/conf/ALL:1.338
--- src/sys/arch/i386/conf/ALL:1.337	Thu Apr 19 17:50:51 2012
+++ src/sys/arch/i386/conf/ALL	Thu Apr 19 20:20:34 2012
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.337 2012/04/19 17:50:51 bouyer Exp $
+# $NetBSD: ALL,v 1.338 2012/04/19 20:20:34 wiz Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"ALL-$Revision: 1.337 $"
+#ident 		"ALL-$Revision: 1.338 $"
 
 maxusers	64		# estimated number of users
 
@@ -2081,7 +2081,7 @@ options HD64461PCMCIA_DEBUG
 options HD64461VIDEO_DEBUG
 options HD64465PCMCIA_DEBUG
 options HDAUDIO_DEBUG
-options HDAUDIO_AFG_DEBUG
+options HDAFG_DEBUG
 options HDLCDEBUG
 options HIFN_DEBUG
 options HMEDEBUG



CVS commit: src/share/man/man4

2012-04-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr 19 20:13:48 UTC 2012

Modified Files:
src/share/man/man4: mpii.4

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/mpii.4

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

Modified files:

Index: src/share/man/man4/mpii.4
diff -u src/share/man/man4/mpii.4:1.1 src/share/man/man4/mpii.4:1.2
--- src/share/man/man4/mpii.4:1.1	Thu Apr 19 17:50:50 2012
+++ src/share/man/man4/mpii.4	Thu Apr 19 20:13:48 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mpii.4,v 1.1 2012/04/19 17:50:50 bouyer Exp $
+.\"	$NetBSD: mpii.4,v 1.2 2012/04/19 20:13:48 wiz Exp $
 .\"	OpenBSD: mpii.4,v 1.8 2010/10/01 12:27:36 mikeb Exp
 .\"
 .\" Copyright (c) 2010 Marco Peereboom 
@@ -50,7 +50,7 @@ Some models of these controllers have va
 and RAID 1.
 .Pp
 .Nm
-supports monitoring of the logical disks in the controller through the  
+supports monitoring of the logical disks in the controller through the
 .Xr bioctl 8
 and
 .Xr envstat 8
@@ -58,14 +58,14 @@ commands.
 .Sh EVENTS
 The
 .Nm
-driver is able to send events to  
+driver is able to send events to
 .Xr powerd 8
 if a logical drive in the controller is not online.
 The
 .Em state-changed
 event will be sent to the
-.Pa /etc/powerd/scripts/sensor_drive  
-script when such condition happens.   
+.Pa /etc/powerd/scripts/sensor_drive
+script when such condition happens.
 .Sh SEE ALSO
 .Xr intro 4 ,
 .Xr pci 4 ,



CVS commit: [netbsd-6] src/doc

2012-04-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Apr 19 20:07:17 UTC 2012

Modified Files:
src/doc [netbsd-6]: CHANGES-6.0

Log Message:
Tickets 185-188.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.71 -r1.1.2.72 src/doc/CHANGES-6.0

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

Modified files:

Index: src/doc/CHANGES-6.0
diff -u src/doc/CHANGES-6.0:1.1.2.71 src/doc/CHANGES-6.0:1.1.2.72
--- src/doc/CHANGES-6.0:1.1.2.71	Wed Apr 18 19:56:34 2012
+++ src/doc/CHANGES-6.0	Thu Apr 19 20:07:17 2012
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-6.0,v 1.1.2.71 2012/04/18 19:56:34 snj Exp $
+# $NetBSD: CHANGES-6.0,v 1.1.2.72 2012/04/19 20:07:17 riz Exp $
 
 A complete list of changes from the initial NetBSD 6.0 branch on 15 Feb 2012
 until the 6.0 release:
@@ -1839,3 +1839,29 @@ sys/arch/xen/xen/hypervisor.c			1.62
 	Retrive and print the hypervisor "extra" (teeny) version.
 	[riz, ticket #184]
 
+sys/dev/rndpseudo.c1.7
+sys/kern/kern_rndq.c1.2
+sys/kern/subr_cprng.c1.6-1.7
+sys/lib/libkern/arc4random.c			1.32
+sys/sys/rnd.h	1.30
+
+	Fix a number of races in the rnd subsystem and prevent crashing.
+	[tls, ticket #185]
+
+usr.sbin/makemandb/apropos-utils.c		1.3-1.4
+usr.sbin/makemandb/apropos.c			1.6
+
+	Improve error messages, and handle pages with slashes in their
+	names better.
+	[wiz, ticket #186]
+
+usr.sbin/cpuctl/arch/i386.c			1.31
+
+	Print CPU family for AMD CPU families 0x12 - 0x15.
+	[cegger, ticket #187]
+
+lib/librumphijack/hijack.c			1.92
+
+	Fix hijacking of pollts/select on 64bit big endian hosts.
+	[martin, ticket #188]
+



CVS commit: [netbsd-6] src/lib/librumphijack

2012-04-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Apr 19 20:06:22 UTC 2012

Modified Files:
src/lib/librumphijack [netbsd-6]: hijack.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #188):
lib/librumphijack/hijack.c: revision 1.92
poll(), pollts() and select() all return int values, but in the hijack
emulation of them these get passed as exit values from a pthread as
a void* (c.f. pthread_join(), pthread_exit()).
Do not use the address of an int variable for these, but provide the address
of a void* and assign the value afterwards.
Fixes hijacking of pollts/select on 64bit big endian hosts.
Spotted by and fix from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.91.2.1 src/lib/librumphijack/hijack.c

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

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.91 src/lib/librumphijack/hijack.c:1.91.2.1
--- src/lib/librumphijack/hijack.c:1.91	Wed Feb  1 05:34:41 2012
+++ src/lib/librumphijack/hijack.c	Thu Apr 19 20:06:21 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.91 2012/02/01 05:34:41 dholland Exp $	*/
+/*  $NetBSD: hijack.c,v 1.91.2.1 2012/04/19 20:06:21 riz Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
 #undef _FORTIFY_SOURCE
 
 #include 
-__RCSID("$NetBSD: hijack.c,v 1.91 2012/02/01 05:34:41 dholland Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.91.2.1 2012/04/19 20:06:21 riz Exp $");
 
 #include 
 #include 
@@ -1654,7 +1654,7 @@ hostpoll(void *arg)
 		parg->errnum = errno;
 	rump_sys_write(parg->pipefd, &rv, sizeof(rv));
 
-	return (void *)(intptr_t)rv;
+	return (void *)rv;
 }
 
 int
@@ -1676,8 +1676,8 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		struct pollfd *pfd_host = NULL, *pfd_rump = NULL;
 		int rpipe[2] = {-1,-1}, hpipe[2] = {-1,-1};
 		struct pollarg parg;
-		uintptr_t lrv;
-		int sverrno = 0, trv;
+		void *trv_val;
+		int sverrno = 0, lrv, trv;
 
 		/*
 		 * ok, this is where it gets tricky.  We must support
@@ -1770,7 +1770,8 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		lrv = op_pollts(pfd_rump, nfds+1, ts, NULL);
 		sverrno = errno;
 		write(hpipe[1], &rv, sizeof(rv));
-		pthread_join(pt, (void *)&trv);
+		pthread_join(pt, &trv_val);
+		trv = (int)(intptr_t)trv_val;
 
 		/* check who "won" and merge results */
 		if (lrv != 0 && pfd_host[nfds].revents & POLLIN) {



CVS commit: [netbsd-6] src/usr.sbin/cpuctl/arch

2012-04-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Apr 19 20:04:37 UTC 2012

Modified Files:
src/usr.sbin/cpuctl/arch [netbsd-6]: i386.c

Log Message:
Pull up following revision(s) (requested by cegger in ticket #187):
usr.sbin/cpuctl/arch/i386.c: revision 1.31
print cpu family for AMD CPU families 0x12 - 0x15


To generate a diff of this commit:
cvs rdiff -u -r1.27.2.3 -r1.27.2.4 src/usr.sbin/cpuctl/arch/i386.c

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

Modified files:

Index: src/usr.sbin/cpuctl/arch/i386.c
diff -u src/usr.sbin/cpuctl/arch/i386.c:1.27.2.3 src/usr.sbin/cpuctl/arch/i386.c:1.27.2.4
--- src/usr.sbin/cpuctl/arch/i386.c:1.27.2.3	Fri Apr  6 17:46:41 2012
+++ src/usr.sbin/cpuctl/arch/i386.c	Thu Apr 19 20:04:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386.c,v 1.27.2.3 2012/04/06 17:46:41 riz Exp $	*/
+/*	$NetBSD: i386.c,v 1.27.2.4 2012/04/19 20:04:37 riz Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.27.2.3 2012/04/06 17:46:41 riz Exp $");
+__RCSID("$NetBSD: i386.c,v 1.27.2.4 2012/04/19 20:04:37 riz Exp $");
 #endif /* not lint */
 
 #include 
@@ -959,24 +959,22 @@ amd_amd64_name(struct cpu_info *ci)
 		}
 		break;
 	case 0x01:
-		switch (model) {
-			case 0x02:
-ret = "Family 10h";
-break;
-			default:
-ret = "Unknown AMD64 CPU";
-break;
-		}
+		ret = "Family 10h";
 		break;
 	case 0x02:
-		switch (model) {
-			case 0x03:
-ret = "Family 11h";
-break;
-			default:
-ret = "Unknown AMD64 CPU";
-break;
-		}
+		ret = "Family 11h";
+		break;
+	case 0x03:
+		ret = "Family 12h";
+		break;
+	case 0x05:
+		ret = "Family 14h";
+		break;
+	case 0x06:
+		ret = "Family 15h";
+		break;
+	default:
+		ret = "Unknown AMD64 CPU";
 		break;
 	}
 



CVS commit: [netbsd-6] src/usr.sbin/makemandb

2012-04-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Apr 19 20:03:00 UTC 2012

Modified Files:
src/usr.sbin/makemandb [netbsd-6]: apropos-utils.c apropos.c

Log Message:
Pull up following revision(s) (requested by wiz in ticket #186):
usr.sbin/makemandb/apropos.c: revision 1.6
usr.sbin/makemandb/apropos-utils.c: revision 1.3
usr.sbin/makemandb/apropos-utils.c: revision 1.4
Add the result from sqlite3_errmsg() to some error messages.
Now we can get "apropos: Unable to query schema version: database is locked"
instead of just "apropos: Unable to query schema version".
Handle pages with slashes in their names better.
>From Abhinav Upadhyay in private mail.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.2.1 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/usr.sbin/makemandb/apropos.c

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

Modified files:

Index: src/usr.sbin/makemandb/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.2 src/usr.sbin/makemandb/apropos-utils.c:1.2.2.1
--- src/usr.sbin/makemandb/apropos-utils.c:1.2	Tue Feb  7 19:17:16 2012
+++ src/usr.sbin/makemandb/apropos-utils.c	Thu Apr 19 20:03:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.2 2012/02/07 19:17:16 joerg Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.2.2.1 2012/04/19 20:03:00 riz Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.2 2012/02/07 19:17:16 joerg Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.2.2.1 2012/04/19 20:03:00 riz Exp $");
 
 #include 
 
@@ -312,12 +312,14 @@ init_db(int db_flag)
 
 	rc = sqlite3_prepare_v2(db, "PRAGMA user_version", -1, &stmt, NULL);
 	if (rc != SQLITE_OK) {
-		warnx("Unable to query schema version");
+		warnx("Unable to query schema version: %s",
+		sqlite3_errmsg(db));
 		goto error;
 	}
 	if (sqlite3_step(stmt) != SQLITE_ROW) {
 		sqlite3_finalize(stmt);
-		warnx("Unable to query schema version");
+		warnx("Unable to query schema version: %s",
+		sqlite3_errmsg(db));
 		goto error;
 	}
 	if (sqlite3_column_int(stmt, 0) != APROPOS_SCHEMA_VERSION) {
@@ -333,14 +335,16 @@ init_db(int db_flag)
 	/* Register the zip and unzip functions for FTS compression */
 	rc = sqlite3_create_function(db, "zip", 1, SQLITE_ANY, NULL, zip, NULL, NULL);
 	if (rc != SQLITE_OK) {
-		warnx("Unable to register function: compress");
+		warnx("Unable to register function: compress: %s",
+		sqlite3_errmsg(db));
 		goto error;
 	}
 
 	rc = sqlite3_create_function(db, "unzip", 1, SQLITE_ANY, NULL, 
  unzip, NULL, NULL);
 	if (rc != SQLITE_OK) {
-		warnx("Unable to register function: uncompress");
+		warnx("Unable to register function: uncompress: %s",
+		sqlite3_errmsg(db));
 		goto error;
 	}
 	return db;
@@ -445,6 +449,8 @@ run_query(sqlite3 *db, const char *snipp
 	const char *name_desc;
 	const char *machine;
 	const char *snippet;
+	const char *name_temp;
+	char *slash_ptr;
 	char *m = NULL;
 	int rc;
 	inverse_document_frequency idf = {0, 0};
@@ -457,9 +463,11 @@ run_query(sqlite3 *db, const char *snipp
 	rc = sqlite3_create_function(db, "rank_func", 1, SQLITE_ANY, (void *)&idf, 
 	 rank_func, NULL, NULL);
 	if (rc != SQLITE_OK) {
+		warnx("Unable to register the ranking function: %s",
+		sqlite3_errmsg(db));
 		sqlite3_close(db);
 		sqlite3_shutdown();
-		errx(EXIT_FAILURE, "Unable to register the ranking function");
+		exit(EXIT_FAILURE);
 	}
 	
 	/* We want to build a query of the form: "select x,y,z from mandb where
@@ -543,13 +551,16 @@ run_query(sqlite3 *db, const char *snipp
 
 	while (sqlite3_step(stmt) == SQLITE_ROW) {
 		section = (const char *) sqlite3_column_text(stmt, 0);
+		name_temp = (const char *) sqlite3_column_text(stmt, 1);
 		name_desc = (const char *) sqlite3_column_text(stmt, 2);
 		machine = (const char *) sqlite3_column_text(stmt, 3);
 		snippet = (const char *) sqlite3_column_text(stmt, 4);
+		if ((slash_ptr = strrchr(name_temp, '/')) != NULL)
+			name_temp = slash_ptr + 1;
 		if (machine && machine[0]) {
 			m = estrdup(machine);
 			easprintf(&name, "%s/%s", lower(m),
-sqlite3_column_text(stmt, 1));
+name_temp);
 			free(m);
 		} else {
 			name = estrdup((const char *) sqlite3_column_text(stmt, 1));

Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.4.2.1 src/usr.sbin/makemandb/apropos.c:1.4.2.2
--- src/usr.sbin/makemandb/apropos.c:1.4.2.1	Sat Feb 18 18:03:26 2012
+++ src/usr.sbin/makemandb/apropos.c	Thu Apr 19 20:03:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.4.2.1 2012/02/18 18:03:26 riz Exp $	*/
+/*	$NetBSD: apropos.c,v 1.4.2.2 2012/04/19 20:03:00 riz Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos.c,v 1.4

CVS commit: [netbsd-6] src/sys

2012-04-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Apr 19 19:59:11 UTC 2012

Modified Files:
src/sys/dev [netbsd-6]: rndpseudo.c
src/sys/kern [netbsd-6]: kern_rndq.c subr_cprng.c
src/sys/lib/libkern [netbsd-6]: arc4random.c
src/sys/sys [netbsd-6]: rnd.h

Log Message:
Pull up following revision(s) (requested by tls in ticket #185):
sys/kern/subr_cprng.c: revision 1.6
sys/kern/subr_cprng.c: revision 1.7
sys/lib/libkern/arc4random.c: revision 1.32
sys/kern/kern_rndq.c: revision 1.2
sys/dev/rndpseudo.c: revision 1.7
sys/sys/rnd.h: revision 1.30
Add a spin mutex to the rndsink structure; it is used to avoid lock
ordering and sleep-holding-locks problems when rekeying, and thus
to avoid a nasty race between cprng destruction and reseeding.
Fix LOCKDEBUG problems pointed out by drochner@
1) Lock ordering in cprng_strong_destroy had us take a spin mutex then
   an adaptive mutex.  Can't do that.  Reordering this requires changing
   cprng_strong_reseed to tryenter the cprng's own mutex and skip the
   reseed on failure, or we could deadlock.
2) Can't free memory with a valid mutex in it.
reorder initialization to improve error handling in case the system
runs out of file descriptors, avoids LOCKDEBUG panic due to double
mutex initialization


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/dev/rndpseudo.c
cvs rdiff -u -r1.1 -r1.1.2.1 src/sys/kern/kern_rndq.c
cvs rdiff -u -r1.5 -r1.5.2.1 src/sys/kern/subr_cprng.c
cvs rdiff -u -r1.31 -r1.31.2.1 src/sys/lib/libkern/arc4random.c
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/sys/rnd.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/dev/rndpseudo.c
diff -u src/sys/dev/rndpseudo.c:1.6 src/sys/dev/rndpseudo.c:1.6.2.1
--- src/sys/dev/rndpseudo.c:1.6	Tue Dec 20 13:42:19 2011
+++ src/sys/dev/rndpseudo.c	Thu Apr 19 19:59:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndpseudo.c,v 1.6 2011/12/20 13:42:19 apb Exp $	*/
+/*	$NetBSD: rndpseudo.c,v 1.6.2.1 2012/04/19 19:59:11 riz Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.6 2011/12/20 13:42:19 apb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.6.2.1 2012/04/19 19:59:11 riz Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -213,15 +213,14 @@ rndopen(dev_t dev, int flag, int ifmt,
 	default:
 		return ENXIO;
 	}
-	ctx = pool_cache_get(rp_cpc, PR_WAITOK);
-	ctx->cprng = NULL;
-	ctx->hard = hard;
-	mutex_init(&ctx->interlock, MUTEX_DEFAULT, IPL_NONE);
-	
+	ctx = pool_cache_get(rp_cpc, PR_WAITOK);	
 	if ((error = fd_allocfile(&fp, &fd)) != 0) {
 	pool_cache_put(rp_cpc, ctx);
 	return error;
 	}
+	ctx->cprng = NULL;
+	ctx->hard = hard;
+	mutex_init(&ctx->interlock, MUTEX_DEFAULT, IPL_NONE);
 
 	return fd_clone(fp, fd, flag, &rnd_fileops, ctx);
 }

Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.1 src/sys/kern/kern_rndq.c:1.1.2.1
--- src/sys/kern/kern_rndq.c:1.1	Thu Feb  2 19:43:07 2012
+++ src/sys/kern/kern_rndq.c	Thu Apr 19 19:59:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.1 2012/02/02 19:43:07 tls Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.1.2.1 2012/04/19 19:59:10 riz Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1 2012/02/02 19:43:07 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.1 2012/04/19 19:59:10 riz Exp $");
 
 #include 
 #include 
@@ -109,13 +109,17 @@ volatile int			rnd_timeout_pending;
 SIMPLEQ_HEAD(, _rnd_sample_t)	rnd_samples;
 kmutex_t			rnd_mtx;
 
+
 /*
  * Entropy sinks: usually other generators waiting to be rekeyed.
  *
  * A sink's callback MUST NOT re-add the sink to the list, or
- * list corruption will occur.
+ * list corruption will occur.  The list is protected by the
+ * rndsink_mtx, which must be released before calling any sink's
+ * callback.
  */
 TAILQ_HEAD(, rndsink)		rnd_sinks;
+kmutex_t			rndsink_mtx;
 
 /*
  * Memory pool for sample buffers
@@ -215,6 +219,7 @@ rnd_wakeup_readers(void)
 	/*
 	 * First, take care of in-kernel consumers needing rekeying.
 	 */
+	mutex_spin_enter(&rndsink_mtx);
 	TAILQ_FOREACH_SAFE(sink, &rnd_sinks, tailq, tsink) {
 		if ((sink->len + RND_ENTROPY_THRESHOLD) * 8 <
 			rndpool_get_entropy_count(&rnd_pool)) {
@@ -225,11 +230,16 @@ rnd_wakeup_readers(void)
 panic("could not extract estimated "
   "entropy from pool");
 			}
+			/* Skip if busy, else mark in-progress */
+			if (!mutex_tryenter(&sink->mtx)) {
+			continue;
+			}
 			/* Move this sink to the list of pending callbacks */
 			TAILQ_REMOVE(&rnd_sinks, sink, tailq);
 			TAILQ_INSERT_HEAD(&sunk, sink, tailq);
 		}
 	}
+	mutex_spin_exit(&rndsink_mtx);
 		
 	/*
 	 * If we still have enough new bits to do something, feed use

CVS commit: src/usr.sbin/makefs/ffs

2012-04-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Thu Apr 19 19:48:15 UTC 2012

Modified Files:
src/usr.sbin/makefs/ffs: mkfs.c

Log Message:
Fix build failure reported by bracket.

(shouldn't this size_t be ino_t?)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/makefs/ffs/mkfs.c

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

Modified files:

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.23 src/usr.sbin/makefs/ffs/mkfs.c:1.24
--- src/usr.sbin/makefs/ffs/mkfs.c:1.23	Thu Apr 19 17:28:26 2012
+++ src/usr.sbin/makefs/ffs/mkfs.c	Thu Apr 19 19:48:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.23 2012/04/19 17:28:26 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.24 2012/04/19 19:48:14 dholland Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.23 2012/04/19 17:28:26 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.24 2012/04/19 19:48:14 dholland Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -666,11 +666,14 @@ initcg(int cylno, time_t utime, const fs
 		exit(37);
 	}
 	acg.cg_cs.cs_nifree += sblock.fs_ipg;
-	if (cylno == 0)
-		for (size_t r = 0; r < ROOTINO; r++) {
+	if (cylno == 0) {
+		size_t r;
+
+		for (r = 0; r < ROOTINO; r++) {
 			setbit(cg_inosused(&acg, 0), r);
 			acg.cg_cs.cs_nifree--;
 		}
+	}
 	if (cylno > 0) {
 		/*
 		 * In cylno 0, beginning space is reserved



CVS commit: src

2012-04-19 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Apr 19 18:51:36 UTC 2012

Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
src/tests/usr.sbin: Makefile
Added Files:
src/tests/usr.sbin/useradd: Makefile t_useradd.sh

Log Message:
Add a test case for PR bin/39546.


To generate a diff of this commit:
cvs rdiff -u -r1.464 -r1.465 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.74 -r1.75 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.sbin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.sbin/useradd/Makefile \
src/tests/usr.sbin/useradd/t_useradd.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.464 src/distrib/sets/lists/tests/mi:1.465
--- src/distrib/sets/lists/tests/mi:1.464	Sat Apr 14 12:21:45 2012
+++ src/distrib/sets/lists/tests/mi	Thu Apr 19 18:51:36 2012
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.464 2012/04/14 12:21:45 jruoho Exp $
+# $NetBSD: mi,v 1.465 2012/04/19 18:51:36 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3246,6 +3246,9 @@
 ./usr/tests/usr.sbin/traceroute			tests-usr.sbin-tests
 ./usr/tests/usr.sbin/traceroute/Atffile		tests-usr.sbin-tests	atf
 ./usr/tests/usr.sbin/traceroute/t_traceroute	tests-usr.sbin-tests	atf
+./usr/tests/usr.sbin/useradd			tests-usr.sbin-tests
+./usr/tests/usr.sbin/useradd/Atffile		tests-usr.sbin-tests	atf
+./usr/tests/usr.sbin/useradd/t_useradd		tests-usr.sbin-tests	atf
 ./usr/tests/utiltests-obsolete		obsolete
 ./usr/tests/util/Atffile			tests-obsolete		obsolete
 ./usr/tests/util/awktests-obsolete		obsolete

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.74 src/etc/mtree/NetBSD.dist.tests:1.75
--- src/etc/mtree/NetBSD.dist.tests:1.74	Sat Apr 14 12:21:46 2012
+++ src/etc/mtree/NetBSD.dist.tests	Thu Apr 19 18:51:36 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.74 2012/04/14 12:21:46 jruoho Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.75 2012/04/19 18:51:36 jruoho Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -300,3 +300,4 @@
 ./usr/tests/usr.sbin/mtree
 ./usr/tests/usr.sbin/tcpdump
 ./usr/tests/usr.sbin/traceroute
+./usr/tests/usr.sbin/useradd

Index: src/tests/usr.sbin/Makefile
diff -u src/tests/usr.sbin/Makefile:1.3 src/tests/usr.sbin/Makefile:1.4
--- src/tests/usr.sbin/Makefile:1.3	Sat Apr 14 12:21:45 2012
+++ src/tests/usr.sbin/Makefile	Thu Apr 19 18:51:35 2012
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.3 2012/04/14 12:21:45 jruoho Exp $
+# $NetBSD: Makefile,v 1.4 2012/04/19 18:51:35 jruoho Exp $
 .include 
 
 TESTSDIR=   ${TESTSBASE}/usr.sbin
 
-TESTS_SUBDIRS+= mtree tcpdump traceroute
+TESTS_SUBDIRS+= mtree tcpdump traceroute useradd
 
 .include 

Added files:

Index: src/tests/usr.sbin/useradd/Makefile
diff -u /dev/null src/tests/usr.sbin/useradd/Makefile:1.1
--- /dev/null	Thu Apr 19 18:51:36 2012
+++ src/tests/usr.sbin/useradd/Makefile	Thu Apr 19 18:51:35 2012
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 2012/04/19 18:51:35 jruoho Exp $
+
+NOMAN=		# defined
+
+.include 
+
+TESTSDIR=	${TESTSBASE}/usr.sbin/useradd
+
+TESTS_SH=	t_useradd
+
+.include 
Index: src/tests/usr.sbin/useradd/t_useradd.sh
diff -u /dev/null src/tests/usr.sbin/useradd/t_useradd.sh:1.1
--- /dev/null	Thu Apr 19 18:51:36 2012
+++ src/tests/usr.sbin/useradd/t_useradd.sh	Thu Apr 19 18:51:36 2012
@@ -0,0 +1,50 @@
+# $NetBSD: t_useradd.sh,v 1.1 2012/04/19 18:51:36 jruoho Exp $
+#
+# Copyright (c) 2012 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jukka Ruohonen.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC

CVS commit: src/sys/arch/i386/i386

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Apr 19 18:07:05 UTC 2012

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Mirror what is done for amd64 boot and ACPI wakeup code by setting
CR0_WP (write protection bit) early on boot. Although it is set later via
cpu_init(), this can help tracking down invalid writes to pages mapped
as read only from ring 0.

No regression observed when booting under anita (QEMU) or a P4 host.

Depending on your hardware or setup, you may trigger code paths I have
overlooked. So if your machine does not start properly, or you get
page faults early during boot, please report them to me.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/i386/i386/locore.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/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.98 src/sys/arch/i386/i386/locore.S:1.99
--- src/sys/arch/i386/i386/locore.S:1.98	Thu Apr 19 18:00:35 2012
+++ src/sys/arch/i386/i386/locore.S	Thu Apr 19 18:07:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $	*/
+/*	$NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_ddb.h"
@@ -682,7 +682,7 @@ try586:	/* Use the `cpuid' instruction. 
  	 */
 	movl	%cr0,%eax		# get control word
 	# enable paging & NPX emulation
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_AM),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0		# and page NOW!
 
 	pushl	$begin			# jump to high mem



CVS commit: src/sys/arch

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Apr 19 18:00:35 UTC 2012

Modified Files:
src/sys/arch/amd64/acpi: acpi_wakecode.S
src/sys/arch/amd64/amd64: locore.S mptramp.S
src/sys/arch/i386/acpi: acpi_wakecode.S
src/sys/arch/i386/i386: locore.S mptramp.S

Log Message:
Set the CR0_AM bit so processes can enable alignment check errors under
x86 through PSL_AC bit.

ATF test incoming shortly.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/acpi/acpi_wakecode.S
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/amd64/amd64/mptramp.S
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/acpi/acpi_wakecode.S
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/i386/mptramp.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/amd64/acpi/acpi_wakecode.S
diff -u src/sys/arch/amd64/acpi/acpi_wakecode.S:1.10 src/sys/arch/amd64/acpi/acpi_wakecode.S:1.11
--- src/sys/arch/amd64/acpi/acpi_wakecode.S:1.10	Mon Aug 24 22:06:50 2009
+++ src/sys/arch/amd64/acpi/acpi_wakecode.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_wakecode.S,v 1.10 2009/08/24 22:06:50 jmcneill Exp $	*/
+/*	$NetBSD: acpi_wakecode.S,v 1.11 2012/04/19 18:00:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger 
@@ -198,7 +198,7 @@ wakeup_32:
 
 	/* Enable paging */
 	movl	%cr0,%eax
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
 	/* Flush prefetch queue */
 	jmp	1f

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.67 src/sys/arch/amd64/amd64/locore.S:1.68
--- src/sys/arch/amd64/amd64/locore.S:1.67	Fri Feb 24 08:06:07 2012
+++ src/sys/arch/amd64/amd64/locore.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.67 2012/02/24 08:06:07 cherry Exp $	*/
+/*	$NetBSD: locore.S,v 1.68 2012/04/19 18:00:34 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -626,7 +626,7 @@ start:	movw	$0x1234,0x472			# warm boot
 	 * 4. Enable paging and the rest of it.
 	 */
 	movl	%cr0,%eax
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
 	jmp	compat
 compat:

Index: src/sys/arch/amd64/amd64/mptramp.S
diff -u src/sys/arch/amd64/amd64/mptramp.S:1.12 src/sys/arch/amd64/amd64/mptramp.S:1.13
--- src/sys/arch/amd64/amd64/mptramp.S:1.12	Tue Apr 20 15:42:21 2010
+++ src/sys/arch/amd64/amd64/mptramp.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mptramp.S,v 1.12 2010/04/20 15:42:21 jym Exp $	*/
+/*	$NetBSD: mptramp.S,v 1.13 2012/04/19 18:00:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -173,7 +173,7 @@ _TRMP_LABEL(mp_startup)
 movl%ecx,%cr3   # load ptd addr into mmu
 
 movl%cr0,%eax   # get control word
-orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax
+orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP|CR0_AM),%eax
 movl%eax,%cr0
 	jmp	mptramp_compat
 mptramp_compat:

Index: src/sys/arch/i386/acpi/acpi_wakecode.S
diff -u src/sys/arch/i386/acpi/acpi_wakecode.S:1.14 src/sys/arch/i386/acpi/acpi_wakecode.S:1.15
--- src/sys/arch/i386/acpi/acpi_wakecode.S:1.14	Mon Aug 24 10:16:12 2009
+++ src/sys/arch/i386/acpi/acpi_wakecode.S	Thu Apr 19 18:00:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_wakecode.S,v 1.14 2009/08/24 10:16:12 jmcneill Exp $	*/
+/*	$NetBSD: acpi_wakecode.S,v 1.15 2012/04/19 18:00:34 jym Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -165,7 +165,7 @@ wakeup_32:
 	movl	WAKEUP_r_cr3 + ACPI_WAKEUP_ADDR,%eax
 	movl	%eax,%cr3
 	movl	%cr0,%eax
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0
 
 	/* Flush the prefetch queue */

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.97 src/sys/arch/i386/i386/locore.S:1.98
--- src/sys/arch/i386/i386/locore.S:1.97	Fri Mar  2 16:43:31 2012
+++ src/sys/arch/i386/i386/locore.S	Thu Apr 19 18:00:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.97 2012/03/02 16:43:31 bouyer Exp $	*/
+/*	$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.97 2012/03/02 16:43:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_ddb.h"
@@ -682,7 +682,7 @@ try586:	/* Use the `cpuid' instruction. 
  	 */
 	movl	%cr0,%eax		# get control word
 	# enable paging & NPX emulation
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|

CVS commit: src/doc

2012-04-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 19 17:52:39 UTC 2012

Modified Files:
src/doc: CHANGES

Log Message:
Note mpii(4)


To generate a diff of this commit:
cvs rdiff -u -r1.1696 -r1.1697 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.1696 src/doc/CHANGES:1.1697
--- src/doc/CHANGES:1.1696	Tue Apr 17 15:30:35 2012
+++ src/doc/CHANGES	Thu Apr 19 17:52:39 2012
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1696 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.1697 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -51,3 +51,5 @@ Changes from NetBSD 6.0 to NetBSD 7.0:
 		[christos 20120306]
 	amiga: Add clockport(4) layer and a driver for A1200 on-board clockport
 		a1k2cp(4). [rkujawa 20120417]
+	kernel: add mpii(4), a driver for LSI Logic Fusion-MPT Message Passing
+		Interface II SAS controllers.  [bouyer 20120419]



CVS commit: src/sys/dev

2012-04-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Apr 19 17:45:21 UTC 2012

Modified Files:
src/sys/dev/scsipi: atapiconf.c cd.c scsiconf.c scsiconf.h
scsipi_base.c scsipi_ioctl.c scsipiconf.h sd.c st.c st_atapi.c
st_scsi.c
src/sys/dev/usb: umass_scsipi.c

Log Message:
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
  SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
  subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
  SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
  is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
  so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
  along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
  sync/wide parameters only make sense for parallel SCSI.
  For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
  tagged queing status if enabled. Just be silent for other
  bustypes.

This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
  do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
  call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
  runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
  appropriate parameters is enough to enable tagged queuing,
  but then scsipi will print:
  sd0: async, 8-bit transfers, tagged queueing
  which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
  but will confuse users. With this change scsipi will only print:
  sd0: tagged queueing
  which is correct.

In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/scsipi/atapiconf.c
cvs rdiff -u -r1.306 -r1.307 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.265 -r1.266 src/sys/dev/scsipi/scsiconf.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/scsipi/scsiconf.h
cvs rdiff -u -r1.157 -r1.158 src/sys/dev/scsipi/scsipi_base.c
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/scsipi/scsipi_ioctl.c
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/scsipi/scsipiconf.h
cvs rdiff -u -r1.297 -r1.298 src/sys/dev/scsipi/sd.c
cvs rdiff -u -r1.220 -r1.221 src/sys/dev/scsipi/st.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/scsipi/st_atapi.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/scsipi/st_scsi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/umass_scsipi.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/dev/scsipi/atapiconf.c
diff -u src/sys/dev/scsipi/atapiconf.c:1.84 src/sys/dev/scsipi/atapiconf.c:1.85
--- src/sys/dev/scsipi/atapiconf.c:1.84	Fri Apr  6 17:12:45 2012
+++ src/sys/dev/scsipi/atapiconf.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $	*/
+/*	$NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1996, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $");
 
 #include 
 #include 
@@ -117,7 +117,8 @@ atapibusmatch(device_t parent, cfdata_t 
 	if (chan == NULL)
 		return (0);
 
-	if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_ATAPI)
+	if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) !=
+	SCSIPI_BUSTYPE_ATAPI)
 		return (0);
 
 	return (1);

Index: src/sys/dev/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.306 src/sys/dev/scsipi/cd.c:1.307
--- src/sys/dev/scsipi/cd.c:1.306	Sat Feb 25 10:17:14 2012
+++ src/sys/dev/scsipi/cd.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $	*/
+/*	$NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd

CVS commit: src/usr.sbin/makefs

2012-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 19 17:28:26 UTC 2012

Modified Files:
src/usr.sbin/makefs: Makefile chfs.c ffs.c walk.c
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c
src/usr.sbin/makefs/chfs: chfs_mkfs.c
src/usr.sbin/makefs/ffs: ffs_alloc.c mkfs.c
src/usr.sbin/makefs/v7fs: v7fs_estimate.c

Log Message:
WARNS=5


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/makefs/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/chfs.c
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/makefs/walk.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/chfs/chfs_mkfs.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/ffs/mkfs.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/v7fs/v7fs_estimate.c

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

Modified files:

Index: src/usr.sbin/makefs/Makefile
diff -u src/usr.sbin/makefs/Makefile:1.30 src/usr.sbin/makefs/Makefile:1.31
--- src/usr.sbin/makefs/Makefile:1.30	Thu Apr 19 11:36:06 2012
+++ src/usr.sbin/makefs/Makefile	Thu Apr 19 13:28:25 2012
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.30 2012/04/19 15:36:06 ttoth Exp $
+#	$NetBSD: Makefile,v 1.31 2012/04/19 17:28:25 christos Exp $
 #
 
-WARNS?=	3	# XXX -Wsign-compare
+WARNS?=	5
 
 .include 
 

Index: src/usr.sbin/makefs/chfs.c
diff -u src/usr.sbin/makefs/chfs.c:1.2 src/usr.sbin/makefs/chfs.c:1.3
--- src/usr.sbin/makefs/chfs.c:1.2	Thu Apr 19 13:09:53 2012
+++ src/usr.sbin/makefs/chfs.c	Thu Apr 19 13:28:25 2012
@@ -98,7 +98,6 @@ chfs_parse_opts(const char *option, fsin
 	}
 	*val++ = '\0';
 
-/*###101 [cc] error: passing argument 1 of 'set_option' discards qualifiers from pointer target type%%%*/
 	retval = set_option(chfs_options, var, val);
 	
 leave_chfs_parse_opts:
@@ -217,8 +216,8 @@ chfs_populate_dir(const char *dir, fsnod
 		if (cur->child == NULL) {
 			continue;
 		}
-		if (snprintf(path, sizeof(path), "%s/%s", dir, cur->name)
-		>= sizeof(path)) {
+		if ((size_t)snprintf(path, sizeof(path), "%s/%s", dir,
+		cur->name) >= sizeof(path)) {
 			errx(EXIT_FAILURE, "Pathname too long");
 		}
 		if (!chfs_populate_dir(path, cur->child, cur, fsopts)) {

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.46 src/usr.sbin/makefs/ffs.c:1.47
--- src/usr.sbin/makefs/ffs.c:1.46	Fri Jan 27 21:35:46 2012
+++ src/usr.sbin/makefs/ffs.c	Thu Apr 19 13:28:25 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.46 2012/01/28 02:35:46 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.47 2012/04/19 17:28:25 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.46 2012/01/28 02:35:46 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.47 2012/04/19 17:28:25 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -536,7 +536,7 @@ ffs_create_image(const char *image, fsin
 		(long long)fs->fs_cstotal.cs_ndir);
 	}
 
-	if (fs->fs_cstotal.cs_nifree + ROOTINO < fsopts->inodes) {
+	if ((off_t)(fs->fs_cstotal.cs_nifree + ROOTINO) < fsopts->inodes) {
 		warnx(
 		"Image file `%s' has %lld free inodes; %lld are required.",
 		image,
@@ -603,7 +603,7 @@ ffs_size_dir(fsnode *root, fsinfo_t *fso
 			if (node->type == S_IFREG)
 ADDSIZE(node->inode->st.st_size);
 			if (node->type == S_IFLNK) {
-int	slen;
+size_t	slen;
 
 slen = strlen(node->symlink) + 1;
 if (slen >= (ffs_opts->version == 1 ?
@@ -626,7 +626,7 @@ static void *
 ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
 		 fsnode *root, fsinfo_t *fsopts)
 {
-	int slen;
+	size_t slen;
 	void *membuf;
 
 	memset(dinp, 0, sizeof(*dinp));
@@ -674,7 +674,7 @@ static void *
 ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
 		 fsnode *root, fsinfo_t *fsopts)
 {
-	int slen;
+	size_t slen;
 	void *membuf;
 
 	memset(dinp, 0, sizeof(*dinp));
@@ -825,8 +825,8 @@ ffs_populate_dir(const char *dir, fsnode
 	for (cur = root; cur != NULL; cur = cur->next) {
 		if (cur->child == NULL)
 			continue;
-		if (snprintf(path, sizeof(path), "%s/%s", dir, cur->name)
-		>= sizeof(path))
+		if ((size_t)snprintf(path, sizeof(path), "%s/%s", dir,
+		cur->name) >= sizeof(path))
 			errx(1, "Pathname too long.");
 		if (! ffs_populate_dir(path, cur->child, fsopts))
 			return (0);
@@ -1047,7 +1047,7 @@ ffs_write_inode(union dinode *dp, uint32
 	int		cg, cgino, i;
 	daddr_t		d;
 	char		sbbuf[FFS_MAXBSIZE];
-	int32_t		initediblk;
+	uint32_t	initediblk;
 	ffs_opt_t	*ffs_opts = fsopts->fs_specific;
 
 	assert (dp != NULL);
@@ -1098,7 +1098,8 @@ ffs_write_inode(union dinode *dp, uint32
 	 * Initialize inode blocks on the fly for UFS2.
 	 */
 	initediblk = ufs_rw32(cgp->cg_initediblk, fsopts->needswap);
-	i

CVS commit: src/sys/ufs/ffs

2012-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 19 17:25:38 UTC 2012

Modified Files:
src/sys/ufs/ffs: fs.h

Log Message:
Fix signed/unsigned issues.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/ufs/ffs/fs.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/ufs/ffs/fs.h
diff -u src/sys/ufs/ffs/fs.h:1.56 src/sys/ufs/ffs/fs.h:1.57
--- src/sys/ufs/ffs/fs.h:1.56	Sun Mar  6 12:08:38 2011
+++ src/sys/ufs/ffs/fs.h	Thu Apr 19 13:25:38 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fs.h,v 1.56 2011/03/06 17:08:38 bouyer Exp $	*/
+/*	$NetBSD: fs.h,v 1.57 2012/04/19 17:25:38 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -672,7 +672,7 @@ struct ocg {
 #define	lfragtosize(fs, frag)	/* calculates ((off_t)frag * fs->fs_fsize) */ \
 	(((off_t)(frag)) << (fs)->fs_fshift)
 #define	lblktosize(fs, blk)	/* calculates ((off_t)blk * fs->fs_bsize) */ \
-	(((off_t)(blk)) << (fs)->fs_bshift)
+	((uint64_t)(((off_t)(blk)) << (fs)->fs_bshift))
 #define	lblkno(fs, loc)		/* calculates (loc / fs->fs_bsize) */ \
 	((loc) >> (fs)->fs_bshift)
 #define	numfrags(fs, loc)	/* calculates (loc / fs->fs_fsize) */ \
@@ -704,12 +704,12 @@ struct ocg {
  */
 #define	blksize(fs, ip, lbn) \
 	(((lbn) >= NDADDR || (ip)->i_size >= lblktosize(fs, (lbn) + 1)) \
-	? (fs)->fs_bsize \
+	? (uint64_t)(fs)->fs_bsize \
 	: (fragroundup(fs, blkoff(fs, (ip)->i_size
 
 #define	sblksize(fs, size, lbn) \
 	(((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
-	  ? (fs)->fs_bsize \
+	  ? (uint64_t)(fs)->fs_bsize \
 	  : (fragroundup(fs, blkoff(fs, (size)
 
 



CVS commit: src/usr.sbin/makefs

2012-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 19 17:09:53 UTC 2012

Modified Files:
src/usr.sbin/makefs: chfs.c makefs.c makefs.h
src/usr.sbin/makefs/chfs: chfs_mkfs.c

Log Message:
- fix compilation isses
- add some error checking
- avoid alloca
- add missing frees


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makefs/chfs.c
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makefs/chfs/chfs_mkfs.c

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

Modified files:

Index: src/usr.sbin/makefs/chfs.c
diff -u src/usr.sbin/makefs/chfs.c:1.1 src/usr.sbin/makefs/chfs.c:1.2
--- src/usr.sbin/makefs/chfs.c:1.1	Thu Apr 19 11:36:06 2012
+++ src/usr.sbin/makefs/chfs.c	Thu Apr 19 13:09:53 2012
@@ -98,6 +98,7 @@ chfs_parse_opts(const char *option, fsin
 	}
 	*val++ = '\0';
 
+/*###101 [cc] error: passing argument 1 of 'set_option' discards qualifiers from pointer target type%%%*/
 	retval = set_option(chfs_options, var, val);
 	
 leave_chfs_parse_opts:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.32 src/usr.sbin/makefs/makefs.c:1.33
--- src/usr.sbin/makefs/makefs.c:1.32	Thu Apr 19 11:36:06 2012
+++ src/usr.sbin/makefs/makefs.c	Thu Apr 19 13:09:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.32 2012/04/19 15:36:06 ttoth Exp $	*/
+/*	$NetBSD: makefs.c,v 1.33 2012/04/19 17:09:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.32 2012/04/19 15:36:06 ttoth Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.33 2012/04/19 17:09:53 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -296,7 +296,7 @@ main(int argc, char *argv[])
 
 
 int
-set_option(option_t *options, const char *var, const char *val)
+set_option(const option_t *options, const char *var, const char *val)
 {
 	int	i;
 

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.25 src/usr.sbin/makefs/makefs.h:1.26
--- src/usr.sbin/makefs/makefs.h:1.25	Thu Apr 19 11:36:06 2012
+++ src/usr.sbin/makefs/makefs.h	Thu Apr 19 13:09:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.25 2012/04/19 15:36:06 ttoth Exp $	*/
+/*	$NetBSD: makefs.h,v 1.26 2012/04/19 17:09:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -158,7 +158,7 @@ typedef struct {
 void		apply_specfile(const char *, const char *, fsnode *, int);
 void		dump_fsnodes(fsnode *);
 const char *	inode_type(mode_t);
-int		set_option(option_t *, const char *, const char *);
+int		set_option(const option_t *, const char *, const char *);
 fsnode *	walk_dir(const char *, const char *, fsnode *, fsnode *);
 void		free_fsnodes(fsnode *);
 

Index: src/usr.sbin/makefs/chfs/chfs_mkfs.c
diff -u src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.1 src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.2
--- src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.1	Thu Apr 19 11:36:06 2012
+++ src/usr.sbin/makefs/chfs/chfs_mkfs.c	Thu Apr 19 13:09:53 2012
@@ -109,39 +109,49 @@ pad_block_if_less_than(fsinfo_t *fsopts,
 void
 write_eb_header(fsinfo_t *fsopts)
 {
-	chfs_opt_t *chfs_opts;
+	chfs_opt_t *opts;
 	struct chfs_eb_hdr ebhdr;
+	char *buf;
 
-	chfs_opts = fsopts->fs_specific;
+	opts = fsopts->fs_specific;
 
-	char buf[chfs_opts->pagesize];
+#define MINSIZE MAX(MAX(CHFS_EB_EC_HDR_SIZE, CHFS_EB_HDR_NOR_SIZE), \
+CHFS_EB_HDR_NAND_SIZE)
+	if (opts->pagesize < MINSIZE)
+		errx(EXIT_FAILURE, "pagesize cannot be less than %zu", MINSIZE);
+	if ((buf = malloc(opts->pagesize)) == NULL)
+		err(EXIT_FAILURE, "Memory allocation failed");
 
-	memset(buf, 0xFF, sizeof(buf));
+	memset(buf, 0xFF, opts->pagesize);
 
 	ebhdr.ec_hdr.magic = htole32(CHFS_MAGIC_BITMASK);
 	ebhdr.ec_hdr.erase_cnt = htole32(1);
-	ebhdr.ec_hdr.crc_ec = htole32(crc32(0, (uint8_t *)&ebhdr.ec_hdr + 8, 4));
+	ebhdr.ec_hdr.crc_ec = htole32(crc32(0,
+	(uint8_t *)&ebhdr.ec_hdr + 8, 4));
 
-	memcpy(&buf, &ebhdr.ec_hdr, CHFS_EB_EC_HDR_SIZE);
+	memcpy(buf, &ebhdr.ec_hdr, CHFS_EB_EC_HDR_SIZE);
 
-	buf_write(fsopts, &buf, chfs_opts->pagesize);
+	buf_write(fsopts, buf, opts->pagesize);
 
-	memset(buf, 0xFF, chfs_opts->pagesize);
+	memset(buf, 0xFF, opts->pagesize);
 
-	if (chfs_opts->mediatype == TYPE_NAND) {
+	if (opts->mediatype == TYPE_NAND) {
 		ebhdr.u.nand_hdr.lid = htole32(lebnumber++);
 		ebhdr.u.nand_hdr.serial = htole64(++(max_serial));
 		ebhdr.u.nand_hdr.crc = htole32(crc32(0,
-		(uint8_t *)&ebhdr.u.nand_hdr + 4, CHFS_EB_HDR_NAND_SIZE - 4));
-		memcpy(&buf, &ebhdr.u.nand_hdr, CHFS_EB_HDR_NAND_SIZE);
+		(uint8_t *)&ebhdr.u.nand_hdr + 4,
+		CHFS_EB_HDR_NAND_SIZE - 4));
+		memcpy(buf, &ebhdr.u.nand_hdr, CHFS_EB_HDR_NAND_SIZE);
 	} else {
 		ebhdr.u.nor_hdr.lid = htole32(lebnumber++);
-		ebhdr.u.nor_hdr.crc = htole32(crc32(0, (uint8_t *)&ebhdr.u.nor_hdr + 4,
+		ebhdr.u.n

CVS commit: src/usr.sbin/makefs

2012-04-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr 19 16:00:26 UTC 2012

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makefs/makefs.8

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

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.39 src/usr.sbin/makefs/makefs.8:1.40
--- src/usr.sbin/makefs/makefs.8:1.39	Thu Apr 19 15:36:06 2012
+++ src/usr.sbin/makefs/makefs.8	Thu Apr 19 16:00:25 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.39 2012/04/19 15:36:06 ttoth Exp $
+.\"	$NetBSD: makefs.8,v 1.40 2012/04/19 16:00:25 wiz Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -355,7 +355,8 @@ Pagesize.
 .It Sy erasesize
 Erase block size of the media.
 .It Sy mediatype
-Type of the media. NOR: 0 or NAND: 1.
+Type of the media.
+NOR: 0 or NAND: 1.
 .El
 .Ss V7FS-specific options
 The following keywords are supported:



CVS commit: src/sys/ufs

2012-04-19 Thread Tamas Toth
Module Name:src
Committed By:   ttoth
Date:   Thu Apr 19 15:55:40 UTC 2012

Modified Files:
src/sys/ufs: files.ufs

Log Message:
chfs/debug.c deleted from files.ufs


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/ufs/files.ufs

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

Modified files:

Index: src/sys/ufs/files.ufs
diff -u src/sys/ufs/files.ufs:1.27 src/sys/ufs/files.ufs:1.28
--- src/sys/ufs/files.ufs:1.27	Thu Nov 24 15:51:31 2011
+++ src/sys/ufs/files.ufs	Thu Apr 19 15:55:40 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ufs,v 1.27 2011/11/24 15:51:31 ahoka Exp $
+#	$NetBSD: files.ufs,v 1.28 2012/04/19 15:55:40 ttoth Exp $
 
 deffs	FFS
 deffs	EXT2FS
@@ -36,7 +36,6 @@ file	ufs/chfs/chfs_gc.c		chfs
 file	ufs/chfs/chfs_nodeops.c		chfs
 file	ufs/chfs/chfs_malloc.c		chfs
 file	ufs/chfs/chfs_pool.c		chfs
-file	ufs/chfs/debug.c			chfs
 file	ufs/chfs/chfs_vnode.c		chfs
 file	ufs/chfs/chfs_subr.c		chfs
 file	ufs/chfs/chfs_vfsops.c		chfs



CVS commit: src/external/gpl3/gcc/dist/libmudflap

2012-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 19 15:52:39 UTC 2012

Modified Files:
src/external/gpl3/gcc/dist/libmudflap: mf-runtime.c mf-runtime.h

Log Message:
Make declarations consistent, and change unsigned int to unsigned long so
that this works on LP64 machines. Why is the __mf_uintptr_t needed anyway?


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c \
src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h

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

Modified files:

Index: src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c:1.2 src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c:1.3
--- src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c:1.2	Tue Apr 17 22:55:05 2012
+++ src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c	Thu Apr 19 11:52:39 2012
@@ -166,7 +166,7 @@ begin_recursion_protect1 (const char *pf
 #define LOOKUP_CACHE_SHIFT_DFL 2
 
 struct __mf_cache __mf_lookup_cache [LOOKUP_CACHE_SIZE_MAX];
-uintptr_t __mf_lc_mask = LOOKUP_CACHE_MASK_DFL;
+__mf_uintptr_t __mf_lc_mask = LOOKUP_CACHE_MASK_DFL;
 unsigned char __mf_lc_shift = LOOKUP_CACHE_SHIFT_DFL;
 #define LOOKUP_CACHE_SIZE (__mf_lc_mask + 1)
 
Index: src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h:1.2 src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h:1.3
--- src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h:1.2	Tue Apr 17 22:55:05 2012
+++ src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h	Thu Apr 19 11:52:39 2012
@@ -31,7 +31,7 @@ see the files COPYING3 and COPYING.RUNTI
 #define MF_RUNTIME_H
 
 typedef void *__mf_ptr_t;
-typedef unsigned int __mf_uintptr_t __attribute__ ((__mode__ (__pointer__)));
+typedef unsigned long __mf_uintptr_t __attribute__ ((__mode__ (__pointer__)));
 typedef __SIZE_TYPE__ __mf_size_t;
 
 /* Global declarations used by instrumentation.  When _MUDFLAP is



CVS commit: src/usr.sbin/makefs

2012-04-19 Thread Tamas Toth
Module Name:src
Committed By:   ttoth
Date:   Thu Apr 19 15:36:06 UTC 2012

Modified Files:
src/usr.sbin/makefs: Makefile makefs.8 makefs.c makefs.h
Added Files:
src/usr.sbin/makefs: chfs.c chfs_makefs.h
src/usr.sbin/makefs/chfs: Makefile.inc chfs_mkfs.c chfs_mkfs.h

Log Message:
added chfs support for makefs


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/makefs/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makefs/chfs.c \
src/usr.sbin/makefs/chfs_makefs.h
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makefs/chfs/Makefile.inc \
src/usr.sbin/makefs/chfs/chfs_mkfs.c src/usr.sbin/makefs/chfs/chfs_mkfs.h

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

Modified files:

Index: src/usr.sbin/makefs/Makefile
diff -u src/usr.sbin/makefs/Makefile:1.29 src/usr.sbin/makefs/Makefile:1.30
--- src/usr.sbin/makefs/Makefile:1.29	Mon Jul 18 22:52:37 2011
+++ src/usr.sbin/makefs/Makefile	Thu Apr 19 15:36:06 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.29 2011/07/18 22:52:37 tron Exp $
+#	$NetBSD: Makefile,v 1.30 2012/04/19 15:36:06 ttoth Exp $
 #
 
 WARNS?=	3	# XXX -Wsign-compare
@@ -6,7 +6,7 @@ WARNS?=	3	# XXX -Wsign-compare
 .include 
 
 PROG=	makefs
-SRCS=	cd9660.c ffs.c v7fs.c \
+SRCS=	cd9660.c chfs.c ffs.c v7fs.c \
 	getid.c \
 	makefs.c misc.c \
 	pack_dev.c \
@@ -21,6 +21,7 @@ CPPFLAGS+=	-I${.CURDIR} -I${MKNODSRC} -I
 .PATH:		${MKNODSRC} ${MTREESRC}
 
 .include "${.CURDIR}/cd9660/Makefile.inc"
+.include "${.CURDIR}/chfs/Makefile.inc"
 .include "${.CURDIR}/ffs/Makefile.inc"
 .include "${.CURDIR}/v7fs/Makefile.inc"
 

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.38 src/usr.sbin/makefs/makefs.8:1.39
--- src/usr.sbin/makefs/makefs.8:1.38	Sat Jan 28 02:35:46 2012
+++ src/usr.sbin/makefs/makefs.8	Thu Apr 19 15:36:06 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.38 2012/01/28 02:35:46 christos Exp $
+.\"	$NetBSD: makefs.8,v 1.39 2012/04/19 15:36:06 ttoth Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 27, 2012
+.Dd April 5, 2012
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -199,6 +199,8 @@ The following file system types are supp
 BSD fast file system (default).
 .It Sy cd9660
 ISO 9660 file system.
+.It Sy chfs
+Chip flash file system.
 .It Sy v7fs
 7th Edition(V7) file system.
 .El
@@ -339,6 +341,22 @@ Use RockRidge extensions (for longer fil
 .It Sy volumeid
 Volume set identifier of the image.
 .El
+.Ss CHFS-specific options
+.Sy chfs
+images have chfs-specific optional parameters that may be provided.
+Each of the options consists of a keyword, an equal sign
+.Pq Ql = ,
+and a value.
+The following keywords are supported:
+.Pp
+.Bl -tag -width optimization -offset indent -compact
+.It Sy pagesize
+Pagesize.
+.It Sy erasesize
+Erase block size of the media.
+.It Sy mediatype
+Type of the media. NOR: 0 or NAND: 1.
+.El
 .Ss V7FS-specific options
 The following keywords are supported:
 .Pp
@@ -370,4 +388,6 @@ utility appeared in
 .An Ram Vedam
 (cd9660 support),
 .An UCHIYAMA Yasushi
-(v7fs support).
+(v7fs support),
+.An Tamas Toth
+(chfs support).

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.31 src/usr.sbin/makefs/makefs.c:1.32
--- src/usr.sbin/makefs/makefs.c:1.31	Sat Jan 28 02:35:46 2012
+++ src/usr.sbin/makefs/makefs.c	Thu Apr 19 15:36:06 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.31 2012/01/28 02:35:46 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.32 2012/04/19 15:36:06 ttoth Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.31 2012/01/28 02:35:46 christos Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.32 2012/04/19 15:36:06 ttoth Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -73,6 +73,8 @@ static fstype_t fstypes[] = {
 	{ "ffs", ffs_prep_opts,	ffs_parse_opts,	ffs_cleanup_opts, ffs_makefs },
 	{ "cd9660", cd9660_prep_opts, cd9660_parse_opts, cd9660_cleanup_opts,
 	  cd9660_makefs},
+	{ "chfs", chfs_prep_opts, chfs_parse_opts, chfs_cleanup_opts,
+	  chfs_makefs },
 	{ "v7fs", v7fs_prep_opts, v7fs_parse_opts, v7fs_cleanup_opts,
 	  v7fs_makefs },
 	{ .type = NULL	},

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.24 src/usr.sbin/makefs/makefs.h:1.25
--- src/usr.sbin/makefs/makefs.h:1.24	Sat Jan 28 02:35:46 2012
+++ src/usr.sbin/makefs/makefs.h	Thu Apr 19 15:36:06 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.24 2012/01/28 02:35:46 christos Exp $	*/
+/*	$NetBSD: makefs.h,v 1.25 2012/04/19 15:36:06 ttoth Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Syste

CVS commit: src/sys/arch

2012-04-19 Thread Hiroyuki Bessho
Module Name:src
Committed By:   bsh
Date:   Thu Apr 19 09:53:53 UTC 2012

Modified Files:
src/sys/arch/arm/imx: files.imx51
src/sys/arch/evbarm/conf: NETWALKER
Added Files:
src/sys/arch/arm/imx: imx51_esdhc.c

Log Message:
support SD/MMC on Netwalker.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/files.imx51
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imx51_esdhc.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbarm/conf/NETWALKER

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/arm/imx/files.imx51
diff -u src/sys/arch/arm/imx/files.imx51:1.4 src/sys/arch/arm/imx/files.imx51:1.5
--- src/sys/arch/arm/imx/files.imx51:1.4	Tue Apr 17 10:19:57 2012
+++ src/sys/arch/arm/imx/files.imx51	Thu Apr 19 09:53:53 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx51,v 1.4 2012/04/17 10:19:57 bsh Exp $
+#	$NetBSD: files.imx51,v 1.5 2012/04/19 09:53:53 bsh Exp $
 #
 # Configuration info for the Freescale i.MX51
 #
@@ -87,8 +87,8 @@ file   arch/arm/imx/imxusb.c			imxehci
 # file	arch/arm/imx/wdc_axi.c			wdc_axi
 
 # SD host controller for SD/MMC
-# device	imxmci: sdmmcbus
-# file	arch/arm/imx/imx51_mci.c		imxmci
+attach	sdhc at axi with sdhc_axi
+file	arch/arm/imx/imx51_esdhc.c		sdhc_axi
 
 # iic Controler
 # device	imxi2c: i2cbus

Index: src/sys/arch/evbarm/conf/NETWALKER
diff -u src/sys/arch/evbarm/conf/NETWALKER:1.11 src/sys/arch/evbarm/conf/NETWALKER:1.12
--- src/sys/arch/evbarm/conf/NETWALKER:1.11	Tue Apr 17 10:19:57 2012
+++ src/sys/arch/evbarm/conf/NETWALKER	Thu Apr 19 09:53:53 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: NETWALKER,v 1.11 2012/04/17 10:19:57 bsh Exp $
+#	$NetBSD: NETWALKER,v 1.12 2012/04/19 09:53:53 bsh Exp $
 #
 #	NETWALKER -- http://www.sharp.co.jp/netwalker/
 #
@@ -194,6 +194,14 @@ imxgpio1	at axi? addr 0x73f88000
 imxgpio2	at axi? addr 0x73f8c000
 imxgpio3	at axi? addr 0x73f9
 
+# SD/MMC
+sdhc0	at axi? addr 0x70004000 irq 1	 # eSDHC1
+#sdhc1   	at axi? addr 0x70008000 irq 2	 # eSDHC2
+sdmmc*		at sdhc?
+ld*		at sdmmc?			# MMC/SD card
+#options 	SDHC_DEBUG
+#options 	SDMMC_DEBUG
+
 # USB
 imxusbc0  at axi?  addr 0x73f8
 ehci0	  at imxusbc0	unit 0	irq 18 # OTG

Added files:

Index: src/sys/arch/arm/imx/imx51_esdhc.c
diff -u /dev/null src/sys/arch/arm/imx/imx51_esdhc.c:1.1
--- /dev/null	Thu Apr 19 09:53:54 2012
+++ src/sys/arch/arm/imx/imx51_esdhc.c	Thu Apr 19 09:53:53 2012
@@ -0,0 +1,128 @@
+/*	$NetBSD: imx51_esdhc.c,v 1.1 2012/04/19 09:53:53 bsh Exp $ */
+
+/*-
+ * Copyright (c) 2012  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials provided
+ *with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: imx51_esdhc.c,v 1.1 2012/04/19 09:53:53 bsh Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct sdhc_axi_softc {
+	struct sdhc_softc  sc_sdhc;
+	/* we have only one slot */
+	struct sdhc_host *sc_hosts[1];
+
+	void *sc_ih;
+};
+
+static int sdhc_match(device_t, cfdata_t, void *);
+static void sdhc_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(sdhc_axi, sizeof(struct sdhc_axi_softc),
+sdhc_match, sdhc_attach, NULL, NULL);
+
+static int
+sdhc_match(device_t parent, cfdata_t cf, void *aux)
+{
+
+	struct axi_attach_args *aa = aux;
+
+	switch (aa->aa_addr) {
+	case ESDHC1_BASE:
+	case ESDHC2_BASE:
+		return 1;
+	}
+
+	return 0;
+}
+
+static void
+sdhc_attach(device_t parent, device_t self, void *aux)
+{
+	struct sdhc_axi_softc *sc = device_private(self);
+	struct axi_attach_args *aa = aux;
+	bus_space_tag_t 

CVS commit: src/sys/dev/pci/voyager

2012-04-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 19 09:03:02 UTC 2012

Modified Files:
src/sys/dev/pci/voyager: voyagerfb.c

Log Message:
glyphcache_init() works best with its parameters in the right order. Doh.
While there request an RGB devcmap.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/voyager/voyagerfb.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/dev/pci/voyager/voyagerfb.c
diff -u src/sys/dev/pci/voyager/voyagerfb.c:1.19 src/sys/dev/pci/voyager/voyagerfb.c:1.20
--- src/sys/dev/pci/voyager/voyagerfb.c:1.19	Tue Mar 20 14:59:36 2012
+++ src/sys/dev/pci/voyager/voyagerfb.c	Thu Apr 19 09:03:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: voyagerfb.c,v 1.19 2012/03/20 14:59:36 macallan Exp $	*/
+/*	$NetBSD: voyagerfb.c,v 1.20 2012/04/19 09:03:01 macallan Exp $	*/
 
 /*
  * Copyright (c) 2009, 2011 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.19 2012/03/20 14:59:36 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.20 2012/04/19 09:03:01 macallan Exp $");
 
 #include 
 #include 
@@ -297,8 +297,8 @@ voyagerfb_attach(device_t parent, device
 		(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
 	}
 	glyphcache_init(&sc->sc_gc, sc->sc_height,
-			sc->sc_width,
 			(sc->sc_fbsize / sc->sc_stride) - sc->sc_height,
+			sc->sc_width,
 			ri->ri_font->fontwidth,
 			ri->ri_font->fontheight,
 			defattr);
@@ -548,10 +548,19 @@ voyagerfb_init_screen(void *cookie, stru
 	if (existing) {
 		ri->ri_flg |= RI_CLEAR;
 	}
+
+	if (sc->sc_depth == 32) {
 #ifdef VOYAGERFB_ANTIALIAS
-	if (sc->sc_depth == 32)
 		ri->ri_flg |= RI_ENABLE_ALPHA;
 #endif
+		/* we always run in RGB */
+		ri->ri_rnum = 8;
+		ri->ri_gnum = 8;
+		ri->ri_bnum = 8;
+		ri->ri_rpos = 16;
+		ri->ri_gpos = 8;
+		ri->ri_bpos = 0;
+	}
 
 	rasops_init(ri, 0, 0);
 	ri->ri_caps = WSSCREEN_WSCOLORS;



CVS commit: src/sys/dev/pci

2012-04-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 19 08:59:42 UTC 2012

Modified Files:
src/sys/dev/pci: r128fb.c

Log Message:
glyphcache_init() works much better with its parameters in the right order


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/r128fb.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/dev/pci/r128fb.c
diff -u src/sys/dev/pci/r128fb.c:1.33 src/sys/dev/pci/r128fb.c:1.34
--- src/sys/dev/pci/r128fb.c:1.33	Thu Apr 19 06:58:55 2012
+++ src/sys/dev/pci/r128fb.c	Thu Apr 19 08:59:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: r128fb.c,v 1.33 2012/04/19 06:58:55 macallan Exp $	*/
+/*	$NetBSD: r128fb.c,v 1.34 2012/04/19 08:59:42 macallan Exp $	*/
 
 /*
  * Copyright (c) 2007 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.33 2012/04/19 06:58:55 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.34 2012/04/19 08:59:42 macallan Exp $");
 
 #include 
 #include 
@@ -224,6 +224,12 @@ r128fb_attach(device_t parent, device_t 
 		aprint_error("%s: no height property\n", device_xname(self));
 		return;
 	}
+
+#ifdef GLYPHCACHE_DEBUG
+	/* leave some visible VRAM unused so we can see the glyph cache */
+	sc->sc_height -= 100;
+#endif
+
 	if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) {
 		aprint_error("%s: no depth property\n", device_xname(self));
 		return;
@@ -288,8 +294,8 @@ r128fb_attach(device_t parent, device_t 
 		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
 		sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
 		glyphcache_init(&sc->sc_gc, sc->sc_height + 5,
-sc->sc_width,
 (0x80 / sc->sc_stride) - sc->sc_height - 5,
+sc->sc_width,
 ri->ri_font->fontwidth,
 ri->ri_font->fontheight,
 defattr);
@@ -302,9 +308,9 @@ r128fb_attach(device_t parent, device_t 
 		 * until someone actually allocates a screen for us
 		 */
 		(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
-		glyphcache_init(&sc->sc_gc, sc->sc_height,
+		glyphcache_init(&sc->sc_gc, sc->sc_height + 5,
+(0x80 / sc->sc_stride) - sc->sc_height - 5,
 sc->sc_width,
-(0x80 / sc->sc_stride) - sc->sc_height,
 ri->ri_font->fontwidth,
 ri->ri_font->fontheight,
 defattr);



CVS commit: src/sys/dev/wscons

2012-04-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 19 08:46:17 UTC 2012

Modified Files:
src/sys/dev/wscons: wsdisplay_glyphcache.c wsdisplay_glyphcachevar.h

Log Message:
no need to convert cell number to coordinates every time we draw a glyph
from cache - just stick the coordinates directly into the map


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/wscons/wsdisplay_glyphcache.c \
src/sys/dev/wscons/wsdisplay_glyphcachevar.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/dev/wscons/wsdisplay_glyphcache.c
diff -u src/sys/dev/wscons/wsdisplay_glyphcache.c:1.1 src/sys/dev/wscons/wsdisplay_glyphcache.c:1.2
--- src/sys/dev/wscons/wsdisplay_glyphcache.c:1.1	Thu Feb 16 17:29:21 2012
+++ src/sys/dev/wscons/wsdisplay_glyphcache.c	Thu Apr 19 08:46:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_glyphcache.c,v 1.1 2012/02/16 17:29:21 macallan Exp $	*/
+/*	$NetBSD: wsdisplay_glyphcache.c,v 1.2 2012/04/19 08:46:17 macallan Exp $	*/
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -82,10 +82,10 @@ glyphcache_add(glyphcache *gc, int c, in
 	if (gc->gc_usedcells >= gc->gc_numcells)
 		return ENOMEM;
 	cell = atomic_add_int_nv(&gc->gc_usedcells, 1) - 1;
-	gc->gc_map[c] = cell;
 	cy = gc->gc_firstline +
 	(cell / gc->gc_cellsperline) * gc->gc_cellheight;
 	cx = (cell % gc->gc_cellsperline) * gc->gc_cellwidth;
+	gc->gc_map[c] = (cx << 16) | cy;
 	gc->gc_bitblt(gc->gc_blitcookie, x, y, cx, cy,
 	gc->gc_cellwidth, gc->gc_cellheight, gc->gc_rop);
 	return 0;
@@ -109,9 +109,8 @@ glyphcache_try(glyphcache *gc, int c, in
 	cell = gc->gc_map[c];
 	if (cell == -1)
 		return GC_ADD;
-	cy = gc->gc_firstline +
-	(cell / gc->gc_cellsperline) * gc->gc_cellheight;
-	cx = (cell % gc->gc_cellsperline) * gc->gc_cellwidth;
+	cy = cell & 0x;
+	cx = (cell >> 16) & 0x;
 	gc->gc_bitblt(gc->gc_blitcookie, cx, cy, x, y,
 	gc->gc_cellwidth, gc->gc_cellheight, gc->gc_rop);
 	return GC_OK;
Index: src/sys/dev/wscons/wsdisplay_glyphcachevar.h
diff -u src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.1 src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.2
--- src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.1	Thu Feb 16 17:29:21 2012
+++ src/sys/dev/wscons/wsdisplay_glyphcachevar.h	Thu Apr 19 08:46:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_glyphcachevar.h,v 1.1 2012/02/16 17:29:21 macallan Exp $	*/
+/*	$NetBSD: wsdisplay_glyphcachevar.h,v 1.2 2012/04/19 08:46:17 macallan Exp $	*/
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -34,7 +34,7 @@ typedef struct _glyphcache {
 	/* mapping char codes to cache cells */
 	volatile unsigned int gc_usedcells;
 	int gc_numcells;
-	int gc_map[256];
+	uint32_t gc_map[256];
 	/* geometry */
 	int gc_cellwidth;
 	int gc_cellheight;