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

2011-08-05 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Aug  6 05:48:01 UTC 2011

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

Log Message:
nuke pq3cfi_addr() and just use ga_addr; obio already sorts out getting
address from chip select reg when cs locator is used.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/dev/pq3cfi.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/pq3cfi.c
diff -u src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.3 src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.4
--- src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.3	Tue Jul 19 20:52:10 2011
+++ src/sys/arch/powerpc/booke/dev/pq3cfi.c	Sat Aug  6 05:48:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3cfi.c,v 1.3 2011/07/19 20:52:10 cliff Exp $	*/
+/*	$NetBSD: pq3cfi.c,v 1.4 2011/08/06 05:48:01 cliff Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pq3cfi.c,v 1.3 2011/07/19 20:52:10 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: pq3cfi.c,v 1.4 2011/08/06 05:48:01 cliff Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -68,29 +68,6 @@
 CFATTACH_DECL_NEW(pq3cfi, sizeof(struct pq3cfi_softc), pq3cfi_match,
 pq3cfi_attach, pq3cfi_detach, NULL);
 
-/*
- * pq3cfi_addr - return bus address for the CFI NOR flash
- *
- * if the chip select not specified, use address from attach args
- * otherwise use address from the chip select.
- */
-static inline bus_addr_t
-pq3cfi_addr(struct generic_attach_args *ga)
-{
-	bus_addr_t addr_aa = ga-ga_addr;
-
-	if (ga-ga_cs != OBIOCF_CS_DEFAULT) {
-#ifdef NOTYET
-		bus_addr_t addr_cs = get_addr_from_cs(ga-ga_cs);
-		if (addr_aa != addr_cs)
-			aprint_warn(%s: configured addr %#x, CS%d addr %#x\n,
-__func__, addr_aa, ga-ga_cs, addr_cs);
-		return addr_cs;
-#endif
-	}
-	return addr_aa;
-}
-
 static int
 pq3cfi_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -102,7 +79,7 @@
 
 	KASSERT(ga-ga_bst != NULL);
 
-	addr = pq3cfi_addr(ga);
+	addr = ga-ga_addr;
 	if (addr == OBIOCF_ADDR_DEFAULT) {
 		aprint_error(%s: no base address\n, __func__);
 		return 0;
@@ -142,7 +119,7 @@
 
 	sc-sc_dev = self;
 	sc-sc_cfi.cfi_bst = ga-ga_bst;
-	sc-sc_addr = pq3cfi_addr(ga);
+	sc-sc_addr = ga-ga_addr;
 
 	/* map enough to identify, remap later when size is known */
 	error = bus_space_map(sc-sc_cfi.cfi_bst, sc-sc_addr, tmpsize,



CVS commit: src/sys/arch/evbmips/conf

2011-08-02 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 20:42:42 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: CPMBR1400

Log Message:
remove unused option RTNORFLASH


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbmips/conf/CPMBR1400

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/evbmips/conf/CPMBR1400
diff -u src/sys/arch/evbmips/conf/CPMBR1400:1.4 src/sys/arch/evbmips/conf/CPMBR1400:1.5
--- src/sys/arch/evbmips/conf/CPMBR1400:1.4	Tue Aug  2 05:08:31 2011
+++ src/sys/arch/evbmips/conf/CPMBR1400	Tue Aug  2 20:42:42 2011
@@ -3,7 +3,6 @@
 options 	SYMTAB_SPACE=45		# size for embedded symbol table
 
 options 	RT3883
-options 	RTNORFLASH
 options 	RTMEMSIZE=128
 #options 	SLICKROCK
 options 	RALINK_ETH_NUM_SW_PARTITIONS=5



CVS commit: src/sys/dev/nor

2011-08-02 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 20:44:10 UTC 2011

Modified Files:
src/sys/dev/nor: nor.c nor.h

Log Message:
add JEDEC Mfgr ID for Macronix


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/nor/nor.c src/sys/dev/nor/nor.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/nor/nor.c
diff -u src/sys/dev/nor/nor.c:1.3 src/sys/dev/nor/nor.c:1.4
--- src/sys/dev/nor/nor.c:1.3	Wed Jul 20 03:42:55 2011
+++ src/sys/dev/nor/nor.c	Tue Aug  2 20:44:09 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nor.c,v 1.3 2011/07/20 03:42:55 cliff Exp $	*/
+/*	$NetBSD: nor.c,v 1.4 2011/08/02 20:44:09 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2011 Department of Software Engineering,
@@ -34,7 +34,7 @@
 /* Common driver for NOR chips implementing the ONFI CFI specification */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nor.c,v 1.3 2011/07/20 03:42:55 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: nor.c,v 1.4 2011/08/02 20:44:09 cliff Exp $);
 
 #include locators.h
 #include opt_nor.h
@@ -107,6 +107,7 @@
 	{ NOR_MFR_NATIONAL,	National },
 	{ NOR_MFR_TOSHIBA,	Toshiba },
 	{ NOR_MFR_HYNIX,	Hynix },
+	{ NOR_MFGR_MACRONIX,	Macronix },
 	{ NOR_MFR_SAMSUNG,	Samsung },
 	{ NOR_MFR_UNKNOWN,	Unknown }
 };
Index: src/sys/dev/nor/nor.h
diff -u src/sys/dev/nor/nor.h:1.3 src/sys/dev/nor/nor.h:1.4
--- src/sys/dev/nor/nor.h:1.3	Sun Jul 17 00:52:42 2011
+++ src/sys/dev/nor/nor.h	Tue Aug  2 20:44:09 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nor.h,v 1.3 2011/07/17 00:52:42 dyoung Exp $	*/
+/*	$NetBSD: nor.h,v 1.4 2011/08/02 20:44:09 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2011 Department of Software Engineering,
@@ -344,16 +344,17 @@
 
 /* Manufacturer IDs defined by JEDEC */
 enum {
-	NOR_MFR_UNKNOWN	= 0x00,
-	NOR_MFR_AMD	= 0x01,
-	NOR_MFR_FUJITSU	= 0x04,
-	NOR_MFR_RENESAS	= 0x07,
-	NOR_MFR_STMICRO	= 0x20,
-	NOR_MFR_MICRON	= 0x2c,
-	NOR_MFR_NATIONAL= 0x8f,
-	NOR_MFR_TOSHIBA	= 0x98,
-	NOR_MFR_HYNIX	= 0xad,
-	NOR_MFR_SAMSUNG	= 0xec
+	NOR_MFR_UNKNOWN		= 0x00,
+	NOR_MFR_AMD		= 0x01,
+	NOR_MFR_FUJITSU		= 0x04,
+	NOR_MFR_RENESAS		= 0x07,
+	NOR_MFR_STMICRO		= 0x20,
+	NOR_MFR_MICRON		= 0x2c,
+	NOR_MFR_NATIONAL	= 0x8f,
+	NOR_MFR_TOSHIBA		= 0x98,
+	NOR_MFR_HYNIX		= 0xad,
+	NOR_MFGR_MACRONIX	= 0xc2,
+	NOR_MFR_SAMSUNG		= 0xec
 };
 
 struct nor_manufacturer {



CVS commit: src/sys/dev/nor

2011-08-01 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 03:37:25 UTC 2011

Modified Files:
src/sys/dev/nor: cfi.c

Log Message:
when unpacking CFI QRY data, byte order within a word is host order,
but order across words appears to be invariant across -el and -eb systems.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/nor/cfi.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/nor/cfi.c
diff -u src/sys/dev/nor/cfi.c:1.5 src/sys/dev/nor/cfi.c:1.6
--- src/sys/dev/nor/cfi.c:1.5	Sat Jul 23 07:17:34 2011
+++ src/sys/dev/nor/cfi.c	Tue Aug  2 03:37:25 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfi.c,v 1.5 2011/07/23 07:17:34 cliff Exp $	*/
+/*	$NetBSD: cfi.c,v 1.6 2011/08/02 03:37:25 cliff Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_cfi.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cfi.c,v 1.5 2011/07/23 07:17:34 cliff Exp $); 
+__KERNEL_RCSID(0, $NetBSD: cfi.c,v 1.6 2011/08/02 03:37:25 cliff Exp $); 
 
 #include sys/param.h
 #include sys/systm.h
@@ -222,11 +222,11 @@
 /* only data[7..0] are used regardless of chip width */
 #define cfi_unpack_1(n)			((n)  0xff)
 
-/* construct (arbitrarily big endian) uint16_t */
+/* construct uint16_t */
 #define cfi_unpack_2(b0, b1)		\
 	((cfi_unpack_1(b1)  8) | cfi_unpack_1(b0))
 
-/* construct (arbitrarily) big endian uint32_t */
+/* construct uint32_t */
 #define cfi_unpack_4(b0, b1, b2, b3)	\
 	((cfi_unpack_1(b3)  24) |	\
 	 (cfi_unpack_1(b2)  16) |	\
@@ -238,12 +238,10 @@
 	(qryp)-qry[0] = cfi_unpack_1(data[0x10]);			\
 	(qryp)-qry[1] = cfi_unpack_1(data[0x11]);			\
 	(qryp)-qry[2] = cfi_unpack_1(data[0x12]);			\
-	(qryp)-id_pri = be16toh(cfi_unpack_2(data[0x13], data[0x14]));	\
-	(qryp)-addr_pri =		\
-		be16toh(cfi_unpack_2(data[0x15], data[0x16]));		\
-	(qryp)-id_alt = be16toh(cfi_unpack_2(data[0x17], data[0x18]));	\
-	(qryp)-addr_alt =		\
-		be16toh(cfi_unpack_2(data[0x19], data[0x1a]));		\
+	(qryp)-id_pri = cfi_unpack_2(data[0x13], data[0x14]);		\
+	(qryp)-addr_pri = cfi_unpack_2(data[0x15], data[0x16]);	\
+	(qryp)-id_alt = cfi_unpack_2(data[0x17], data[0x18]);		\
+	(qryp)-addr_alt = cfi_unpack_2(data[0x19], data[0x1a]);	\
 	(qryp)-vcc_min = cfi_unpack_1(data[0x1b]);			\
 	(qryp)-vcc_max = cfi_unpack_1(data[0x1c]);			\
 	(qryp)-vpp_min = cfi_unpack_1(data[0x1d]);			\
@@ -258,18 +256,18 @@
 	(qryp)-erase_chip_time_max = cfi_unpack_1(data[0x26]);		\
 	(qryp)-device_size = cfi_unpack_1(data[0x27]);			\
 	(qryp)-interface_code_desc =	\
-		be16toh(cfi_unpack_2(data[0x28], data[0x29]));		\
+		cfi_unpack_2(data[0x28], data[0x29]);			\
 	(qryp)-write_nbyte_size_max = 	\
-		be16toh(cfi_unpack_2(data[0x2a], data[0x2b]));		\
+		cfi_unpack_2(data[0x2a], data[0x2b]);			\
 	(qryp)-erase_blk_regions = cfi_unpack_1(data[0x2c]);		\
 	u_int _i = 0x2d;		\
 	const u_int _n = (qryp)-erase_blk_regions;			\
 	KASSERT(_n = 4);		\
 	for (u_int _r = 0; _r  _n; _r++, _i+=4) {			\
 		(qryp)-erase_blk_info[_r].y =\
-			be32toh(cfi_unpack_2(data[_i+0], data[_i+1]));	\
+			cfi_unpack_2(data[_i+0], data[_i+1]);		\
 		(qryp)-erase_blk_info[_r].z =\
-			be32toh(cfi_unpack_2(data[_i+2], data[_i+3]));	\
+			cfi_unpack_2(data[_i+2], data[_i+3]);		\
 	}\
 } while (0)
 



CVS commit: src/sys/arch/mips/ralink

2011-08-01 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 03:38:48 UTC 2011

Added Files:
src/sys/arch/mips/ralink: ralink_cfi.c

Log Message:
CFI NOR support for mips/ralink


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/mips/ralink/ralink_cfi.c

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

Added files:

Index: src/sys/arch/mips/ralink/ralink_cfi.c
diff -u /dev/null src/sys/arch/mips/ralink/ralink_cfi.c:1.1
--- /dev/null	Tue Aug  2 03:38:48 2011
+++ src/sys/arch/mips/ralink/ralink_cfi.c	Tue Aug  2 03:38:48 2011
@@ -0,0 +1,191 @@
+/*	$NetBSD: ralink_cfi.c,v 1.1 2011/08/02 03:38:48 cliff Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Cliff Neighbors.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * NOR CFI driver support for ralink
+ */
+
+#include opt_flash.h
+#include locators.h
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: ralink_cfi.c,v 1.1 2011/08/02 03:38:48 cliff Exp $);
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/cdefs.h
+#include sys/device.h
+#include sys/endian.h
+
+#include sys/bus.h
+
+#include mips/ralink/ralink_var.h
+#include mips/ralink/ralink_reg.h
+
+#include dev/nor/nor.h
+#include dev/nor/cfi.h
+
+
+static int  ra_cfi_match(device_t, cfdata_t, void *);
+static void ra_cfi_attach(device_t, device_t, void *);
+static int  ra_cfi_detach(device_t, int);
+
+struct ra_cfi_softc {
+	device_t		sc_dev;
+	device_t		sc_nordev;
+	struct cfi			sc_cfi;
+	bus_addr_t		sc_addr;
+	bus_size_t		sc_size;
+	struct nor_interface	sc_nor_if;
+};
+
+CFATTACH_DECL_NEW(ralink_cfi, sizeof(struct ra_cfi_softc), ra_cfi_match,
+ra_cfi_attach, ra_cfi_detach, NULL);
+
+/*
+ * ra_cfi_addr - return bus address for the CFI NOR flash
+ */
+static inline bus_addr_t
+ra_cfi_addr(struct mainbus_attach_args * const ma)
+{
+	return RA_FLASH_BASE;	/* XXX configure TBD */
+}
+
+static int
+ra_cfi_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct mainbus_attach_args * const ma = aux;
+	bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+	bus_addr_t addr;
+	struct cfi cfi;
+	int rv;
+
+	KASSERT(ma-ma_memt != NULL);
+
+	addr = ra_cfi_addr(ma);
+#ifdef NOTYET
+	if (addr == MAINBUSCF_ADDR_DEFAULT) {
+		aprint_error(%s: no base address\n, __func__);
+		return 0;
+	}
+#endif
+
+	cfi.cfi_bst = ma-ma_memt;
+	int error = bus_space_map(cfi.cfi_bst, addr, tmpsize, 0, cfi.cfi_bsh);
+	if (error != 0) {
+		aprint_error(%s: cannot map %# PRIxBUSSIZE  at offset %#
+		PRIxBUSADDR , error %d\n,	__func__, tmpsize, addr, error);
+		return false;
+	}
+
+	if (! cfi_probe(cfi)) {
+		aprint_debug(%s: probe addr %# PRIxBUSADDR
+		, CFI not found\n, __func__, addr);
+		rv = 0;
+	} else {
+		rv = 1;
+	}
+
+	bus_space_unmap(cfi.cfi_bst, cfi.cfi_bsh, tmpsize);
+
+	return rv;
+}
+
+static void
+ra_cfi_attach(device_t parent, device_t self, void *aux)
+{
+	struct ra_cfi_softc *sc = device_private(self);
+	struct mainbus_attach_args * const ma = aux;
+	struct cfi_query_data * const qryp = sc-sc_cfi.cfi_qry_data;
+	const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+	bool found;
+	int error;
+
+	aprint_normal(\n);
+
+	sc-sc_dev = self;
+	sc-sc_cfi.cfi_bst = ma-ma_memt;
+	sc-sc_addr = ra_cfi_addr(ma);
+
+	/* map enough to identify, remap later when size is known */
+	error = bus_space_map(sc-sc_cfi.cfi_bst, sc-sc_addr, tmpsize,
+		0, sc-sc_cfi.cfi_bsh);
+	if (error != 0) {
+		aprint_error_dev(self, could not map error %d\n, error);
+		return;
+	}
+
+	found = cfi_identify(sc-sc_cfi);
+
+	bus_space_unmap(sc-sc_cfi.cfi_bst

CVS commit: src/sys/arch/mips/conf

2011-08-01 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 03:40:01 UTC 2011

Modified Files:
src/sys/arch/mips/conf: files.ralink

Log Message:
CFI NOR support for mips/ralink


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/conf/files.ralink

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/mips/conf/files.ralink
diff -u src/sys/arch/mips/conf/files.ralink:1.2 src/sys/arch/mips/conf/files.ralink:1.3
--- src/sys/arch/mips/conf/files.ralink:1.2	Thu Jul 28 15:38:48 2011
+++ src/sys/arch/mips/conf/files.ralink	Tue Aug  2 03:40:00 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ralink,v 1.2 2011/07/28 15:38:48 matt Exp $
+#	$NetBSD: files.ralink,v 1.3 2011/08/02 03:40:00 cliff Exp $
 
 file	arch/mips/ralink/ralink_intr.c
 file	arch/mips/ralink/ralink_bus.c
@@ -37,3 +37,9 @@
 device	reth: ether, ifnet, arp, mii
 attach	reth at mainbus
 file	arch/mips/ralink/ralink_eth.c		reth
+
+# Ralink CFI NOR
+device  cfi: norbus
+attach	cfi at mainbus with ralink_cfi
+file	arch/mips/ralink/ralink_cfi.c		ralink_cfi
+



CVS commit: src/sys/arch/evbmips/conf

2011-08-01 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 03:41:16 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: CPMBR1400

Log Message:
configure CFI NOR flash


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/conf/CPMBR1400

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/evbmips/conf/CPMBR1400
diff -u src/sys/arch/evbmips/conf/CPMBR1400:1.2 src/sys/arch/evbmips/conf/CPMBR1400:1.3
--- src/sys/arch/evbmips/conf/CPMBR1400:1.2	Thu Jul 28 15:50:13 2011
+++ src/sys/arch/evbmips/conf/CPMBR1400	Tue Aug  2 03:41:16 2011
@@ -198,6 +198,12 @@
 ri2c0		at mainbus?
 iic*		at ri2c?
 
+# NOR Flash
+#options 	NOR_VERBOSE
+cfi0 		at mainbus0
+nor*		at cfi?
+flash*		at nor? offset 0 size 0x200
+
 # USB Hubs
 uhub*		at usb?
 uhub*		at uhub? port ?



CVS commit: src/sys/arch/evbmips/conf

2011-08-01 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Aug  2 05:08:31 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: CPMBR1400

Log Message:
configure NOR flash partitions


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/conf/CPMBR1400

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/evbmips/conf/CPMBR1400
diff -u src/sys/arch/evbmips/conf/CPMBR1400:1.3 src/sys/arch/evbmips/conf/CPMBR1400:1.4
--- src/sys/arch/evbmips/conf/CPMBR1400:1.3	Tue Aug  2 03:41:16 2011
+++ src/sys/arch/evbmips/conf/CPMBR1400	Tue Aug  2 05:08:31 2011
@@ -201,8 +201,14 @@
 # NOR Flash
 #options 	NOR_VERBOSE
 cfi0 		at mainbus0
-nor*		at cfi?
-flash*		at nor? offset 0 size 0x200
+nor0		at cfi0
+flash0		at nor0 offset 0x size 0x0004
+flash1		at nor0 offset 0x0004 size 0x0002
+flash2		at nor0 offset 0x0006 size 0x0002
+flash3		at nor0 offset 0x0008 size 0x0012	# kernel
+flash4		at nor0 offset 0x001a size 0x006e	# filesystem
+flash5		at nor0 offset 0x0088 size 0x0176	# upgrade
+flash6		at nor0 offset 0x01fe size 0x0002
 
 # USB Hubs
 uhub*		at usb?



CVS commit: src/sys/dev/nor

2011-07-23 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Jul 23 06:24:54 UTC 2011

Modified Files:
src/sys/dev/nor: files.nor

Log Message:
- add option flags CFI_DEBUG_QRY CFI_DEBUG_JEDEC in opt_cfi.h


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/nor/files.nor

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/nor/files.nor
diff -u src/sys/dev/nor/files.nor:1.2 src/sys/dev/nor/files.nor:1.3
--- src/sys/dev/nor/files.nor:1.2	Fri Jul 15 19:19:57 2011
+++ src/sys/dev/nor/files.nor	Sat Jul 23 06:24:54 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.nor,v 1.2 2011/07/15 19:19:57 cliff Exp $
+# $NetBSD: files.nor,v 1.3 2011/07/23 06:24:54 cliff Exp $
 
 define	norbus	{ }
 
@@ -9,5 +9,5 @@
 file	dev/nor/cfi.c		nor
 file	dev/nor/cfi_0002.c	nor
 
-defflag opt_nor.h		NOR_DEBUG
-defflag opt_nor.h		NOR_VERBOSE
+defflag opt_nor.h		NOR_DEBUG NOR_VERBOSE
+defflag opt_cfi.h		CFI_DEBUG_QRY CFI_DEBUG_JEDEC



CVS commit: src/sys/dev/nor

2011-07-23 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Jul 23 07:17:34 UTC 2011

Modified Files:
src/sys/dev/nor: cfi.c

Log Message:
- add little endian variants of cfi_opmodes tables (untested)
- try to reduce glop factor in cfi_jedec_fill()


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/nor/cfi.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/nor/cfi.c
diff -u src/sys/dev/nor/cfi.c:1.4 src/sys/dev/nor/cfi.c:1.5
--- src/sys/dev/nor/cfi.c:1.4	Sat Jul 23 06:27:40 2011
+++ src/sys/dev/nor/cfi.c	Sat Jul 23 07:17:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfi.c,v 1.4 2011/07/23 06:27:40 cliff Exp $	*/
+/*	$NetBSD: cfi.c,v 1.5 2011/07/23 07:17:34 cliff Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include opt_cfi.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cfi.c,v 1.4 2011/07/23 06:27:40 cliff Exp $); 
+__KERNEL_RCSID(0, $NetBSD: cfi.c,v 1.5 2011/07/23 07:17:34 cliff Exp $); 
 
 #include sys/param.h
 #include sys/systm.h
@@ -83,16 +83,15 @@
  * in Intel Common Flash Interface (CFI) and Command Sets
  * Application Note 646, April 2000
  *
- * The byte ordering of the signature string here varies from that table
- * because of discrepancy in observed behavior, for the case:
- *	- x16 device operating in 16-bit mode
- * Similar discrepancy is expected (but not verified) for the case:
- *	- x32 device operating in 32-bit mode
- * so the ordering is changed here for that case also.
+ * Assume the byte order of the flash (and of the signature there)
+ * is the same as host byte order. The Intel App. Note describes the
+ * little endian variant.
  *
  * XXX down-sized, interleaved  multi-chip opmodes not yet supported
  */
 
+#if BYTE_ORDER == BIG_ENDIAN
+/* BIG ENDIAN host */
 /* 1-byte access */
 static const struct cfi_opmodes cfi_opmodes_1[] = {
 	{ 0, 0, 0, 0x10,  3, QRY, x8 device operating in 8-bit mode },
@@ -109,6 +108,25 @@
 	{ 2, 2, 0, 0x40, 12, \0\0\0Q\0\0\0R\0\0\0Y,
 		x32 device operating in 32-bit mode },
 };
+#else
+/* LITTLE ENDIAN host */
+/* 1-byte access */
+static const struct cfi_opmodes cfi_opmodes_1[] = {
+	{ 0, 0, 0, 0x10,  3, QRY, x8 device operating in 8-bit mode },
+};
+
+/* 2-byte access */
+static const struct cfi_opmodes cfi_opmodes_2[] = {
+	{ 1, 1, 0, 0x20,  6, Q\0R\0Y\0,
+		x16 device operating in 16-bit mode },
+};
+
+/* 4-byte access */
+static const struct cfi_opmodes cfi_opmodes_4[] = {
+	{ 2, 2, 0, 0x40, 12, Q\0\0\0R\0\0\0Y\0\0\0,
+		x32 device operating in 32-bit mode },
+};
+#endif
 
 
 #define LOG2_64K	16
@@ -863,26 +881,30 @@
 static void
 cfi_jedec_fill(struct cfi *cfi, const struct cfi_jedec_tab *jt)
 {
+
 	cfi-cfi_name = jt-jt_name;
 	cfi-cfi_opmode = jt-jt_opmode;
-	memset(cfi-cfi_qry_data, 0, sizeof(struct cfi_query_data));
-	cfi-cfi_qry_data.id_pri = jt-jt_id_pri;
-	cfi-cfi_qry_data.id_alt = jt-jt_id_alt;
-	cfi-cfi_qry_data.interface_code_desc = jt-jt_interface_code_desc;
-	cfi-cfi_qry_data.write_word_time_typ = jt-jt_write_word_time_typ;
-	cfi-cfi_qry_data.write_nbyte_time_typ = jt-jt_write_nbyte_time_typ;
-	cfi-cfi_qry_data.erase_blk_time_typ = jt-jt_erase_blk_time_typ;
-	cfi-cfi_qry_data.erase_chip_time_typ = jt-jt_erase_chip_time_typ;
-	cfi-cfi_qry_data.write_word_time_max = jt-jt_write_word_time_max;
-	cfi-cfi_qry_data.write_nbyte_time_max = jt-jt_write_nbyte_time_max;
-	cfi-cfi_qry_data.erase_blk_time_max = jt-jt_erase_blk_time_max;
-	cfi-cfi_qry_data.erase_chip_time_max = jt-jt_erase_chip_time_max;
-	cfi-cfi_qry_data.device_size = jt-jt_device_size;
-	cfi-cfi_qry_data.interface_code_desc = jt-jt_interface_code_desc;
-	cfi-cfi_qry_data.write_nbyte_size_max = jt-jt_write_nbyte_size_max;
-	cfi-cfi_qry_data.erase_blk_regions = jt-jt_erase_blk_regions;
+
+	struct cfi_query_data *qryp = cfi-cfi_qry_data;
+	memset(qryp, 0, sizeof(*qryp));
+	qryp-id_pri = jt-jt_id_pri;
+	qryp-id_alt = jt-jt_id_alt;
+	qryp-interface_code_desc = jt-jt_interface_code_desc;
+	qryp-write_word_time_typ = jt-jt_write_word_time_typ;
+	qryp-write_nbyte_time_typ = jt-jt_write_nbyte_time_typ;
+	qryp-erase_blk_time_typ = jt-jt_erase_blk_time_typ;
+	qryp-erase_chip_time_typ = jt-jt_erase_chip_time_typ;
+	qryp-write_word_time_max = jt-jt_write_word_time_max;
+	qryp-write_nbyte_time_max = jt-jt_write_nbyte_time_max;
+	qryp-erase_blk_time_max = jt-jt_erase_blk_time_max;
+	qryp-erase_chip_time_max = jt-jt_erase_chip_time_max;
+	qryp-device_size = jt-jt_device_size;
+	qryp-interface_code_desc = jt-jt_interface_code_desc;
+	qryp-write_nbyte_size_max = jt-jt_write_nbyte_size_max;
+	qryp-erase_blk_regions = jt-jt_erase_blk_regions;
 	for (u_int i=0; i  4; i++)
-		cfi-cfi_qry_data.erase_blk_info[i] = jt-jt_erase_blk_info[i];
+		qryp-erase_blk_info[i] = jt-jt_erase_blk_info[i];
+
 }
 
 void



CVS commit: src/sys

2011-07-19 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Jul 19 20:52:10 UTC 2011

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3cfi.c
src/sys/dev/nor: cfi.c cfi_0002.c cfi_0002.h

Log Message:
add TNF copyright


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/powerpc/booke/dev/pq3cfi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/nor/cfi.c src/sys/dev/nor/cfi_0002.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/nor/cfi_0002.h

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

Modified files:

Index: src/sys/arch/powerpc/booke/dev/pq3cfi.c
diff -u src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.2 src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.3
--- src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.2	Sun Jul 17 23:08:56 2011
+++ src/sys/arch/powerpc/booke/dev/pq3cfi.c	Tue Jul 19 20:52:10 2011
@@ -1,4 +1,32 @@
-/*	$NetBSD: pq3cfi.c,v 1.2 2011/07/17 23:08:56 dyoung Exp $	*/
+/*	$NetBSD: pq3cfi.c,v 1.3 2011/07/19 20:52:10 cliff Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Cliff Neighbors.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 /*
  * NOR CFI driver support for booke
@@ -8,7 +36,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pq3cfi.c,v 1.2 2011/07/17 23:08:56 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: pq3cfi.c,v 1.3 2011/07/19 20:52:10 cliff Exp $);
 
 #include sys/param.h
 #include sys/systm.h

Index: src/sys/dev/nor/cfi.c
diff -u src/sys/dev/nor/cfi.c:1.2 src/sys/dev/nor/cfi.c:1.3
--- src/sys/dev/nor/cfi.c:1.2	Sun Jul 17 00:52:42 2011
+++ src/sys/dev/nor/cfi.c	Tue Jul 19 20:52:10 2011
@@ -1,10 +1,38 @@
-/*	$NetBSD: cfi.c,v 1.2 2011/07/17 00:52:42 dyoung Exp $	*/
+/*	$NetBSD: cfi.c,v 1.3 2011/07/19 20:52:10 cliff Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Cliff Neighbors.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include opt_nor.h
 #include opt_flash.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cfi.c,v 1.2 2011/07/17 00:52:42 dyoung Exp $); 
+__KERNEL_RCSID(0, $NetBSD: cfi.c,v 1.3 2011/07/19 20:52:10 cliff Exp $); 
 
 #include sys/param.h
 #include sys/systm.h
Index: src/sys/dev/nor

CVS commit: src/sys/dev/nor

2011-07-19 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Jul 20 03:42:55 UTC 2011

Modified Files:
src/sys/dev/nor: nor.c

Log Message:
replace 'nor_manufacturer_t' with 'struct nor_manufacturer'


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/nor/nor.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/nor/nor.c
diff -u src/sys/dev/nor/nor.c:1.2 src/sys/dev/nor/nor.c:1.3
--- src/sys/dev/nor/nor.c:1.2	Fri Jul 15 19:37:41 2011
+++ src/sys/dev/nor/nor.c	Wed Jul 20 03:42:55 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nor.c,v 1.2 2011/07/15 19:37:41 cliff Exp $	*/
+/*	$NetBSD: nor.c,v 1.3 2011/07/20 03:42:55 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2011 Department of Software Engineering,
@@ -34,7 +34,7 @@
 /* Common driver for NOR chips implementing the ONFI CFI specification */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nor.c,v 1.2 2011/07/15 19:37:41 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: nor.c,v 1.3 2011/07/20 03:42:55 cliff Exp $);
 
 #include locators.h
 #include opt_nor.h
@@ -98,7 +98,7 @@
 };
 
 #ifdef NOR_VERBOSE
-const nor_manufacturer_t nor_mfrs[] = {
+const struct nor_manufacturer nor_mfrs[] = {
 	{ NOR_MFR_AMD,		AMD },
 	{ NOR_MFR_FUJITSU,	Fujitsu },
 	{ NOR_MFR_RENESAS,	Renesas },



CVS commit: src/sys/dev/nor

2011-07-15 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Jul 15 19:37:41 UTC 2011

Modified Files:
src/sys/dev/nor: nor.c

Log Message:
More support for CFI NOR.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/nor/nor.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/nor/nor.c
diff -u src/sys/dev/nor/nor.c:1.1 src/sys/dev/nor/nor.c:1.2
--- src/sys/dev/nor/nor.c:1.1	Wed Jun 22 21:59:15 2011
+++ src/sys/dev/nor/nor.c	Fri Jul 15 19:37:41 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nor.c,v 1.1 2011/06/22 21:59:15 ahoka Exp $	*/
+/*	$NetBSD: nor.c,v 1.2 2011/07/15 19:37:41 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2011 Department of Software Engineering,
@@ -34,9 +34,10 @@
 /* Common driver for NOR chips implementing the ONFI CFI specification */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nor.c,v 1.1 2011/06/22 21:59:15 ahoka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nor.c,v 1.2 2011/07/15 19:37:41 cliff Exp $);
 
 #include locators.h
+#include opt_nor.h
 
 #include sys/param.h
 #include sys/types.h
@@ -46,19 +47,34 @@
 #include sys/atomic.h
 
 #include dev/flash/flash.h
+#include dev/flash/flash_io.h
 #include dev/nor/nor.h
-#include dev/nor/cfi.h
 
-//#include opt_nor.h
 
-int nor_match(device_t, cfdata_t, void *);
-void nor_attach(device_t, device_t, void *);
-int nor_detach(device_t, int);
-bool nor_shutdown(device_t, int);
-
-int nor_print(void *, const char *);
+static int nor_match(device_t, cfdata_t, void *);
+static void nor_attach(device_t, device_t, void *);
+static int nor_detach(device_t, int);
+static bool nor_shutdown(device_t, int);
+static int nor_print(void *, const char *);
 static int nor_search(device_t, cfdata_t, const int *, void *);
 
+/* flash interface implementation */
+static int nor_flash_isbad(device_t, flash_off_t, bool *);
+static int nor_flash_markbad(device_t, flash_off_t);
+static int nor_flash_write(device_t, flash_off_t, size_t, size_t *,
+	const u_char *);
+static int nor_flash_read(device_t, flash_off_t, size_t, size_t *, uint8_t *);
+static int nor_flash_erase_all(device_t);
+static int nor_flash_erase(device_t, struct flash_erase_instruction *);
+static int nor_flash_submit(device_t, buf_t *);
+
+/* default functions for driver development */
+static void nor_default_select(device_t, bool);
+static int  nor_default_read_page(device_t, flash_off_t, uint8_t *);
+static int  nor_default_program_page(device_t, flash_off_t, const uint8_t *);
+
+static int nor_scan_media(device_t, struct nor_chip *);
+
 CFATTACH_DECL_NEW(nor, sizeof(struct nor_softc),
 nor_match, nor_attach, nor_detach, NULL);
 
@@ -69,8 +85,20 @@
 int nor_cachesync_timeout = 1;
 int nor_cachesync_nodenum;
 
+struct flash_interface nor_flash_if = {
+	.type = FLASH_TYPE_NOR,
+
+	.read = nor_flash_read,
+	.write = nor_flash_write,
+	.erase = nor_flash_erase,
+	.block_isbad = nor_flash_isbad,
+	.block_markbad = nor_flash_markbad,
+
+	.submit = nor_flash_submit
+};
+
 #ifdef NOR_VERBOSE
-const struct nor_manufacturer nor_mfrs[] = {
+const nor_manufacturer_t nor_mfrs[] = {
 	{ NOR_MFR_AMD,		AMD },
 	{ NOR_MFR_FUJITSU,	Fujitsu },
 	{ NOR_MFR_RENESAS,	Renesas },
@@ -100,33 +128,44 @@
 #endif
 
 /* ARGSUSED */
-int
+static int
 nor_match(device_t parent, cfdata_t match, void *aux)
 {
 	/* pseudo device, always attaches */
 	return 1;
 }
 
-void
+static void
 nor_attach(device_t parent, device_t self, void *aux)
 {
-	struct nor_softc *sc = device_private(self);
-	struct nor_attach_args *naa = aux;
-	struct nor_chip *chip = sc-sc_chip;
+	struct nor_softc * const sc = device_private(self);
+	struct nor_attach_args * const naa = aux;
+	struct nor_chip * const chip = sc-sc_chip;
 
 	sc-sc_dev = self;
-	sc-controller_dev = parent;
-	sc-nor_if = naa-naa_nor_if;
+	sc-sc_controller_dev = parent;
+	sc-sc_nor_if = naa-naa_nor_if;
 
 	aprint_naive(\n);
+	aprint_normal(\n);
+
+	if (nor_scan_media(self, chip))
+		return;
+
+	sc-sc_flash_if = nor_flash_if;
+	sc-sc_flash_if.erasesize = chip-nc_block_size;
+	sc-sc_flash_if.page_size = chip-nc_page_size;
+	sc-sc_flash_if.writesize = chip-nc_page_size;
 
 	/* allocate cache */
+#ifdef NOTYET
 	chip-nc_oob_cache = kmem_alloc(chip-nc_spare_size, KM_SLEEP);
+#endif
 	chip-nc_page_cache = kmem_alloc(chip-nc_page_size, KM_SLEEP);
 
 	mutex_init(sc-sc_device_lock, MUTEX_DEFAULT, IPL_NONE);
 
-	if (nor_sync_thread_start(self)) {
+	if (flash_sync_thread_init(sc-sc_flash_io, self, sc-sc_flash_if)) {
 		goto error;
 	}
 
@@ -145,8 +184,11 @@
 	config_search_ia(nor_search, self, NULL, NULL);
 
 	return;
+
 error:
+#ifdef NOTET
 	kmem_free(chip-nc_oob_cache, chip-nc_spare_size);
+#endif
 	kmem_free(chip-nc_page_cache, chip-nc_page_size);
 	mutex_destroy(sc-sc_device_lock);
 }
@@ -154,44 +196,25 @@
 static int
 nor_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
 {
-	struct nor_softc *sc = device_private(parent);
-	struct nor_chip *chip = 

CVS commit: src/sys/arch/evbmips/conf

2011-07-15 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Jul 15 19:41:28 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: XLSATX

Log Message:
bump SYMTAB_SPACE


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbmips/conf/XLSATX

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/evbmips/conf/XLSATX
diff -u src/sys/arch/evbmips/conf/XLSATX:1.6 src/sys/arch/evbmips/conf/XLSATX:1.7
--- src/sys/arch/evbmips/conf/XLSATX:1.6	Fri Jul  1 22:10:31 2011
+++ src/sys/arch/evbmips/conf/XLSATX	Fri Jul 15 19:41:28 2011
@@ -1,8 +1,8 @@
-#	$NetBSD: XLSATX,v 1.6 2011/07/01 22:10:31 dyoung Exp $
+#	$NetBSD: XLSATX,v 1.7 2011/07/15 19:41:28 cliff Exp $
 
 include 	arch/evbmips/conf/std.rmixl
 
-#ident 		XLSATX-$Revision: 1.6 $
+#ident 		XLSATX-$Revision: 1.7 $
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -41,7 +41,7 @@
 options 	DDB		# kernel dynamic debugger
 options 	DDB_HISTORY_SIZE=100 # enable history editing in DDB
 makeoptions 	DEBUG=-g	# compile full symbol table
-options 	SYMTAB_SPACE=503000	# size for embedded symbol table
+options 	SYMTAB_SPACE=51	# size for embedded symbol table
 #options 	DDB_COMMANDONENTER=trace;show registers
 options 	DB_MAX_LINE=-1
 



CVS commit: src/sys/arch/powerpc/ibm4xx

2011-06-15 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Jun 15 06:28:39 UTC 2011

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap_subr.S

Log Message:
- FRAME_SAVE_CALLEE() starts at r14 (not r13, which is curlwp) (from matt@)
- INTR_SAVE() must also save r13 (from matt@).
- fitint must pass clock frame, not trap frame
- fix comment in pitint and fitint to indicate passing clock frame, not intr 
frame


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/ibm4xx/trap_subr.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/powerpc/ibm4xx/trap_subr.S
diff -u src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.15 src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.16
--- src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.15	Sun Jun  5 16:52:25 2011
+++ src/sys/arch/powerpc/ibm4xx/trap_subr.S	Wed Jun 15 06:28:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.15 2011/06/05 16:52:25 matt Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.16 2011/06/15 06:28:39 cliff Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -287,7 +287,7 @@
 	stw	%r31,FRAME_SRR1(%r1)
 
 #define	FRAME_SAVE_CALLEE		\
-	stmw	%r13, FRAME_R13(%r1)
+	stmw	%r14, FRAME_R14(%r1)
 
 #define	FRAME_RESTORE			\
 	lwz	%r6,FRAME_LR(%r1);	\
@@ -439,6 +439,7 @@
 	stw	%r10,FRAME_R10(%r1);	\
 	stw	%r11,FRAME_R11(%r1);	\
 	stw	%r12,FRAME_R12(%r1);	\
+	stw	%r13,FRAME_R13(%r1);	\
 	mfctr	%r31;			\
 	stmw	%r28,FRAME_LR(%r1);	/* save LR, CR, XER, CTR */	\
 	GET_CPUINFO(%r5);		\
@@ -491,7 +492,7 @@
 _C_LABEL(pitint):
 	INTR_PROLOG(CI_TEMPSAVE)
 	INTR_SAVE(CI_TEMPSAVE)
-	addi	%r3,%r1,FRAME_CF	/* intr frame */
+	addi	%r3,%r1,FRAME_CF	/* clock frame */
 	bl	_C_LABEL(decr_intr)
 	b	intr_exit
 
@@ -502,7 +503,7 @@
 _C_LABEL(fitint):
 	INTR_PROLOG(CI_TEMPSAVE)
 	INTR_SAVE(CI_TEMPSAVE)
-	addi	%r3,%r1,FRAME_TF	/* intr frame */
+	addi	%r3,%r1,FRAME_CF	/* clock frame */
 	bl	_C_LABEL(stat_intr)
 	b	intr_exit
 



CVS commit: src/sys/arch/evbppc/walnut/dev

2011-06-14 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Jun 15 05:21:38 UTC 2011

Modified Files:
src/sys/arch/evbppc/walnut/dev: pbus.c

Log Message:
in pbus_attach() make locs[] and pass to config_found_sm_loc()
to avoid triggering KASSERT in config_stdsubmatch().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbppc/walnut/dev/pbus.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/evbppc/walnut/dev/pbus.c
diff -u src/sys/arch/evbppc/walnut/dev/pbus.c:1.11 src/sys/arch/evbppc/walnut/dev/pbus.c:1.12
--- src/sys/arch/evbppc/walnut/dev/pbus.c:1.11	Mon Jun  6 16:42:18 2011
+++ src/sys/arch/evbppc/walnut/dev/pbus.c	Wed Jun 15 05:21:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pbus.c,v 1.11 2011/06/06 16:42:18 matt Exp $	*/
+/*	$NetBSD: pbus.c,v 1.12 2011/06/15 05:21:38 cliff Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pbus.c,v 1.11 2011/06/06 16:42:18 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pbus.c,v 1.12 2011/06/15 05:21:38 cliff Exp $);
 
 #include locators.h
 #include pckbc.h
@@ -152,7 +152,12 @@
 		pba.pb_bt = pbus_tag;
 		pba.pb_dmat = paa-plb_dmat;
 
-		(void) config_found_sm_loc(self, pbus, NULL, pba, pbus_print,
+		const int locs[PBUSCF_NLOCS] = {
+		[PBUSCF_ADDR] = pba.pb_addr,
+		[PBUSCF_IRQ] = pba.pb_irq
+		};
+
+		(void) config_found_sm_loc(self, pbus, locs, pba, pbus_print,
 		config_stdsubmatch);
 	}
 



CVS commit: src/sys/arch/evbppc/walnut/dev

2011-06-14 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Jun 15 05:29:32 UTC 2011

Modified Files:
src/sys/arch/evbppc/walnut/dev: ds1743.c

Log Message:
- convert to use device_t, cfattach_t, CFATTACH_DECL_NEW etc.
- in dsrtcattach() use struct clock_ymdhms instead of rtc in DEBUG code block,
and move that block down after sc_todr.cookie is initialized so dsrtc_read() 
works.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbppc/walnut/dev/ds1743.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/evbppc/walnut/dev/ds1743.c
diff -u src/sys/arch/evbppc/walnut/dev/ds1743.c:1.7 src/sys/arch/evbppc/walnut/dev/ds1743.c:1.8
--- src/sys/arch/evbppc/walnut/dev/ds1743.c:1.7	Mon Sep 18 22:05:47 2006
+++ src/sys/arch/evbppc/walnut/dev/ds1743.c	Wed Jun 15 05:29:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ds1743.c,v 1.7 2006/09/18 22:05:47 gdamore Exp $	*/
+/*	$NetBSD: ds1743.c,v 1.8 2011/06/15 05:29:32 cliff Exp $	*/
 
 /*
  * Copyright (c) 2001-2002 Wasabi Sysetms, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ds1743.c,v 1.7 2006/09/18 22:05:47 gdamore Exp $);
+__KERNEL_RCSID(0, $NetBSD: ds1743.c,v 1.8 2011/06/15 05:29:32 cliff Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -52,14 +52,14 @@
 #include evbppc/walnut/dev/pbusvar.h
 
 struct dsrtc_softc {
-	struct device	sc_dev;
+	device_t	sc_dev;
 	bus_space_tag_t	sc_iot;
 	bus_space_handle_t sc_ioh;
 	struct todr_chip_handle sc_todr;
 };
 
-static void dsrtcattach(struct device *, struct device *, void *);
-static int dsrtcmatch(struct device *, struct cfdata *, void *);
+static void dsrtcattach(device_t, device_t, void *);
+static int dsrtcmatch(device_t, cfdata_t, void *);
 #if 0	/* Nothing uses these yet */
 static int ds1743_ram_read(struct dsrtc_softc *, int);
 static void ds1743_ram_write(struct dsrtc_softc *, int, int);
@@ -73,7 +73,7 @@
 static void ds1743_unlock(struct dsrtc_softc *, u_char);
 
 /* device and attach structures */
-CFATTACH_DECL(ds1743rtc, sizeof(struct dsrtc_softc),
+CFATTACH_DECL_NEW(ds1743rtc, sizeof(struct dsrtc_softc),
 dsrtcmatch, dsrtcattach, NULL, NULL);
 
 /*
@@ -86,7 +86,7 @@
 #define DS_SCRATCH_ADDR 0x1FF7
 
 static int
-dsrtcmatch(struct device *parent, struct cfdata *cf, void *aux)
+dsrtcmatch(device_t parent, cfdata_t cf, void *aux)
 {
 	struct pbus_attach_args *paa = aux;
 	int retval = !ds1743found;
@@ -131,13 +131,14 @@
  */
 
 static void
-dsrtcattach(struct device *parent, struct device *self, void *aux)
+dsrtcattach(device_t parent, device_t self, void *aux)
 {
-	struct dsrtc_softc *sc = (struct dsrtc_softc *)self;
+	struct dsrtc_softc *sc = device_private(self);
 	struct pbus_attach_args *paa = aux;
 
 	ds1743found = 1;
 	
+	sc-sc_dev = self;
 	sc-sc_iot = paa-pb_bt;
 	if (bus_space_map(sc-sc_iot, paa-pb_addr, DS_SIZE, 0, sc-sc_ioh)) {
 		printf(: can't map i/o space\n);
@@ -149,19 +150,20 @@
 		printf(: lithium cell is dead, RTC unreliable);
 	printf(\n);
 
+	sc-sc_todr.todr_gettime_ymdhms = dsrtc_read;
+	sc-sc_todr.todr_settime_ymdhms = dsrtc_write;
+	sc-sc_todr.cookie = sc;
+
 #ifdef DEBUG
 	{
-		rtc_t rtc;
-		dsrtc_read(sc, rtc);
-		printf(RTC: %d/%d/%02d%02d %d:%02d:%02d\n,
-			rtc.rtc_mon, rtc.rtc_day, rtc.rtc_cen, rtc.rtc_year,
-			rtc.rtc_hour, rtc.rtc_min, rtc.rtc_sec);
+		struct clock_ymdhms dt;
+		dsrtc_read(sc-sc_todr, dt);
+		printf(RTC: %d/%d/%04d %d:%02d:%02d\n,
+			dt.dt_mon, dt.dt_day, dt.dt_year,
+			dt.dt_hour, dt.dt_min, dt.dt_sec);
 	}
 #endif
 
-	sc-sc_todr.todr_gettime_ymdhms = dsrtc_read;
-	sc-sc_todr.todr_settime_ymdhms = dsrtc_write;
-	sc-sc_todr.cookie = sc;
 	todr_attach(sc-sc_todr);
 }
 



CVS commit: [matt-nb5-mips64] src/distrib/sets/lists/comp

2011-06-01 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Jun  1 08:35:34 UTC 2011

Modified Files:
src/distrib/sets/lists/comp [matt-nb5-mips64]: ad.mips64eb ad.mips64el

Log Message:
since elf2aout is obsolete, it's debug file is, for mips64e[bl] too.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/distrib/sets/lists/comp/ad.mips64eb \
src/distrib/sets/lists/comp/ad.mips64el

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/comp/ad.mips64eb
diff -u src/distrib/sets/lists/comp/ad.mips64eb:1.1.2.3 src/distrib/sets/lists/comp/ad.mips64eb:1.1.2.4
--- src/distrib/sets/lists/comp/ad.mips64eb:1.1.2.3	Thu Jan 28 17:10:20 2010
+++ src/distrib/sets/lists/comp/ad.mips64eb	Wed Jun  1 08:35:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64eb,v 1.1.2.3 2010/01/28 17:10:20 matt Exp $
+# $NetBSD: ad.mips64eb,v 1.1.2.4 2011/06/01 08:35:34 cliff Exp $
 ./usr/bin/elf2aoutcomp-sysutil-bin	obsolete
 ./usr/bin/elf2ecoffcomp-sysutil-bin
 ./usr/include/mipscomp-c-include
@@ -805,7 +805,7 @@
 ./usr/lib/o32/libz.sobase-sys-shlib		compat,pic
 ./usr/lib/o32/libz_p.acomp-c-proflib		compat,profile
 ./usr/lib/o32/libz_pic.a			comp-c-piclib		compat,pic
-./usr/libdata/debug/usr/bin/elf2aout.debug	comp-sysutil-debug	debug
+./usr/libdata/debug/usr/bin/elf2aout.debug	comp-obsolete		obsolete
 ./usr/libdata/debug/usr/bin/elf2ecoff.debug	comp-sysutil-debug	debug
 ./usr/libdata/ldscripts/elf32btsmip.x		comp-util-bin
 ./usr/libdata/ldscripts/elf32btsmip.xbn		comp-util-bin
Index: src/distrib/sets/lists/comp/ad.mips64el
diff -u src/distrib/sets/lists/comp/ad.mips64el:1.1.2.3 src/distrib/sets/lists/comp/ad.mips64el:1.1.2.4
--- src/distrib/sets/lists/comp/ad.mips64el:1.1.2.3	Thu Jan 28 17:10:20 2010
+++ src/distrib/sets/lists/comp/ad.mips64el	Wed Jun  1 08:35:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips64el,v 1.1.2.3 2010/01/28 17:10:20 matt Exp $
+# $NetBSD: ad.mips64el,v 1.1.2.4 2011/06/01 08:35:34 cliff Exp $
 ./usr/bin/elf2aoutcomp-sysutil-bin	obsolete
 ./usr/bin/elf2ecoffcomp-sysutil-bin
 ./usr/include/mipscomp-c-include
@@ -805,7 +805,7 @@
 ./usr/lib/o32/libz.sobase-sys-shlib		compat,pic
 ./usr/lib/o32/libz_p.acomp-c-proflib		compat,profile
 ./usr/lib/o32/libz_pic.a			comp-c-piclib		compat,pic
-./usr/libdata/debug/usr/bin/elf2aout.debug	comp-sysutil-debug	debug
+./usr/libdata/debug/usr/bin/elf2aout.debug	comp-obsolete		obsolete
 ./usr/libdata/debug/usr/bin/elf2ecoff.debug	comp-sysutil-debug	debug
 ./usr/libdata/ldscripts/elf32btsmip.x		comp-util-bin
 ./usr/libdata/ldscripts/elf32btsmip.xbn		comp-util-bin



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-05-27 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat May 28 02:21:37 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: trap.c

Log Message:
add cpu number to fault print


To generate a diff of this commit:
cvs rdiff -u -r1.217.12.36 -r1.217.12.37 src/sys/arch/mips/mips/trap.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/mips/mips/trap.c
diff -u src/sys/arch/mips/mips/trap.c:1.217.12.36 src/sys/arch/mips/mips/trap.c:1.217.12.37
--- src/sys/arch/mips/mips/trap.c:1.217.12.36	Thu May 26 19:21:56 2011
+++ src/sys/arch/mips/mips/trap.c	Sat May 28 02:21:36 2011
@@ -629,9 +629,9 @@
 	utf-tf_regs[_R_CAUSE] = cause;
 	utf-tf_regs[_R_BADVADDR] = vaddr;
 #if defined(DEBUG)
-	printf(trap: pid %d(%s): sig %d: cause=%#x epc=%#PRIxREGISTER
+	printf(trap: cpu%d, pid %d(%s): sig %d: cause=%#x epc=%#PRIxREGISTER
 	 va=%#PRIxVADDR\n,
-	p-p_pid, p-p_comm, ksi.ksi_signo, cause,
+	cpu_number(), p-p_pid, p-p_comm, ksi.ksi_signo, cause,
 	utf-tf_regs[_R_PC], vaddr);
 	printf(registers:\n);
 	for (size_t i = 0; i  32; i += 4) {



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-05-27 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat May 28 02:24:47 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: cpu_subr.c

Log Message:
use intr instead of int for clock evcnt names


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.18 -r1.1.2.19 src/sys/arch/mips/mips/cpu_subr.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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.1.2.18 src/sys/arch/mips/mips/cpu_subr.c:1.1.2.19
--- src/sys/arch/mips/mips/cpu_subr.c:1.1.2.18	Thu May 26 19:21:56 2011
+++ src/sys/arch/mips/mips/cpu_subr.c	Sat May 28 02:24:47 2011
@@ -228,10 +228,10 @@
 
 	evcnt_attach_dynamic(ci-ci_ev_count_compare,
 		EVCNT_TYPE_INTR, NULL, xname,
-		int 5 (clock));
+		intr 5 (clock));
 	evcnt_attach_dynamic(ci-ci_ev_count_compare_missed,
 		EVCNT_TYPE_INTR, NULL, xname,
-		int 5 (clock) missed);
+		intr 5 (clock) missed);
 	evcnt_attach_dynamic(ci-ci_ev_fpu_loads,
 		EVCNT_TYPE_MISC, NULL, xname,
 		fpu loads);



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-05-10 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed May 11 00:37:20 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_com.c

Log Message:
simplify rmixl_com_initmap() a bit


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/sys/arch/mips/rmi/rmixl_com.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/mips/rmi/rmixl_com.c
diff -u src/sys/arch/mips/rmi/rmixl_com.c:1.1.2.14 src/sys/arch/mips/rmi/rmixl_com.c:1.1.2.15
--- src/sys/arch/mips/rmi/rmixl_com.c:1.1.2.14	Fri May 21 23:33:52 2010
+++ src/sys/arch/mips/rmi/rmixl_com.c	Wed May 11 00:37:20 2011
@@ -1,4 +1,4 @@
-/* $Id: rmixl_com.c,v 1.1.2.14 2010/05/21 23:33:52 cliff Exp $ */
+/* $Id: rmixl_com.c,v 1.1.2.15 2011/05/11 00:37:20 cliff Exp $ */
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
  * Copyright (c) 2006 Garrett D'Amore.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_com.c,v 1.1.2.14 2010/05/21 23:33:52 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_com.c,v 1.1.2.15 2011/05/11 00:37:20 cliff Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -300,14 +300,10 @@
 void
 rmixl_com_initmap(struct com_regs *regsp)
 {
-	int i;
-	int sz;
-
 	/*
 	 * map the 4 byte register stride
 	 */
-	sz = sizeof(regsp-cr_map) / sizeof(regsp-cr_map[0]);
-	for (i = 0; i  sz; i++)
+	for (int i = 0; i  __arraycount(regsp-cr_map); i++)
 		regsp-cr_map[i] = com_std_map[i] * 4;
 }
 



CVS commit: src/sys/arch/mips/rmi

2011-05-10 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed May 11 00:38:03 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_com.c

Log Message:
sync from matt-nb5-mips64 branch


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_com.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/mips/rmi/rmixl_com.c
diff -u src/sys/arch/mips/rmi/rmixl_com.c:1.3 src/sys/arch/mips/rmi/rmixl_com.c:1.4
--- src/sys/arch/mips/rmi/rmixl_com.c:1.3	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_com.c	Wed May 11 00:38:03 2011
@@ -1,4 +1,4 @@
-/* $Id: rmixl_com.c,v 1.3 2011/02/20 07:48:37 matt Exp $ */
+/* $Id: rmixl_com.c,v 1.4 2011/05/11 00:38:03 cliff Exp $ */
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
  * Copyright (c) 2006 Garrett D'Amore.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_com.c,v 1.3 2011/02/20 07:48:37 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_com.c,v 1.4 2011/05/11 00:38:03 cliff Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -300,14 +300,10 @@
 void
 rmixl_com_initmap(struct com_regs *regsp)
 {
-	int i;
-	int sz;
-
 	/*
 	 * map the 4 byte register stride
 	 */
-	sz = sizeof(regsp-cr_map) / sizeof(regsp-cr_map[0]);
-	for (i = 0; i  sz; i++)
+	for (int i = 0; i  __arraycount(regsp-cr_map); i++)
 		regsp-cr_map[i] = com_std_map[i] * 4;
 }
 



CVS commit: src/sys/arch/mips/rmi

2011-04-14 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 06:12:21 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_cpucore.c

Log Message:
- fix comment at cpucore_rmixl_run()


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_cpucore.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/mips/rmi/rmixl_cpucore.c
diff -u src/sys/arch/mips/rmi/rmixl_cpucore.c:1.3 src/sys/arch/mips/rmi/rmixl_cpucore.c:1.4
--- src/sys/arch/mips/rmi/rmixl_cpucore.c:1.3	Thu Apr 14 05:14:23 2011
+++ src/sys/arch/mips/rmi/rmixl_cpucore.c	Thu Apr 14 06:12:21 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpucore.c,v 1.3 2011/04/14 05:14:23 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpucore.c,v 1.4 2011/04/14 06:12:21 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpucore.c,v 1.3 2011/04/14 05:14:23 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpucore.c,v 1.4 2011/04/14 06:12:21 cliff Exp $);
 
 #include opt_multiprocessor.h
 
@@ -199,7 +199,8 @@
 
 /*
  * cpucore_rmixl_run
- *	called from cpu_rmixl_hatch for each cpu
+ *	called from cpucore_rmixl_attach for primary core
+ *	and called from cpu_rmixl_run for each hatched cpu
  *	the first call for each cpucore causes init of per-core features:
  *	- disable unused threads
  *	- set Fine-grained (Round Robin) thread scheduling mode



CVS commit: src/sys/arch/mips/mips

2011-04-14 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 06:54:58 UTC 2011

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c

Log Message:
cpuwatch_* stuff is #if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0
now cobalt can build


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/mips/cpu_subr.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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.8 src/sys/arch/mips/mips/cpu_subr.c:1.9
--- src/sys/arch/mips/mips/cpu_subr.c:1.8	Thu Apr 14 05:54:24 2011
+++ src/sys/arch/mips/mips/cpu_subr.c	Thu Apr 14 06:54:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.8 2011/04/14 05:54:24 cliff Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.9 2011/04/14 06:54:57 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.8 2011/04/14 05:54:24 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.9 2011/04/14 06:54:57 cliff Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -1014,6 +1014,8 @@
 }
 
 
+#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0
+
 #if (CPUWATCH_MAX != 8)
 # error CPUWATCH_MAX
 #endif
@@ -1145,3 +1147,4 @@
 	mipsNN_cp0_watchlo_write(cwnum, 0);
 }
 
+#endif	/* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0 */



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Apr 13 21:06:31 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_pcix.c

Log Message:
initialize mutex in attach


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_pcix.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/mips/rmi/rmixl_pcix.c
diff -u src/sys/arch/mips/rmi/rmixl_pcix.c:1.3 src/sys/arch/mips/rmi/rmixl_pcix.c:1.4
--- src/sys/arch/mips/rmi/rmixl_pcix.c:1.3	Mon Apr  4 20:37:52 2011
+++ src/sys/arch/mips/rmi/rmixl_pcix.c	Wed Apr 13 21:06:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_pcix.c,v 1.3 2011/04/04 20:37:52 dyoung Exp $	*/
+/*	$NetBSD: rmixl_pcix.c,v 1.4 2011/04/13 21:06:30 cliff Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.3 2011/04/04 20:37:52 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.4 2011/04/13 21:06:30 cliff Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -316,6 +316,8 @@
 
 	aprint_normal(: RMI XLR PCI-X Interface\n);
 
+	mutex_init(sc-sc_mutex, MUTEX_DEFAULT, IPL_HIGH);
+
 	rmixl_pcix_intcfg(sc);
 
 	rmixl_pcix_errata(sc);



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Wed Apr 13 21:10:11 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_pcix.c

Log Message:
initialize mutex in attach


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/arch/mips/rmi/rmixl_pcix.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/mips/rmi/rmixl_pcix.c
diff -u src/sys/arch/mips/rmi/rmixl_pcix.c:1.1.2.7 src/sys/arch/mips/rmi/rmixl_pcix.c:1.1.2.8
--- src/sys/arch/mips/rmi/rmixl_pcix.c:1.1.2.7	Mon Sep 20 19:42:31 2010
+++ src/sys/arch/mips/rmi/rmixl_pcix.c	Wed Apr 13 21:10:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_pcix.c,v 1.1.2.7 2010/09/20 19:42:31 cliff Exp $	*/
+/*	$NetBSD: rmixl_pcix.c,v 1.1.2.8 2011/04/13 21:10:11 cliff Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.1.2.7 2010/09/20 19:42:31 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.1.2.8 2011/04/13 21:10:11 cliff Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -316,6 +316,8 @@
 
 	aprint_normal(: RMI XLR PCI-X Interface\n);
 
+	mutex_init(sc-sc_mutex, MUTEX_DEFAULT, IPL_HIGH);
+
 	rmixl_pcix_intcfg(sc);
 
 	rmixl_pcix_errata(sc);



CVS commit: src/sys/arch/evbmips/conf

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:05:35 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: XLSATX

Log Message:
- remove options LOCKDEBUG; is set in XLSATX64.MP
- option MIPS_DDB_WATCH is deprecated, removed


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/conf/XLSATX

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/evbmips/conf/XLSATX
diff -u src/sys/arch/evbmips/conf/XLSATX:1.3 src/sys/arch/evbmips/conf/XLSATX:1.4
--- src/sys/arch/evbmips/conf/XLSATX:1.3	Fri Mar 18 02:14:55 2011
+++ src/sys/arch/evbmips/conf/XLSATX	Thu Apr 14 05:05:35 2011
@@ -1,8 +1,8 @@
-#	$NetBSD: XLSATX,v 1.3 2011/03/18 02:14:55 cliff Exp $
+#	$NetBSD: XLSATX,v 1.4 2011/04/14 05:05:35 cliff Exp $
 
 include 	arch/evbmips/conf/std.rmixl
 
-#ident 		XLSATX-$Revision: 1.3 $
+#ident 		XLSATX-$Revision: 1.4 $
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -39,13 +39,11 @@
 options 	USERCONF	# userconf(4) support
 #options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 options 	DDB		# kernel dynamic debugger
-options 	MIPS_DDB_WATCH	# enable T_WATCH (see IEU_DEFAUTURE[DBE])
 options 	DDB_HISTORY_SIZE=100 # enable history editing in DDB
 makeoptions 	DEBUG=-g	# compile full symbol table
 options 	SYMTAB_SPACE=50	# size for embedded symbol table
 #options 	DDB_COMMANDONENTER=trace;show registers
 options 	DB_MAX_LINE=-1
-options 	LOCKDEBUG
 
 # Compatibility options
 #options 	COMPAT_43	# compatibility with 4.3BSD binaries



CVS commit: src/sys/arch/evbmips/conf

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:06:10 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: XLSATX32

Log Message:
- 32 bit kernel must MEMLIMIT to 512MB


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/conf/XLSATX32

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/evbmips/conf/XLSATX32
diff -u src/sys/arch/evbmips/conf/XLSATX32:1.2 src/sys/arch/evbmips/conf/XLSATX32:1.3
--- src/sys/arch/evbmips/conf/XLSATX32:1.2	Sun Feb 20 07:48:33 2011
+++ src/sys/arch/evbmips/conf/XLSATX32	Thu Apr 14 05:06:10 2011
@@ -1,8 +1,10 @@
-# $NetBSD: XLSATX32,v 1.2 2011/02/20 07:48:33 matt Exp $
+# $NetBSD: XLSATX32,v 1.3 2011/04/14 05:06:10 cliff Exp $
 #
 
+#ident 		XLSATX32-$Revision: 1.3 $
+
 include arch/evbmips/conf/XLSATX
 
-#ident 		XLSATX32-$Revision: 1.2 $
+options 	MEMLIMIT=0x2000 # 512MB 
 
 makeoptions	LP64=no



CVS commit: src/sys/arch/evbmips/conf

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:06:39 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: XLSATX64.MP

Log Message:
- remove cpucore and cpu reconfiguration stuff
cares and threads can be specified here,
but it's easier to do at boot time from firmmware
e.g. using 'userapp_mask_cpus mask' command


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/conf/XLSATX64.MP

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/evbmips/conf/XLSATX64.MP
diff -u src/sys/arch/evbmips/conf/XLSATX64.MP:1.2 src/sys/arch/evbmips/conf/XLSATX64.MP:1.3
--- src/sys/arch/evbmips/conf/XLSATX64.MP:1.2	Sun Feb 20 07:48:34 2011
+++ src/sys/arch/evbmips/conf/XLSATX64.MP	Thu Apr 14 05:06:39 2011
@@ -1,4 +1,4 @@
-# $NetBSD: XLSATX64.MP,v 1.2 2011/02/20 07:48:34 matt Exp $
+# $NetBSD: XLSATX64.MP,v 1.3 2011/04/14 05:06:39 cliff Exp $
 #
 include arch/evbmips/conf/XLSATX64
 
@@ -7,13 +7,3 @@
 
 pseudo-device	lockstat
 
-no cpucore*
-no cpu*
-cpucore0 at cpunode0 core 0
-cpu0 at cpucore0 thread 0
-cpucore1 at cpunode0 core 1
-cpu4 at cpucore1 thread 0
-#cpucore2 at cpunode0 core 2
-#cpu8 at cpucore2 thread 0
-#cpucore3 at cpunode0 core 3
-#cpu12 at cpucore3 thread 0



CVS commit: src/sys/arch/mips/conf

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:07:00 UTC 2011

Modified Files:
src/sys/arch/mips/conf: files.mips

Log Message:
- option MIPS_DDB_WATCH is deprecated, removed


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/mips/conf/files.mips

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/mips/conf/files.mips
diff -u src/sys/arch/mips/conf/files.mips:1.67 src/sys/arch/mips/conf/files.mips:1.68
--- src/sys/arch/mips/conf/files.mips:1.67	Wed Apr  6 05:47:54 2011
+++ src/sys/arch/mips/conf/files.mips	Thu Apr 14 05:07:00 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mips,v 1.67 2011/04/06 05:47:54 matt Exp $
+#	$NetBSD: files.mips,v 1.68 2011/04/14 05:07:00 cliff Exp $
 #
 
 defflag	opt_cputype.h		NOFPU FPEMUL
@@ -19,7 +19,6 @@
 defflag opt_mips3_wired.h		ENABLE_MIPS3_WIRED_MAP
 
 defflag	opt_ddb.h		DDB_TRACE
-defflag	opt_ddb.h		MIPS_DDB_WATCH
 
 file	arch/mips/mips/locore_mips1.S		mips1
 file	arch/mips/mips/locore_mips3.S		mips3|mips4|mips32|mips32r2|mips64|mips64r2



CVS commit: src/sys/arch/mips/include

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:07:31 UTC 2011

Modified Files:
src/sys/arch/mips/include: cpu.h

Log Message:
- MIPS CPU (COP0) watchpoint support moved from db_machdep.h to cpu.h
- CPU watchpoints are per-cpu; add ci_cpuwatch_count, ci_watchpoint_tab[]
to struct cpuinfo


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/mips/include/cpu.h

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

Modified files:

Index: src/sys/arch/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.100 src/sys/arch/mips/include/cpu.h:1.101
--- src/sys/arch/mips/include/cpu.h:1.100	Wed Apr  6 05:42:21 2011
+++ src/sys/arch/mips/include/cpu.h	Thu Apr 14 05:07:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.100 2011/04/06 05:42:21 matt Exp $	*/
+/*	$NetBSD: cpu.h,v 1.101 2011/04/14 05:07:30 cliff Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -56,6 +56,30 @@
 #include sys/device_if.h
 #include sys/evcnt.h
 
+typedef struct cpu_watchpoint {
+	register_t	cw_addr;
+	register_t	cw_mask;
+	uint32_t	cw_asid;
+	uint32_t	cw_mode;
+} cpu_watchpoint_t;
+/* (abstract) mode bits */
+#define CPUWATCH_WRITE	__BIT(0)
+#define CPUWATCH_READ	__BIT(1)
+#define CPUWATCH_EXEC	__BIT(2)
+#define CPUWATCH_MASK	__BIT(3)
+#define CPUWATCH_ASID	__BIT(4)
+#define CPUWATCH_RWX	(CPUWATCH_EXEC|CPUWATCH_READ|CPUWATCH_WRITE)
+
+#define CPUWATCH_MAX	8	/* max possible number of watchpoints */
+
+u_int		  cpuwatch_discover(void);
+void		  cpuwatch_free(cpu_watchpoint_t *);
+cpu_watchpoint_t *cpuwatch_alloc(void);
+void		  cpuwatch_set_all(void);
+void		  cpuwatch_clr_all(void);
+void		  cpuwatch_set(cpu_watchpoint_t *);
+void		  cpuwatch_clr(cpu_watchpoint_t *);
+
 struct cpu_info {
 	struct cpu_data ci_data;	/* MI per-cpu data */
 	struct cpu_info *ci_next;	/* Next CPU in list */
@@ -96,6 +120,8 @@
 	vaddr_t ci_pmap_dstbase;	/* starting VA of ephemeral dst space */
 #endif
 
+	u_int ci_cpuwatch_count;	/* number of watchpoints on this CPU */
+	cpu_watchpoint_t ci_cpuwatch_tab[CPUWATCH_MAX];
 
 #ifdef MULTIPROCESSOR
 	volatile u_long ci_flags;



CVS commit: src/sys/arch/mips/include

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:07:56 UTC 2011

Modified Files:
src/sys/arch/mips/include: db_machdep.h

Log Message:
- remove include mips/proc.h, unused
- db_mach_watch_set_all() is deprecated, removed,
superceded by cpuwatch_set_all()


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/mips/include/db_machdep.h

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

Modified files:

Index: src/sys/arch/mips/include/db_machdep.h
diff -u src/sys/arch/mips/include/db_machdep.h:1.25 src/sys/arch/mips/include/db_machdep.h:1.26
--- src/sys/arch/mips/include/db_machdep.h:1.25	Wed Apr  6 05:53:27 2011
+++ src/sys/arch/mips/include/db_machdep.h	Thu Apr 14 05:07:56 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.25 2011/04/06 05:53:27 matt Exp $ */
+/* $NetBSD: db_machdep.h,v 1.26 2011/04/14 05:07:56 cliff Exp $ */
 
 /*
  * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -38,7 +38,6 @@
 #include mips/trap.h			/* T_BREAK */
 #include mips/reg.h			/* register state */
 #include mips/regnum.h		/* symbolic register indices */
-#include mips/proc.h
 #include mips/pcb.h
 
 
@@ -117,9 +116,6 @@
 bool ddb_running_on_this_cpu_p(void);
 bool ddb_running_on_any_cpu_p(void);
 void db_resume_others(void);
-#ifdef MIPS_DDB_WATCH
-void db_mach_watch_set_all(void);
-#endif
 
 /*
  * We have machine-dependent commands.



CVS commit: src/sys/arch/mips/include

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:08:22 UTC 2011

Modified Files:
src/sys/arch/mips/include: locore.h

Log Message:
- add lsw_cpu_run function pointer to struct locoresw


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/mips/include/locore.h

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

Modified files:

Index: src/sys/arch/mips/include/locore.h
diff -u src/sys/arch/mips/include/locore.h:1.87 src/sys/arch/mips/include/locore.h:1.88
--- src/sys/arch/mips/include/locore.h:1.87	Tue Apr 12 22:54:31 2011
+++ src/sys/arch/mips/include/locore.h	Thu Apr 14 05:08:22 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.87 2011/04/12 22:54:31 matt Exp $ */
+/* $NetBSD: locore.h,v 1.88 2011/04/14 05:08:22 cliff Exp $ */
 
 /*
  * This file should not be included by MI code!!!
@@ -362,6 +362,7 @@
 	int		(*lsw_send_ipi)(struct cpu_info *, int);
 	void		(*lsw_cpu_offline_md)(void);
 	void		(*lsw_cpu_init)(struct cpu_info *);
+	void		(*lsw_cpu_run)(struct cpu_info *);
 	int		(*lsw_bus_error)(unsigned int);
 };
 



CVS commit: src/sys/arch/mips/mips

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:08:51 UTC 2011

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c

Log Message:
- MIPS CPU (COP0) watchpoint support moved from db_interface.c to cpu_subr.c
see the cpuwatch_* functions
- ci_cpuwatch_count in allocated cpu_info is inherited from cpu_info_store
- cpu_hatch() calls lsw_cpu_run (if not NULL)
to optionally allow running MIPS chip-specific code
after subordinate cpus have been set running
- #ifdef DDB cpu_debug_dump() to allow compile when DDB not defined


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/mips/cpu_subr.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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.6 src/sys/arch/mips/mips/cpu_subr.c:1.7
--- src/sys/arch/mips/mips/cpu_subr.c:1.6	Wed Apr  6 05:53:27 2011
+++ src/sys/arch/mips/mips/cpu_subr.c	Thu Apr 14 05:08:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.6 2011/04/06 05:53:27 matt Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.7 2011/04/14 05:08:51 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.6 2011/04/06 05:53:27 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.7 2011/04/14 05:08:51 cliff Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -101,7 +101,6 @@
 static int  cpu_ipi_wait(volatile __cpuset_t *, u_long);
 static void cpu_ipi_error(const char *, __cpuset_t, __cpuset_t);
 
-
 static struct cpu_info *cpu_info_last = cpu_info_store;
 
 struct cpu_info *
@@ -151,6 +150,7 @@
 ci-ci_cycles_per_hz = cpu_info_store.ci_cycles_per_hz;
 ci-ci_divisor_delay = cpu_info_store.ci_divisor_delay;
 ci-ci_divisor_recip = cpu_info_store.ci_divisor_recip;
+ci-ci_cpuwatch_count = cpu_info_store.ci_cpuwatch_count;
 
 	/*
 	 * Attach its TLB info (which must be direct-mapped)
@@ -785,9 +785,6 @@
 #endif
 		break;
 	}
-#if defined(DDB)  defined(MIPS_DDB_WATCH)
-	db_mach_watch_set_all();
-#endif
 
 	splx(s);
 }
@@ -848,6 +845,7 @@
 	return CPUSET_HAS_P(cpus_paused, index);
 }
 
+#ifdef DDB
 void
 cpu_debug_dump(void)
 {
@@ -871,6 +869,7 @@
 			ci-ci_active_ipis, ci-ci_request_ipis);
 	}
 }
+#endif
 
 void
 cpu_hatch(struct cpu_info *ci)
@@ -934,6 +933,13 @@
 	ci-ci_data.cpu_cc_skew = 0;
 
 	/*
+	 * Let this CPU do its own post-running initialization
+	 * (for things that have to be done on the local CPU).
+	 */
+	if (mips_locoresw.lsw_cpu_run != NULL)
+		(*mips_locoresw.lsw_cpu_run)(ci);
+
+	/*
 	 * Now turn on interrupts.
 	 */
 	spl0();
@@ -1007,3 +1013,136 @@
 #endif
 	return 0;
 }
+
+
+#if (CPUWATCH_MAX != 8)
+# error CPUWATCH_MAX
+#endif
+
+/*
+ * cpuwatch_discover - determine how many COP0 watchpoints this CPU supports
+ */
+u_int
+cpuwatch_discover(void)
+{
+	int i;
+
+	for (i=0; i  CPUWATCH_MAX; i++) {
+		uint32_t watchhi = mipsNN_cp0_watchhi_read(i);
+		if ((watchhi  __BIT(31)) == 0)	/* test 'M' bit */
+			break;
+	}
+	return i + 1;
+}
+
+void
+cpuwatch_free(cpu_watchpoint_t *cwp)
+{
+#ifdef DIAGNOSTIC
+	struct cpu_info * const ci = curcpu();
+	KASSERT(cwp = ci-ci_cpuwatch_tab[0] 
+		cwp = ci-ci_cpuwatch_tab[ci-ci_cpuwatch_count-1]);
+#endif
+	cwp-cw_mode = 0;
+	cwp-cw_asid = 0;
+	cwp-cw_addr = 0;
+	cpuwatch_clr(cwp);
+}
+
+/*
+ * cpuwatch_alloc
+ * 	find an empty slot
+ *	no locking for the table since it is CPU private
+ */
+cpu_watchpoint_t *
+cpuwatch_alloc(void)
+{
+	struct cpu_info * const ci = curcpu();
+	cpu_watchpoint_t *cwp;
+
+	for (int i=0; i  ci-ci_cpuwatch_count; i++) {
+		cwp = ci-ci_cpuwatch_tab[i];
+		if ((cwp-cw_mode  CPUWATCH_RWX) == 0)
+			return cwp;
+	}
+	return NULL;
+}
+
+
+void
+cpuwatch_set_all(void)
+{
+	struct cpu_info * const ci = curcpu();
+	cpu_watchpoint_t *cwp;
+	int i;
+
+	for (i=0; i  ci-ci_cpuwatch_count; i++) {
+		cwp = ci-ci_cpuwatch_tab[i];
+		if ((cwp-cw_mode  CPUWATCH_RWX) != 0)
+			cpuwatch_set(cwp);
+	}
+}
+
+void
+cpuwatch_clr_all(void)
+{
+	struct cpu_info * const ci = curcpu();
+	cpu_watchpoint_t *cwp;
+	int i;
+
+	for (i=0; i  ci-ci_cpuwatch_count; i++) {
+		cwp = ci-ci_cpuwatch_tab[i];
+		if ((cwp-cw_mode  CPUWATCH_RWX) != 0)
+			cpuwatch_clr(cwp);
+	}
+}
+
+/*
+ * cpuwatch_set - establish a MIPS COP0 watchpoint
+ */
+void
+cpuwatch_set(cpu_watchpoint_t *cwp)
+{
+	struct cpu_info * const ci = curcpu();
+	uint32_t watchhi;
+	register_t watchlo;
+	int cwnum = cwp - ci-ci_cpuwatch_tab[0];
+
+	KASSERT(cwp = ci-ci_cpuwatch_tab[0] 
+		cwp = ci-ci_cpuwatch_tab[ci-ci_cpuwatch_count-1]);
+
+	watchlo = cwp-cw_addr;
+	if (cwp-cw_mode  CPUWATCH_WRITE)
+		watchlo |= __BIT(0);
+	if (cwp-cw_mode  CPUWATCH_READ)
+		watchlo |= __BIT(1);
+	if (cwp-cw_mode  CPUWATCH_EXEC)
+		watchlo |= __BIT(2);
+
+	if (cwp-cw_mode  CPUWATCH_ASID)
+		watchhi = cwp-cw_asid  16;	/* addr qualified by asid */
+	else
+		watchhi = __BIT(30);		

CVS commit: src/sys/arch/mips/mips

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:09:34 UTC 2011

Modified Files:
src/sys/arch/mips/mips: db_interface.c

Log Message:
- option MIPS_DDB_WATCH is dedprecated, removed; now using
(MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0 for conditional
compile of db_mach_watch stuff
- MIPS CPU (COP0) watchpoint support moved from db_interface.c
to cpu_subr.c, cpu.h; ddb_mach_watch etc now use those cpu functions.
- ddb_cpu now volatile
- 'struct db_mach_watch' definition etc moved to mips/include/db_machdep.h
- db_mach_watch_tab is replaced by curcpu()-ci_watch_tab
to allow per-cpu watchpoint control
- improve MP function in kdb_trap()
- fix conditions for printing cp0 regs


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/mips/mips/db_interface.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/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.70 src/sys/arch/mips/mips/db_interface.c:1.71
--- src/sys/arch/mips/mips/db_interface.c:1.70	Wed Apr  6 05:53:27 2011
+++ src/sys/arch/mips/mips/db_interface.c	Thu Apr 14 05:09:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.70 2011/04/06 05:53:27 matt Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.71 2011/04/14 05:09:34 cliff Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.70 2011/04/06 05:53:27 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.71 2011/04/14 05:09:34 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_cputype.h	/* which mips CPUs do we support? */
@@ -67,34 +67,15 @@
 #endif
 
 #define NOCPU   ~0
-u_int ddb_cpu = NOCPU;
+volatile u_int ddb_cpu = NOCPU;
 
 int		db_active = 0;
 db_regs_t	ddb_regs;
 
-#ifdef MIPS_DDB_WATCH
-struct db_mach_watch {
-	register_t	addr;
-	register_t	mask;
-	uint32_t	asid;
-	uint32_t	mode;
-};
-/* mode bits */
-#define DB_WATCH_WRITE	__BIT(0)
-#define DB_WATCH_READ	__BIT(1)
-#define DB_WATCH_EXEC	__BIT(2)
-#define DB_WATCH_MASK	__BIT(3)
-#define DB_WATCH_ASID	__BIT(4)
-#define DB_WATCH_RWX	(DB_WATCH_EXEC|DB_WATCH_READ|DB_WATCH_WRITE)
-
-#define DBNWATCH	1
-static volatile struct db_mach_watch db_mach_watch_tab[DBNWATCH];
-
-static void db_mach_watch_set(int, register_t, register_t, uint32_t, uint32_t,
-	bool);
+#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0
 static void db_watch_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void db_unwatch_cmd(db_expr_t, bool, db_expr_t, const char *);
-#endif	/* MIPS_DDB_WATCH */
+#endif	/* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0 */
 
 #ifdef MULTIPROCESSOR
 static void db_mach_cpu(db_expr_t, bool, db_expr_t, const char *);
@@ -146,6 +127,8 @@
 		break;
 	}
 
+	s = splhigh();
+
 #ifdef MULTIPROCESSOR
 	bool first_in_ddb = false;
 	const u_int cpu_me = cpu_number();
@@ -155,26 +138,25 @@
 		cpu_pause_others();
 	} else {
 		if (old_ddb_cpu != cpu_me) {
+			KASSERT(cpu_is_paused(cpu_me));
 			cpu_pause(regs);
+			splx(s);
 			return 1;
 		}
 	}
+	KASSERT(! cpu_is_paused(cpu_me));
 #endif
 
-	/* Should switch to kdb`s own stack here. */
 	ddb_regs = *regs;
-
-	s = splhigh();
 	db_active++;
 	cnpollc(1);
 	db_trap(type  ~T_USER, 0 /*code*/);
 	cnpollc(0);
 	db_active--;
-	splx(s);
+	*regs = ddb_regs;
 
 #ifdef MULTIPROCESSOR
-	if (ddb_cpu == cpu_me) {
-		ddb_cpu = NOCPU;
+	if (atomic_cas_uint(ddb_cpu, cpu_me, NOCPU) == cpu_me) {
 		cpu_resume_others();
 	} else {
 		cpu_resume(ddb_cpu);
@@ -183,9 +165,8 @@
 	}
 #endif
 
-	*regs = ddb_regs;
-
-	return (1);
+	splx(s);
+	return 1;
 }
 
 void
@@ -411,10 +392,12 @@
 		SHOW32(MIPS_COP_0_COUNT, count);
 	}
 
-	if ((cp0flags  MIPS_CP0FL_EIRR) != 0)
-		SHOW64SEL(9, 6, eirr);
-	if ((cp0flags  MIPS_CP0FL_EIMR) != 0)
-		SHOW64SEL(9, 7, eimr);
+	if ((cp0flags  MIPS_CP0FL_USE) != 0) {
+		if ((cp0flags  MIPS_CP0FL_EIRR) != 0)
+			SHOW64SEL(9, 6, eirr);
+		if ((cp0flags  MIPS_CP0FL_EIMR) != 0)
+			SHOW64SEL(9, 7, eimr);
+	}
 
 	if (CPUIS64BITS) {
 		SHOW64(MIPS_COP_0_TLB_HI, entryhi);
@@ -479,146 +462,98 @@
 			else
 SHOW32(MIPS_COP_0_LLADDR, lladdr);
 		}
+	}
 
-		SHOW32(MIPS_COP_0_WATCH_HI, watchhi);
-		if (CPUIS64BITS)
-			SHOW64(MIPS_COP_0_WATCH_LO, watchlo);
-		else
-			SHOW32(MIPS_COP_0_WATCH_LO, watchlo);
-
+#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0
+	for (int i=0; i  curcpu()-ci_cpuwatch_count; i++) {
+		uint32_t r = mipsNN_cp0_watchlo_read(i);
+		printf(  %s%d:%*s %#x\n, watchlo, i, FLDWIDTH - 8, , r);
+	}
+	for (int i=0; i  curcpu()-ci_cpuwatch_count; i++) {
 		if (CPUIS64BITS) {
-			SHOW64(MIPS_COP_0_TLB_XCONTEXT, xcontext);
-		}
-
-		if (CPUISMIPSNN) {
-			if (CPUIS64BITS) {
-SHOW64(MIPS_COP_0_PERFCNT, perfcnt);
-			} else {
-SHOW32(MIPS_COP_0_PERFCNT, perfcnt);
-			}
+			uint32_t r = mipsNN_cp0_watchhi_read(i);
+			printf(  %s%d:%*s %#x\n,
+watchhi, i, FLDWIDTH - 8, , r);
+		} else {
+			uint64_t r = mipsNN_cp0_watchhi_read(i);
+	

CVS commit: src/sys/arch/mips/mips

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:10:04 UTC 2011

Modified Files:
src/sys/arch/mips/mips: mips_machdep.c

Log Message:
- add mips_watchpoint_init() to discover number of CPU watchpoints,
and call that from {mips32,mips32r2,mips64,mips64r2}_vector_init()


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/sys/arch/mips/mips/mips_machdep.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/mips/mips/mips_machdep.c
diff -u src/sys/arch/mips/mips/mips_machdep.c:1.238 src/sys/arch/mips/mips/mips_machdep.c:1.239
--- src/sys/arch/mips/mips/mips_machdep.c:1.238	Wed Apr  6 05:50:39 2011
+++ src/sys/arch/mips/mips/mips_machdep.c	Thu Apr 14 05:10:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_machdep.c,v 1.238 2011/04/06 05:50:39 matt Exp $	*/
+/*	$NetBSD: mips_machdep.c,v 1.239 2011/04/14 05:10:04 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -112,7 +112,7 @@
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: mips_machdep.c,v 1.238 2011/04/06 05:50:39 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: mips_machdep.c,v 1.239 2011/04/14 05:10:04 cliff Exp $);
 
 #define __INTR_PRIVATE
 #include opt_cputype.h
@@ -188,6 +188,10 @@
 u_long	cpu_dump_mempagecnt(void);
 int	cpu_dump(void);
 
+#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0
+static void mips_watchpoint_init(void);
+#endif
+
 #if defined(MIPS3_PLUS)
 uint32_t mips3_cp0_tlb_page_mask_probe(void);
 uint64_t mips3_cp0_tlb_entry_hi_probe(void);
@@ -784,6 +788,8 @@
 
 	/* Clear BEV in SR so we start handling our own exceptions */
 	mips_cp0_status_write(mips_cp0_status_read()  ~MIPS_SR_BEV);
+
+	mips_watchpoint_init();
 }
 #endif /* MIPS32 */
 
@@ -849,6 +855,8 @@
 
 	/* Clear BEV in SR so we start handling our own exceptions */
 	mips_cp0_status_write(mips_cp0_status_read()  ~MIPS_SR_BEV);
+
+	mips_watchpoint_init();
 }
 #endif /* MIPS32R2 */
 
@@ -902,6 +910,8 @@
 
 	/* Clear BEV in SR so we start handling our own exceptions */
 	mips_cp0_status_write(mips_cp0_status_read()  ~MIPS_SR_BEV);
+
+	mips_watchpoint_init();
 }
 #endif /* MIPS64 */
 
@@ -972,6 +982,8 @@
 
 	/* Clear BEV in SR so we start handling our own exceptions */
 	mips_cp0_status_write(mips_cp0_status_read()  ~MIPS_SR_BEV);
+
+	mips_watchpoint_init();
 }
 #endif /* MIPS64R2 */
 
@@ -2196,3 +2208,14 @@
 	KASSERT(ci-ci_cpl == IPL_NONE);
 }
 #endif /* PARANOIA */
+
+#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2)  0
+static void
+mips_watchpoint_init(void)
+{
+	/*
+	 * determine number of CPU watchpoints
+	 */
+	curcpu()-ci_cpuwatch_count = cpuwatch_discover();
+}
+#endif



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:12:58 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_cpu.c

Log Message:
- add cpu_rmixl_run(), and set in mips_locoresw.lsw_cpu_run
to be called from cpu_hatch() once cpus are running,
so we can determine what threads are configured
and running, and can finish initialization of per-core registers
depending on that.
- in cpu_rmixl_db_watch_init() clear IEU_DEFEATURE[DBE],
and init all COP0 watchpoint regs
- option MIPS_DDB_WATCH is deprecated, removed; use of cpu watchpoints
is longer depends on that or DDB


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/rmi/rmixl_cpu.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/mips/rmi/rmixl_cpu.c
diff -u src/sys/arch/mips/rmi/rmixl_cpu.c:1.2 src/sys/arch/mips/rmi/rmixl_cpu.c:1.3
--- src/sys/arch/mips/rmi/rmixl_cpu.c:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_cpu.c	Thu Apr 14 05:12:58 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpu.c,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_cpu.c,v 1.3 2011/04/14 05:12:58 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.2 2011/02/20 07:48:37 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.3 2011/04/14 05:12:58 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -78,6 +78,7 @@
 
 #ifdef MULTIPROCESSOR
 void		cpu_rmixl_hatch(struct cpu_info *);
+void		cpu_rmixl_run(struct cpu_info *);
 #if 0
 static void	cpu_setup_trampoline_ipi(struct device *, struct cpu_info *);
 #endif
@@ -98,19 +99,25 @@
 static struct rmixl_cpu_trampoline_args rmixl_cpu_trampoline_args;
 #endif
 
-#if defined(DDB)  defined(MIPS_DDB_WATCH)
 /*
  * cpu_rmixl_db_watch_init - initialize COP0 watchpoint stuff
  *
  * clear IEU_DEFEATURE[DBE] to ensure T_WATCH on watchpoint exception
  * set COP0 watchhi and watchlo
+ *
+ * disable all watchpoints
  */
 static void
 cpu_rmixl_db_watch_init(void)
 {
-	db_mach_watch_set_all();
+	uint32_t r;
+
+	r = rmixl_mfcr(RMIXL_PCR_IEU_DEFEATURE);
+	r = ~__BIT(7);		/* DBE */
+	rmixl_mtcr(RMIXL_PCR_IEU_DEFEATURE, r);
+
+	cpuwatch_clr_all();
 }
-#endif	/* DDB  MIPS_DDB_WATCH */
 
 /*
  * cpu_xls616_erratum
@@ -186,6 +193,7 @@
 
 #ifdef MULTIPROCESSOR
 		mips_locoresw.lsw_cpu_init = cpu_rmixl_hatch;
+		mips_locoresw.lsw_cpu_run = cpu_rmixl_run;
 	} else {
 		struct cpucore_attach_args *ca = aux;
 		struct cpucore_softc * const ccsc = device_private(parent);
@@ -255,9 +263,7 @@
 	asm volatile(dmfc0 %0, $15, 1; : =r(ebase));
 	ci-ci_cpuid = ebase  __BITS(9,0);
 
-#if defined(DDB)  defined(MIPS_DDB_WATCH)
 	cpu_rmixl_db_watch_init();
-#endif
 
 	rmixl_fmn_init();
 
@@ -295,6 +301,18 @@
 
 #ifdef MULTIPROCESSOR
 /*
+ * cpu_rmixl_run
+ *
+ * - chip-specific post-running code called from cpu_hatch via lsw_cpu_run
+ */
+void
+cpu_rmixl_run(struct cpu_info *ci)
+{
+	struct rmixl_cpu_softc * const sc = (void *)ci-ci_softc;
+	cpucore_rmixl_run(device_parent(sc-sc_dev));
+}
+
+/*
  * cpu_rmixl_hatch
  *
  * - chip-specific hatch code called from cpu_hatch via lsw_cpu_init
@@ -318,9 +336,7 @@
 
 	cpucore_rmixl_hatch(device_parent(sc-sc_dev));
 
-#if defined(DDB)  defined(MIPS_DDB_WATCH)
 	cpu_rmixl_db_watch_init();
-#endif
 }
 
 static int
@@ -359,8 +375,8 @@
 	 *   RMI firmware only passes the lower 32-bit half of 'ta'
 	 *   to rmixl_cpu_trampoline (the upper half is clear)
 	 *   so rmixl_cpu_trampoline must reconstruct the missing upper half
-	 *   rmixl_cpu_trampoline knows to use MIPS_KSEG0_START
-	 *   to reconstruct upper half of 'ta'.
+	 *   rmixl_cpu_trampoline knows 'ta' is a KSEG0 address
+	 *   and sign-extends to make an LP64 KSEG0 address.
 	 */
 	KASSERT(MIPS_KSEG0_P(ta));
 



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:14:23 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_cpucore.c

Log Message:
- in cpucore_rmixl_attach(), keep track of which threads are
enabled by firmware and configured and attach, or not.
- add cpucore_rmixl_run() to do the post-running initialization:
disable unused threads in RMIXL_PCR_THREADEN, and
set Round Robin thread scheduling mode.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/rmi/rmixl_cpucore.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/mips/rmi/rmixl_cpucore.c
diff -u src/sys/arch/mips/rmi/rmixl_cpucore.c:1.2 src/sys/arch/mips/rmi/rmixl_cpucore.c:1.3
--- src/sys/arch/mips/rmi/rmixl_cpucore.c:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_cpucore.c	Thu Apr 14 05:14:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpucore.c,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_cpucore.c,v 1.3 2011/04/14 05:14:23 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpucore.c,v 1.2 2011/02/20 07:48:37 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpucore.c,v 1.3 2011/04/14 05:14:23 cliff Exp $);
 
 #include opt_multiprocessor.h
 
@@ -145,25 +145,44 @@
 		(u_int)(rcp-rc_psb_info.userapp_cpu_map  core_shft)  thread_mask;
 	u_int threads_dis = (~threads_enb)  thread_mask;
 
+	sc-sc_threads_dis = threads_dis;
 	if (threads_dis != 0) {
 		aprint_normal_dev(self, threads);
-		while (threads_dis != 0) {
-			u_int t = ffs(threads_dis) - 1;
-			threads_dis ^= (1  t);
-			aprint_normal( %d%s,
-t, (threads_dis==0) ?  : ,);
+		u_int d = threads_dis;
+		while (d != 0) {
+			u_int t = ffs(d) - 1;
+			d ^= (1  t);
+			aprint_normal( %d%s, t, (d==0) ?  : ,);
 		}
 		aprint_normal( offline (disabled by firmware)\n);
 	}
 
-	while (threads_enb != 0) {
-		u_int t = ffs(threads_enb) - 1;
-		threads_enb ^= (1  t);
+	u_int threads_try_attach = threads_enb;
+	while (threads_try_attach != 0) {
+		u_int t = ffs(threads_try_attach) - 1;
+		threads_try_attach ^= (1  t);
 		ca.ca_name = cpu;
 		ca.ca_thread = t;
 		ca.ca_core = sc-sc_core;
-		config_found(self, ca, cpucore_rmixl_print);
+		if (config_found(self, ca, cpucore_rmixl_print) == NULL) {
+			/*
+			 * thread did not attach, e.g. not configured
+			 * arrange to have it disabled in THREADEN PCR
+			 */
+			u_int bit = 1  t;
+			threads_enb ^= bit;
+			threads_dis |= bit;
+		}
 	}
+	sc-sc_threads_enb = threads_enb;
+	sc-sc_threads_dis = threads_dis;
+
+	/*
+	 * when attaching the core of the primary cpu,
+	 * do the post-running initialization here
+	 */
+	if (sc-sc_core == RMIXL_CPU_CORE((curcpu()-ci_cpuid)))
+		cpucore_rmixl_run(self);
 }
 
 static int
@@ -178,6 +197,25 @@
 	return (UNCONF);
 }
 
+/*
+ * cpucore_rmixl_run
+ *	called from cpu_rmixl_hatch for each cpu
+ *	the first call for each cpucore causes init of per-core features:
+ *	- disable unused threads
+ *	- set Fine-grained (Round Robin) thread scheduling mode
+ */
+void
+cpucore_rmixl_run(device_t self)
+{
+	struct cpucore_softc * const sc = device_private(self);
+
+	if (sc-sc_running == false) {
+		sc-sc_running = true;
+		rmixl_mtcr(RMIXL_PCR_THREADEN, sc-sc_threads_enb);
+		rmixl_mtcr(RMIXL_PCR_SCHEDULING, 0);
+	}
+}
+
 #ifdef MULTIPROCESSOR
 /*
  * cpucore_rmixl_hatch



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:15:22 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_cpucorevar.h

Log Message:
- add sc_running flag to allow cpucore_rmixl_run() to do once-per-core
initializations once we know what threads are configured
- add sc_threads_enb and sc_threads_dis to track what threads are
enabled by firmware and configured and attach, or not.
- add prototype for cpucore_rmixl_run()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/rmi/rmixl_cpucorevar.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixl_cpucorevar.h
diff -u src/sys/arch/mips/rmi/rmixl_cpucorevar.h:1.2 src/sys/arch/mips/rmi/rmixl_cpucorevar.h:1.3
--- src/sys/arch/mips/rmi/rmixl_cpucorevar.h:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_cpucorevar.h	Thu Apr 14 05:15:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpucorevar.h,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_cpucorevar.h,v 1.3 2011/04/14 05:15:22 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,10 @@
 struct cpucore_softc {
 	device_t	sc_dev;
 	bool		sc_attached;
+	bool		sc_running;
 	u_int		sc_core;
+	u_int		sc_threads_enb;
+	u_int		sc_threads_dis;
 	bool		sc_hatched;
 #ifdef MULTIPROCESSOR
 	struct pmap_tlb_info *sc_tlbinfo;
@@ -52,5 +55,6 @@
 };
 
 extern void cpucore_rmixl_hatch(device_t);
+extern void cpucore_rmixl_run(device_t);
 
 #endif	/* _ARCH_MIPS_RMI_RMIXL_CPUCOREVAR_H_ */



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:16:00 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_intr.c

Log Message:
- in evbmips_iointr(), call assembly function rmixl_eirr_ack()
to ack the EIRR, instead of using a bunch of asm() here.
- in rmixl_ipi_intr(), remove overly paranoid assert that the given
IPI request is pending; if the request is clear, it was previously processed.
- in rmixl_vecnames_common[], give ipi vectors unique (numbered) names


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixl_intr.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/mips/rmi/rmixl_intr.c
diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.3 src/sys/arch/mips/rmi/rmixl_intr.c:1.4
--- src/sys/arch/mips/rmi/rmixl_intr.c:1.3	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.c	Thu Apr 14 05:16:00 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.c,v 1.3 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_intr.c,v 1.4 2011/04/14 05:16:00 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.3 2011/02/20 07:48:37 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.4 2011/04/14 05:16:00 cliff Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -292,15 +292,15 @@
 	vec 5,		/*  5 */
 	vec 6,		/*  6 */
 	vec 7,		/*  7 */
-	vec 8 (ipi),		/*  8 */
-	vec 9 (ipi),		/*  9 */
-	vec 10 (ipi),		/* 10 */
-	vec 11 (ipi),		/* 11 */
-	vec 12 (ipi),		/* 12 */
-	vec 13 (ipi),		/* 13 */
-	vec 14 (ipi),		/* 14 */
-	vec 15 (ipi),		/* 15 */
-	vec 16 (fmn),		/* 16 */
+	vec 8 (ipi 0),	/*  8 */
+	vec 9 (ipi 1),	/*  9 */
+	vec 10 (ipi 2),	/* 10 */
+	vec 11 (ipi 3),	/* 11 */
+	vec 12 (ipi 4),	/* 12 */
+	vec 13 (ipi 5),	/* 13 */
+	vec 14 (ipi 6),	/* 14 */
+	vec 15 (fmn),		/* 15 */
+	vec 16,		/* 16 */
 	vec 17,		/* 17 */
 	vec 18,		/* 18 */
 	vec 19,		/* 19 */
@@ -920,18 +920,10 @@
 		KASSERT ((vecbit  RMIXL_EIRR_PRESERVE_MASK) == 0);
 
 		/*
-		 * ack in EIRR the irq we are about to handle
-		 * disable all interrupt to prevent a race that would allow
-		 * e.g. softints set from a higher interrupt getting
-		 * clobbered by the EIRR read-modify-write 
+		 * ack in EIRR, and in PIC if needed,
+		 * the irq we are about to handle
 		 */
-		asm volatile(dmtc0 $0, $9, 7;);
-		asm volatile(dmfc0 %0, $9, 6; : =r(eirr));
-		eirr = RMIXL_EIRR_PRESERVE_MASK;
-		eirr |= vecbit;
-		asm volatile(dmtc0 %0, $9, 6; :: r(eirr));
-		asm volatile(dmtc0 %0, $9, 7; :: r(eimr));
-
+		rmixl_eirr_ack(eimr, vecbit, RMIXL_EIRR_PRESERVE_MASK);
 		if (RMIXL_VECTOR_IS_IRT(vec))
 			RMIXL_PICREG_WRITE(RMIXL_PIC_INTRACK,
 1  RMIXL_VECTOR_IRT(vec));
@@ -993,12 +985,14 @@
 rmixl_ipi_intr(void *arg)
 {
 	struct cpu_info * const ci = curcpu();
+	const uint64_t ipi_mask = 1  (uintptr_t)arg;
 
 	KASSERT(ci-ci_cpl = IPL_SCHED);
-
 	KASSERT((uintptr_t)arg  NIPIS);
-	const uint64_t ipi_mask = 1  (uintptr_t)arg;
-	KASSERT((ci-ci_request_ipis  ipi_mask) != 0);
+
+	/* if the request is clear, it was previously processed */
+	if ((ci-ci_request_ipis  ipi_mask) == 0)
+		return 0;
 
 	atomic_or_64(ci-ci_active_ipis, ipi_mask);
 	atomic_and_64(ci-ci_request_ipis, ~ipi_mask);



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:16:28 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_intr.h

Log Message:
- add compile time check in case NIPIS ever exceeds number of available vectors


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/rmi/rmixl_intr.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixl_intr.h
diff -u src/sys/arch/mips/rmi/rmixl_intr.h:1.2 src/sys/arch/mips/rmi/rmixl_intr.h:1.3
--- src/sys/arch/mips/rmi/rmixl_intr.h:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.h	Thu Apr 14 05:16:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.h,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_intr.h,v 1.3 2011/04/14 05:16:28 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -56,7 +56,12 @@
 /*
  * vectors (0 = vec  8)  are CAUSE[8..15] (including softintrs and count/compare)
  * vectors (8 = vec  31) are for other non-IRT based interrupts
+ * we use one for FMN, and each IPI currently gets own vector;
+ * if NIPIS = (32 - 8 - 1), then redesign so IPIs share vector(s)
  */
+#if NIPIS = 23
+# error too many IPIs
+#endif
 #define RMIXL_INTRVEC_IPI	8
 #define RMIXL_INTRVEC_FMN	(RMIXL_INTRVEC_IPI + NIPIS)
 



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:20:53 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_usbi.c

Log Message:
- report of BIST result is information only; don't fail attach because of it


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/rmi/rmixl_usbi.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/mips/rmi/rmixl_usbi.c
diff -u src/sys/arch/mips/rmi/rmixl_usbi.c:1.2 src/sys/arch/mips/rmi/rmixl_usbi.c:1.3
--- src/sys/arch/mips/rmi/rmixl_usbi.c:1.2	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixl_usbi.c	Thu Apr 14 05:20:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_usbi.c,v 1.2 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixl_usbi.c,v 1.3 2011/04/14 05:20:52 cliff Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_usbi.c,v 1.2 2011/02/20 07:48:37 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_usbi.c,v 1.3 2011/04/14 05:20:52 cliff Exp $);
 
 #include locators.h
 
@@ -148,10 +148,10 @@
 r = RMIXL_IOREG_READ(RMIXL_IO_DEV_GPIO + RMIXL_GPIO_BIST_EACH_STS);
 	aprint_normal(: BIST status=);
 	if ((r  __BIT(18)) == 0) {			/* XXX USB_BIST */
-		aprint_normal(FAIL\n);
-		return;
+		aprint_normal(FAIL,);
+	} else {
+		aprint_normal(OK,);
 	}
-	aprint_normal(OK);
 
 	/*
 	 * set BYTESWAP_EN register nonzero when software is little endian



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:21:22 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixlvar.h

Log Message:
- add prototype for rmixl_eirr_ack()


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/rmi/rmixlvar.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixlvar.h
diff -u src/sys/arch/mips/rmi/rmixlvar.h:1.4 src/sys/arch/mips/rmi/rmixlvar.h:1.5
--- src/sys/arch/mips/rmi/rmixlvar.h:1.4	Fri Mar 18 00:58:54 2011
+++ src/sys/arch/mips/rmi/rmixlvar.h	Thu Apr 14 05:21:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixlvar.h,v 1.4 2011/03/18 00:58:54 cliff Exp $	*/
+/*	$NetBSD: rmixlvar.h,v 1.5 2011/04/14 05:21:22 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -164,6 +164,7 @@
 
 extern uint64_t rmixl_mfcr(u_int);
 extern void rmixl_mtcr(uint64_t, u_int);
+extern void rmixl_eirr_ack(uint64_t, uint64_t, uint64_t);
 
 
 /*



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:22:03 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_pcie.c

Log Message:
- in rmixl_pcie_intr_string(), convert irq to vector when calling
rmixl_intr_string()


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/rmi/rmixl_pcie.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/mips/rmi/rmixl_pcie.c
diff -u src/sys/arch/mips/rmi/rmixl_pcie.c:1.4 src/sys/arch/mips/rmi/rmixl_pcie.c:1.5
--- src/sys/arch/mips/rmi/rmixl_pcie.c:1.4	Mon Apr  4 20:37:52 2011
+++ src/sys/arch/mips/rmi/rmixl_pcie.c	Thu Apr 14 05:22:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_pcie.c,v 1.4 2011/04/04 20:37:52 dyoung Exp $	*/
+/*	$NetBSD: rmixl_pcie.c,v 1.5 2011/04/14 05:22:03 cliff Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_pcie.c,v 1.4 2011/04/04 20:37:52 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_pcie.c,v 1.5 2011/04/14 05:22:03 cliff Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -1112,7 +1112,7 @@
 		switch (irq) {
 		case 26:
 		case 27:
-			name = rmixl_intr_string(irq);
+			name = rmixl_intr_string(RMIXL_IRT_VECTOR(irq));
 			break;
 		}
 		break;
@@ -1123,7 +1123,7 @@
 		case 24:
 		case 26:
 		case 27:
-			name = rmixl_intr_string(irq);
+			name = rmixl_intr_string(RMIXL_IRT_VECTOR(irq));
 			break;
 		}
 		break;
@@ -1137,7 +1137,7 @@
 		case 27:
 		case 28:
 		case 29:
-			name = rmixl_intr_string(irq);
+			name = rmixl_intr_string(RMIXL_IRT_VECTOR(irq));
 			break;
 		}
 		break;



CVS commit: src/sys/arch/mips/rmi

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:22:47 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_pcix.c

Log Message:
- in rmixl_pcix_intr_string() convert irq to vector when calling
rmixl_intr_string()
- in rmixl_pcix_intr_establish(), initialize dispatch data 'counts' pointer
- in rmixl_pcix_pip_add_1(), zero out pip_new after allocated.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/rmi/rmixl_pcix.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/mips/rmi/rmixl_pcix.c
diff -u src/sys/arch/mips/rmi/rmixl_pcix.c:1.4 src/sys/arch/mips/rmi/rmixl_pcix.c:1.5
--- src/sys/arch/mips/rmi/rmixl_pcix.c:1.4	Wed Apr 13 21:06:30 2011
+++ src/sys/arch/mips/rmi/rmixl_pcix.c	Thu Apr 14 05:22:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_pcix.c,v 1.4 2011/04/13 21:06:30 cliff Exp $	*/
+/*	$NetBSD: rmixl_pcix.c,v 1.5 2011/04/14 05:22:47 cliff Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.4 2011/04/13 21:06:30 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_pcix.c,v 1.5 2011/04/14 05:22:47 cliff Exp $);
 
 #include opt_pci.h
 #include pci.h
@@ -797,7 +797,7 @@
 		panic(%s: cpu %#x not supported\n,
 			__func__, mips_options.mips_cpu_id);
 
-	return rmixl_intr_string(irq);
+	return rmixl_intr_string(RMIXL_IRT_VECTOR(irq));
 }
 
 const struct evcnt *
@@ -925,6 +925,7 @@
 	dip-irq = irq;
 	dip-func = func;
 	dip-arg = arg;
+	dip-counts = RMIXL_PCIX_EVCNT(sc, bitno, 0);
 #if NEVER
 	snprintf(dip-count_name, sizeof(dip-count_name),
 		pin %d, bitno + 1);
@@ -990,6 +991,8 @@
 		return NULL;
 	}
 
+	memset(pip_new, 0, size);
+
 	if (pip_old == NULL) {
 		/* initialize the interrupt struct */
 		pip_new-sc = sc;



CVS commit: src/sys/arch/mips/mips

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:50:44 UTC 2011

Modified Files:
src/sys/arch/mips/mips: locore_mips1.S

Log Message:
- add loocoresw slot for lsw_cpu_run
- fix comments for locoresw entries


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/mips/mips/locore_mips1.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/mips/mips/locore_mips1.S
diff -u src/sys/arch/mips/mips/locore_mips1.S:1.77 src/sys/arch/mips/mips/locore_mips1.S:1.78
--- src/sys/arch/mips/mips/locore_mips1.S:1.77	Wed Apr  6 14:12:36 2011
+++ src/sys/arch/mips/mips/locore_mips1.S	Thu Apr 14 05:50:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_mips1.S,v 1.77 2011/04/06 14:12:36 tsutsui Exp $	*/
+/*	$NetBSD: locore_mips1.S,v 1.78 2011/04/14 05:50:43 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -1697,12 +1697,13 @@
 
 	.globl _C_LABEL(MIPSX(locoresw))
 _C_LABEL(MIPSX(locoresw)):
-	PTR_WORD _C_LABEL(MIPSX(wbflush))		# wbflush
-	PTR_WORD _C_LABEL(nullop)			# idle
-	PTR_WORD _C_LABEL(nullop)			# send ipi
-	PTR_WORD _C_LABEL(nullop)			# cpu_offline_md
-	PTR_WORD _C_LABEL(nullop)			# spare
-	PTR_WORD _C_LABEL(nullop)			# spare
+	PTR_WORD _C_LABEL(MIPSX(wbflush))		# lsw_wbflush
+	PTR_WORD _C_LABEL(nullop)			# lsw_cpu_idle
+	PTR_WORD _C_LABEL(nullop)			# lsw_send_ipi
+	PTR_WORD _C_LABEL(nullop)			# lsw_cpu_offline_md
+	PTR_WORD _C_LABEL(nullop)			# lsw_cpu_init
+	PTR_WORD _C_LABEL(nullop)			# lsw_cpu_run
+	PTR_WORD _C_LABEL(nullop)			# lsw_bus_error
 
 MIPSX(excpt_sw):
 	



CVS commit: src/sys/arch/mips/mips

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:51:28 UTC 2011

Modified Files:
src/sys/arch/mips/mips: mipsX_subr.S

Log Message:
- add loocoresw slot for lsw_cpu_run
- fix comments for locoresw fields


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/mips/mips/mipsX_subr.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/mips/mips/mipsX_subr.S
diff -u src/sys/arch/mips/mips/mipsX_subr.S:1.43 src/sys/arch/mips/mips/mipsX_subr.S:1.44
--- src/sys/arch/mips/mips/mipsX_subr.S:1.43	Wed Apr  6 14:04:32 2011
+++ src/sys/arch/mips/mips/mipsX_subr.S	Thu Apr 14 05:51:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mipsX_subr.S,v 1.43 2011/04/06 14:04:32 tsutsui Exp $	*/
+/*	$NetBSD: mipsX_subr.S,v 1.44 2011/04/14 05:51:27 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -2569,12 +2569,13 @@
 
 	.globl _C_LABEL(MIPSX(locoresw))
 _C_LABEL(MIPSX(locoresw)):
-	PTR_WORD _C_LABEL(MIPSX(wbflush)) # wbflush
-	PTR_WORD _C_LABEL(nullop)	# cpu_idle
-	PTR_WORD _C_LABEL(nullop)	# send ipi
-	PTR_WORD _C_LABEL(nullop)	# cpu_offline_md
-	PTR_WORD _C_LABEL(nullop)	# cpu_init_md
-	PTR_WORD _C_LABEL(nullop)	# lsw_bus_error
+	PTR_WORD _C_LABEL(MIPSX(wbflush))	# lsw_wbflush
+	PTR_WORD _C_LABEL(nullop)		# lsw_cpu_idle
+	PTR_WORD _C_LABEL(nullop)		# lsw_send_ipi
+	PTR_WORD _C_LABEL(nullop)		# lsw_cpu_offline_md
+	PTR_WORD _C_LABEL(nullop)		# lsw_cpu_init
+	PTR_WORD _C_LABEL(nullop)		# lsw_cpu_run
+	PTR_WORD _C_LABEL(nullop)		# lsw_bus_error
 
 MIPSX(excpt_sw):
 	



CVS commit: src/sys/arch/mips/mips

2011-04-13 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Thu Apr 14 05:54:24 UTC 2011

Modified Files:
src/sys/arch/mips/mips: cpu_subr.c

Log Message:
- no need to check lsw_cpu_run != NULL before calling, nullop is default


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/mips/cpu_subr.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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.7 src/sys/arch/mips/mips/cpu_subr.c:1.8
--- src/sys/arch/mips/mips/cpu_subr.c:1.7	Thu Apr 14 05:08:51 2011
+++ src/sys/arch/mips/mips/cpu_subr.c	Thu Apr 14 05:54:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_subr.c,v 1.7 2011/04/14 05:08:51 cliff Exp $	*/
+/*	$NetBSD: cpu_subr.c,v 1.8 2011/04/14 05:54:24 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.7 2011/04/14 05:08:51 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.8 2011/04/14 05:54:24 cliff Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -936,8 +936,7 @@
 	 * Let this CPU do its own post-running initialization
 	 * (for things that have to be done on the local CPU).
 	 */
-	if (mips_locoresw.lsw_cpu_run != NULL)
-		(*mips_locoresw.lsw_cpu_run)(ci);
+	(*mips_locoresw.lsw_cpu_run)(ci);
 
 	/*
 	 * Now turn on interrupts.



CVS commit: src/sys/compat/netbsd32

2011-03-19 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Mar 19 13:47:43 UTC 2011

Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.h

Log Message:
include flashio.h


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/compat/netbsd32/netbsd32_ioctl.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/compat/netbsd32/netbsd32_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.32 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.33
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.32	Sat Mar 19 04:07:35 2011
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h	Sat Mar 19 13:47:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.h,v 1.32 2011/03/19 04:07:35 cliff Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.h,v 1.33 2011/03/19 13:47:43 cliff Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -29,6 +29,7 @@
 #include sys/device.h
 #include sys/disklabel.h
 #include sys/disk.h
+#include sys/flashio.h
 
 #include net/zlib.h
 



CVS commit: src/./sys/arch/mips/rmi

2011-03-18 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 07:12:29 UTC 2011

Modified Files:
src/./sys/arch/mips/rmi: rmixl_iobus_space.c

Log Message:
RMIXL_FLASH_BAR_MASK_MAX is __BITS(34,0)
so avoid using extent if that value overflows 'long'


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/./sys/arch/mips/rmi/rmixl_iobus_space.c

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

Modified files:




CVS commit: src/./sys/arch/mips/rmi

2011-03-18 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 19:58:21 UTC 2011

Modified Files:
src/./sys/arch/mips/rmi: rmixl_nand.c

Log Message:
style improvements, input from matt@


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/./sys/arch/mips/rmi/rmixl_nand.c

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

Modified files:




CVS commit: src/./sys/arch/mips/rmi

2011-03-18 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 20:23:26 UTC 2011

Modified Files:
src/./sys/arch/mips/rmi: rmixl_nand.c

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/./sys/arch/mips/rmi/rmixl_nand.c

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

Modified files:




CVS commit: src/sys/compat/netbsd32

2011-03-18 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Mar 19 04:07:36 UTC 2011

Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.c netbsd32_ioctl.h

Log Message:
compat/netbsd32 ioctl support for FLASH_GET_INFO


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/compat/netbsd32/netbsd32_ioctl.c
cvs rdiff -u -r1.31 -r1.32 src/sys/compat/netbsd32/netbsd32_ioctl.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/compat/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.54 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.55
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.54	Tue Feb  1 00:53:22 2011
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Sat Mar 19 04:07:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.54 2011/02/01 00:53:22 matt Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.55 2011/03/19 04:07:35 cliff Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: netbsd32_ioctl.c,v 1.54 2011/02/01 00:53:22 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: netbsd32_ioctl.c,v 1.55 2011/03/19 04:07:35 cliff Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -51,6 +51,7 @@
 #include sys/ktrace.h
 #include sys/kmem.h
 #include sys/envsys.h
+#include sys/flashio.h
 
 #ifdef __sparc__
 #include dev/sun/fbio.h
@@ -442,6 +443,25 @@
 	*s32p = (netbsd32_u_long)*p;
 }
 
+static inline void
+netbsd32_to_flash_info_params(struct netbsd32_flash_info_params *s32p,
+	struct flash_info_params *p, u_long cmd)
+{
+	p-ip_flash_size = s32p-ip_flash_size;
+	p-ip_page_size = (size_t)s32p-ip_page_size;
+	p-ip_erase_size = (size_t)s32p-ip_erase_size;
+	p-ip_flash_type = s32p-ip_flash_type;
+}
+
+static inline void
+netbsd32_from_flash_info_params(struct flash_info_params *p,
+	struct netbsd32_flash_info_params *s32p, u_long cmd)
+{
+	s32p-ip_flash_size = p-ip_flash_size;
+	s32p-ip_page_size = (netbsd32_size_t)p-ip_page_size;
+	s32p-ip_erase_size = (netbsd32_size_t)p-ip_erase_size;
+	s32p-ip_flash_type = p-ip_flash_type;
+}
 
 /*
  * main ioctl syscall.
@@ -744,6 +764,9 @@
 	case ENVSYS_REMOVEPROPS32:
 		IOCTL_STRUCT_CONV_TO(ENVSYS_REMOVEPROPS, plistref);
 
+	case FLASH_GET_INFO32:
+		IOCTL_STRUCT_CONV_TO(FLASH_GET_INFO, flash_info_params);
+
 	default:
 #ifdef NETBSD32_MD_IOCTL
 		error = netbsd32_md_ioctl(fp, com, data32, l);

Index: src/sys/compat/netbsd32/netbsd32_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.31 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.32
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.31	Sun Mar  6 17:08:34 2011
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h	Sat Mar 19 04:07:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.h,v 1.31 2011/03/06 17:08:34 bouyer Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.h,v 1.32 2011/03/19 04:07:35 cliff Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -393,3 +393,11 @@
 #define ENVSYS_SETDICTIONARY32	_IOWR('E', 1, struct netbsd32_plistref)
 #define ENVSYS_REMOVEPROPS32	_IOWR('E', 2, struct netbsd32_plistref)
 
+/* from sys/flashio.h */
+struct netbsd32_flash_info_params {
+	flash_addr_t ip_flash_size;
+	netbsd32_size_t ip_page_size;
+	netbsd32_size_t ip_erase_size;
+	uint8_t ip_flash_type;
+};
+#define FLASH_GET_INFO32	 _IOWR('', 2, struct netbsd32_flash_info_params)



CVS commit: src/sys/dev/nand

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 00:57:51 UTC 2011

Modified Files:
src/sys/dev/nand: nand_micron.c

Log Message:
- add suport for MT29FxGx family devices


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/nand/nand_micron.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/nand/nand_micron.c
diff -u src/sys/dev/nand/nand_micron.c:1.1 src/sys/dev/nand/nand_micron.c:1.2
--- src/sys/dev/nand/nand_micron.c:1.1	Wed Mar  9 10:05:08 2011
+++ src/sys/dev/nand/nand_micron.c	Fri Mar 18 00:57:51 2011
@@ -39,39 +39,123 @@
 #include nand.h
 #include onfi.h
 
+#define MT29F2G08AAC	0xda
+#define MT29F2G08ABC	0xaa
+#define MT29F2G16AAC	0xca
+#define MT29F2G16ABC	0xba
+#define MT29F4G08BAC	0xdc
+#define MT29F8G08FAC	0xdc		/* each 4GB section */
+
+#define MT29FxG_PARAM_WIDTH(p)		(((p)  1)  __BIT(0))
+#define MT29FxG_PAGESIZE		(2 * 1024)
+#define MT29FxG_BLOCK_PAGES		64		/* pages per block */
+#define MT29FxG_BLOCKSIZE		(128 * 1024)	/* not including spares */
+#define MT29FxG_SPARESIZE		64
+
+struct nand_micron_devices {
+	const char *name;
+	uint8_t	id;
+	uint8_t width;			/* bus width */
+	u_int lun_blocks;		/* number of blocks per LUN */
+	u_int num_luns;			/* number LUNs */
+};
+
+static const struct nand_micron_devices nand_micron_devices[] = {
+	{ MT29F2G08AAC, MT29F2G08AAC,  8,  2048, 1 },
+	{ MT29F2G08ABC, MT29F2G08ABC,  8,  2048, 1 },
+	{ MT29F2G16AAC, MT29F2G16AAC, 16,  2048, 1 },
+	{ MT29F2G16ABC, MT29F2G16ABC, 16,  2048, 1 },
+	{ MT29F4G08BAC, MT29F4G08BAC,  8,  4096, 1 },
+#ifdef NOTYET
+	/* how do we recognize/match this? */
+	{ MT29F8G08FAC, MT29F8G08FAC,  8,  4096, 2 },
+#endif
+};
+
+static int mt29fxgx_parameters(device_t, struct nand_chip *, u_int8_t, uint8_t);
+
+static const struct nand_micron_devices *
+nand_micron_device_lookup(u_int8_t id)
+{
+	for (int i=0; i  __arraycount(nand_micron_devices); i++)
+		if (nand_micron_devices[i].id == id)
+			return nand_micron_devices[i];
+	return NULL;
+}
+
 int
 nand_read_parameters_micron(device_t self, struct nand_chip *chip)
 {
-	uint8_t byte;
+	uint8_t mfgrid;
+	uint8_t devid;
+	uint8_t dontcare;
+	uint8_t params;
 
 	KASSERT(chip-nc_manf_id == NAND_MFR_MICRON);
+	switch (chip-nc_manf_id) {
+	case NAND_MFR_MICRON:
+		break;
+	default:
+		return 1;
+	}
 
 	nand_select(self, true);
 	nand_command(self, ONFI_READ_ID);
 	nand_address(self, 0x00);
+	nand_read_byte(self, mfgrid);
+	nand_read_byte(self, devid);
+	nand_read_byte(self, dontcare);
+	nand_read_byte(self, params);
+	nand_select(self, false);
 
-	switch (chip-nc_manf_id) {
-		/* three dummy reads */
-		nand_read_byte(self, byte); /* vendor */
-		nand_read_byte(self, byte); /* device */
-		nand_read_byte(self, byte); /* unused */
-
-		/* this is the interesting one */
-		nand_read_byte(self, byte);
-		/* TODO actually get info */
-		nand_select(self, false);
-		return 1;
-		
-		break;
+	KASSERT(chip-nc_manf_id == mfgrid);
+
+	switch(devid) {
+	case MT29F2G08AAC:
+	case MT29F2G08ABC:
+	case MT29F2G16AAC:
+	case MT29F2G16ABC:
+	case MT29F4G08BAC:
+		return mt29fxgx_parameters(self, chip, devid, params);
 	default:
-		nand_select(self, false);
+		aprint_error_dev(self, unsupported device id %#x\n, devid);
 		return 1;
 	}
-	
-	chip-nc_num_luns = 1;
-	chip-nc_lun_blocks = chip-nc_size / chip-nc_block_size;
+}
 
-	nand_select(self, false);
+static int
+mt29fxgx_parameters(device_t self, struct nand_chip *chip,
+	u_int8_t devid, uint8_t params)
+{
+	const struct nand_micron_devices *dp;
+	const char *vendor = Micron;
+
+	dp = nand_micron_device_lookup(devid);
+	if (dp == NULL) {
+		aprint_error_dev(self, unknown device id %#x\n, devid); 
+		return 1;
+	}
+
+	/*
+	 * MT29FxGx params across models are the same
+	 * except for luns, blocks per lun, and bus width
+	 * (and voltage)
+	 */
+	chip-nc_addr_cycles_column = 2;	/* XXX */
+	chip-nc_addr_cycles_row = 3;		/* XXX */
+	if (dp-width == 16)
+		chip-nc_flags |= NC_BUSWIDTH_16;
+	chip-nc_page_size = MT29FxG_PAGESIZE;
+	chip-nc_block_pages = MT29FxG_BLOCK_PAGES;
+	chip-nc_block_size = MT29FxG_BLOCK_PAGES * MT29FxG_PAGESIZE;
+	chip-nc_spare_size = MT29FxG_SPARESIZE;
+	chip-nc_lun_blocks = dp-lun_blocks;
+	chip-nc_num_luns = dp-num_luns;
+	chip-nc_size = MT29FxG_PAGESIZE * MT29FxG_BLOCK_PAGES *
+		dp-lun_blocks * dp-num_luns;
+
+	aprint_normal_dev(self, %s %s, size %ldMB\n,
+		vendor, dp-name, chip-nc_size  20);
 
 	return 0;
 }



CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 00:58:35 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixlreg.h

Log Message:
- add register  bit defines for GPIO, Peripherals IO Bus, Flash, NAND


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixlreg.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixlreg.h
diff -u src/sys/arch/mips/rmi/rmixlreg.h:1.3 src/sys/arch/mips/rmi/rmixlreg.h:1.4
--- src/sys/arch/mips/rmi/rmixlreg.h:1.3	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixlreg.h	Fri Mar 18 00:58:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixlreg.h,v 1.3 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixlreg.h,v 1.4 2011/03/18 00:58:35 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -262,7 +262,7 @@
 #define RMIXL_IO_DEV_I2C_1	0x16000	/* I2C_1 */
 #define RMIXL_IO_DEV_I2C_2	0x17000	/* I2C_2 */
 #define RMIXL_IO_DEV_GPIO	0x18000	/* GPIO */
-#define RMIXL_IO_DEV_FLASH	0x19000	/* Flash ROM */
+#define RMIXL_IO_DEV_FLASH	0x19000	/* Peripherals IO Bus, to Flash memory etc. */
 #define RMIXL_IO_DEV_DMA	0x1a000	/* DMA */
 #define RMIXL_IO_DEV_L2		0x1b000	/* L2 Cache */
 #define RMIXL_IO_DEV_TB		0x1c000	/* Trace Buffer */
@@ -303,9 +303,11 @@
 #define RMIXL_SBC_DRAM_CHNBD_DTR(n)	_RMIXL_OFFSET(0x010 + (n))
 	/* DRAM Region Channels B,D Address Translation Regs[0-7] */
 #define RMIXL_SBC_DRAM_BRIDGE_CFG	_RMIXL_OFFSET(0x18)	/* SBC DRAM config reg */
+
+#define RMIXL_SBC_IO_BAR		_RMIXL_OFFSET(0x19)	/* I/O Config Base Addr reg */
+#define RMIXL_SBC_FLASH_BAR		_RMIXL_OFFSET(0x1a)	/* Flash Memory Base Addr reg */
+
 #if defined(MIPS64_XLR)
-#define RMIXLR_SBC_IO_BAR		_RMIXL_OFFSET(0x19)	/* I/O Config Base Addr reg */
-#define RMIXLR_SBC_FLASH_BAR		_RMIXL_OFFSET(0x1a)	/* Flash Memory Base Addr reg */
 #define RMIXLR_SBC_SRAM_BAR		_RMIXL_OFFSET(0x1b)	/* SRAM Base Addr reg */
 #define RMIXLR_SBC_HTMEM_BAR		_RMIXL_OFFSET(0x1c)	/* HyperTransport Mem Base Addr reg */
 #define RMIXLR_SBC_HTINT_BAR		_RMIXL_OFFSET(0x1d)	/* HyperTransport Interrupt Base Addr reg */
@@ -319,8 +321,6 @@
 #define RMIXLR_SBC_SYS2IO_CREDITS	_RMIXL_OFFSET(0x35)	/* System Bridge I/O Transaction Credits register */
 #endif	/* MIPS64_XLR */
 #if defined(MIPS64_XLS)
-#define RMIXLS_SBC_IO_BAR		_RMIXL_OFFSET(0x19)	/* I/O Config Base Addr reg */
-#define RMIXLS_SBC_FLASH_BAR		_RMIXL_OFFSET(0x20)	/* Flash Memory Base Addr reg */
 #define RMIXLS_SBC_PCIE_CFG_BAR		_RMIXL_OFFSET(0x40)	/* PCI Configuration BAR */
 #define RMIXLS_SBC_PCIE_ECFG_BAR	_RMIXL_OFFSET(0x41)	/* PCI Extended Configuration BAR */
 #define RMIXLS_SBC_PCIE_MEM_BAR		_RMIXL_OFFSET(0x42)	/* PCI Memory region BAR */
@@ -350,6 +350,19 @@
 #define RMIXL_ADDR_ERR_BITERR_INT_EN	_RMIXL_OFFSET(0x33)	/* Bit Error intr enable */
 
 /*
+ * RMIXL_SBC_FLASH_BAR bit defines
+ */
+#define RMIXL_FLASH_BAR_BASE		__BITS(31,16)	/* phys address bits 39:24 */
+#define RMIXL_FLASH_BAR_TO_BA(r)	\
+		(((r)  RMIXL_FLASH_BAR_BASE)  (24 - 16))
+#define RMIXL_FLASH_BAR_MASK		__BITS(15,5)	/* phys address mask bits 34:24 */
+#define RMIXL_FLASH_BAR_TO_MASK(r)	\
+		(r)  RMIXL_FLASH_BAR_MASK))  (24 - 5)) | __BITS(23, 0))
+#define RMIXL_FLASH_BAR_RESV		__BITS(4,1)	/* (reserved) */
+#define RMIXL_FLASH_BAR_ENB		__BIT(0)	/* 1=Enable */
+#define RMIXL_FLASH_BAR_MASK_MAX	RMIXL_FLASH_BAR_TO_MASK(RMIXL_FLASH_BAR_MASK)
+
+/*
  * RMIXL_SBC_DRAM_BAR bit defines
  */
 #define RMIXL_DRAM_BAR_BASE_ADDR	__BITS(31,16)	/* bits 39:24 of Base Address */
@@ -429,7 +442,6 @@
 #define RMIXL_PCIX_IO_BAR(ba, en)	\
 		((uint32_t)(((ba)  (26 - 18)) | ((en) ? RMIXL_PCIX_IO_BAR_ENB : 0)))
 
-
 /*
  * RMIXLS_SBC_PCIE_CFG_BAR bit defines
  */
@@ -563,18 +575,92 @@
 
 /*
  * GPIO Controller registers
+ * bit number is same as GPIO pin number for the GPIO masks below
  */
 
+#define RMIXL_GPIO_NSIGNALS		25			/* 25 GPIO signals supported in HW */
+
 /* GPIO Signal Registers */
 #define RMIXL_GPIO_INT_ENB		_RMIXL_OFFSET(0x0)	/* Interrupt Enable register */
 #define RMIXL_GPIO_INT_INV		_RMIXL_OFFSET(0x1)	/* Interrupt Inversion register */
 #define RMIXL_GPIO_IO_DIR		_RMIXL_OFFSET(0x2)	/* I/O Direction register */
 #define RMIXL_GPIO_OUTPUT		_RMIXL_OFFSET(0x3)	/* Output Write register */
-#define RMIXL_GPIO_INPUT		_RMIXL_OFFSET(0x4)	/* Intput Read register */
-#define RMIXL_GPIO_INT_CLR		_RMIXL_OFFSET(0x5)	/* Interrupt Inversion register */
-#define RMIXL_GPIO_INT_STS		_RMIXL_OFFSET(0x6)	/* Interrupt Status register */
+#define RMIXL_GPIO_INPUT		_RMIXL_OFFSET(0x4)	/* Intput Read register *//* ro */
+#define RMIXL_GPIO_INT_CLR		_RMIXL_OFFSET(0x5)	/* Interrupt Clear register */
+#define RMIXL_GPIO_INT_STS		_RMIXL_OFFSET(0x6)	/* Interrupt Status register *//* ro */
 #define RMIXL_GPIO_INT_TYP		_RMIXL_OFFSET(0x7)	/* Interrupt Type register */
-#define RMIXL_GPIO_RESET		_RMIXL_OFFSET(0x8)	/* XLS Soft Reset register */
+#define 

CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 00:58:54 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixlvar.h

Log Message:
- add to struct rmixl_config storage for IO Peripherals Bus
base address, address mask, and bus space.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/rmi/rmixlvar.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixlvar.h
diff -u src/sys/arch/mips/rmi/rmixlvar.h:1.3 src/sys/arch/mips/rmi/rmixlvar.h:1.4
--- src/sys/arch/mips/rmi/rmixlvar.h:1.3	Sun Feb 20 07:48:37 2011
+++ src/sys/arch/mips/rmi/rmixlvar.h	Fri Mar 18 00:58:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixlvar.h,v 1.3 2011/02/20 07:48:37 matt Exp $	*/
+/*	$NetBSD: rmixlvar.h,v 1.4 2011/03/18 00:58:54 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -112,6 +112,8 @@
 
 struct rmixl_config {
 	uint64_t		 rc_io_pbase;	
+	uint64_t		 rc_flash_pbase;	/* FLASH_BAR */
+	uint64_t		 rc_flash_mask;		/* FLASH_BAR */
 	bus_addr_t		 rc_pci_cfg_pbase;	
 	bus_size_t		 rc_pci_cfg_size;
 	bus_addr_t		 rc_pci_ecfg_pbase;	
@@ -122,6 +124,7 @@
 	bus_size_t		 rc_pci_io_size;
 	struct mips_bus_space	 rc_obio_eb_memt; 	/* DEVIO -eb */
 	struct mips_bus_space	 rc_obio_el_memt; 	/* DEVIO -el */
+	struct mips_bus_space	 rc_iobus_memt; 	/* Peripherals IO Bus */
 	struct mips_bus_space	 rc_pci_cfg_memt; 	/* PCI CFG  */
 	struct mips_bus_space	 rc_pci_ecfg_memt; 	/* PCI ECFG */
 	struct mips_bus_space	 rc_pci_memt; 		/* PCI MEM */
@@ -133,6 +136,7 @@
 	struct extent		*rc_phys_ex;	/* Note: MB units */
 	struct extent		*rc_obio_eb_ex;
 	struct extent		*rc_obio_el_ex;
+	struct extent		*rc_iobus_ex;
 	struct extent		*rc_pci_cfg_ex;
 	struct extent		*rc_pci_ecfg_ex;
 	struct extent		*rc_pci_mem_ex;
@@ -149,6 +153,7 @@
 
 extern void rmixl_obio_eb_bus_mem_init(bus_space_tag_t, void *);
 extern void rmixl_obio_el_bus_mem_init(bus_space_tag_t, void *);
+extern void rmixl_iobus_bus_mem_init(bus_space_tag_t, void *);
 extern void rmixl_pci_cfg_bus_mem_init(bus_space_tag_t, void *);
 extern void rmixl_pci_ecfg_bus_mem_init(bus_space_tag_t, void *);
 extern void rmixl_pci_bus_mem_init(bus_space_tag_t, void *);



CVS commit: src/sys/arch/evbmips/conf

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 00:59:13 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: files.rmixl

Log Message:
- remove obsolete TBD comment


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/conf/files.rmixl

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/evbmips/conf/files.rmixl
diff -u src/sys/arch/evbmips/conf/files.rmixl:1.3 src/sys/arch/evbmips/conf/files.rmixl:1.4
--- src/sys/arch/evbmips/conf/files.rmixl:1.3	Sun Feb 20 07:48:34 2011
+++ src/sys/arch/evbmips/conf/files.rmixl	Fri Mar 18 00:59:13 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.rmixl,v 1.3 2011/02/20 07:48:34 matt Exp $
+#	$NetBSD: files.rmixl,v 1.4 2011/03/18 00:59:13 cliff Exp $
 
 file	arch/evbmips/rmixl/autoconf.c
 file	arch/evbmips/rmixl/machdep.c
@@ -43,8 +43,6 @@
 #
 # PCI bus support.
 #
-## TBD
-
 
 device	pchb
 attach	pchb at pci



CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 01:03:10 UTC 2011

Added Files:
src/sys/arch/mips/rmi: rmixl_gpio.c

Log Message:
add gpio support for RMI XL* chips


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/mips/rmi/rmixl_gpio.c

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

Added files:

Index: src/sys/arch/mips/rmi/rmixl_gpio.c
diff -u /dev/null src/sys/arch/mips/rmi/rmixl_gpio.c:1.1
--- /dev/null	Fri Mar 18 01:03:10 2011
+++ src/sys/arch/mips/rmi/rmixl_gpio.c	Fri Mar 18 01:03:10 2011
@@ -0,0 +1,238 @@
+/*	$NetBSD: rmixl_gpio.c,v 1.1 2011/03/18 01:03:10 cliff Exp $	*/
+/*	$NetBSD: rmixl_gpio.c,v 1.1 2011/03/18 01:03:10 cliff Exp $	*/
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: rmixl_gpio.c,v 1.1 2011/03/18 01:03:10 cliff Exp $);
+
+#define _INTR_PRIVATE
+
+#include locators.h
+#include gpio.h
+ 
+#include sys/param.h
+#include sys/evcnt.h
+#include sys/atomic.h
+ 
+#include uvm/uvm_extern.h
+  
+#include machine/intr.h
+ 
+#include mips/cpu.h
+
+#include machine/bus.h
+
+#include mips/rmi/rmixlreg.h
+#include mips/rmi/rmixlvar.h
+#include mips/rmi/rmixl_obiovar.h
+
+#if NGPIO  0
+#include sys/gpio.h
+#include dev/gpio/gpiovar.h
+#endif
+
+struct gpio_softc {
+	device_t gpio_dev;
+	void *gpio_ih;
+	bus_space_tag_t gpio_memt;
+	bus_space_handle_t gpio_memh;
+	uint32_t gpio_enable_mask;
+	uint32_t gpio_edge_mask;
+	uint32_t gpio_edge_falling_mask;
+	uint32_t gpio_edge_rising_mask;
+	uint32_t gpio_level_mask;
+	uint32_t gpio_level_hi_mask;
+	uint32_t gpio_level_lo_mask;
+	uint32_t gpio_inuse_mask;
+#if NGPIO  0
+	struct gpio_chipset_tag gpio_chipset;
+	gpio_pin_t gpio_pins[RMIXL_GPIO_NSIGNALS];
+#endif
+};
+
+#define	GPIO_READ(gpio, reg) \
+	bus_space_read_4((gpio)-gpio_memt, (gpio)-gpio_memh, (reg))
+#define	GPIO_WRITE(gpio, reg, val) \
+	bus_space_write_4((gpio)-gpio_memt, (gpio)-gpio_memh, (reg), (val))
+
+static int gpio_match(device_t, cfdata_t, void *);
+static void gpio_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(rmixl_gpio,
+	sizeof(struct gpio_softc),
+	gpio_match, gpio_attach,
+	NULL, NULL);
+
+#if NGPIO  0
+
+static int
+rmixl_gpio_pin_read(void *arg, int pin)
+{
+	struct gpio_softc * const gpio = arg;
+
+	KASSERT(((1  pin)  RMIXL_GPIO_INPUT_MASK) != 0);
+	return (GPIO_READ(gpio, RMIXL_GPIO_INPUT)  pin)  1;
+}
+
+static void
+rmixl_gpio_pin_write(void *arg, int pin, int value)
+{
+	struct gpio_softc * const gpio = arg;
+	uint32_t mask = 1  pin;
+	uint32_t old, new;
+
+	KASSERT(((1  pin)  RMIXL_GPIO_OUTPUT_MASK) != 0);
+
+	old = GPIO_READ(gpio, RMIXL_GPIO_OUTPUT);
+	if (value)
+		new = old | mask; 
+	else
+		new = old  ~mask;
+
+	if (old != new)
+		GPIO_WRITE(gpio, RMIXL_GPIO_OUTPUT, new);
+}
+
+static void
+rmixl_gpio_pin_ctl(void *arg, int pin, int flags)
+{
+	struct gpio_softc * const gpio = arg;
+	uint32_t mask = 1  pin;
+	uint32_t old, new;
+
+	KASSERT((flags  (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) != (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT));
+	old = GPIO_READ(gpio, RMIXL_GPIO_IO_DIR);
+	new = old;
+	switch (flags  (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
+	case GPIO_PIN_INPUT:	new = ~mask; break;
+	case GPIO_PIN_OUTPUT:	new |= mask; break;
+	default:		return;
+	}
+	if (old != new)
+		GPIO_WRITE(gpio, RMIXL_GPIO_IO_DIR, new);
+}
+
+static void
+gpio_defer(device_t self)
+{
+	struct gpio_softc * const gpio = device_private(self);
+	struct gpio_chipset_tag * const gp = 

CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 01:04:09 UTC 2011

Added Files:
src/sys/arch/mips/rmi: rmixl_iobus_space.c rmixl_iobusvar.h

Log Message:
- add support for Peripherals IO Bus for RMI XL* chips


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/mips/rmi/rmixl_iobus_space.c \
src/sys/arch/mips/rmi/rmixl_iobusvar.h

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

Added files:

Index: src/sys/arch/mips/rmi/rmixl_iobus_space.c
diff -u /dev/null src/sys/arch/mips/rmi/rmixl_iobus_space.c:1.1
--- /dev/null	Fri Mar 18 01:04:09 2011
+++ src/sys/arch/mips/rmi/rmixl_iobus_space.c	Fri Mar 18 01:04:09 2011
@@ -0,0 +1,62 @@
+/*	$NetBSD: rmixl_iobus_space.c,v 1.1 2011/03/18 01:04:09 cliff Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * bus_space(9) support for Peripherals IO Bus on RMI {XLP,XLR,XLS} chips
+ */
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: rmixl_iobus_space.c,v 1.1 2011/03/18 01:04:09 cliff Exp $);
+
+#include sys/types.h
+#include sys/param.h
+
+#include machine/bus.h
+#include mips/rmi/rmixl_iobusvar.h
+#include mips/rmi/rmixlreg.h
+#include mips/rmi/rmixlvar.h
+
+#define	CHIP			rmixl_iobus
+#define	CHIP_MEM		/* defined */
+#define	CHIP_ACCESS_SIZE	1
+#define CHIP_BIG_ENDIAN
+
+#define CHIP_EX_MALLOC_SAFE(v)	(((struct rmixl_config *)(v))-rc_mallocsafe)
+#define CHIP_EXTENT(v)		(((struct rmixl_config *)(v))-rc_iobus_ex)
+
+
+/* MEM region 1 */
+#define	CHIP_W1_BUS_START(v)	0
+#define	CHIP_W1_BUS_END(v)	RMIXL_FLASH_BAR_MASK_MAX
+#define	CHIP_W1_SYS_START(v)	(((struct rmixl_config *)(v))-rc_flash_pbase)
+#define	CHIP_W1_SYS_END(v)	(CHIP_W1_SYS_START(v) + RMIXL_FLASH_BAR_MASK_MAX)
+
+#include mips/mips/bus_space_alignstride_chipdep.c
Index: src/sys/arch/mips/rmi/rmixl_iobusvar.h
diff -u /dev/null src/sys/arch/mips/rmi/rmixl_iobusvar.h:1.1
--- /dev/null	Fri Mar 18 01:04:09 2011
+++ src/sys/arch/mips/rmi/rmixl_iobusvar.h	Fri Mar 18 01:04:09 2011
@@ -0,0 +1,45 @@
+/*	$NetBSD: rmixl_iobusvar.h,v 1.1 2011/03/18 01:04:09 cliff Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Cliff Neighbors
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE

CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 01:04:46 UTC 2011

Added Files:
src/sys/arch/mips/rmi: rmixl_nand.c

Log Message:
- add NAND suport for RMI XL* chips


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/mips/rmi/rmixl_nand.c

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

Added files:

Index: src/sys/arch/mips/rmi/rmixl_nand.c
diff -u /dev/null src/sys/arch/mips/rmi/rmixl_nand.c:1.1
--- /dev/null	Fri Mar 18 01:04:46 2011
+++ src/sys/arch/mips/rmi/rmixl_nand.c	Fri Mar 18 01:04:46 2011
@@ -0,0 +1,420 @@
+/*	$NetBSD: rmixl_nand.c,v 1.1 2011/03/18 01:04:46 cliff Exp $	*/
+/*	$NetBSD: rmixl_nand.c,v 1.1 2011/03/18 01:04:46 cliff Exp $	*/
+
+/*-
+ * Copyright (c) 2010 Department of Software Engineering,
+ *		  University of Szeged, Hungary
+ * Copyright (c) 2010 Adam Hoka ah...@netbsd.org
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by the Department of Software Engineering, University of Szeged, Hungary
+ *
+ * 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 AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * Device driver for the RMI XLS NAND controller
+ */
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: rmixl_nand.c,v 1.1 2011/03/18 01:04:46 cliff Exp $);
+
+#include opt_flash.h
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/cdefs.h
+#include sys/device.h
+#include sys/endian.h
+
+#include machine/bus.h
+
+#include mips/rmi/rmixlreg.h
+#include mips/rmi/rmixlvar.h
+#include mips/rmi/rmixl_iobusvar.h
+#include mips/rmi/rmixl_intr.h
+
+#include dev/nand/nand.h
+#include dev/nand/onfi.h
+
+
+static int  rmixl_nand_match(struct device *, struct cfdata *, void *);
+static void rmixl_nand_attach(struct device *, struct device *, void *);
+static int  rmixl_nand_detach(device_t, int);
+static void rmixl_nand_command(device_t, uint8_t);
+static void rmixl_nand_address(device_t, uint8_t);
+static void rmixl_nand_busy(device_t);
+static void rmixl_nand_read_byte(device_t, uint8_t *);
+static void rmixl_nand_write_byte(device_t, uint8_t);
+static void rmixl_nand_read_word(device_t, uint16_t *);
+static void rmixl_nand_write_word(device_t, uint16_t);
+static void rmixl_nand_read_buf(device_t, void *, size_t);
+static void rmixl_nand_write_buf(device_t, const void *, size_t);
+
+
+struct rmixl_nand_softc {
+	device_t sc_dev;
+	device_t sc_nanddev;
+	struct iobus_softc *sc_iobus_sc;
+
+	int			sc_cs;		/* chip select index */
+	int			sc_buswidth;	/* in bytes */
+
+	struct nand_interface	sc_nand_if;
+
+	bus_space_tag_t		sc_obio_bst;
+	bus_space_handle_t	sc_obio_bsh;
+	u_long			sc_cmd_reg;
+	u_long			sc_addr_reg;
+
+	bus_addr_t		sc_iobus_addr;
+	bus_size_t		sc_iobus_size;
+	bus_space_tag_t		sc_iobus_bst;
+	bus_space_handle_t	sc_iobus_bsh;
+	u_long			sc_data_reg;
+
+};
+
+CFATTACH_DECL_NEW(rmixl_nand, sizeof(struct rmixl_nand_softc), rmixl_nand_match,
+rmixl_nand_attach, rmixl_nand_detach, NULL);
+
+static int
+rmixl_nand_match(struct device *parent, struct cfdata *match, void *aux)
+{
+	struct rmixl_iobus_attach_args *ia = aux;
+	bus_space_handle_t bsh;
+	volatile uint32_t *vaddr;
+	int err;
+	int rv = 0;
+
+	if ((ia-ia_dev_parm  RMIXL_FLASH_CSDEV_NANDEN) == 0)
+		return rv;	/* not NAND */
+
+	if (cpu_rmixlp(mips_options.mips_cpu)) {
+		aprint_error(%s: NAND not yet supported on XLP, __func__);
+		return rv;
+	}
+
+	if (! cpu_rmixls(mips_options.mips_cpu)) {
+		aprint_error(%s: NAND not supported on this processor,
+			__func__);
+		return rv;
+	}
+
+	/*
+	 * probe for NAND -- this may be redundant
+	 * if the device isn't there, the NANDEN test (above)
+	 * should have failed
+	 */
+	err = bus_space_map(ia-ia_iobus_bst, ia-ia_iobus_addr,
+		

CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 01:05:57 UTC 2011

Added Files:
src/sys/arch/mips/rmi: rmixl_iobus.c

Log Message:
- add support for Peripherals IO Bus for RMI XL* chips


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/mips/rmi/rmixl_iobus.c

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

Added files:

Index: src/sys/arch/mips/rmi/rmixl_iobus.c
diff -u /dev/null src/sys/arch/mips/rmi/rmixl_iobus.c:1.1
--- /dev/null	Fri Mar 18 01:05:57 2011
+++ src/sys/arch/mips/rmi/rmixl_iobus.c	Fri Mar 18 01:05:57 2011
@@ -0,0 +1,385 @@
+/*	$NetBSD: rmixl_iobus.c,v 1.1 2011/03/18 01:05:57 cliff Exp $	*/
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Cliff Neighbors
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * RMI Peripherals IO Bus support
+ * - interface to NOR, NAND, PCMCIA Memory controlers, etc.
+ * - manages the 10 Chip Selects
+ * - manages the Flash interrupts
+ * - manages the Flash errors
+ */
+
+/*
+ * iobus control registers are accessed as 32 bits.
+ * ALEn and CLEn NAND control registers are defined as 8 bits wide
+ * but that seems to be a documentation error.
+ *
+ * iobus data access may be as 1 or 2 or 4 bytes, even if device is 1 byte wide;
+ * the controller will sequence the bytes, in big-endian order.
+ */
+
+#include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: rmixl_iobus.c,v 1.1 2011/03/18 01:05:57 cliff Exp $);
+
+#include locators.h
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/device.h
+
+#include machine/bus.h
+
+#include mips/rmi/rmixlreg.h
+#include mips/rmi/rmixlvar.h
+#include mips/rmi/rmixl_intr.h
+#include mips/rmi/rmixl_obiovar.h
+#include mips/rmi/rmixl_iobusvar.h
+// #include mips/rmi/rmixl_gpiovar.h
+
+typedef struct {
+	bool		cs_allocated;
+	uint32_t	cs_addr; /* base address on the Peripherals I/O Bus */
+	uint32_t	cs_mask; /* address mask on the Peripherals I/O Bus */
+	uint32_t	cs_dev_parm; 
+} rmixl_iobus_csconfig_t;
+ 
+typedef struct rmixl_iobus_softc {
+	device_t		sc_dev;
+	bus_space_tag_t		sc_obio_bst;	/* for iobus device controler access */
+	bus_space_handle_t	sc_obio_bsh;	/*  */
+	bus_addr_t		sc_obio_addr;
+	bus_size_t		sc_obio_size;
+	bus_space_tag_t		sc_iobus_bst;	/* for iobus access */
+	rmixl_iobus_csconfig_t	sc_csconfig[RMIXL_FLASH_NCS];
+} rmixl_iobus_softc_t;
+
+
+static int	rmixl_iobus_match(device_t, cfdata_t, void *);
+static void	rmixl_iobus_attach(device_t, device_t, void *);
+static void	rmixl_iobus_csconfig_init(struct rmixl_iobus_softc *);
+static int  	rmixl_iobus_print(void *, const char *);
+static int  	rmixl_iobus_search(device_t, cfdata_t, const int *, void *);
+#ifdef NOTYET
+static int  rmixl_iobus_intr(void *);
+#endif
+
+#ifdef RMIXL_IOBUS_DEBUG
+rmixl_iobus_softc_t *rmixl_iobus_sc;
+#endif
+
+
+CFATTACH_DECL_NEW(rmixl_iobus, sizeof (rmixl_iobus_softc_t),
+rmixl_iobus_match, rmixl_iobus_attach, NULL, NULL);
+
+int
+rmixl_iobus_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct obio_attach_args *obio = aux;
+
+if (obio-obio_addr == RMIXL_IO_DEV_FLASH)
+		return rmixl_probe_4((volatile uint32_t *)
+			RMIXL_IOREG_VADDR(obio-obio_addr));
+
+return 0;
+}
+
+void
+rmixl_iobus_attach(device_t parent, device_t self, void *aux)
+{
+	rmixl_iobus_softc_t *sc = device_private(self);
+	struct obio_attach_args *obio = aux;
+	struct rmixl_config *rcp = rmixl_configuration;
+	uint64_t r;
+	int err;
+
+#ifdef RMIXL_IOBUS_DEBUG
+	rmixl_iobus_sc = sc;
+#endif
+	sc

CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 01:21:34 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_iobus.c

Log Message:
- fix typo when clearing pre-existing intrs in attach


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mips/rmi/rmixl_iobus.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/mips/rmi/rmixl_iobus.c
diff -u src/sys/arch/mips/rmi/rmixl_iobus.c:1.1 src/sys/arch/mips/rmi/rmixl_iobus.c:1.2
--- src/sys/arch/mips/rmi/rmixl_iobus.c:1.1	Fri Mar 18 01:05:57 2011
+++ src/sys/arch/mips/rmi/rmixl_iobus.c	Fri Mar 18 01:21:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_iobus.c,v 1.1 2011/03/18 01:05:57 cliff Exp $	*/
+/*	$NetBSD: rmixl_iobus.c,v 1.2 2011/03/18 01:21:34 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_iobus.c,v 1.1 2011/03/18 01:05:57 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_iobus.c,v 1.2 2011/03/18 01:21:34 cliff Exp $);
 
 #include locators.h
 
@@ -156,7 +156,7 @@
 
 	/* write-1-to-clear Flash interrupt status */
 	bus_space_write_4(sc-sc_obio_bst, sc-sc_obio_bsh,
-		RMIXL_FLASH_INT_STATUS, 0);
+		RMIXL_FLASH_INT_STATUS, ~0);
 
 	rmixl_iobus_csconfig_init(sc);
 



CVS commit: src/sys/arch/mips/rmi

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 02:01:45 UTC 2011

Modified Files:
src/sys/arch/mips/rmi: rmixl_nand.c

Log Message:
cosmetics


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mips/rmi/rmixl_nand.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/mips/rmi/rmixl_nand.c
diff -u src/sys/arch/mips/rmi/rmixl_nand.c:1.1 src/sys/arch/mips/rmi/rmixl_nand.c:1.2
--- src/sys/arch/mips/rmi/rmixl_nand.c:1.1	Fri Mar 18 01:04:46 2011
+++ src/sys/arch/mips/rmi/rmixl_nand.c	Fri Mar 18 02:01:45 2011
@@ -1,5 +1,4 @@
-/*	$NetBSD: rmixl_nand.c,v 1.1 2011/03/18 01:04:46 cliff Exp $	*/
-/*	$NetBSD: rmixl_nand.c,v 1.1 2011/03/18 01:04:46 cliff Exp $	*/
+/*	$NetBSD: rmixl_nand.c,v 1.2 2011/03/18 02:01:45 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -37,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_nand.c,v 1.1 2011/03/18 01:04:46 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_nand.c,v 1.2 2011/03/18 02:01:45 cliff Exp $);
 
 #include opt_flash.h
 
@@ -105,20 +104,20 @@
 	bus_space_handle_t bsh;
 	volatile uint32_t *vaddr;
 	int err;
-	int rv = 0;
+	int rv;
 
 	if ((ia-ia_dev_parm  RMIXL_FLASH_CSDEV_NANDEN) == 0)
-		return rv;	/* not NAND */
+		return 0;	/* not NAND */
 
 	if (cpu_rmixlp(mips_options.mips_cpu)) {
 		aprint_error(%s: NAND not yet supported on XLP, __func__);
-		return rv;
+		return 0;
 	}
 
 	if (! cpu_rmixls(mips_options.mips_cpu)) {
 		aprint_error(%s: NAND not supported on this processor,
 			__func__);
-		return rv;
+		return 0;
 	}
 
 	/*
@@ -132,7 +131,7 @@
 		aprint_debug(%s: bus_space_map err %d, 
 			iobus space addr %# PRIxBUSADDR \n,
 			__func__, err, ia-ia_iobus_addr);
-		return rv;
+		return 0;
 	}
 
 	vaddr = bus_space_vaddr(ia-ia_iobus_bst, bsh);
@@ -201,8 +200,7 @@
 		sc-sc_buswidth = 4;	/* 32 bit */
 		break;
 	}
-	aprint_debug_dev(self, bus width %d bits\n,
-		8 * sc-sc_buswidth);
+	aprint_debug_dev(self, bus width %d bits\n, 8 * sc-sc_buswidth);
 
 	sc-sc_nand_if.select = nand_default_select;
 	sc-sc_nand_if.command = rmixl_nand_command;
@@ -247,8 +245,7 @@
 	if (sc-sc_nanddev != NULL)
 		rv = config_detach(sc-sc_nanddev, flags);
 
-	bus_space_unmap(sc-sc_iobus_bst, sc-sc_iobus_bsh,
-		sc-sc_iobus_size);
+	bus_space_unmap(sc-sc_iobus_bst, sc-sc_iobus_bsh, sc-sc_iobus_size);
 
 	return rv;
 }
@@ -313,8 +310,7 @@
 {
 	struct rmixl_nand_softc *sc = device_private(self);
 	
-	*data = bus_space_read_2(sc-sc_iobus_bst, sc-sc_iobus_bsh,
-		0);
+	*data = bus_space_read_2(sc-sc_iobus_bst, sc-sc_iobus_bsh, 0);
 }
 
 static void



CVS commit: src/sys/arch/mips/conf

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 02:13:46 UTC 2011

Modified Files:
src/sys/arch/mips/conf: files.rmixl

Log Message:
- add config for gpio
- add config for iobus, nand, flash


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/conf/files.rmixl

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/mips/conf/files.rmixl
diff -u src/sys/arch/mips/conf/files.rmixl:1.3 src/sys/arch/mips/conf/files.rmixl:1.4
--- src/sys/arch/mips/conf/files.rmixl:1.3	Sun Feb 20 07:45:46 2011
+++ src/sys/arch/mips/conf/files.rmixl	Fri Mar 18 02:13:46 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.rmixl,v 1.3 2011/02/20 07:45:46 matt Exp $
+#	$NetBSD: files.rmixl,v 1.4 2011/03/18 02:13:46 cliff Exp $
 #
 # Configuration info for RMI XLP, XLR, XLS
 #
@@ -41,6 +41,11 @@
 file	arch/mips/rmi/rmixl_com.c		com_rmixl
 defparam opt_com.hCONSADDR CONSFREQ CONSPEED CONMODE
 
+# GPIO
+device	rmixl_gpio: gpiobus
+attach	rmixl_gpio at obio
+file	arch/mips/rmi/rmixl_gpio.c		rmixl_gpio
+
 # PCIe
 device  rmixl_pcie: pcibus
 attach  rmixl_pcie at obio
@@ -51,6 +56,23 @@
 attach  rmixl_pcix at obio
 filearch/mips/rmi/rmixl_pcix.c		rmixl_pcix	needs-flag
 
+# RMI Periperal IO Bus to Flash, PCMCIA memory controllers
+define	rmixl_iobus { [cs=-1], [addr=-1], [size=-1], [intr=-1] }
+device	rmixl_iobus: rmixl_iobus
+attach  rmixl_iobus at obio
+filearch/mips/rmi/rmixl_iobus_space.c	rmixl_iobus
+filearch/mips/rmi/rmixl_iobus.c		rmixl_iobus
+
+# NAND flash controller
+device	rmixl_nand: nandbus 
+attach  rmixl_nand at rmixl_iobus
+filearch/mips/rmi/rmixl_nand.c		rmixl_nand
+
+# PCMCIA controller
+device	rmixl_pcic: pcmciabus 
+attach  rmixl_pcic at rmixl_iobus
+filearch/mips/rmi/rmixl_pcic.c		rmixl_pcic
+
 # On-chip USB interface
 define rmixl_usbi { [addr=-1], [size=-1], [intr=-1] }
 device	rmixl_usbi: rmixl_usbi



CVS commit: src/sys/arch/evbmips/conf

2011-03-17 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Fri Mar 18 02:14:56 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf: XLSATX

Log Message:
- add config for gpio, iobus, nand, flash
- config for pcic, pcmcia stubbed for now (drivers TBD)
- ensure space-tab is used to maintain format when commented


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/conf/XLSATX

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/evbmips/conf/XLSATX
diff -u src/sys/arch/evbmips/conf/XLSATX:1.2 src/sys/arch/evbmips/conf/XLSATX:1.3
--- src/sys/arch/evbmips/conf/XLSATX:1.2	Sun Feb 20 07:48:33 2011
+++ src/sys/arch/evbmips/conf/XLSATX	Fri Mar 18 02:14:55 2011
@@ -1,8 +1,8 @@
-#	$NetBSD: XLSATX,v 1.2 2011/02/20 07:48:33 matt Exp $
+#	$NetBSD: XLSATX,v 1.3 2011/03/18 02:14:55 cliff Exp $
 
 include 	arch/evbmips/conf/std.rmixl
 
-#ident 		XLSATX-$Revision: 1.2 $
+#ident 		XLSATX-$Revision: 1.3 $
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -11,13 +11,13 @@
 #
 # MEMSIZE can be used to limit memory amount used
 #
-##options		MEMSIZE=0x1000		# 256MB 
+#options  	MEMSIZE=0x1000		# 256MB 
 
 #
 # MEMLIMIT can be used to limit memory address used
 #
 defparam opt_memsize.h MEMLIMIT
-##options	MEMLIMIT=0x1000			# 256MB 
+#options 	MEMLIMIT=0x1000			# 256MB 
 
 options 	NOFPU		# No FPU
 #options 	FPEMUL		# emulate FPU insn
@@ -39,12 +39,13 @@
 options 	USERCONF	# userconf(4) support
 #options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 options 	DDB		# kernel dynamic debugger
-options		MIPS_DDB_WATCH	# enable T_WATCH (see IEU_DEFAUTURE[DBE])
+options 	MIPS_DDB_WATCH	# enable T_WATCH (see IEU_DEFAUTURE[DBE])
 options 	DDB_HISTORY_SIZE=100 # enable history editing in DDB
 makeoptions 	DEBUG=-g	# compile full symbol table
 options 	SYMTAB_SPACE=50	# size for embedded symbol table
-#options	DDB_COMMANDONENTER=trace;show registers
-options		DB_MAX_LINE=-1
+#options 	DDB_COMMANDONENTER=trace;show registers
+options 	DB_MAX_LINE=-1
+options 	LOCKDEBUG
 
 # Compatibility options
 #options 	COMPAT_43	# compatibility with 4.3BSD binaries
@@ -140,16 +141,25 @@
 
 
 mainbus0 	at root
-cpunode*	at mainbus? node ?
-cpucore*	at cpunode? core ?
+cpunode* 	at mainbus? node ?
+cpucore* 	at cpunode? core ?
 cpu*		at cpucore? thread ?
 obio0		at cpunode?
 com0		at obio0	addr 0x14000 intr 9
 com1		at obio0	addr 0x15000 intr 10
-options		COM_REGMAP
-rmixl_pcix0	at obio0
+options 	COM_REGMAP
+rmixl_gpio0 	at obio0	addr 0x18000 intr 14
+gpio*		at rmixl_gpio?
+rmixl_iobus0 	at obio0	addr 0x19000
+rmixl_nand* 	at rmixl_iobus?	addr 0x0180
+#rmixl_nand* 	at rmixl_iobus?	cs 2
+nand*		at rmixl_nand?
+flash*		at nand?
+#rmixl_pcic* 	at rmixl_iobus?	cs 6 addr 0x0100
+#pcmcia* 	at rmixl_pcic
+rmixl_pcix0 	at obio0
 pci*		at rmixl_pcix0
-rmixl_pcie0	at obio0
+rmixl_pcie0 	at obio0
 pci*		at rmixl_pcie0
 ppb*		at pci?
 pci*		at ppb?
@@ -160,11 +170,11 @@
 msk*		at mskc?
 makphy*		at mii? phy ?			# Marvell 88E1000 PHYs
 ukphy*		at mii? phy ?			# unknown PHY
-rmixl_usbi0	at obio0	addr 0x25000 intr 31
+rmixl_usbi0 	at obio0	addr 0x25000 intr 31
 ohci0		at rmixl_usbi0	addr 0x24400 size 0x400 intr 0
 ohci1		at rmixl_usbi0	addr 0x24800 size 0x400 intr 1
 ehci0		at rmixl_usbi0	addr 0x24000 size 0x400 intr 2
-siisata*	at pci? dev ? function ?
+siisata* 	at pci? dev ? function ?
 atabus*		at ata?
 wd*		at atabus? drive ? flags 0x
 
@@ -175,7 +185,7 @@
 uhub*		at uhub? port ?
 umass*		at uhub? port ? configuration ? interface ?
 wd*		at umass?
-scsibus*	at umass? channel ?
+scsibus* 	at umass? channel ?
 sd*		at scsibus? target ? lun ?
 
 



CVS commit: [matt-nb5-mips64] src/sys/lib/libkern

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 19:00:15 UTC 2011

Modified Files:
src/sys/lib/libkern [matt-nb5-mips64]: softfloat.c

Log Message:
- remove erroneous include of opt_multiprocessor.h
(MULTIPROCESSOR instance was inside a comment)


To generate a diff of this commit:
cvs rdiff -u -r1.4.94.1 -r1.4.94.2 src/sys/lib/libkern/softfloat.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/lib/libkern/softfloat.c
diff -u src/sys/lib/libkern/softfloat.c:1.4.94.1 src/sys/lib/libkern/softfloat.c:1.4.94.2
--- src/sys/lib/libkern/softfloat.c:1.4.94.1	Sat Feb  5 06:00:14 2011
+++ src/sys/lib/libkern/softfloat.c	Tue Feb  8 19:00:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat.c,v 1.4.94.1 2011/02/05 06:00:14 cliff Exp $ */
+/* $NetBSD: softfloat.c,v 1.4.94.2 2011/02/08 19:00:14 cliff Exp $ */
 
 /*
  * This version hacked for use with gcc -msoft-float by bjh21.
@@ -47,11 +47,9 @@
 /* If you need this in a boot program, you have bigger problems... */
 #ifndef _STANDALONE
 
-#include opt_multiprocessor.h
-
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: softfloat.c,v 1.4.94.1 2011/02/05 06:00:14 cliff Exp $);
+__RCSID($NetBSD: softfloat.c,v 1.4.94.2 2011/02/08 19:00:14 cliff Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #ifdef SOFTFLOAT_FOR_GCC



CVS commit: [matt-nb5-mips64] src/sys/arch/evbmips/conf

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 19:04:44 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf [matt-nb5-mips64]: XLSATX

Log Message:
- improve formatting: a space char followed by tab char follows options


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.12 -r1.1.2.13 src/sys/arch/evbmips/conf/XLSATX

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/evbmips/conf/XLSATX
diff -u src/sys/arch/evbmips/conf/XLSATX:1.1.2.12 src/sys/arch/evbmips/conf/XLSATX:1.1.2.13
--- src/sys/arch/evbmips/conf/XLSATX:1.1.2.12	Sat Feb  5 06:02:09 2011
+++ src/sys/arch/evbmips/conf/XLSATX	Tue Feb  8 19:04:43 2011
@@ -1,8 +1,8 @@
-#	$NetBSD: XLSATX,v 1.1.2.12 2011/02/05 06:02:09 cliff Exp $
+#	$NetBSD: XLSATX,v 1.1.2.13 2011/02/08 19:04:43 cliff Exp $
 
 include 	arch/evbmips/conf/std.rmixl
 
-#ident 		XLSATX-$Revision: 1.1.2.12 $
+#ident 		XLSATX-$Revision: 1.1.2.13 $
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -11,13 +11,13 @@
 #
 # MEMSIZE can be used to limit memory amount used
 #
-##options		MEMSIZE=0x1000		# 256MB 
+#options 		MEMSIZE=0x1000		# 256MB 
 
 #
 # MEMLIMIT can be used to limit memory address used
 #
 defparam opt_memsize.h MEMLIMIT
-##options	MEMLIMIT=0x1000			# 256MB 
+#options 	MEMLIMIT=0x1000			# 256MB 
 
 options 	NOFPU		# No FPU
 #options 	FPEMUL		# emulate FPU insn
@@ -39,12 +39,12 @@
 options 	USERCONF	# userconf(4) support
 #options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 options 	DDB		# kernel dynamic debugger
-options		MIPS_DDB_WATCH	# enable T_WATCH (see IEU_DEFAUTURE[DBE])
+options 	MIPS_DDB_WATCH	# enable T_WATCH (see IEU_DEFAUTURE[DBE])
 options 	DDB_HISTORY_SIZE=100 # enable history editing in DDB
 makeoptions 	DEBUG=-g	# compile full symbol table
 options 	SYMTAB_SPACE=50	# size for embedded symbol table
-#options	DDB_COMMANDONENTER=trace;show registers
-options		DB_MAX_LINE=-1
+#options 	DDB_COMMANDONENTER=trace;show registers
+options 	DB_MAX_LINE=-1
 
 # Compatibility options
 #options 	COMPAT_43	# compatibility with 4.3BSD binaries
@@ -146,7 +146,7 @@
 obio0		at cpunode?
 com0		at obio0	addr 0x14000 intr 9
 com1		at obio0	addr 0x15000 intr 10
-options		COM_REGMAP
+options 	COM_REGMAP
 rmixl_pcix0	at obio0
 pci*		at rmixl_pcix0
 rmixl_pcie0	at obio0



CVS commit: [matt-nb5-mips64] src/sys/arch/mips

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 19:18:23 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: db_machdep.h
src/sys/arch/mips/mips [matt-nb5-mips64]: cpu_subr.c db_interface.c

Log Message:
- rename ddb_running_on_this_cpu to ddb_running_on_this_cpu_p
according to pedicate unction naming style convention


To generate a diff of this commit:
cvs rdiff -u -r1.22.62.2 -r1.22.62.3 src/sys/arch/mips/include/db_machdep.h
cvs rdiff -u -r1.1.2.15 -r1.1.2.16 src/sys/arch/mips/mips/cpu_subr.c
cvs rdiff -u -r1.64.16.19 -r1.64.16.20 src/sys/arch/mips/mips/db_interface.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/mips/include/db_machdep.h
diff -u src/sys/arch/mips/include/db_machdep.h:1.22.62.2 src/sys/arch/mips/include/db_machdep.h:1.22.62.3
--- src/sys/arch/mips/include/db_machdep.h:1.22.62.2	Sat Feb  5 06:04:59 2011
+++ src/sys/arch/mips/include/db_machdep.h	Tue Feb  8 19:18:22 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.22.62.2 2011/02/05 06:04:59 cliff Exp $ */
+/* $NetBSD: db_machdep.h,v 1.22.62.3 2011/02/08 19:18:22 cliff Exp $ */
 
 /*
  * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -113,7 +113,7 @@
 db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
 db_addr_t next_instr_address(db_addr_t pc, bool bd);
 
-bool ddb_running_on_this_cpu(void);
+bool ddb_running_on_this_cpu_p(void);
 bool ddb_running_on_any_cpu(void);
 void db_resume_others(void);
 #ifdef MIPS_DDB_WATCH

Index: src/sys/arch/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.1.2.15 src/sys/arch/mips/mips/cpu_subr.c:1.1.2.16
--- src/sys/arch/mips/mips/cpu_subr.c:1.1.2.15	Tue Feb  8 06:01:47 2011
+++ src/sys/arch/mips/mips/cpu_subr.c	Tue Feb  8 19:18:22 2011
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 #include opt_sa.h
 
-__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.1.2.15 2011/02/08 06:01:47 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.1.2.16 2011/02/08 19:18:22 cliff Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -739,7 +739,7 @@
 		CPUSET_ADD(cpus_resumed, index);
 
 #if defined(DDB)
-		if (ddb_running_on_this_cpu())
+		if (ddb_running_on_this_cpu_p())
 			cpu_Debugger();
 		if (ddb_running_on_any_cpu())
 			continue;

Index: src/sys/arch/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.64.16.19 src/sys/arch/mips/mips/db_interface.c:1.64.16.20
--- src/sys/arch/mips/mips/db_interface.c:1.64.16.19	Sat Feb  5 06:07:07 2011
+++ src/sys/arch/mips/mips/db_interface.c	Tue Feb  8 19:18:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.64.16.19 2011/02/05 06:07:07 cliff Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.64.16.20 2011/02/08 19:18:22 cliff Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.64.16.19 2011/02/05 06:07:07 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.64.16.20 2011/02/08 19:18:22 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_cputype.h	/* which mips CPUs do we support? */
@@ -109,8 +109,6 @@
 void db_mtcr_cmd(db_expr_t, bool, db_expr_t, const char *);
 #endif
 
-bool ddb_running_on_this_cpu(void);
-
 static void	kdbpoke_4(vaddr_t addr, int newval);
 static void	kdbpoke_2(vaddr_t addr, short newval);
 static void	kdbpoke_1(vaddr_t addr, char newval);
@@ -1081,7 +1079,7 @@
 #ifdef MULTIPROCESSOR
 
 bool 
-ddb_running_on_this_cpu(void)
+ddb_running_on_this_cpu_p(void)
 {   
 	return ddb_cpu == cpu_index(curcpu());
 }



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 19:50:23 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_cpu.c rmixl_cpuvar.h
rmixl_intr.c rmixl_intr.h

Log Message:
- remove sc_ih_clk, sc_ih_fmn, sc_ih_ipi from struct rmixl_cpu_softc;
they were unused just taking up space
- rmixl_intr_init_clk() and rmixl_intr_init_ipi() are now type void


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.18 -r1.1.2.19 src/sys/arch/mips/rmi/rmixl_cpu.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/mips/rmi/rmixl_cpuvar.h
cvs rdiff -u -r1.1.2.26 -r1.1.2.27 src/sys/arch/mips/rmi/rmixl_intr.c
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 src/sys/arch/mips/rmi/rmixl_intr.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixl_cpu.c
diff -u src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.18 src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.19
--- src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.18	Tue Feb  8 06:03:01 2011
+++ src/sys/arch/mips/rmi/rmixl_cpu.c	Tue Feb  8 19:50:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpu.c,v 1.1.2.18 2011/02/08 06:03:01 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpu.c,v 1.1.2.19 2011/02/08 19:50:22 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.18 2011/02/08 06:03:01 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.19 2011/02/08 19:50:22 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -258,9 +258,9 @@
 
 	rmixl_fmn_init();
 
-	sc-sc_ih_clk = rmixl_intr_init_clk();
+	rmixl_intr_init_clk();
 #ifdef MULTIPROCESSOR
-	sc-sc_ih_ipi = rmixl_intr_init_ipi();
+	rmixl_intr_init_ipi();
 #endif
 
 #ifdef NOTYET
@@ -269,7 +269,6 @@
 	if (ih == NULL)
 		panic(%s: rmixl_fmn_intr_establish failed,
 			__func__);
-	sc-sc_ih_fmn = ih;
 #endif
 
 }

Index: src/sys/arch/mips/rmi/rmixl_cpuvar.h
diff -u src/sys/arch/mips/rmi/rmixl_cpuvar.h:1.1.2.2 src/sys/arch/mips/rmi/rmixl_cpuvar.h:1.1.2.3
--- src/sys/arch/mips/rmi/rmixl_cpuvar.h:1.1.2.2	Tue Apr 13 18:15:16 2010
+++ src/sys/arch/mips/rmi/rmixl_cpuvar.h	Tue Feb  8 19:50:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpuvar.h,v 1.1.2.2 2010/04/13 18:15:16 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpuvar.h,v 1.1.2.3 2011/02/08 19:50:22 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,9 +40,6 @@
 struct rmixl_cpu_softc {
 	device_t sc_dev;
 	struct cpu_info *sc_ci;
-	void *sc_ih_clk;
-	void *sc_ih_fmn;
-	void *sc_ih_ipi;
 	struct evcnt sc_vec_evcnts[64];
 };
 

Index: src/sys/arch/mips/rmi/rmixl_intr.c
diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.26 src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.27
--- src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.26	Tue Feb  8 06:04:20 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.c	Tue Feb  8 19:50:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.c,v 1.1.2.26 2011/02/08 06:04:20 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.c,v 1.1.2.27 2011/02/08 19:50:22 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.26 2011/02/08 06:04:20 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.27 2011/02/08 19:50:22 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -446,7 +446,7 @@
  * even though cpu_intr() handles the interrupt
  * note the 'mpsafe' arg here is a placeholder only
  */
-void *
+void
 rmixl_intr_init_clk(void)
 {
 	int vec = ffs(MIPS_INT_MASK_5  8) - 1;
@@ -459,14 +459,13 @@
 
 	mutex_exit(rmixl_intr_lock);
 	
-	return ih;
 }
 
 #ifdef MULTIPROCESSOR
 /*
  * establish IPI interrupt and send function
  */
-void *
+void
 rmixl_intr_init_ipi(void)
 {
 	u_int ipi, vec;
@@ -487,7 +486,6 @@
 
 	mutex_exit(rmixl_intr_lock);
 
-	return ih;
 }
 #endif 	/* MULTIPROCESSOR */
 

Index: src/sys/arch/mips/rmi/rmixl_intr.h
diff -u src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.6 src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.7
--- src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.6	Sat Feb  5 06:31:06 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.h	Tue Feb  8 19:50:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.h,v 1.1.2.6 2011/02/05 06:31:06 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.h,v 1.1.2.7 2011/02/08 19:50:22 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -102,9 +102,9 @@
 extern void  rmixl_vec_disestablish(void *);
 extern const char *rmixl_intr_string(int);
 extern void rmixl_intr_init_cpu(struct cpu_info *);
-extern void *rmixl_intr_init_clk(void);
+extern void rmixl_intr_init_clk(void);
 #ifdef MULTIPROCESSOR
-extern void *rmixl_intr_init_ipi(void);
+extern void rmixl_intr_init_ipi(void);
 #endif
 
 #endif	/* _MIPS_RMI_RMIXL_INTR_H_ */



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 21:27:15 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_intr.c

Log Message:
- use mutex_obj_alloc() instead of declaring locks statically


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.27 -r1.1.2.28 src/sys/arch/mips/rmi/rmixl_intr.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/mips/rmi/rmixl_intr.c
diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.27 src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.28
--- src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.27	Tue Feb  8 19:50:22 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.c	Tue Feb  8 21:27:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.c,v 1.1.2.27 2011/02/08 19:50:22 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.c,v 1.1.2.28 2011/02/08 21:27:15 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.27 2011/02/08 19:50:22 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.28 2011/02/08 21:27:15 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -95,7 +95,6 @@
 #include dev/pci/pcireg.h
 #include dev/pci/pcivar.h
 
-// #define IOINTR_DEBUG	1
 #ifdef IOINTR_DEBUG
 int iointr_debug = IOINTR_DEBUG;
 # define DPRINTF(x)	do { if (iointr_debug) printf x ; } while(0)
@@ -351,13 +350,14 @@
 
 /*
  * mask of CPUs attached
- * once they are attached, this var is read-only so mp safe
+ * while CPUs are attaching, we cast to volatile;
+ * once they are attached, it's read-only so mp safe
  */
 static uint32_t cpu_present_mask;
 
-kmutex_t rmixl_ipi_lock;	/* covers RMIXL_PIC_IPIBASE */
-kmutex_t rmixl_intr_lock;	/* covers rest of PIC, and rmixl_intrhand[] */
-rmixl_intrhand_t rmixl_intrhand[NINTRVECS];
+static kmutex_t *rmixl_ipi_lock;  /* covers RMIXL_PIC_IPIBASE */
+static kmutex_t *rmixl_intr_lock; /* covers rest of PIC, and rmixl_intrhand[] */
+static rmixl_intrhand_t rmixl_intrhand[NINTRVECS];
 
 #ifdef DIAGNOSTIC
 static int rmixl_pic_init_done;
@@ -411,10 +411,10 @@
 			__func__, rmixl_pic_init_done);
 #endif
 
-	mutex_init(rmixl_ipi_lock, MUTEX_DEFAULT, IPL_HIGH);
-	mutex_init(rmixl_intr_lock, MUTEX_DEFAULT, IPL_HIGH);
+	rmixl_ipi_lock  = mutex_obj_alloc(MUTEX_DEFAULT, IPL_HIGH);
+	rmixl_intr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_HIGH);
 
-	mutex_enter(rmixl_intr_lock);
+	mutex_enter(rmixl_intr_lock);
 
 	/*
 	 * initialize (zero) all IRT Entries in the PIC
@@ -436,7 +436,7 @@
 #ifdef DIAGNOSTIC
 	rmixl_pic_init_done = 1;
 #endif
-	mutex_exit(rmixl_intr_lock);
+	mutex_exit(rmixl_intr_lock);
 
 }
 
@@ -451,13 +451,13 @@
 {
 	int vec = ffs(MIPS_INT_MASK_5  8) - 1;
 
-	mutex_enter(rmixl_intr_lock);
+	mutex_enter(rmixl_intr_lock);
 
 	void *ih = rmixl_vec_establish(vec, 0, IPL_SCHED, NULL, NULL, false);
 	if (ih == NULL)
 		panic(%s: establish vec %d failed, __func__, vec);
 
-	mutex_exit(rmixl_intr_lock);
+	mutex_exit(rmixl_intr_lock);
 	
 }
 
@@ -471,7 +471,7 @@
 	u_int ipi, vec;
 	void *ih;
 
-	mutex_enter(rmixl_intr_lock);
+	mutex_enter(rmixl_intr_lock);
 
 	for (ipi=0; ipi  NIPIS; ipi++) {
 		vec = RMIXL_INTRVEC_IPI + ipi;
@@ -484,7 +484,7 @@
 
 	mips_locoresw.lsw_send_ipi = rmixl_send_ipi;
 
-	mutex_exit(rmixl_intr_lock);
+	mutex_exit(rmixl_intr_lock);
 
 }
 #endif 	/* MULTIPROCESSOR */
@@ -646,7 +646,7 @@
 static void
 rmixl_irt_disestablish(int irt)
 {
-	KASSERT(mutex_owned(rmixl_intr_lock));
+	KASSERT(mutex_owned(rmixl_intr_lock));
 	DPRINTF((%s: irt %d, irtc1 %#x\n, __func__, irt, 0));
 	rmixl_irt_init(irt);
 }
@@ -662,7 +662,7 @@
 	uint32_t irtc1;
 	uint32_t irtc0;
 
-	KASSERT(mutex_owned(rmixl_intr_lock));
+	KASSERT(mutex_owned(rmixl_intr_lock));
 
 	if (irt = NIRTS)
 		panic(%s: bad irt %d\n, __func__, irt);
@@ -724,7 +724,7 @@
 	uint64_t eimr_bit;
 	int s;
 
-	KASSERT(mutex_owned(rmixl_intr_lock));
+	KASSERT(mutex_owned(rmixl_intr_lock));
 
 	DPRINTF((%s: vec %d, cpumask %#x, ipl %d, func %p, arg %p\n
 			__func__, vec, cpumask, ipl, func, arg));
@@ -804,7 +804,7 @@
 
 	DPRINTF((%s: irt %d, vec %d, ipl %d\n, __func__, irt, vec, ipl));
 
-	mutex_enter(rmixl_intr_lock);
+	mutex_enter(rmixl_intr_lock);
 
 	/*
 	 * establish vector
@@ -816,7 +816,7 @@
 	 */
 	rmixl_irt_establish(irt, vec, cpumask, trigger, polarity);
 
-	mutex_exit(rmixl_intr_lock);
+	mutex_exit(rmixl_intr_lock);
 
 	return ih;
 }
@@ -827,7 +827,7 @@
 	rmixl_intrhand_t *ih = cookie;
 	uint64_t eimr_bit;
 
-	KASSERT(mutex_owned(rmixl_intr_lock));
+	KASSERT(mutex_owned(rmixl_intr_lock));
 	KASSERT(ih-ih_vec  NINTRVECS);
 	KASSERT(ih == rmixl_intrhand[ih-ih_vec]);
 
@@ -851,7 +851,7 @@
 	KASSERT(vec  NINTRVECS);
 	KASSERT(ih == rmixl_intrhand[vec]);
 
-	mutex_enter(rmixl_intr_lock);
+	mutex_enter(rmixl_intr_lock);
 
 	/*
 	 * disable/invalidate the IRT Entry if needed
@@ -864,7 +864,7 @@
 	 */
 	rmixl_vec_disestablish(cookie);
 
-	

CVS commit: [matt-nb5-mips64] src/sys/kern

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 21:56:02 UTC 2011

Modified Files:
src/sys/kern [matt-nb5-mips64]: subr_autoconf.c

Log Message:
use mutex_obj_alloc() to allocate config_queues_lock and dc_funcs_lock
instead of declaring them statically.


To generate a diff of this commit:
cvs rdiff -u -r1.163.4.2.4.2 -r1.163.4.2.4.3 src/sys/kern/subr_autoconf.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/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.163.4.2.4.2 src/sys/kern/subr_autoconf.c:1.163.4.2.4.3
--- src/sys/kern/subr_autoconf.c:1.163.4.2.4.2	Tue Feb  8 06:04:59 2011
+++ src/sys/kern/subr_autoconf.c	Tue Feb  8 21:56:01 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.163.4.2.4.2 2011/02/08 06:04:59 cliff Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.163.4.2.4.3 2011/02/08 21:56:01 cliff Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: subr_autoconf.c,v 1.163.4.2.4.2 2011/02/08 06:04:59 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: subr_autoconf.c,v 1.163.4.2.4.3 2011/02/08 21:56:01 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -204,14 +204,14 @@
  * - interrupt_config_queue
  * is held for short durations, and is initialized to spin
  */
-static kmutex_t config_queues_lock;
+static kmutex_t *config_queues_lock;
 
 /*
  * dc_funcs_lock ensures the driver dc_func's are not called concurrently
  * many (most?) are not MP safe
  * is held for unknown durations, and is initialized to sleep
  */
-static kmutex_t dc_funcs_lock;
+static kmutex_t *dc_funcs_lock;
 
 struct deferred_config_head deferred_config_queue =
 	TAILQ_HEAD_INITIALIZER(deferred_config_queue);
@@ -376,9 +376,8 @@
 	mutex_init(config_misc_lock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(config_misc_cv, cfgmisc);
 
-	mutex_init(dc_funcs_lock, MUTEX_DEFAULT, IPL_SOFTNET);
-
-	mutex_init(config_queues_lock, MUTEX_DEFAULT, IPL_VM);
+	dc_funcs_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
+	config_queues_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_VM);
 
 	/* allcfdrivers is statically initialized. */
 	for (i = 0; cfdriver_list_initial[i] != NULL; i++) {
@@ -416,18 +415,18 @@
 {
 	struct deferred_config *dc;
 
-	mutex_enter(config_queues_lock);
+	mutex_enter(config_queues_lock);
 	while ((dc = TAILQ_FIRST(interrupt_config_queue)) != NULL) {
 		TAILQ_REMOVE(interrupt_config_queue, dc, dc_queue);
-		mutex_exit(config_queues_lock);
-		mutex_enter(dc_funcs_lock);
+		mutex_exit(config_queues_lock);
+		mutex_enter(dc_funcs_lock);
 		(*dc-dc_func)(dc-dc_dev);
-		mutex_exit(dc_funcs_lock);
+		mutex_exit(dc_funcs_lock);
 		kmem_free(dc, sizeof(*dc));
 		config_pending_decr();
-		mutex_enter(config_queues_lock);
+		mutex_enter(config_queues_lock);
 	}
-	mutex_exit(config_queues_lock);
+	mutex_exit(config_queues_lock);
 
 	kthread_exit(0);
 }
@@ -1677,13 +1676,13 @@
 		panic(config_defer: can't defer config of a root device);
 
 #ifdef DIAGNOSTIC
-	mutex_enter(config_queues_lock);
+	mutex_enter(config_queues_lock);
 	for (dc = TAILQ_FIRST(deferred_config_queue); dc != NULL;
 	 dc = TAILQ_NEXT(dc, dc_queue)) {
 		if (dc-dc_dev == dev)
 			panic(config_defer: deferred twice);
 	}
-	mutex_exit(config_queues_lock);
+	mutex_exit(config_queues_lock);
 #endif
 
 	dc = kmem_alloc(sizeof(*dc), kmflags);
@@ -1693,9 +1692,9 @@
 	dc-dc_dev = dev;
 	dc-dc_func = func;
 
-	mutex_enter(config_queues_lock);
+	mutex_enter(config_queues_lock);
 	TAILQ_INSERT_TAIL(deferred_config_queue, dc, dc_queue);
-	mutex_exit(config_queues_lock);
+	mutex_exit(config_queues_lock);
 
 	config_pending_incr();
 }
@@ -1719,13 +1718,13 @@
 	}
 
 #ifdef DIAGNOSTIC
-	mutex_enter(config_queues_lock);
+	mutex_enter(config_queues_lock);
 	for (dc = TAILQ_FIRST(interrupt_config_queue); dc != NULL;
 	 dc = TAILQ_NEXT(dc, dc_queue)) {
 		if (dc-dc_dev == dev)
 			panic(config_interrupts: deferred twice);
 	}
-	mutex_exit(config_queues_lock);
+	mutex_exit(config_queues_lock);
 #endif
 
 	dc = kmem_alloc(sizeof(*dc), kmflags);
@@ -1734,9 +1733,9 @@
 
 	dc-dc_dev = dev;
 	dc-dc_func = func;
-	mutex_enter(config_queues_lock);
+	mutex_enter(config_queues_lock);
 	TAILQ_INSERT_TAIL(interrupt_config_queue, dc, dc_queue);
-	mutex_exit(config_queues_lock);
+	mutex_exit(config_queues_lock);
 	config_pending_incr();
 }
 
@@ -1749,21 +1748,21 @@
 {
 	struct deferred_config *dc, *ndc;
 
-	mutex_enter(config_queues_lock);
+	mutex_enter(config_queues_lock);
 	for (dc = TAILQ_FIRST(queue); dc != NULL; dc = ndc) {
 		ndc = TAILQ_NEXT(dc, dc_queue);
 		if (parent == NULL || dc-dc_dev-dv_parent == parent) {
 			TAILQ_REMOVE(queue, dc, dc_queue);
-			mutex_exit(config_queues_lock);
-			mutex_enter(dc_funcs_lock);
+			mutex_exit(config_queues_lock);
+			mutex_enter(dc_funcs_lock);
 			(*dc-dc_func)(dc-dc_dev);
-			mutex_exit(dc_funcs_lock);
+			

CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 22:37:36 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_intr.c

Log Message:
- in rmixl_intr_init_clk, use MIPS_INT_MASK_SHIFT instead of 8
when calculating vector number for clock.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.28 -r1.1.2.29 src/sys/arch/mips/rmi/rmixl_intr.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/mips/rmi/rmixl_intr.c
diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.28 src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.29
--- src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.28	Tue Feb  8 21:27:15 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.c	Tue Feb  8 22:37:36 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.c,v 1.1.2.28 2011/02/08 21:27:15 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.c,v 1.1.2.29 2011/02/08 22:37:36 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.28 2011/02/08 21:27:15 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.29 2011/02/08 22:37:36 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -449,7 +449,7 @@
 void
 rmixl_intr_init_clk(void)
 {
-	int vec = ffs(MIPS_INT_MASK_5  8) - 1;
+	int vec = ffs(MIPS_INT_MASK_5  MIPS_INT_MASK_SHIFT) - 1;
 
 	mutex_enter(rmixl_intr_lock);
 



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 22:42:32 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: db_interface.c

Log Message:
- cpu index variables (ddb_cpu, cpu_me) are now type u_int
- can now cpu_number() instead of cpu_index(curcpu())
since they are the same.


To generate a diff of this commit:
cvs rdiff -u -r1.64.16.20 -r1.64.16.21 src/sys/arch/mips/mips/db_interface.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/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.64.16.20 src/sys/arch/mips/mips/db_interface.c:1.64.16.21
--- src/sys/arch/mips/mips/db_interface.c:1.64.16.20	Tue Feb  8 19:18:22 2011
+++ src/sys/arch/mips/mips/db_interface.c	Tue Feb  8 22:42:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.64.16.20 2011/02/08 19:18:22 cliff Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.64.16.21 2011/02/08 22:42:32 cliff Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.64.16.20 2011/02/08 19:18:22 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.64.16.21 2011/02/08 22:42:32 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_cputype.h	/* which mips CPUs do we support? */
@@ -67,8 +67,8 @@
 #include ddb/db_run.h	/* for db_continue_cmd() proto */
 #endif
 
-#define NOCPU   -1
-int ddb_cpu = NOCPU;
+#define NOCPU   ~0
+u_int ddb_cpu = NOCPU;
 
 int		db_active = 0;
 db_regs_t	ddb_regs;
@@ -211,8 +211,9 @@
 
 #ifdef MULTIPROCESSOR
 	bool first_in_ddb = false;
-	int cpu_me = cpu_index(curcpu());
-	int old_ddb_cpu = atomic_cas_32(ddb_cpu, NOCPU, cpu_me);
+	u_int cpu_me = cpu_number();
+	u_int old_ddb_cpu =
+		atomic_cas_uint(ddb_cpu, NOCPU, cpu_me);
 	if (old_ddb_cpu == NOCPU) {
 		first_in_ddb = true;
 		cpu_pause_others();
@@ -1081,7 +1082,7 @@
 bool 
 ddb_running_on_this_cpu_p(void)
 {   
-	return ddb_cpu == cpu_index(curcpu());
+	return ddb_cpu == cpu_number();
 }
 
 bool 
@@ -1093,9 +1094,9 @@
 void
 db_resume_others(void)
 {
-	int cpu_me = cpu_index(curcpu());
+	u_int cpu_me = cpu_number();
 
-	if (atomic_cas_32(ddb_cpu, cpu_me, NOCPU) == cpu_me)
+	if (atomic_cas_uint(ddb_cpu, cpu_me, NOCPU) == cpu_me)
 		cpu_resume_others();
 }
 



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 23:01:28 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_cpu.c rmixl_cpucore.c

Log Message:
- make compile without MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.19 -r1.1.2.20 src/sys/arch/mips/rmi/rmixl_cpu.c
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 src/sys/arch/mips/rmi/rmixl_cpucore.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/mips/rmi/rmixl_cpu.c
diff -u src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.19 src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.20
--- src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.19	Tue Feb  8 19:50:22 2011
+++ src/sys/arch/mips/rmi/rmixl_cpu.c	Tue Feb  8 23:01:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpu.c,v 1.1.2.19 2011/02/08 19:50:22 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpu.c,v 1.1.2.20 2011/02/08 23:01:28 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.19 2011/02/08 19:50:22 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.20 2011/02/08 23:01:28 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -168,7 +168,6 @@
 cpu_rmixl_attach(device_t parent, device_t self, void *aux)
 {
 	struct rmixl_cpu_softc * const sc = device_private(self);
-	struct cpucore_attach_args *ca = aux;
 	struct cpu_info *ci = NULL;
 	static bool once = false;
 	extern void rmixl_spl_init_cpu(void);
@@ -190,6 +189,7 @@
 		struct cpucore_softc * const ccsc = device_private(parent);
 		rmixlfw_psb_type_t psb_type = rmixl_configuration.rc_psb_type;
 		cpuid_t cpuid;
+		struct cpucore_attach_args *ca = aux;
 
 		KASSERT(ca-ca_core  8);
 		KASSERT(ca-ca_thread  4);

Index: src/sys/arch/mips/rmi/rmixl_cpucore.c
diff -u src/sys/arch/mips/rmi/rmixl_cpucore.c:1.1.2.9 src/sys/arch/mips/rmi/rmixl_cpucore.c:1.1.2.10
--- src/sys/arch/mips/rmi/rmixl_cpucore.c:1.1.2.9	Tue Feb  8 06:03:36 2011
+++ src/sys/arch/mips/rmi/rmixl_cpucore.c	Tue Feb  8 23:01:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpucore.c,v 1.1.2.9 2011/02/08 06:03:36 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpucore.c,v 1.1.2.10 2011/02/08 23:01:28 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpucore.c,v 1.1.2.9 2011/02/08 06:03:36 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpucore.c,v 1.1.2.10 2011/02/08 23:01:28 cliff Exp $);
 
 #include opt_multiprocessor.h
 
@@ -91,9 +91,10 @@
 
 	sc-sc_dev = self;
 	sc-sc_core = na-na_core;
-	sc-sc_hatched = false;
 
 #ifdef MULTIPROCESSOR
+	sc-sc_hatched = false;
+
 	/*
 	 * Create the TLB structure needed - one per core and core0 uses the
 	 * default one for the system.



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/include

2011-02-08 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 23:05:00 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: cpu.h

Log Message:
- fix cpu_number() define for non- MULTIPROCESSOR case


To generate a diff of this commit:
cvs rdiff -u -r1.90.16.34 -r1.90.16.35 src/sys/arch/mips/include/cpu.h

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

Modified files:

Index: src/sys/arch/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.90.16.34 src/sys/arch/mips/include/cpu.h:1.90.16.35
--- src/sys/arch/mips/include/cpu.h:1.90.16.34	Tue Feb  8 06:01:08 2011
+++ src/sys/arch/mips/include/cpu.h	Tue Feb  8 23:04:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.90.16.34 2011/02/08 06:01:08 cliff Exp $	*/
+/*	$NetBSD: cpu.h,v 1.90.16.35 2011/02/08 23:04:59 cliff Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -202,7 +202,7 @@
 #define	cpu_number()		(curcpu()-ci_index)
 #define	CPU_IS_PRIMARY(ci)	((ci)-ci_flags  CPUF_PRIMARY)
 #else
-#define	cpu_number()		(0L)
+#define	cpu_number()		0
 #endif
 
 /* XXX simonb



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/include

2011-02-07 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 06:01:09 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: cpu.h

Log Message:
- re-define cpu_number() to now mean ci_index instead of ci_cpuid
- re-define CPU_IS_PRIMARY() to use CPUF_PRIMARY instead of ci_cpuid


To generate a diff of this commit:
cvs rdiff -u -r1.90.16.33 -r1.90.16.34 src/sys/arch/mips/include/cpu.h

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

Modified files:

Index: src/sys/arch/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.90.16.33 src/sys/arch/mips/include/cpu.h:1.90.16.34
--- src/sys/arch/mips/include/cpu.h:1.90.16.33	Sat Feb  5 06:04:07 2011
+++ src/sys/arch/mips/include/cpu.h	Tue Feb  8 06:01:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.90.16.33 2011/02/05 06:04:07 cliff Exp $	*/
+/*	$NetBSD: cpu.h,v 1.90.16.34 2011/02/08 06:01:08 cliff Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -199,8 +199,8 @@
 #define	curcpu()		(curlwp-l_cpu)
 #define	curpcb			(curlwp-l_addr-u_pcb)
 #ifdef MULTIPROCESSOR
-#define	cpu_number()		(curcpu()-ci_cpuid)
-#define	CPU_IS_PRIMARY(ci)	((ci)-ci_cpuid == 0)
+#define	cpu_number()		(curcpu()-ci_index)
+#define	CPU_IS_PRIMARY(ci)	((ci)-ci_flags  CPUF_PRIMARY)
 #else
 #define	cpu_number()		(0L)
 #endif



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-02-07 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 06:01:47 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: cpu_subr.c

Log Message:
- add cpuid column to table displayed by cpu_debug_dump()


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/sys/arch/mips/mips/cpu_subr.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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.1.2.14 src/sys/arch/mips/mips/cpu_subr.c:1.1.2.15
--- src/sys/arch/mips/mips/cpu_subr.c:1.1.2.14	Sat Feb  5 06:06:11 2011
+++ src/sys/arch/mips/mips/cpu_subr.c	Tue Feb  8 06:01:47 2011
@@ -33,7 +33,7 @@
 #include opt_multiprocessor.h
 #include opt_sa.h
 
-__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.1.2.14 2011/02/05 06:06:11 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.1.2.15 2011/02/08 06:01:47 cliff Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -816,17 +816,17 @@
 	struct cpu_info *ci;
 	char running, hatched, paused, resumed, halted;
 
-	db_printf(CPU STATE CPUINFOCPL INT MTX IPIS\n);
+	db_printf(CPU CPUID STATE CPUINFOCPL INT MTX IPIS\n);
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		hatched = (CPUSET_HAS(cpus_hatched, cpu_index(ci)) ? 'H' : '-');
 		running = (CPUSET_HAS(cpus_running, cpu_index(ci)) ? 'R' : '-');
 		paused  = (CPUSET_HAS(cpus_paused,  cpu_index(ci)) ? 'P' : '-');
 		resumed = (CPUSET_HAS(cpus_resumed, cpu_index(ci)) ? 'r' : '-');
 		halted  = (CPUSET_HAS(cpus_halted,  cpu_index(ci)) ? 'h' : '-');
-		db_printf(%3d %c%c%c%c%c %p 
+		db_printf(%3d 0x%03lx %c%c%c%c%c %p 
 			%3d %3d %3d 
 			0x%02 PRIx64 /0x%02 PRIx64 \n,
-			cpu_index(ci),
+			cpu_index(ci), ci-ci_cpuid,
 			running, hatched, paused, resumed, halted,
 			ci, ci-ci_cpl, ci-ci_idepth, ci-ci_mtx_count,
 			ci-ci_active_ipis, ci-ci_request_ipis);



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-07 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 06:03:01 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_cpu.c

Log Message:
- renamed cpu_rmixl_attach_once() to cpu_rmixl_attach_primary() (more clear)
- cpu_rmixl_attach_primary() obtains ci_cpuid from COP0 EBASE reg
instead of assuming always cpuid==0
- in cpu_rmixl_attach(), first call of the function determines we are attaching
primary cpu, instead of asuming core0 thread0 is always the primary cpu
- cpu_fmn_intr() uses CPU_IS_PRIMARY() instead of asuming cpu_number()==0
always indicates the primary cpu
- debug function rmixl_cpuinfo_print() argument is now a cpu index, not cpuid


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.17 -r1.1.2.18 src/sys/arch/mips/rmi/rmixl_cpu.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/mips/rmi/rmixl_cpu.c
diff -u src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.17 src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.18
--- src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.17	Sat Feb  5 06:10:29 2011
+++ src/sys/arch/mips/rmi/rmixl_cpu.c	Tue Feb  8 06:03:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpu.c,v 1.1.2.17 2011/02/05 06:10:29 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpu.c,v 1.1.2.18 2011/02/08 06:03:01 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.17 2011/02/05 06:10:29 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.18 2011/02/08 06:03:01 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -70,7 +70,7 @@
 
 static int	cpu_rmixl_match(device_t, cfdata_t, void *);
 static void	cpu_rmixl_attach(device_t, device_t, void *);
-static void	cpu_rmixl_attach_once(struct rmixl_cpu_softc * const);
+static void	cpu_rmixl_attach_primary(struct rmixl_cpu_softc * const);
 #ifdef NOTYET
 static int	cpu_fmn_intr(void *, rmixl_fmn_rxmsg_t *);
 #endif
@@ -87,7 +87,7 @@
 #ifdef DEBUG
 void		rmixl_cpu_data_print(struct cpu_data *);
 struct cpu_info *
-		rmixl_cpuinfo_print(cpuid_t);
+		rmixl_cpuinfo_print(u_int);
 #endif	/* DEBUG */
 
 CFATTACH_DECL_NEW(cpu_rmixl, sizeof(struct rmixl_cpu_softc),
@@ -170,16 +170,19 @@
 	struct rmixl_cpu_softc * const sc = device_private(self);
 	struct cpucore_attach_args *ca = aux;
 	struct cpu_info *ci = NULL;
+	static bool once = false;
 	extern void rmixl_spl_init_cpu(void);
-
-	if (ca-ca_thread == 0  ca-ca_core == 0) {
+	
+	if (once == false) {
+		/* first attach is the primary cpu */
+		once = true;
 		ci = curcpu();
 		sc-sc_dev = self;
 		sc-sc_ci = ci;
 		ci-ci_softc = (void *)sc;
 
 		rmixl_spl_init_cpu();	/* spl initialization for CPU#0 */
-		cpu_rmixl_attach_once(sc);
+		cpu_rmixl_attach_primary(sc);
 
 #ifdef MULTIPROCESSOR
 		mips_locoresw.lsw_cpu_init = cpu_rmixl_hatch;
@@ -232,15 +235,22 @@
 cpu_attach_common(self, ci);
 }
 
+/*
+ * attach the primary processor
+ */
 static void
-cpu_rmixl_attach_once(struct rmixl_cpu_softc * const sc)
+cpu_rmixl_attach_primary(struct rmixl_cpu_softc * const sc)
 {
-	static bool once = false;
+	struct cpu_info *ci = sc-sc_ci;
+	uint32_t ebase;
+
+	KASSERT(CPU_IS_PRIMARY(ci));
 
-	KASSERT(once != true);
-	if (once == true)
-		return;
-	once = true;
+	/*
+	 * obtain and set cpuid of the primary processor
+	 */
+	asm volatile(dmfc0 %0, $15, 1; : =r(ebase));
+	ci-ci_cpuid = ebase  __BITS(9,0);
 
 #if defined(DDB)  defined(MIPS_DDB_WATCH)
 	cpu_rmixl_db_watch_init();
@@ -268,8 +278,8 @@
 static int
 cpu_fmn_intr(void *arg, rmixl_fmn_rxmsg_t *rxmsg)
 {
-	if (cpu_number() == 0) {
-		printf(%s: cpu %ld: rxsid=%#x, code=%d, size=%d\n,
+	if (CPU_IS_PRIMARY(curcpu())) {
+		printf(%s: cpu%ld: rxsid=%#x, code=%d, size=%d\n,
 			__func__, cpu_number(),
 			rxmsg-rxsid, rxmsg-code, rxmsg-size);
 		for (int i=0; i  rxmsg-size; i++)
@@ -426,9 +436,9 @@
 }
 
 struct cpu_info *
-rmixl_cpuinfo_print(cpuid_t cpuid)
+rmixl_cpuinfo_print(u_int cpuindex)
 {
-	struct cpu_info * const ci = cpu_lookup(cpuid);
+	struct cpu_info * const ci = cpu_lookup(cpuindex);
 
 	if (ci != NULL) {
 		rmixl_cpu_data_print(ci-ci_data);



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-07 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 06:03:56 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_fmn.c

Log Message:
- eliminate assumptions that cpuid 0 is primary
- distinguish between cpuid and cpu index.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/arch/mips/rmi/rmixl_fmn.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/mips/rmi/rmixl_fmn.c
diff -u src/sys/arch/mips/rmi/rmixl_fmn.c:1.1.2.5 src/sys/arch/mips/rmi/rmixl_fmn.c:1.1.2.6
--- src/sys/arch/mips/rmi/rmixl_fmn.c:1.1.2.5	Sat Feb  5 06:11:16 2011
+++ src/sys/arch/mips/rmi/rmixl_fmn.c	Tue Feb  8 06:03:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_fmn.c,v 1.1.2.5 2011/02/05 06:11:16 cliff Exp $	*/
+/*	$NetBSD: rmixl_fmn.c,v 1.1.2.6 2011/02/08 06:03:56 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,6 +32,7 @@
 
 #include sys/cdefs.h
 #include sys/param.h
+#include sys/systm.h
 #include sys/cpu.h
 #include mips/cpuregs.h
 #include mips/rmi/rmixlreg.h
@@ -404,8 +405,9 @@
 	fmn_t *fmnp;
 	static bool once=false;
 
-	KASSERT(cpu_number() == 0);
-	fmnp = fmn_lookup(cpu_number());
+	KASSERTMSG((CPU_IS_PRIMARY(curcpu())), (ci=%p, index=%d\n,
+		curcpu(), cpu_index(curcpu(;
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 
 	if (once == true)
 		panic(%s: call only once!, __func__);
@@ -480,10 +482,10 @@
 	fmn_t *fmnp;
 	kmutex_t *lk;
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 	KASSERT(fmnp != NULL);
-	KASSERT(fmnp-fmn_core == RMIXL_CPU_CORE(cpu_number()));
-	KASSERT(fmnp-fmn_thread == RMIXL_CPU_THREAD(cpu_number()));
+	KASSERT(fmnp-fmn_core == RMIXL_CPU_CORE(curcpu()-ci_cpuid));
+	KASSERT(fmnp-fmn_thread == RMIXL_CPU_THREAD(curcpu()-ci_cpuid));
 
 	lk = mutex_obj_alloc(MUTEX_DEFAULT, RMIXL_FMN_INTR_IPL);
 	if (lk == NULL)
@@ -633,7 +635,7 @@
 {
 	fmn_t *fmnp;
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 	mutex_enter(fmnp-fmn_lock);
 
 	for (int i=0; i  fmnp-fmn_nstid; i++)
@@ -665,7 +667,7 @@
 	fmn_t *fmnp;
 	fmn_intrhand_t *ih;
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 
 	mutex_enter(fmnp-fmn_lock);
 
@@ -692,7 +694,7 @@
 	fmn_t *fmnp;
 	fmn_intrhand_t *ih = cookie;
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 	mutex_enter(fmnp-fmn_lock);
 
 	if (ih-ih_func != NULL) {
@@ -786,7 +788,7 @@
 	KASSERT(code = 0xff);
 	KASSERT(dest_id = 0xff);
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 	mutex_enter(fmnp-fmn_lock);
 cp0_status = rmixl_cp2_enable();
 
@@ -821,13 +823,13 @@
 			goto send;
 		DELAY(10);		/* XXX ??? */
 	}
-	DIAG_PRF((%s: cpu=%ld, msg %p, dst_id=%d, sts=%#x: can't send\n,
+	DIAG_PRF((%s: cpu%d, msg %p, dst_id=%d, sts=%#x: can't send\n,
 		__func__, cpu_number(), msg, dest_id, msg_status));
 	rv = -1;
 	goto out;
  send:
 	desc = RMIXL_MSGSND_DESC(size, code, dest_id);
-	DPRINTF((%s: cpu %ld, desc %#x\n, __func__, cpu_number(), desc));
+	DPRINTF((%s: cpu%d, desc %#x\n, __func__, cpu_number(), desc));
 	for (int try=16; try--; ) {
 		rmixl_msgsnd(desc);
 		RMIXL_MFC2(RMIXL_COP_2_MSG_STS, 0, msg_status);
@@ -853,7 +855,7 @@
 			RMIXL_MTC2(RMIXL_COP_2_MSG_STS, 1, msg_status1);
 		}
 		DIAG_PRF((%s: src=%ld, dst=%d, sts=%#x, %#x: send error, try %d\n,
-			__func__, cpu_number(), dest_id, msg_status, msg_status1, try));
+			__func__, curcpu()-ci_cpuid, dest_id, msg_status, msg_status1, try));
 		DELAY(10);
 	}
 	rv = -1;
@@ -876,7 +878,7 @@
 	fmn_t *fmnp;
 	int rv;
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 	mutex_enter(fmnp-fmn_lock);
 	rv = rmixl_fmn_msg_recv_subr(bucket, rxmsg);
 	mutex_exit(fmnp-fmn_lock);
@@ -897,7 +899,7 @@
 	uint32_t msg_status;
 	int rv;
 
-	fmnp = fmn_lookup(cpu_number());
+	fmnp = fmn_lookup(curcpu()-ci_cpuid);
 	KASSERT(mutex_owned(fmnp-fmn_lock) != 0);
 
 	for (int try=16; try--; ) {
@@ -905,14 +907,14 @@
 		if ((msg_status  (RMIXL_MSG_STS0_LPF)) == 0)
 			goto recv;
 	}
-	DIAG_PRF((%s: cpu=%ld, bucket=%d, sts=%#x: Load Pending Fail\n,
+	DIAG_PRF((%s: cpu%d, bucket=%d, sts=%#x: Load Pending Fail\n,
 		__func__, cpu_number(), bucket, msg_status));
 	rv = -1;
 	goto out;
  recv:
 	rmixl_msgld(bucket);
 	RMIXL_MFC2(RMIXL_COP_2_MSG_STS, 0, msg_status);
-	DPRINTF((%s: cpu=%ld, bucket=%d, sts=%#x\n,
+	DPRINTF((%s: cpu%d, bucket=%d, sts=%#x\n,
 		__func__, cpu_number(), bucket, msg_status));
 	rv = msg_status  (RMIXL_MSG_STS0_LEF|RMIXL_MSG_STS0_LPF);
 	if (rv == 0) {
@@ -1146,7 +1148,7 @@
 	FMN_CP2_4SEL_READ(RMIXL_COP_2_CREDITS+3, 0, cc[3][0]);
 	FMN_CP2_4SEL_READ(RMIXL_COP_2_CREDITS+3, 4, cc[3][4]);
 
-	printf(%s: cpu %ld\n, __func__, cpu_number());
+	printf(%s: cpu%d\n, __func__, cpu_number());
 	for (int i=0; i  4; i++) {
 		for (int j=0; j  8; j++)
 			printf( %#x,, cc[i][j]);


CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-07 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 06:04:20 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_intr.c

Log Message:
- distinguish between cpuid and cpu index.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.25 -r1.1.2.26 src/sys/arch/mips/rmi/rmixl_intr.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/mips/rmi/rmixl_intr.c
diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.25 src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.26
--- src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.25	Sat Feb  5 06:11:47 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.c	Tue Feb  8 06:04:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.c,v 1.1.2.25 2011/02/05 06:11:47 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.c,v 1.1.2.26 2011/02/08 06:04:20 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.25 2011/02/05 06:11:47 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.26 2011/02/08 06:04:20 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -508,8 +508,8 @@
 			device_xname(sc-sc_dev),
 			rmixl_intr_string(vec));
 
-	KASSERT(ci-ci_cpuid  (sizeof(cpu_present_mask) * 8));
-	atomic_or_32((volatile uint32_t *)cpu_present_mask, 1  ci-ci_cpuid);
+	KASSERT(cpu_index(ci)  (sizeof(cpu_present_mask) * 8));
+	atomic_or_32((volatile uint32_t *)cpu_present_mask, 1  cpu_index(ci));
 }
 
 /*
@@ -955,9 +955,9 @@
 static int
 rmixl_send_ipi(struct cpu_info *ci, int tag)
 {
-	const cpuid_t cpu = ci-ci_cpuid;
-	uint32_t core = (uint32_t)(cpu  2);
-	uint32_t thread = (uint32_t)(cpu  __BITS(1,0));
+	const cpuid_t cpuid = ci-ci_cpuid;
+	uint32_t core = (uint32_t)(cpuid  2);
+	uint32_t thread = (uint32_t)(cpuid  __BITS(1,0));
 	uint64_t req = 1  tag;
 	uint32_t r;
 	extern volatile mips_cpuset_t cpus_running;



CVS commit: [matt-nb5-mips64] src/sys/kern

2011-02-07 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Tue Feb  8 06:05:00 UTC 2011

Modified Files:
src/sys/kern [matt-nb5-mips64]: subr_autoconf.c

Log Message:
- add config_queues_lock to serialize access to deferred_config_queue and
interrupt_config_queue for adds, deletes and (those DIAGNOSTIC) searches
- add dc_funcs_lock to serialize dispatch of deferred config functions
many (all?) of which may not be MP safe.


To generate a diff of this commit:
cvs rdiff -u -r1.163.4.2.4.1 -r1.163.4.2.4.2 src/sys/kern/subr_autoconf.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/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.163.4.2.4.1 src/sys/kern/subr_autoconf.c:1.163.4.2.4.2
--- src/sys/kern/subr_autoconf.c:1.163.4.2.4.1	Sat Feb  5 06:00:14 2011
+++ src/sys/kern/subr_autoconf.c	Tue Feb  8 06:04:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.163.4.2.4.1 2011/02/05 06:00:14 cliff Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.163.4.2.4.2 2011/02/08 06:04:59 cliff Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: subr_autoconf.c,v 1.163.4.2.4.1 2011/02/05 06:00:14 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: subr_autoconf.c,v 1.163.4.2.4.2 2011/02/08 06:04:59 cliff Exp $);
 
 #include opt_multiprocessor.h
 #include opt_ddb.h
@@ -198,6 +198,21 @@
 
 TAILQ_HEAD(deferred_config_head, deferred_config);
 
+/*
+ * config_queues_lock protects MP access to
+ * - deferred_config_queue
+ * - interrupt_config_queue
+ * is held for short durations, and is initialized to spin
+ */
+static kmutex_t config_queues_lock;
+
+/*
+ * dc_funcs_lock ensures the driver dc_func's are not called concurrently
+ * many (most?) are not MP safe
+ * is held for unknown durations, and is initialized to sleep
+ */
+static kmutex_t dc_funcs_lock;
+
 struct deferred_config_head deferred_config_queue =
 	TAILQ_HEAD_INITIALIZER(deferred_config_queue);
 struct deferred_config_head interrupt_config_queue =
@@ -361,6 +376,10 @@
 	mutex_init(config_misc_lock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(config_misc_cv, cfgmisc);
 
+	mutex_init(dc_funcs_lock, MUTEX_DEFAULT, IPL_SOFTNET);
+
+	mutex_init(config_queues_lock, MUTEX_DEFAULT, IPL_VM);
+
 	/* allcfdrivers is statically initialized. */
 	for (i = 0; cfdriver_list_initial[i] != NULL; i++) {
 		if (config_cfdriver_attach(cfdriver_list_initial[i]) != 0)
@@ -397,12 +416,19 @@
 {
 	struct deferred_config *dc;
 
+	mutex_enter(config_queues_lock);
 	while ((dc = TAILQ_FIRST(interrupt_config_queue)) != NULL) {
 		TAILQ_REMOVE(interrupt_config_queue, dc, dc_queue);
+		mutex_exit(config_queues_lock);
+		mutex_enter(dc_funcs_lock);
 		(*dc-dc_func)(dc-dc_dev);
+		mutex_exit(dc_funcs_lock);
 		kmem_free(dc, sizeof(*dc));
 		config_pending_decr();
+		mutex_enter(config_queues_lock);
 	}
+	mutex_exit(config_queues_lock);
+
 	kthread_exit(0);
 }
 
@@ -1651,11 +1677,13 @@
 		panic(config_defer: can't defer config of a root device);
 
 #ifdef DIAGNOSTIC
+	mutex_enter(config_queues_lock);
 	for (dc = TAILQ_FIRST(deferred_config_queue); dc != NULL;
 	 dc = TAILQ_NEXT(dc, dc_queue)) {
 		if (dc-dc_dev == dev)
 			panic(config_defer: deferred twice);
 	}
+	mutex_exit(config_queues_lock);
 #endif
 
 	dc = kmem_alloc(sizeof(*dc), kmflags);
@@ -1664,7 +1692,11 @@
 
 	dc-dc_dev = dev;
 	dc-dc_func = func;
+
+	mutex_enter(config_queues_lock);
 	TAILQ_INSERT_TAIL(deferred_config_queue, dc, dc_queue);
+	mutex_exit(config_queues_lock);
+
 	config_pending_incr();
 }
 
@@ -1687,11 +1719,13 @@
 	}
 
 #ifdef DIAGNOSTIC
+	mutex_enter(config_queues_lock);
 	for (dc = TAILQ_FIRST(interrupt_config_queue); dc != NULL;
 	 dc = TAILQ_NEXT(dc, dc_queue)) {
 		if (dc-dc_dev == dev)
 			panic(config_interrupts: deferred twice);
 	}
+	mutex_exit(config_queues_lock);
 #endif
 
 	dc = kmem_alloc(sizeof(*dc), kmflags);
@@ -1700,7 +1734,9 @@
 
 	dc-dc_dev = dev;
 	dc-dc_func = func;
+	mutex_enter(config_queues_lock);
 	TAILQ_INSERT_TAIL(interrupt_config_queue, dc, dc_queue);
+	mutex_exit(config_queues_lock);
 	config_pending_incr();
 }
 
@@ -1713,15 +1749,21 @@
 {
 	struct deferred_config *dc, *ndc;
 
+	mutex_enter(config_queues_lock);
 	for (dc = TAILQ_FIRST(queue); dc != NULL; dc = ndc) {
 		ndc = TAILQ_NEXT(dc, dc_queue);
 		if (parent == NULL || dc-dc_dev-dv_parent == parent) {
 			TAILQ_REMOVE(queue, dc, dc_queue);
+			mutex_exit(config_queues_lock);
+			mutex_enter(dc_funcs_lock);
 			(*dc-dc_func)(dc-dc_dev);
+			mutex_exit(dc_funcs_lock);
 			kmem_free(dc, sizeof(*dc));
 			config_pending_decr();
+			mutex_enter(config_queues_lock);
 		}
 	}
+	mutex_exit(config_queues_lock);
 }
 
 /*



CVS commit: [matt-nb5-mips64] src/sys

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:00:15 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: pmap.h vmparam.h
src/sys/arch/mips/mips [matt-nb5-mips64]: mips3_clock.c mips_fixup.c
mips_fpu.c pmap_segtab.c
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_cpucore.c
rmixl_cpucorevar.h
src/sys/kern [matt-nb5-mips64]: kern_cctr.c kern_lwp.c kern_mutex.c
kern_runq.c kern_rwlock.c kern_stub.c subr_autoconf.c
src/sys/lib/libkern [matt-nb5-mips64]: softfloat.c
src/sys/miscfs/procfs [matt-nb5-mips64]: procfs_linux.c
src/sys/sys [matt-nb5-mips64]: lwp.h

Log Message:
- include opt_multiprocessor.h for explicit MULTIPROCESSOR dependency


To generate a diff of this commit:
cvs rdiff -u -r1.54.26.15 -r1.54.26.16 src/sys/arch/mips/include/pmap.h
cvs rdiff -u -r1.41.28.17 -r1.41.28.18 src/sys/arch/mips/include/vmparam.h
cvs rdiff -u -r1.10.28.1 -r1.10.28.2 src/sys/arch/mips/mips/mips3_clock.c
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/sys/arch/mips/mips/mips_fixup.c \
src/sys/arch/mips/mips/pmap_segtab.c
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/mips/mips/mips_fpu.c
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/arch/mips/rmi/rmixl_cpucore.c
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/mips/rmi/rmixl_cpucorevar.h
cvs rdiff -u -r1.8 -r1.8.14.1 src/sys/kern/kern_cctr.c
cvs rdiff -u -r1.126.2.2 -r1.126.2.2.4.1 src/sys/kern/kern_lwp.c
cvs rdiff -u -r1.44 -r1.44.10.1 src/sys/kern/kern_mutex.c
cvs rdiff -u -r1.22.4.3.4.1 -r1.22.4.3.4.2 src/sys/kern/kern_runq.c
cvs rdiff -u -r1.28.10.2.2.1 -r1.28.10.2.2.2 src/sys/kern/kern_rwlock.c
cvs rdiff -u -r1.11 -r1.11.8.1 src/sys/kern/kern_stub.c
cvs rdiff -u -r1.163.4.2 -r1.163.4.2.4.1 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.4 -r1.4.94.1 src/sys/lib/libkern/softfloat.c
cvs rdiff -u -r1.54.14.1 -r1.54.14.2 src/sys/miscfs/procfs/procfs_linux.c
cvs rdiff -u -r1.114.4.1 -r1.114.4.1.4.1 src/sys/sys/lwp.h

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

Modified files:

Index: src/sys/arch/mips/include/pmap.h
diff -u src/sys/arch/mips/include/pmap.h:1.54.26.15 src/sys/arch/mips/include/pmap.h:1.54.26.16
--- src/sys/arch/mips/include/pmap.h:1.54.26.15	Wed Dec 22 06:05:41 2010
+++ src/sys/arch/mips/include/pmap.h	Sat Feb  5 06:00:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.54.26.15 2010/12/22 06:05:41 matt Exp $	*/
+/*	$NetBSD: pmap.h,v 1.54.26.16 2011/02/05 06:00:12 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -74,6 +74,8 @@
 #ifndef	_MIPS_PMAP_H_
 #define	_MIPS_PMAP_H_
 
+#include opt_multiprocessor.h
+
 #include mips/cpuregs.h	/* for KSEG0 below */
 //#include mips/pte.h
 

Index: src/sys/arch/mips/include/vmparam.h
diff -u src/sys/arch/mips/include/vmparam.h:1.41.28.17 src/sys/arch/mips/include/vmparam.h:1.41.28.18
--- src/sys/arch/mips/include/vmparam.h:1.41.28.17	Thu Aug 19 07:19:31 2010
+++ src/sys/arch/mips/include/vmparam.h	Sat Feb  5 06:00:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.41.28.17 2010/08/19 07:19:31 matt Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.41.28.18 2011/02/05 06:00:12 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -79,6 +79,8 @@
 #ifndef _MIPS_VMPARAM_H_
 #define	_MIPS_VMPARAM_H_
 
+#include opt_multiprocessor.h
+
 /*
  * Machine dependent VM constants for MIPS.
  */

Index: src/sys/arch/mips/mips/mips3_clock.c
diff -u src/sys/arch/mips/mips/mips3_clock.c:1.10.28.1 src/sys/arch/mips/mips/mips3_clock.c:1.10.28.2
--- src/sys/arch/mips/mips/mips3_clock.c:1.10.28.1	Wed Jan 20 06:58:36 2010
+++ src/sys/arch/mips/mips/mips3_clock.c	Sat Feb  5 06:00:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips3_clock.c,v 1.10.28.1 2010/01/20 06:58:36 matt Exp $	*/
+/*	$NetBSD: mips3_clock.c,v 1.10.28.2 2011/02/05 06:00:13 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -78,7 +78,9 @@
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: mips3_clock.c,v 1.10.28.1 2010/01/20 06:58:36 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: mips3_clock.c,v 1.10.28.2 2011/02/05 06:00:13 cliff Exp $);
+
+#include opt_multiprocessor.h
 
 #include sys/param.h
 #include sys/systm.h

Index: src/sys/arch/mips/mips/mips_fixup.c
diff -u src/sys/arch/mips/mips/mips_fixup.c:1.1.2.8 src/sys/arch/mips/mips/mips_fixup.c:1.1.2.9
--- src/sys/arch/mips/mips/mips_fixup.c:1.1.2.8	Wed Dec 29 00:46:17 2010
+++ src/sys/arch/mips/mips/mips_fixup.c	Sat Feb  5 06:00:13 2011
@@ -29,8 +29,9 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: mips_fixup.c,v 1.1.2.8 2010/12/29 00:46:17 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: mips_fixup.c,v 1.1.2.9 2011/02/05 06:00:13 cliff Exp $);
 
+#include opt_multiprocessor.h
 #include opt_mips3_wired.h
 #include sys/param.h
 
Index: src/sys/arch/mips/mips/pmap_segtab.c
diff -u src/sys/arch/mips/mips/pmap_segtab.c:1.1.2.8 src/sys/arch/mips/mips/pmap_segtab.c:1.1.2.9
--- src/sys/arch/mips/mips/pmap_segtab.c:1.1.2.8	Mon Aug 16 

CVS commit: [matt-nb5-mips64] src/sys/arch/mips/conf

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:01:23 UTC 2011

Modified Files:
src/sys/arch/mips/conf [matt-nb5-mips64]: files.mips

Log Message:
- define config options flag MIPS_DDB_WATCH, enables COP0 watchpoint support in 
ddb


To generate a diff of this commit:
cvs rdiff -u -r1.58.24.12 -r1.58.24.13 src/sys/arch/mips/conf/files.mips

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/mips/conf/files.mips
diff -u src/sys/arch/mips/conf/files.mips:1.58.24.12 src/sys/arch/mips/conf/files.mips:1.58.24.13
--- src/sys/arch/mips/conf/files.mips:1.58.24.12	Wed Dec 29 00:40:40 2010
+++ src/sys/arch/mips/conf/files.mips	Sat Feb  5 06:01:23 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.mips,v 1.58.24.12 2010/12/29 00:40:40 matt Exp $
+#	$NetBSD: files.mips,v 1.58.24.13 2011/02/05 06:01:23 cliff Exp $
 #
 
 defflag	opt_cputype.h		NOFPU FPEMUL
@@ -17,6 +17,7 @@
 defflag opt_mips3_wired.h		ENABLE_MIPS3_WIRED_MAP
 
 defflag	opt_ddb.h		DDB_TRACE
+defflag	opt_ddb.h		MIPS_DDB_WATCH
 
 file	arch/mips/mips/locore_mips1.S		mips1
 file	arch/mips/mips/locore_mips3.S		mips3 | mips4 | mips32 | mips64



CVS commit: [matt-nb5-mips64] src/sys/arch/evbmips/conf

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:02:09 UTC 2011

Modified Files:
src/sys/arch/evbmips/conf [matt-nb5-mips64]: XLSATX

Log Message:
- add options MIPS_DDB_WATCH, to enable COP0 watchpoint support in ddb
- add config netbsd-sd0a for disk-rooted kernel


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.11 -r1.1.2.12 src/sys/arch/evbmips/conf/XLSATX

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/evbmips/conf/XLSATX
diff -u src/sys/arch/evbmips/conf/XLSATX:1.1.2.11 src/sys/arch/evbmips/conf/XLSATX:1.1.2.12
--- src/sys/arch/evbmips/conf/XLSATX:1.1.2.11	Mon Aug 16 18:44:45 2010
+++ src/sys/arch/evbmips/conf/XLSATX	Sat Feb  5 06:02:09 2011
@@ -1,8 +1,8 @@
-#	$NetBSD: XLSATX,v 1.1.2.11 2010/08/16 18:44:45 matt Exp $
+#	$NetBSD: XLSATX,v 1.1.2.12 2011/02/05 06:02:09 cliff Exp $
 
 include 	arch/evbmips/conf/std.rmixl
 
-#ident 		XLSATX-$Revision: 1.1.2.11 $
+#ident 		XLSATX-$Revision: 1.1.2.12 $
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -39,6 +39,7 @@
 options 	USERCONF	# userconf(4) support
 #options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 options 	DDB		# kernel dynamic debugger
+options		MIPS_DDB_WATCH	# enable T_WATCH (see IEU_DEFAUTURE[DBE])
 options 	DDB_HISTORY_SIZE=100 # enable history editing in DDB
 makeoptions 	DEBUG=-g	# compile full symbol table
 options 	SYMTAB_SPACE=50	# size for embedded symbol table
@@ -135,6 +136,7 @@
 config	netbsd		root on ? type ?
 config	netbsd-wm0	root on wm0 type nfs
 config	netbsd-msk0	root on msk0 type nfs
+config	netbsd-sd0a	root on sd0a type ffs
 
 
 mainbus0 	at root



CVS commit: [matt-nb5-mips64] src/sys/arch/evbmips/rmixl

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:02:52 UTC 2011

Modified Files:
src/sys/arch/evbmips/rmixl [matt-nb5-mips64]: machdep.c

Log Message:
- include opt_multiprocessor.h for MULTIPROCESSOR dependency
- in rmixl_pcr_init_core(), ifdef MIPS_DDB_WATCH, clear IEU_DEFEATURE
so we can get T_WATCH execeptions if/when we set COP0 watchpoint


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.32 -r1.1.2.33 src/sys/arch/evbmips/rmixl/machdep.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/evbmips/rmixl/machdep.c
diff -u src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.32 src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.33
--- src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.32	Fri Jan  7 00:17:42 2011
+++ src/sys/arch/evbmips/rmixl/machdep.c	Sat Feb  5 06:02:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.1.2.32 2011/01/07 00:17:42 cliff Exp $	*/
+/*	$NetBSD: machdep.c,v 1.1.2.33 2011/02/05 06:02:51 cliff Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -112,10 +112,11 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.1.2.32 2011/01/07 00:17:42 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.1.2.33 2011/02/05 06:02:51 cliff Exp $);
 
 #define __INTR_PRIVATE
 
+#include opt_multiprocessor.h
 #include opt_ddb.h
 #include opt_com.h
 #include opt_execfmt.h
@@ -488,6 +489,17 @@
 	r = rmixl_mfcr(RMIXL_PCR_L1D_CONFIG0);
 	r = ~__BIT(14);			/* disable Unaligned Access */
 	rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r);
+
+#if defined(DDB)  defined(MIPS_DDB_WATCH)
+	/*
+	 * clear IEU_DEFEATURE[DBE]
+	 * this enables COP0 watchpoint to trigger T_WATCH exception
+	 * instead of signaling JTAG.
+	 */
+	r = rmixl_mfcr(RMIXL_PCR_IEU_DEFEATURE);
+	r = ~__BIT(7);
+	rmixl_mtcr(RMIXL_PCR_IEU_DEFEATURE, r);
+#endif
 }
 
 #ifdef MULTIPROCESSOR



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/include

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:04:08 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: cpu.h

Log Message:
- include cpuset.h, we're using CPUSET_* macros now for cpus_running, 
cpus_paused, etc.
those data are now type mips_cpuset_t.
- move opt_* includes up above sys/* includes
- add declarations for IPI broadcast, multicast functions
- add declarations for cpu halt, pause, resume, etc functions useful for ddb


To generate a diff of this commit:
cvs rdiff -u -r1.90.16.32 -r1.90.16.33 src/sys/arch/mips/include/cpu.h

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

Modified files:

Index: src/sys/arch/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.90.16.32 src/sys/arch/mips/include/cpu.h:1.90.16.33
--- src/sys/arch/mips/include/cpu.h:1.90.16.32	Wed Sep  1 00:59:42 2010
+++ src/sys/arch/mips/include/cpu.h	Sat Feb  5 06:04:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.90.16.32 2010/09/01 00:59:42 matt Exp $	*/
+/*	$NetBSD: cpu.h,v 1.90.16.33 2011/02/05 06:04:07 cliff Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -46,16 +46,18 @@
 #ifdef _KERNEL
 
 #ifndef _LOCORE
-#include sys/cpu_data.h
-#include sys/device.h
-#include sys/evcnt.h
-
 #if defined(_KERNEL_OPT)
 #include opt_cputype.h
 #include opt_lockdebug.h
 #include opt_multiprocessor.h
 #endif
 
+#include sys/cpu_data.h
+#include sys/device.h
+#include sys/evcnt.h
+#include mips/reg.h
+#include mips/cpuset.h
+
 struct cpu_info {
 	struct cpu_data ci_data;	/* MI per-cpu data */
 	struct cpu_info *ci_next;	/* Next CPU in list */
@@ -352,6 +354,16 @@
 #define	cpu_swapout(p)			panic(cpu_swapout: can't get here);
 
 /*
+ * Send an inter-processor interupt to each other CPU (excludes curcpu())
+ */
+void cpu_broadcast_ipi(int);
+
+/*
+ * Send an inter-processor interupt to CPUs in cpuset (excludes curcpu())
+ */
+void cpu_multicast_ipi(mips_cpuset_t, int);
+
+/*
  * Send an inter-processor interupt to another CPU.
  */
 int cpu_send_ipi(struct cpu_info *, int);
@@ -426,13 +438,6 @@
 
 extern int mips_poolpage_vmfreelist;	/* freelist to allocate poolpages */
 
-/* cpu_subr.c */
-#ifdef MULTIPROCESSOR
-extern volatile u_long cpus_running;
-extern volatile u_long cpus_hatched;
-extern volatile u_long cpus_halted;
-#endif
-
 struct cpu_info *
 	cpu_info_alloc(struct pmap_tlb_info *, cpuid_t, cpuid_t, cpuid_t,
 	cpuid_t);
@@ -441,10 +446,25 @@
 #ifdef _LP64
 void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
 #endif
+
 #ifdef MULTIPROCESSOR
 void	cpu_hatch(struct cpu_info *ci);
 void	cpu_trampoline(void);
 void	cpu_boot_secondary_processors(void);
+void	cpu_halt(void);
+void	cpu_halt_others(void);
+void	cpu_pause(struct reg *);
+void	cpu_pause_others(void);
+void	cpu_resume(int);
+void	cpu_resume_others(void);
+int	cpu_is_paused(int);
+void	cpu_debug_dump(void);
+
+extern volatile mips_cpuset_t cpus_running;
+extern volatile mips_cpuset_t cpus_hatched;
+extern volatile mips_cpuset_t cpus_paused;
+extern volatile mips_cpuset_t cpus_resumed;
+extern volatile mips_cpuset_t cpus_halted;
 #endif
 
 /* copy.S */



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/include

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:04:59 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: db_machdep.h

Log Message:
- declare new md MP ddb functions.


To generate a diff of this commit:
cvs rdiff -u -r1.22.62.1 -r1.22.62.2 src/sys/arch/mips/include/db_machdep.h

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

Modified files:

Index: src/sys/arch/mips/include/db_machdep.h
diff -u src/sys/arch/mips/include/db_machdep.h:1.22.62.1 src/sys/arch/mips/include/db_machdep.h:1.22.62.2
--- src/sys/arch/mips/include/db_machdep.h:1.22.62.1	Mon Feb  1 04:16:19 2010
+++ src/sys/arch/mips/include/db_machdep.h	Sat Feb  5 06:04:59 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.22.62.1 2010/02/01 04:16:19 matt Exp $ */
+/* $NetBSD: db_machdep.h,v 1.22.62.2 2011/02/05 06:04:59 cliff Exp $ */
 
 /*
  * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -113,6 +113,13 @@
 db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
 db_addr_t next_instr_address(db_addr_t pc, bool bd);
 
+bool ddb_running_on_this_cpu(void);
+bool ddb_running_on_any_cpu(void);
+void db_resume_others(void);
+#ifdef MIPS_DDB_WATCH
+void db_mach_watch_set_all(void);
+#endif
+
 /*
  * We have machine-dependent commands.
  */



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/include

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:05:35 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: intr.h

Log Message:
- include opt_multiprocessor.h for MULTIPROCESSOR dependency
- add IPI tag defines for SUSPEND, HALT, and bump NIPIS


To generate a diff of this commit:
cvs rdiff -u -r1.3.96.14 -r1.3.96.15 src/sys/arch/mips/include/intr.h

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

Modified files:

Index: src/sys/arch/mips/include/intr.h
diff -u src/sys/arch/mips/include/intr.h:1.3.96.14 src/sys/arch/mips/include/intr.h:1.3.96.15
--- src/sys/arch/mips/include/intr.h:1.3.96.14	Wed Dec 22 06:09:02 2010
+++ src/sys/arch/mips/include/intr.h	Sat Feb  5 06:05:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.3.96.14 2010/12/22 06:09:02 matt Exp $ */
+/* $NetBSD: intr.h,v 1.3.96.15 2011/02/05 06:05:35 cliff Exp $ */
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,6 +31,8 @@
 #ifndef _MIPS_INTR_H_
 #define	_MIPS_INTR_H_
 
+#include opt_multiprocessor.h
+
 /*
  * This is a common machine/intr.h for all MIPS platforms.
  */
@@ -63,7 +65,9 @@
 #define	IPI_FPSAVE	3		/* save current fp registers */
 #define	IPI_SYNCICACHE	4		/* sync icache for pages */
 #define	IPI_KPREEMPT	5		/* schedule a kernel preemption */
-#define	NIPIS		6
+#define	IPI_SUSPEND	6		/* DDB suspend signaling */
+#define	IPI_HALT	7		/* halt cpu */
+#define	NIPIS		8
 
 #ifdef __INTR_PRIVATE
 struct splsw {



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:06:11 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: cpu_subr.c

Log Message:
- add ddb related includes
- convert 'cpus_running' et. al. to mips_cpuset_t, and use CPUSET_* macros
- add IPI broadcast, multicast functions
- add IPI halt, pause, resume, functions and related, useful for MP ddb


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.13 -r1.1.2.14 src/sys/arch/mips/mips/cpu_subr.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/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.1.2.13 src/sys/arch/mips/mips/cpu_subr.c:1.1.2.14
--- src/sys/arch/mips/mips/cpu_subr.c:1.1.2.13	Wed Dec 22 05:53:38 2010
+++ src/sys/arch/mips/mips/cpu_subr.c	Sat Feb  5 06:06:11 2011
@@ -29,10 +29,11 @@
 
 #include sys/cdefs.h
 
+#include opt_ddb.h
 #include opt_multiprocessor.h
 #include opt_sa.h
 
-__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.1.2.13 2010/12/22 05:53:38 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu_subr.c,v 1.1.2.14 2011/02/05 06:06:11 cliff Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -57,6 +58,15 @@
 #include mips/frame.h
 #include mips/userret.h
 #include mips/pte.h
+#include mips/cpuset.h
+
+#if defined(DDB) || defined(KGDB)
+#ifdef DDB 
+#include mips/db_machdep.h
+#include ddb/db_command.h
+#include ddb/db_output.h
+#endif
+#endif
 
 struct cpu_info cpu_info_store
 #ifdef MULTIPROCESSOR
@@ -82,9 +92,15 @@
 
 #ifdef MULTIPROCESSOR
 
-volatile u_long cpus_running = 1;
-volatile u_long cpus_hatched = 1;
-volatile u_long cpus_paused = 0;
+volatile mips_cpuset_t cpus_running = 1;
+volatile mips_cpuset_t cpus_hatched = 1;
+volatile mips_cpuset_t cpus_paused = 0;
+volatile mips_cpuset_t cpus_resumed = 0;
+volatile mips_cpuset_t cpus_halted = 0;
+
+static int  cpu_ipi_wait(volatile mips_cpuset_t *, u_long);
+static void cpu_ipi_error(const char *, mips_cpuset_t, mips_cpuset_t);
+
 
 static struct cpu_info *cpu_info_last = cpu_info_store;
 
@@ -602,6 +618,32 @@
 }
 
 #ifdef MULTIPROCESSOR
+
+void
+cpu_broadcast_ipi(int tag)
+{
+	(void)cpu_multicast_ipi(
+		CPUSET_EXCEPT(cpus_running, cpu_index(curcpu())), tag);
+}
+
+void
+cpu_multicast_ipi(mips_cpuset_t cpuset, int tag)
+{
+	CPU_INFO_ITERATOR cii;
+	struct cpu_info *ci;
+
+	CPUSET_DEL(cpuset, cpu_index(curcpu()));
+	if (CPUSET_EMPTY(cpuset))
+		return;
+
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		if (CPUSET_HAS(cpuset, cpu_index(ci))) {
+			CPUSET_DEL(cpuset, cpu_index(ci));
+			(void)cpu_send_ipi(ci, tag);
+		}
+	}
+}
+
 int
 cpu_send_ipi(struct cpu_info *ci, int tag)
 {
@@ -609,11 +651,192 @@
 	return (*mips_locoresw.lsw_send_ipi)(ci, tag);
 }
 
+static void
+cpu_ipi_error(const char *s, mips_cpuset_t succeeded, mips_cpuset_t expected)
+{
+	CPUSET_SUB(expected, succeeded);
+	if (!CPUSET_EMPTY(expected)) {
+		printf(Failed to %s:, s);
+		do {
+			int index = CPUSET_NEXT(expected);
+			CPUSET_DEL(expected, index);
+			printf( cpu%d, index);
+		} while(!CPUSET_EMPTY(expected));
+		printf(\n);
+	}
+}
+
+static int
+cpu_ipi_wait(volatile mips_cpuset_t *watchset, u_long mask)
+{
+	u_long limit = curcpu()-ci_cpu_freq;	/* some finite amount of time */
+
+	while (limit--)
+		if (*watchset == mask)
+			return 0;		/* success */
+
+	return 1;/* timed out */
+}
+
+/*
+ * Halt this cpu
+ */
+void
+cpu_halt(void)
+{
+	int index = cpu_index(curcpu());
+
+	printf(cpu%d: shutting down\n, index);
+	CPUSET_ADD(cpus_halted, index);
+	spl0();		/* allow interrupts e.g. further ipi ? */
+	for (;;) ;	/* spin */
+
+	/* NOTREACHED */
+}
+
+/*
+ * Halt all running cpus, excluding current cpu.
+ */
+void
+cpu_halt_others(void)
+{
+	mips_cpuset_t cpumask, cpuset;
+
+	CPUSET_ASSIGN(cpuset, cpus_running);
+	CPUSET_DEL(cpuset, cpu_index(curcpu()));
+	CPUSET_ASSIGN(cpumask, cpuset);
+	CPUSET_SUB(cpuset, cpus_halted);
+
+	if (CPUSET_EMPTY(cpuset))
+		return;
+
+	cpu_multicast_ipi(cpuset, IPI_HALT);
+	if (cpu_ipi_wait(cpus_halted, cpumask))
+		cpu_ipi_error(halt, cpumask, cpus_halted);
+
+	/*
+	 * TBD
+	 * Depending on available firmware methods, other cpus will
+	 * either shut down themselfs, or spin and wait for us to
+	 * stop them.
+	 */
+}
+
+/*
+ * Pause this cpu
+ */
+void
+cpu_pause(struct reg *regsp)
+{
+	int s = splhigh();
+	int index = cpu_index(curcpu());
+
+	for (;;) {
+		CPUSET_ADD(cpus_paused, index);
+		do {
+			;
+		} while(CPUSET_HAS(cpus_paused, index));
+		CPUSET_ADD(cpus_resumed, index);
+
+#if defined(DDB)
+		if (ddb_running_on_this_cpu())
+			cpu_Debugger();
+		if (ddb_running_on_any_cpu())
+			continue;
+#endif
+		break;
+	}
+#if defined(DDB)  defined(MIPS_DDB_WATCH)
+	db_mach_watch_set_all();
+#endif
+
+	splx(s);
+}
+
+/*
+ * Pause all running cpus, excluding current cpu.
+ */
+void
+cpu_pause_others(void)
+{
+	mips_cpuset_t cpuset;
+
+	CPUSET_ASSIGN(cpuset, cpus_running);
+	CPUSET_DEL(cpuset, cpu_index(curcpu()));
+
+	if 

CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:07:07 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: db_interface.c

Log Message:
- add suport for MP ddb
- add 'mach watch' command and related to enable ddb use of MIPS CP0 watchpoint
operator may specify one or more of rwx access mode qualifiers,
optional mask, and optional asid.  with no args, 'mach watch' dumps the
CP0 watchpoints table.
- 'mach unwatch' command deletes entries from the table; either
a) all entries matching an optional address, or
b) with no address specified, deletes all entries.
- fix 'mach cp0' dump of CP0 watchhi, watchlo regs
- fix opcode in 'mach mtcr' command function


To generate a diff of this commit:
cvs rdiff -u -r1.64.16.18 -r1.64.16.19 src/sys/arch/mips/mips/db_interface.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/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.64.16.18 src/sys/arch/mips/mips/db_interface.c:1.64.16.19
--- src/sys/arch/mips/mips/db_interface.c:1.64.16.18	Wed Dec 29 00:48:22 2010
+++ src/sys/arch/mips/mips/db_interface.c	Sat Feb  5 06:07:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.64.16.18 2010/12/29 00:48:22 matt Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.64.16.19 2011/02/05 06:07:07 cliff Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,8 +27,9 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.64.16.18 2010/12/29 00:48:22 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.64.16.19 2011/02/05 06:07:07 cliff Exp $);
 
+#include opt_multiprocessor.h
 #include opt_cputype.h	/* which mips CPUs do we support? */
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -39,9 +40,13 @@
 #include sys/proc.h
 #include sys/user.h
 #include sys/reboot.h
+#include sys/atomic.h
+#include sys/cpu.h
 
 #include uvm/uvm_extern.h
 
+#include mips/asm.h
+#include mips/regnum.h
 #include mips/cache.h
 #include mips/pte.h
 #include mips/cpu.h
@@ -59,11 +64,43 @@
 #include ddb/db_extern.h
 #include ddb/db_interface.h
 #include ddb/db_lex.h
+#include ddb/db_run.h	/* for db_continue_cmd() proto */
 #endif
 
+#define NOCPU   -1
+int ddb_cpu = NOCPU;
+
 int		db_active = 0;
 db_regs_t	ddb_regs;
 
+#ifdef MIPS_DDB_WATCH
+struct db_mach_watch {
+	register_t	addr;
+	register_t	mask;
+	uint32_t	asid;
+	uint32_t	mode;
+};
+/* mode bits */
+#define DB_WATCH_WRITE	__BIT(0)
+#define DB_WATCH_READ	__BIT(1)
+#define DB_WATCH_EXEC	__BIT(2)
+#define DB_WATCH_MASK	__BIT(3)
+#define DB_WATCH_ASID	__BIT(4)
+#define DB_WATCH_RWX	(DB_WATCH_EXEC|DB_WATCH_READ|DB_WATCH_WRITE)
+
+#define DBNWATCH	1
+static volatile struct db_mach_watch db_mach_watch_tab[DBNWATCH];
+
+static void db_mach_watch_set(int, register_t, register_t, uint32_t, uint32_t,
+	bool);
+static void db_watch_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void db_unwatch_cmd(db_expr_t, bool, db_expr_t, const char *);
+#endif	/* MIPS_DDB_WATCH */
+
+#ifdef MULTIPROCESSOR
+static void db_mach_cpu(db_expr_t, bool, db_expr_t, const char *);
+#endif
+
 void db_tlbdump_cmd(db_expr_t, bool, db_expr_t, const char *);
 void db_kvtophys_cmd(db_expr_t, bool, db_expr_t, const char *);
 void db_cp0dump_cmd(db_expr_t, bool, db_expr_t, const char *);
@@ -72,6 +109,8 @@
 void db_mtcr_cmd(db_expr_t, bool, db_expr_t, const char *);
 #endif
 
+bool ddb_running_on_this_cpu(void);
+
 static void	kdbpoke_4(vaddr_t addr, int newval);
 static void	kdbpoke_2(vaddr_t addr, short newval);
 static void	kdbpoke_1(vaddr_t addr, char newval);
@@ -152,32 +191,66 @@
 int
 kdb_trap(int type, struct reg *regs)
 {
+	int s;
+	extern const char * const trap_type[];
 
-#ifdef notyet
 	switch (type) {
+	case T_WATCH:		/* watchpoint */
 	case T_BREAK:		/* breakpoint */
-	case -1:		/* keyboard interrupt */
+		printf(kernel: %s trap\n, trap_type[type  0xff]);
+		break;
+	case -1:		/* keyboard interrupt *//* ??? */
+		printf(kernel: -1 trap\n);
 		break;
 	default:
-		printf(kernel: %s trap, trap_type[type  0xff]);
+		printf(kernel: %s trap\n, trap_type[type  0xff]);
 		if (db_recover != 0) {
 			db_error(Faulted in DDB; continuing...\n);
 			/*NOTREACHED*/
 		}
 		break;
 	}
+
+#ifdef MULTIPROCESSOR
+	bool first_in_ddb = false;
+	int cpu_me = cpu_index(curcpu());
+	int old_ddb_cpu = atomic_cas_32(ddb_cpu, NOCPU, cpu_me);
+	if (old_ddb_cpu == NOCPU) {
+		first_in_ddb = true;
+		cpu_pause_others();
+	} else {
+		if (old_ddb_cpu != cpu_me) {
+			cpu_pause(regs);
+			return 1;
+		}
+	}
 #endif
+
 	/* Should switch to kdb`s own stack here. */
+	KASSERT(sizeof(ddb_regs) == sizeof(*regs));
 	ddb_regs = *regs;
 
+	s = splhigh();
 	db_active++;
-	cnpollc(1);
+	cnpollc(TRUE);
 	db_trap(type  ~T_USER, 0 /*code*/);
-	cnpollc(0);
+	cnpollc(FALSE);
 	db_active--;
+	splx(s);
 
 	*regs = ddb_regs;
 
+#ifdef MULTIPROCESSOR
+	if (ddb_cpu == cpu_me) {
+		ddb_cpu = NOCPU;
+		cpu_resume_others();
+	} else {
+		

CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:07:39 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: ipifuncs.c

Log Message:
- add support for MP ddb
- add IPI halt func


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/mips/mips/ipifuncs.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/mips/mips/ipifuncs.c
diff -u src/sys/arch/mips/mips/ipifuncs.c:1.1.2.4 src/sys/arch/mips/mips/ipifuncs.c:1.1.2.5
--- src/sys/arch/mips/mips/ipifuncs.c:1.1.2.4	Wed Dec 22 05:57:48 2010
+++ src/sys/arch/mips/mips/ipifuncs.c	Sat Feb  5 06:07:38 2011
@@ -27,9 +27,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include opt_ddb.h
+
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: ipifuncs.c,v 1.1.2.4 2010/12/22 05:57:48 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: ipifuncs.c,v 1.1.2.5 2011/02/05 06:07:38 cliff Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -38,6 +40,13 @@
 #include uvm/uvm_extern.h
 
 #include mips/cache.h
+#ifdef DDB
+#include mips/db_machdep.h
+#endif
+
+
+static void ipi_halt(void) __attribute__((__noreturn__));
+
 
 static const char * const ipi_names[] = {
 	[IPI_NOP]	= ipi nop,
@@ -46,6 +55,8 @@
 	[IPI_FPSAVE]	= ipi fpsave,
 	[IPI_SYNCICACHE]	= ipi isync,
 	[IPI_KPREEMPT]	= ipi kpreempt,
+	[IPI_SUSPEND]	= ipi suspend,
+	[IPI_HALT]	= ipi halt,
 };
 
 static void
@@ -89,6 +100,22 @@
 }
 #endif
 
+/*
+ * Process cpu stop-self event.
+ * XXX could maybe add/use locoresw halt function?
+ */
+static void
+ipi_halt(void)
+{
+	int index = cpu_index(curcpu());
+	printf(cpu%d: shutting down\n, index);
+	CPUSET_ADD(cpus_halted, index);
+	splhigh();
+	for (;;)
+		;
+	/* NOTREACHED */
+}
+
 void
 ipi_process(struct cpu_info *ci, uint64_t ipi_mask)
 {
@@ -114,12 +141,14 @@
 		ci-ci_evcnt_per_ipi[IPI_NOP].ev_count++;
 		ipi_syncicache(ci);
 	}
-#ifdef IPI_HALT
+	if (ipi_mask  __BIT(IPI_SUSPEND)) {
+		ci-ci_evcnt_per_ipi[IPI_SUSPEND].ev_count++;
+		cpu_pause(NULL);
+	}
 	if (ipi_mask  __BIT(IPI_HALT)) {
-		ci-ci_evcnt_per_ipi[IPI_NOP].ev_count++;
+		ci-ci_evcnt_per_ipi[IPI_HALT].ev_count++;
 		ipi_halt();
 	}
-#endif
 }
 
 void



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/mips

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:08:12 UTC 2011

Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: trap.c

Log Message:
- include opt_multiprocessor.h for MULTIPROCESSOR dependency
- in trap at dopanic:, use snprintf to allow a single, idempotent, readable
printf; needed for MP, but harmless for UP so not ifdef'ed.
- add case for case T_WATCH (not USER), handled same as T_BREAK
i.e. entry to ddb if configured


To generate a diff of this commit:
cvs rdiff -u -r1.217.12.33 -r1.217.12.34 src/sys/arch/mips/mips/trap.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/mips/mips/trap.c
diff -u src/sys/arch/mips/mips/trap.c:1.217.12.33 src/sys/arch/mips/mips/trap.c:1.217.12.34
--- src/sys/arch/mips/mips/trap.c:1.217.12.33	Wed Jan 26 03:32:31 2011
+++ src/sys/arch/mips/mips/trap.c	Sat Feb  5 06:08:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.217.12.33 2011/01/26 03:32:31 matt Exp $	*/
+/*	$NetBSD: trap.c,v 1.217.12.34 2011/02/05 06:08:12 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -78,8 +78,9 @@
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.217.12.33 2011/01/26 03:32:31 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.217.12.34 2011/02/05 06:08:12 cliff Exp $);
 
+#include opt_multiprocessor.h
 #include opt_cputype.h	/* which mips CPU levels do we support? */
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -217,21 +218,42 @@
 	default:
 	dopanic:
 		(void)splhigh();
-		printf(pid %d(%s): , p-p_pid, p-p_comm);
-		printf(trap: %s in %s mode\n,
-			trap_type[TRAPTYPE(cause)],
+
+		/*
+		 * use snprintf to allow a single, idempotent, readable printf
+		 */
+		char strbuf[256], *str = strbuf;
+		int n, sz = sizeof(strbuf);
+
+		n = snprintf(str, sz, pid %d(%s): , p-p_pid, p-p_comm);
+		sz -= n; 
+		str += n;
+		n = snprintf(str, sz, trap: cpu%d, %s in %s mode\n,
+			cpu_index(ci), trap_type[TRAPTYPE(cause)],
 			USERMODE(status) ? user : kernel);
-		printf(status=0x%x, cause=0x%x, epc=%# PRIxVADDR
-			, vaddr=%# PRIxVADDR, status, cause, pc, vaddr);
+		sz -= n; 
+		str += n;
+		n = snprintf(str, sz, status=0x%x, cause=0x%x, epc=%#
+			PRIxVADDR , vaddr=%# PRIxVADDR \n,
+			status, cause, pc, vaddr);
+		sz -= n; 
+		str += n;
 		if (USERMODE(status)) {
 			KASSERT(tf == utf);
-			printf( frame=%p usp=%# PRIxREGISTER
+			n = snprintf(str, sz, frame=%p usp=%# PRIxREGISTER
 			 ra=%# PRIxREGISTER \n,
-			   tf, tf-tf_regs[_R_SP], tf-tf_regs[_R_RA]);
+			tf, tf-tf_regs[_R_SP], tf-tf_regs[_R_RA]);
+			sz -= n; 
+			str += n;
 		} else {
-			printf( tf=%p ksp=%p ra=%# PRIxREGISTER \n,
-			   tf, tf+1, tf-tf_regs[_R_RA]);
+			n = snprintf(str, sz, tf=%p ksp=%p ra=%#
+			PRIxREGISTER  ppl=%#x\n,
+			tf, tf+1, tf-tf_regs[_R_RA],
+			tf-tf_ppl);
+			sz -= n; 
+			str += n;
 		}
+		printf(%s, strbuf);
 
 		if ((TRAPTYPE(cause) == 6) || (TRAPTYPE(cause) == 7))
 			(void)(*mips_locoresw.lsw_bus_error)(cause);
@@ -530,6 +552,7 @@
 		}
 		break; /* SIGNAL */
 
+	case T_WATCH:	/* XXX */
 	case T_BREAK:
 #if defined(DDB)
 		kdb_trap(type, tf-tf_registers);



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:10:29 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_cpu.c

Log Message:
- include opt_multiprocessor.h for MULTIPROCESSOR dependency
- add suport for MIPS COP0 watchpoint in ddb
- add ci_pmap_asid_cur print in rmixl_cpuinfo_print().
- note rmixl_cpuinfo_print() (or something like it) should eventually get moved
into a md support fn of a (hypothetical) ddb 'show cpu' command.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.16 -r1.1.2.17 src/sys/arch/mips/rmi/rmixl_cpu.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/mips/rmi/rmixl_cpu.c
diff -u src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.16 src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.17
--- src/sys/arch/mips/rmi/rmixl_cpu.c:1.1.2.16	Fri Jan  7 00:17:22 2011
+++ src/sys/arch/mips/rmi/rmixl_cpu.c	Sat Feb  5 06:10:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpu.c,v 1.1.2.16 2011/01/07 00:17:22 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpu.c,v 1.1.2.17 2011/02/05 06:10:29 cliff Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -38,7 +38,10 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.16 2011/01/07 00:17:22 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_cpu.c,v 1.1.2.17 2011/02/05 06:10:29 cliff Exp $);
+
+#include opt_multiprocessor.h
+#include opt_ddb.h
 
 #include sys/param.h
 #include sys/device.h
@@ -60,6 +63,9 @@
 #include mips/rmi/rmixl_cpuvar.h
 #include mips/rmi/rmixl_intr.h
 #include mips/rmi/rmixl_fmnvar.h
+#ifdef DDB
+#include mips/db_machdep.h
+#endif
 
 
 static int	cpu_rmixl_match(device_t, cfdata_t, void *);
@@ -91,6 +97,20 @@
 static struct rmixl_cpu_trampoline_args rmixl_cpu_trampoline_args;
 #endif
 
+#if defined(DDB)  defined(MIPS_DDB_WATCH)
+/*
+ * cpu_rmixl_db_watch_init - initialize COP0 watchpoint stuff
+ *
+ * clear IEU_DEFEATURE[DBE] to ensure T_WATCH on watchpoint exception
+ * set COP0 watchhi and watchlo
+ */
+static void
+cpu_rmixl_db_watch_init(void)
+{
+	db_mach_watch_set_all();
+}
+#endif	/* DDB  MIPS_DDB_WATCH */
+
 /*
  * cpu_xls616_erratum
  *
@@ -222,6 +242,10 @@
 		return;
 	once = true;
 
+#if defined(DDB)  defined(MIPS_DDB_WATCH)
+	cpu_rmixl_db_watch_init();
+#endif
+
 	rmixl_fmn_init();
 
 	sc-sc_ih_clk = rmixl_intr_init_clk();
@@ -280,6 +304,10 @@
 #endif
 
 	cpucore_rmixl_hatch(device_parent(sc-sc_dev));
+
+#if defined(DDB)  defined(MIPS_DDB_WATCH)
+	cpu_rmixl_db_watch_init();
+#endif
 }
 
 static int
@@ -422,6 +450,7 @@
 		for (int i=0; i  SOFTINT_COUNT; i++)
 			printf(ci_softlwps[%d] %p\n, i, ci-ci_softlwps[i]);
 		printf(ci_tlb_slot %d\n, ci-ci_tlb_slot);
+		printf(ci_pmap_asid_cur %d\n, ci-ci_pmap_asid_cur);
 		printf(ci_tlb_info %p\n, ci-ci_tlb_info);
 		printf(ci_pmap_seg0tab %p\n, ci-ci_pmap_seg0tab);
 #ifdef _LP64
@@ -441,5 +470,4 @@
 
 	return ci;
 }
-
 #endif	/* DEBUG */



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:11:16 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_fmn.c

Log Message:
- obtain rmixl_intr_lock before rmixl_vec_establish(),
he expects that lock is held


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/mips/rmi/rmixl_fmn.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/mips/rmi/rmixl_fmn.c
diff -u src/sys/arch/mips/rmi/rmixl_fmn.c:1.1.2.4 src/sys/arch/mips/rmi/rmixl_fmn.c:1.1.2.5
--- src/sys/arch/mips/rmi/rmixl_fmn.c:1.1.2.4	Tue Apr 13 18:15:16 2010
+++ src/sys/arch/mips/rmi/rmixl_fmn.c	Sat Feb  5 06:11:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_fmn.c,v 1.1.2.4 2010/04/13 18:15:16 cliff Exp $	*/
+/*	$NetBSD: rmixl_fmn.c,v 1.1.2.5 2011/02/05 06:11:16 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -644,10 +644,15 @@
 	/*
 	 * establish dispatcher for FMN interrupt
 	 */
-	void *ih = rmixl_vec_establish(RMIXL_INTRVEC_FMN, -1, RMIXL_FMN_INTR_IPL,
+	extern kmutex_t rmixl_intr_lock;
+	void *ih;
+
+	mutex_enter(rmixl_intr_lock);
+	ih = rmixl_vec_establish(RMIXL_INTRVEC_FMN, -1, RMIXL_FMN_INTR_IPL,
 		rmixl_fmn_intr_dispatch, fmnp, fmn);
 	if (ih == NULL)
 		panic(%s: rmixl_vec_establish failed, __func__);
+	mutex_exit(rmixl_intr_lock);
 	fmnp-fmn_ih = ih;
 #endif
 



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:11:48 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_intr.c

Log Message:
- include opt_multiprocessor.h for MULTIPROCESSOR dependency
- use seperate vectors for various IPI tags, instead of all piling on one.
this theoretically allows different functions to interrupt at different
priorities.  the fmn vector number got rippled up in the process.
- add rmixl_ipi_lock to serialize access to RMIXL_PIC_IPIBASE
- add rmixl_intr_lock to serialize access to rest of PIC and rmixl_intrhand[]
- include mips/cpuset.h and use CPUSET_* macros for cpus_running etc.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.24 -r1.1.2.25 src/sys/arch/mips/rmi/rmixl_intr.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/mips/rmi/rmixl_intr.c
diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.24 src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.25
--- src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.24	Mon Sep 20 19:41:05 2010
+++ src/sys/arch/mips/rmi/rmixl_intr.c	Sat Feb  5 06:11:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.c,v 1.1.2.24 2010/09/20 19:41:05 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.c,v 1.1.2.25 2011/02/05 06:11:47 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,8 +64,9 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.24 2010/09/20 19:41:05 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_intr.c,v 1.1.2.25 2011/02/05 06:11:47 cliff Exp $);
 
+#include opt_multiprocessor.h
 #include opt_ddb.h
 #define	__INTR_PRIVATE
 
@@ -76,6 +77,7 @@
 #include sys/device.h
 #include sys/kernel.h
 #include sys/atomic.h
+#include sys/mutex.h
 #include sys/cpu.h
 
 #include machine/bus.h
@@ -290,14 +292,14 @@
 	vec 6,		/*  6 */
 	vec 7,		/*  7 */
 	vec 8 (ipi),		/*  8 */
-	vec 9 (fmn),		/*  9 */
-	vec 10,		/* 10 */
-	vec 11,		/* 11 */
-	vec 12,		/* 12 */
-	vec 13,		/* 13 */
-	vec 14,		/* 14 */
-	vec 15,		/* 15 */
-	vec 16,		/* 16 */
+	vec 9 (ipi),		/*  9 */
+	vec 10 (ipi),		/* 10 */
+	vec 11 (ipi),		/* 11 */
+	vec 12 (ipi),		/* 12 */
+	vec 13 (ipi),		/* 13 */
+	vec 14 (ipi),		/* 14 */
+	vec 15 (ipi),		/* 15 */
+	vec 16 (fmn),		/* 16 */
 	vec 17,		/* 17 */
 	vec 18,		/* 18 */
 	vec 19,		/* 19 */
@@ -353,6 +355,8 @@
  */
 static uint32_t cpu_present_mask;
 
+kmutex_t rmixl_ipi_lock;	/* covers RMIXL_PIC_IPIBASE */
+kmutex_t rmixl_intr_lock;	/* covers rest of PIC, and rmixl_intrhand[] */
 rmixl_intrhand_t rmixl_intrhand[NINTRVECS];
 
 #ifdef DIAGNOSTIC
@@ -407,6 +411,11 @@
 			__func__, rmixl_pic_init_done);
 #endif
 
+	mutex_init(rmixl_ipi_lock, MUTEX_DEFAULT, IPL_HIGH);
+	mutex_init(rmixl_intr_lock, MUTEX_DEFAULT, IPL_HIGH);
+
+	mutex_enter(rmixl_intr_lock);
+
 	/*
 	 * initialize (zero) all IRT Entries in the PIC
 	 */
@@ -427,6 +436,7 @@
 #ifdef DIAGNOSTIC
 	rmixl_pic_init_done = 1;
 #endif
+	mutex_exit(rmixl_intr_lock);
 
 }
 
@@ -440,9 +450,14 @@
 rmixl_intr_init_clk(void)
 {
 	int vec = ffs(MIPS_INT_MASK_5  8) - 1;
+
+	mutex_enter(rmixl_intr_lock);
+
 	void *ih = rmixl_vec_establish(vec, 0, IPL_SCHED, NULL, NULL, false);
 	if (ih == NULL)
 		panic(%s: establish vec %d failed, __func__, vec);
+
+	mutex_exit(rmixl_intr_lock);
 	
 	return ih;
 }
@@ -454,14 +469,24 @@
 void *
 rmixl_intr_init_ipi(void)
 {
-	void *ih = rmixl_vec_establish(RMIXL_INTRVEC_IPI, -1, IPL_SCHED,
-		rmixl_ipi_intr, NULL, false);
-	if (ih == NULL)
-		panic(%s: establish vec %d failed,
-			__func__, RMIXL_INTRVEC_IPI);
+	u_int ipi, vec;
+	void *ih;
+
+	mutex_enter(rmixl_intr_lock);
+
+	for (ipi=0; ipi  NIPIS; ipi++) {
+		vec = RMIXL_INTRVEC_IPI + ipi;
+		ih = rmixl_vec_establish(vec, -1, IPL_SCHED,
+			rmixl_ipi_intr, (void *)(uintptr_t)ipi, true);
+		if (ih == NULL)
+			panic(%s: establish ipi %d at vec %d failed,
+__func__, ipi, vec);
+	}
 
 	mips_locoresw.lsw_send_ipi = rmixl_send_ipi;
 
+	mutex_exit(rmixl_intr_lock);
+
 	return ih;
 }
 #endif 	/* MULTIPROCESSOR */
@@ -484,7 +509,7 @@
 			rmixl_intr_string(vec));
 
 	KASSERT(ci-ci_cpuid  (sizeof(cpu_present_mask) * 8));
-	cpu_present_mask |= 1  ci-ci_cpuid;
+	atomic_or_32((volatile uint32_t *)cpu_present_mask, 1  ci-ci_cpuid);
 }
 
 /*
@@ -623,6 +648,7 @@
 static void
 rmixl_irt_disestablish(int irt)
 {
+	KASSERT(mutex_owned(rmixl_intr_lock));
 	DPRINTF((%s: irt %d, irtc1 %#x\n, __func__, irt, 0));
 	rmixl_irt_init(irt);
 }
@@ -638,6 +664,8 @@
 	uint32_t irtc1;
 	uint32_t irtc0;
 
+	KASSERT(mutex_owned(rmixl_intr_lock));
+
 	if (irt = NIRTS)
 		panic(%s: bad irt %d\n, __func__, irt);
 
@@ -698,6 +726,8 @@
 	uint64_t eimr_bit;
 	int s;
 
+	KASSERT(mutex_owned(rmixl_intr_lock));
+
 	DPRINTF((%s: vec %d, cpumask %#x, ipl %d, func %p, arg %p\n
 			__func__, vec, cpumask, ipl, func, arg));
 #ifdef DIAGNOSTIC
@@ -756,7 +786,6 @@
 {
 	rmixl_intrhand_t *ih;
 	int vec;
-	int s;
 
 #ifdef DIAGNOSTIC
 	if (rmixl_pic_init_done == 0)
@@ -777,7 +806,7 @@
 

CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:12:42 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_intr.h

Log Message:
- include opt_multiprocessor.h for MULTIPROCESSOR dependency
- move RMIXL_INTRVEC_FMN to RMIXL_INTRVEC_IPI + NIPIS
since each IPI tag now has own vector


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/mips/rmi/rmixl_intr.h

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

Modified files:

Index: src/sys/arch/mips/rmi/rmixl_intr.h
diff -u src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.4 src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.5
--- src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.4	Fri May 21 23:35:42 2010
+++ src/sys/arch/mips/rmi/rmixl_intr.h	Sat Feb  5 06:12:42 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.h,v 1.1.2.4 2010/05/21 23:35:42 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.h,v 1.1.2.5 2011/02/05 06:12:42 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,6 +31,8 @@
 #ifndef _MIPS_RMI_RMIXL_INTR_H_
 #define _MIPS_RMI_RMIXL_INTR_H_
 
+#include opt_multiprocessor.h
+
 /*
  * A 'vector' is bit number in EIRR/EIMR
  * - non-IRT-based interrupts use vectors 0..31
@@ -54,7 +56,7 @@
  * vectors (8 = vec  31) are for other non-IRT based interrupts
  */
 #define RMIXL_INTRVEC_IPI	8
-#define RMIXL_INTRVEC_FMN	9
+#define RMIXL_INTRVEC_FMN	(RMIXL_INTRVEC_IPI + NIPIS)
 
 typedef enum {
 	RMIXL_TRIG_NONE=0,



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/rmi

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:13:17 UTC 2011

Modified Files:
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_usbi.c

Log Message:
- if obio_intr is OBIOCF_INTR_DEFAULT, don't establish an interrupt


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/arch/mips/rmi/rmixl_usbi.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/mips/rmi/rmixl_usbi.c
diff -u src/sys/arch/mips/rmi/rmixl_usbi.c:1.1.2.5 src/sys/arch/mips/rmi/rmixl_usbi.c:1.1.2.6
--- src/sys/arch/mips/rmi/rmixl_usbi.c:1.1.2.5	Mon Apr 12 22:42:07 2010
+++ src/sys/arch/mips/rmi/rmixl_usbi.c	Sat Feb  5 06:13:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_usbi.c,v 1.1.2.5 2010/04/12 22:42:07 cliff Exp $	*/
+/*	$NetBSD: rmixl_usbi.c,v 1.1.2.6 2011/02/05 06:13:16 cliff Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: rmixl_usbi.c,v 1.1.2.5 2010/04/12 22:42:07 cliff Exp $);
+__KERNEL_RCSID(0, $NetBSD: rmixl_usbi.c,v 1.1.2.6 2011/02/05 06:13:16 cliff Exp $);
 
 #include locators.h
 
@@ -173,11 +173,14 @@
 	RMIXL_USBI_GEN_WRITE(RMIXL_USB_INTERRUPT_ENABLE, 0);
 
 	/* establish interrupt */
-	ih = rmixl_intr_establish(obio-obio_intr, obio-obio_tmsk,
-		IPL_USB, RMIXL_TRIG_LEVEL, RMIXL_POLR_HIGH,
-		rmixl_usbi_intr, sc, false);
-	if (ih == NULL)
-		panic(%s: couldn't establish interrupt, device_xname(self));
+	if (obio-obio_intr != OBIOCF_INTR_DEFAULT) {
+		ih = rmixl_intr_establish(obio-obio_intr, obio-obio_tmsk,
+			IPL_USB, RMIXL_TRIG_LEVEL, RMIXL_POLR_HIGH,
+			rmixl_usbi_intr, sc, false);
+		if (ih == NULL)
+			panic(%s: couldn't establish interrupt,
+device_xname(self));
+	}
 
 	aprint_normal(\n);
 



CVS commit: [matt-nb5-mips64] src/sys/kern

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:13:45 UTC 2011

Modified Files:
src/sys/kern [matt-nb5-mips64]: subr_evcnt.c

Log Message:
- add evcnt_lock and use to protect the 'allevents' list
(pulled back fromk -current)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.94.1 src/sys/kern/subr_evcnt.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/kern/subr_evcnt.c
diff -u src/sys/kern/subr_evcnt.c:1.4 src/sys/kern/subr_evcnt.c:1.4.94.1
--- src/sys/kern/subr_evcnt.c:1.4	Sun Dec 11 12:24:30 2005
+++ src/sys/kern/subr_evcnt.c	Sat Feb  5 06:13:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_evcnt.c,v 1.4 2005/12/11 12:24:30 christos Exp $ */
+/* $NetBSD: subr_evcnt.c,v 1.4.94.1 2011/02/05 06:13:45 cliff Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,16 +77,18 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: subr_evcnt.c,v 1.4 2005/12/11 12:24:30 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: subr_evcnt.c,v 1.4.94.1 2011/02/05 06:13:45 cliff Exp $);
 
 #include opt_ddb.h
 
 #include sys/param.h
 #include sys/device.h
+#include sys/mutex.h
 #include sys/systm.h
 
 /* list of all events */
 struct evcntlist allevents = TAILQ_HEAD_INITIALIZER(allevents);
+static kmutex_t evcnt_lock;
 
 /*
  * We need a dummy object to stuff into the evcnt link set to
@@ -105,6 +107,8 @@
 	__link_set_decl(evcnts, struct evcnt);
 	struct evcnt * const *evp;
 
+	mutex_init(evcnt_lock, MUTEX_DEFAULT, IPL_NONE);
+
 	__link_set_foreach(evp, evcnts) {
 		if (*evp == dummy_static_evcnt)
 			continue;
@@ -121,6 +125,9 @@
 {
 	int len;
 
+#ifdef DEBUG	/* XXX TMP FIXME */
+	printf(%s: %p \%s\\n, __func__, ev, ev-ev_name);
+#endif
 	len = strlen(ev-ev_group);
 #ifdef DIAGNOSTIC
 	if (len = EVCNT_STRING_MAX)		/* ..._MAX includes NUL */
@@ -135,7 +142,9 @@
 #endif
 	ev-ev_namelen = len;
 
+	mutex_enter(evcnt_lock);
 	TAILQ_INSERT_TAIL(allevents, ev, ev_list);
+	mutex_exit(evcnt_lock);
 }
 
 /*
@@ -162,7 +171,9 @@
 evcnt_detach(struct evcnt *ev)
 {
 
+	mutex_enter(evcnt_lock);
 	TAILQ_REMOVE(allevents, ev, ev_list);
+	mutex_exit(evcnt_lock);
 }
 
 #ifdef DDB



CVS commit: [matt-nb5-mips64] src/sys/arch/mips/include

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:17:41 UTC 2011

Added Files:
src/sys/arch/mips/include [matt-nb5-mips64]: cpuset.h

Log Message:
add cpuset.h to allow abstracting bit-per-cpu run state variables (cpus_running 
et. al.)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/arch/mips/include/cpuset.h

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

Added files:

Index: src/sys/arch/mips/include/cpuset.h
diff -u /dev/null src/sys/arch/mips/include/cpuset.h:1.1.2.1
--- /dev/null	Sat Feb  5 06:17:41 2011
+++ src/sys/arch/mips/include/cpuset.h	Sat Feb  5 06:17:41 2011
@@ -0,0 +1,54 @@
+/*	$NetBSD: cpuset.h,v 1.1.2.1 2011/02/05 06:17:41 cliff Exp $	*/
+/*	$NetBSD: cpuset.h,v 1.1.2.1 2011/02/05 06:17:41 cliff Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MIPS_CPUSET_H_
+#define	_MIPS_CPUSET_H_
+
+#include sys/atomic.h
+
+#define	CPUSET_MAXNUMCPU	64
+typedef	uint64_t mips_cpuset_t;
+
+#define	CPUSET_SINGLE(cpu)		((mips_cpuset_t)1  (cpu))
+
+#define	CPUSET_ADD(set, cpu)		atomic_or_64((volatile uint64_t *)(set), CPUSET_SINGLE(cpu))
+#define	CPUSET_DEL(set, cpu)		atomic_and_64((volatile uint64_t *)(set), ~CPUSET_SINGLE(cpu))
+#define	CPUSET_SUB(set1, set2)		atomic_and_64((volatile uint64_t *)(set1), ~(set2))
+
+#define	CPUSET_EXCEPT(set, cpu)		((set)  ~CPUSET_SINGLE(cpu))
+
+#define	CPUSET_HAS(set, cpu)		((set)  CPUSET_SINGLE(cpu))
+#define	CPUSET_NEXT(set)		(ffs(set) - 1)
+
+#define	CPUSET_EMPTY(set)		((set) == (mips_cpuset_t)0)
+#define	CPUSET_EQUAL(set1, set2)	((set1) == (set2))
+#define	CPUSET_CLEAR(set)		((set) = (mips_cpuset_t)0)
+#define	CPUSET_ASSIGN(set1, set2)	((set1) = (set2))
+
+#endif /* _MIPS_CPUSET_H_ */



CVS commit: [matt-nb5-mips64] src/sys

2011-02-04 Thread Cliff Neighbors
Module Name:src
Committed By:   cliff
Date:   Sat Feb  5 06:31:07 UTC 2011

Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: intr.h pmap.h vmparam.h
src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_cpucorevar.h
rmixl_intr.h
src/sys/sys [matt-nb5-mips64]: lwp.h

Log Message:
- protect option includes (opt_multiprocessor.h) with #ifdef _KERNEL_OPT


To generate a diff of this commit:
cvs rdiff -u -r1.3.96.15 -r1.3.96.16 src/sys/arch/mips/include/intr.h
cvs rdiff -u -r1.54.26.16 -r1.54.26.17 src/sys/arch/mips/include/pmap.h
cvs rdiff -u -r1.41.28.18 -r1.41.28.19 src/sys/arch/mips/include/vmparam.h
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/arch/mips/rmi/rmixl_cpucorevar.h \
src/sys/arch/mips/rmi/rmixl_intr.h
cvs rdiff -u -r1.114.4.1.4.1 -r1.114.4.1.4.2 src/sys/sys/lwp.h

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

Modified files:

Index: src/sys/arch/mips/include/intr.h
diff -u src/sys/arch/mips/include/intr.h:1.3.96.15 src/sys/arch/mips/include/intr.h:1.3.96.16
--- src/sys/arch/mips/include/intr.h:1.3.96.15	Sat Feb  5 06:05:35 2011
+++ src/sys/arch/mips/include/intr.h	Sat Feb  5 06:31:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.3.96.15 2011/02/05 06:05:35 cliff Exp $ */
+/* $NetBSD: intr.h,v 1.3.96.16 2011/02/05 06:31:05 cliff Exp $ */
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,7 +31,9 @@
 #ifndef _MIPS_INTR_H_
 #define	_MIPS_INTR_H_
 
+#ifdef _KERNEL_OPT
 #include opt_multiprocessor.h
+#endif
 
 /*
  * This is a common machine/intr.h for all MIPS platforms.

Index: src/sys/arch/mips/include/pmap.h
diff -u src/sys/arch/mips/include/pmap.h:1.54.26.16 src/sys/arch/mips/include/pmap.h:1.54.26.17
--- src/sys/arch/mips/include/pmap.h:1.54.26.16	Sat Feb  5 06:00:12 2011
+++ src/sys/arch/mips/include/pmap.h	Sat Feb  5 06:31:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.54.26.16 2011/02/05 06:00:12 cliff Exp $	*/
+/*	$NetBSD: pmap.h,v 1.54.26.17 2011/02/05 06:31:05 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -74,7 +74,9 @@
 #ifndef	_MIPS_PMAP_H_
 #define	_MIPS_PMAP_H_
 
+#ifdef _KERNEL_OPT
 #include opt_multiprocessor.h
+#endif
 
 #include mips/cpuregs.h	/* for KSEG0 below */
 //#include mips/pte.h

Index: src/sys/arch/mips/include/vmparam.h
diff -u src/sys/arch/mips/include/vmparam.h:1.41.28.18 src/sys/arch/mips/include/vmparam.h:1.41.28.19
--- src/sys/arch/mips/include/vmparam.h:1.41.28.18	Sat Feb  5 06:00:12 2011
+++ src/sys/arch/mips/include/vmparam.h	Sat Feb  5 06:31:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.41.28.18 2011/02/05 06:00:12 cliff Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.41.28.19 2011/02/05 06:31:05 cliff Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -79,7 +79,9 @@
 #ifndef _MIPS_VMPARAM_H_
 #define	_MIPS_VMPARAM_H_
 
+#ifdef _KERNEL_OPT
 #include opt_multiprocessor.h
+#endif
 
 /*
  * Machine dependent VM constants for MIPS.

Index: src/sys/arch/mips/rmi/rmixl_cpucorevar.h
diff -u src/sys/arch/mips/rmi/rmixl_cpucorevar.h:1.1.2.5 src/sys/arch/mips/rmi/rmixl_cpucorevar.h:1.1.2.6
--- src/sys/arch/mips/rmi/rmixl_cpucorevar.h:1.1.2.5	Sat Feb  5 06:00:13 2011
+++ src/sys/arch/mips/rmi/rmixl_cpucorevar.h	Sat Feb  5 06:31:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_cpucorevar.h,v 1.1.2.5 2011/02/05 06:00:13 cliff Exp $	*/
+/*	$NetBSD: rmixl_cpucorevar.h,v 1.1.2.6 2011/02/05 06:31:05 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,7 +31,9 @@
 #ifndef _ARCH_MIPS_RMI_RMIXL_CPUCOREVAR_H_
 #define _ARCH_MIPS_RMI_RMIXL_CPUCOREVAR_H_
 
+#ifdef _KERNEL_OPT
 #include opt_multiprocessor.h
+#endif
 
 struct cpucore_softc {
 	device_t	sc_dev;
Index: src/sys/arch/mips/rmi/rmixl_intr.h
diff -u src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.5 src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.6
--- src/sys/arch/mips/rmi/rmixl_intr.h:1.1.2.5	Sat Feb  5 06:12:42 2011
+++ src/sys/arch/mips/rmi/rmixl_intr.h	Sat Feb  5 06:31:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rmixl_intr.h,v 1.1.2.5 2011/02/05 06:12:42 cliff Exp $	*/
+/*	$NetBSD: rmixl_intr.h,v 1.1.2.6 2011/02/05 06:31:06 cliff Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,7 +31,9 @@
 #ifndef _MIPS_RMI_RMIXL_INTR_H_
 #define _MIPS_RMI_RMIXL_INTR_H_
 
+#ifdef _KERNEL_OPT
 #include opt_multiprocessor.h
+#endif
 
 /*
  * A 'vector' is bit number in EIRR/EIMR

Index: src/sys/sys/lwp.h
diff -u src/sys/sys/lwp.h:1.114.4.1.4.1 src/sys/sys/lwp.h:1.114.4.1.4.2
--- src/sys/sys/lwp.h:1.114.4.1.4.1	Sat Feb  5 06:00:15 2011
+++ src/sys/sys/lwp.h	Sat Feb  5 06:31:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: lwp.h,v 1.114.4.1.4.1 2011/02/05 06:00:15 cliff Exp $	*/
+/*	$NetBSD: lwp.h,v 1.114.4.1.4.2 2011/02/05 06:31:06 cliff Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -32,7 +32,9 @@
 #ifndef _SYS_LWP_H_
 #define _SYS_LWP_H_
 
+#ifdef _KERNEL_OPT
 #include 

  1   2   3   4   >