CVS commit: src/sys/arch/hp700/hp700

2012-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 13 07:05:57 UTC 2012

Modified Files:
src/sys/arch/hp700/hp700: autoconf.c

Log Message:
Allow uturn(4) to provide the boot device.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/hp700/hp700/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/arch/hp700/hp700/autoconf.c
diff -u src/sys/arch/hp700/hp700/autoconf.c:1.42 src/sys/arch/hp700/hp700/autoconf.c:1.43
--- src/sys/arch/hp700/hp700/autoconf.c:1.42	Fri Jan 13 07:01:04 2012
+++ src/sys/arch/hp700/hp700/autoconf.c	Fri Jan 13 07:05:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.42 2012/01/13 07:01:04 skrll Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.43 2012/01/13 07:05:57 skrll Exp $	*/
 
 /*	$OpenBSD: autoconf.c,v 1.15 2001/06/25 00:43:10 mickey Exp $	*/
 
@@ -86,7 +86,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.42 2012/01/13 07:01:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.43 2012/01/13 07:05:57 skrll Exp $");
 
 #include "opt_kgdb.h"
 #include "opt_useleds.h"
@@ -352,7 +352,8 @@ device_register(device_t dev, void *aux)
 	 * controller's struct dev in boot_device. The SCSI device is located
 	 * later, see below.
 	 */
-	if (device_is_a(pdev, "gsc") || device_is_a(pdev, "phantomas")) {
+	if (device_is_a(pdev, "gsc") || device_is_a(pdev, "phantomas") ||
+	device_is_a(pdev, "uturn")) {
 		struct confargs *ca = aux;
 
 		if ((hppa_hpa_t)PAGE0->mem_boot.pz_hpa == ca->ca_hpa) {



CVS commit: src/sys/arch/hp700/hp700

2012-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 13 07:01:04 UTC 2012

Modified Files:
src/sys/arch/hp700/hp700: autoconf.c

Log Message:
Make device_register less ugly.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/hp700/hp700/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/arch/hp700/hp700/autoconf.c
diff -u src/sys/arch/hp700/hp700/autoconf.c:1.41 src/sys/arch/hp700/hp700/autoconf.c:1.42
--- src/sys/arch/hp700/hp700/autoconf.c:1.41	Fri Jan  6 22:14:04 2012
+++ src/sys/arch/hp700/hp700/autoconf.c	Fri Jan 13 07:01:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.41 2012/01/06 22:14:04 skrll Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.42 2012/01/13 07:01:04 skrll Exp $	*/
 
 /*	$OpenBSD: autoconf.c,v 1.15 2001/06/25 00:43:10 mickey Exp $	*/
 
@@ -86,7 +86,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.41 2012/01/06 22:14:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.42 2012/01/13 07:01:04 skrll Exp $");
 
 #include "opt_kgdb.h"
 #include "opt_useleds.h"
@@ -352,11 +352,14 @@ device_register(device_t dev, void *aux)
 	 * controller's struct dev in boot_device. The SCSI device is located
 	 * later, see below.
 	 */
-	if ((device_is_a(pdev, "gsc") || device_is_a(pdev, "phantomas"))
-	&& (hppa_hpa_t)PAGE0->mem_boot.pz_hpa ==
-	((struct gsc_attach_args *)aux)->ga_ca.ca_hpa)
-		/* This is (the controller of) the boot device. */
-		boot_device = dev;
+	if (device_is_a(pdev, "gsc") || device_is_a(pdev, "phantomas")) {
+		struct confargs *ca = aux;
+
+		if ((hppa_hpa_t)PAGE0->mem_boot.pz_hpa == ca->ca_hpa) {
+			/* This is (the controller of) the boot device. */
+			boot_device = dev;
+		}
+	}
 	/*
 	 * If the boot device is a PCI device the HPA is the address where the
 	 * firmware has mapped the PCI memory of the PCI device. This is quite
@@ -396,38 +399,52 @@ device_register(device_t dev, void *aux)
 		}
 		/* This is the PCI host bridge in front of the boot device. */
 		boot_device = dev;
+
+	}
+	if (device_is_a(dev, "ppb") && boot_device == device_parent(pdev)) {
+		/*
+		 * XXX Guesswork. No hardware to test how firmware handles
+		 * a ppb.
+		 */
+		struct pci_attach_args *paa = (struct pci_attach_args*)aux;
+		
+		if (paa->pa_device == PAGE0->mem_boot.pz_dp.dp_bc[3] &&
+		paa->pa_function == PAGE0->mem_boot.pz_dp.dp_bc[4]) {
+			/*
+			 * This is the PCI - PCI bridge in front of the boot
+			 * device.
+			 */
+			boot_device = dev;
+		}
+	}
+	if (device_is_a(pdev, "pci") && boot_device == device_parent(pdev)) {
+		struct pci_attach_args *paa = (struct pci_attach_args*)aux;
+
+		if (paa->pa_device == PAGE0->mem_boot.pz_dp.dp_bc[5] &&
+		paa->pa_function == PAGE0->mem_boot.pz_dp.dp_mod) {
+			/*
+			 * This is (the controller of) the boot device.
+			 */
+			boot_device = dev;
+		}
 	}
-	/* XXX Guesswork. No hardware to test how firmware handles a ppb. */
-	if (device_is_a(dev, "ppb")
-	&& boot_device == device_parent(pdev)
-	&& ((struct pci_attach_args*)aux)->pa_device
-	== PAGE0->mem_boot.pz_dp.dp_bc[3]
-	&& ((struct pci_attach_args*)aux)->pa_function
-	== PAGE0->mem_boot.pz_dp.dp_bc[4])
-		/* This is the PCI - PCI bridge in front of the boot device. */
-		boot_device = dev;
-	if (device_is_a(pdev, "pci")
-	&& boot_device == device_parent(pdev)
-	&& ((struct pci_attach_args*)aux)->pa_device
-	== PAGE0->mem_boot.pz_dp.dp_bc[5]
-	&& ((struct pci_attach_args*)aux)->pa_function
-	== PAGE0->mem_boot.pz_dp.dp_mod)
-		/* This is (the controller of) the boot device. */
-		boot_device = dev;
 	/*
 	 * When SCSI devices are attached, we look if the SCSI device hangs
 	 * below the controller remembered in boot_device. If so, we compare
 	 * the SCSI ID and LUN with the DP layer information. If they match
 	 * we found the boot device.
 	 */
-	if (device_is_a(pdev, "scsibus")
-	&& boot_device == device_parent(pdev)
-	&& ((struct scsipibus_attach_args *)aux)->sa_periph->periph_target
-	== PAGE0->mem_boot.pz_dp.dp_layers[0]
-	&& ((struct scsipibus_attach_args *)aux)->sa_periph->periph_lun
-	== PAGE0->mem_boot.pz_dp.dp_layers[1])
-		/* This is the boot device. */
-		boot_device = dev;
+	if (device_is_a(pdev, "scsibus") &&
+	boot_device == device_parent(pdev)) {
+		struct scsipibus_attach_args *saa = aux;
+		struct scsipi_periph *p = saa->sa_periph;
+		
+		if (p->periph_target == PAGE0->mem_boot.pz_dp.dp_layers[0] &&
+		p->periph_lun == PAGE0->mem_boot.pz_dp.dp_layers[1]) {
+			/* This is the boot device. */
+			boot_device = dev;
+		}
+	}
 
 	hp700_pagezero_unmap(pagezero_cookie);
 	return;



CVS commit: src/sys/arch/hp700/dev

2012-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 23:10:28 UTC 2012

Modified Files:
src/sys/arch/hp700/dev: uturn.c

Log Message:
Copyright correction


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/hp700/dev/uturn.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/hp700/dev/uturn.c
diff -u src/sys/arch/hp700/dev/uturn.c:1.17 src/sys/arch/hp700/dev/uturn.c:1.18
--- src/sys/arch/hp700/dev/uturn.c:1.17	Thu Jan 12 23:06:45 2012
+++ src/sys/arch/hp700/dev/uturn.c	Thu Jan 12 23:10:27 2012
@@ -1,9 +1,9 @@
-/*	$NetBSD: uturn.c,v 1.17 2012/01/12 23:06:45 skrll Exp $	*/
+/*	$NetBSD: uturn.c,v 1.18 2012/01/12 23:10:27 skrll Exp $	*/
 
 /*	$OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $	*/
 
 /*-
- * Copyright (c) 2012, 2004 The NetBSD Foundation, Inc.
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation



CVS commit: src/share/man/man4/man4.hp700

2012-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 23:08:50 UTC 2012

Modified Files:
src/share/man/man4/man4.hp700: uturn.4

Log Message:
Real mode is no longer used.


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

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

Modified files:

Index: src/share/man/man4/man4.hp700/uturn.4
diff -u src/share/man/man4/man4.hp700/uturn.4:1.1 src/share/man/man4/man4.hp700/uturn.4:1.2
--- src/share/man/man4/man4.hp700/uturn.4:1.1	Thu Jun 24 16:34:51 2010
+++ src/share/man/man4/man4.hp700/uturn.4	Thu Jan 12 23:08:50 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: uturn.4,v 1.1 2010/06/24 16:34:51 skrll Exp $
+.\" $NetBSD: uturn.4,v 1.2 2012/01/12 23:08:50 skrll Exp $
 .\"	$OpenBSD: uturn.4,v 1.8 2008/04/27 19:33:39 jmc Exp $
 .\"
 .\" Copyright (c) 2004 Michael Shalayeff
@@ -24,7 +24,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 24, 2010
+.Dd January 12, 2012
 .Dt UTURN 4 hp700
 .Os
 .Sh NAME
@@ -46,9 +46,6 @@ Modern systems, based on the PA-8000 and
 version, whilst earlier systems, based on the PA-7200 CPU, used
 a different version of the chip called
 .Nm U2 .
-.Pp
-.Nm
-operates in real mode and doesn't make use of the I/O TLB.
 .Sh SEE ALSO
 .Xr astro 4 ,
 .Xr cpu 4 ,



CVS commit: src/sys/arch/hp700/dev

2012-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 23:06:45 UTC 2012

Modified Files:
src/sys/arch/hp700/dev: uturn.c

Log Message:
Support virtual mode as PCX-U/U+ (and probably other) CPU based machines
required it. Only PCX-W seemed to work with real mode.

Gratuitous copying of code from astro. Deadlines!


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hp700/dev/uturn.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/hp700/dev/uturn.c
diff -u src/sys/arch/hp700/dev/uturn.c:1.16 src/sys/arch/hp700/dev/uturn.c:1.17
--- src/sys/arch/hp700/dev/uturn.c:1.16	Fri Jul  1 18:33:09 2011
+++ src/sys/arch/hp700/dev/uturn.c	Thu Jan 12 23:06:45 2012
@@ -1,7 +1,52 @@
-/*	$NetBSD: uturn.c,v 1.16 2011/07/01 18:33:09 dyoung Exp $	*/
+/*	$NetBSD: uturn.c,v 1.17 2012/01/12 23:06:45 skrll Exp $	*/
 
 /*	$OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $	*/
 
+/*-
+ * Copyright (c) 2012, 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 2007 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
 /*
  * Copyright (c) 2004 Michael Shalayeff
  * All rights reserved.
@@ -28,7 +73,13 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* TODO IOA programming */
+/*
+ * References:
+ * 1. Hardware Cache Coherent Input/Output. Hewlett-Packard Journal, February
+ *1996.
+ * 2. PA-RISC 1.1 Architecture and Instruction Set Reference Manual,
+ *Hewlett-Packard, February 1994, Third Edition
+ */
 
 #include 
 #include 
@@ -37,6 +88,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -46,6 +98,7 @@
 
 #include 
 
+#define UTURNDEBUG
 #ifdef UTURNDEBUG
 
 #define	DPRINTF(s)	do {	\
@@ -101,15 +154,61 @@ struct uturn_regs {
 	uint32_t	io_io_high;		/* Offset 15 */
 };
 
+
+/* Uturn supports 256 TLB entries */
+#define	UTURN_CHAINID_SHIFT	8
+#define	UTURN_CHAINID_MASK	0xff
+#define	UTURN_TLB_ENTRIES	(1 << UTURN_CHAINID_SHIFT)
+
+#define	UTURN_IOVP_SIZE		PAGE_SIZE
+#define	UTURN_IOVP_SHIFT	PAGE_SHIFT
+#define	UTURN_IOVP_MASK		PAGE_MASK
+
+#define	UTURN_IOVA(iovp, off)	((iovp) | (off))
+#define	UTURN_IOVP(iova)	((iova) & UTURN_IOVP_MASK)
+#define	UTURN_IOVA_INDEX(iova)	((iova) >> UTURN_IOVP_SHIFT)
+
 struct uturn_softc {
 	device_t sc_dv;
 
 	bus_dma_tag_t sc_dmat;
 	struct uturn_regs volatile *sc_regs;
+	uint64_t *sc_pdir;
+	uint32_t sc_chainid_shift;
+
+	char sc_mapname[20];
+	struct extent *sc_map;
 
 	struct hppa_bus_dma_tag sc_dmatag;
 };
 
+/*
+ * per-map IOVA page table
+ */
+struct uturn_page_entry {
+	SPLAY_ENTRY(uturn_page_entry) upe_node;
+	paddr_t	upe_pa;
+	vaddr_t	upe_va;
+	bus_addr_t upe_iova;
+};
+
+struct uturn_page_map {
+	SPLAY_HEAD(uturn_page_tree, uturn_page_entry) upm_tree;
+	int upm_maxpage;	/* Size of allocate

CVS commit: src/share/man/man4

2012-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 22:22:10 UTC 2012

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

Log Message:
Update hp700 key sequences section.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/share/man/man4/ddb.4

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

Modified files:

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.147 src/share/man/man4/ddb.4:1.148
--- src/share/man/man4/ddb.4:1.147	Sun Oct 23 22:02:45 2011
+++ src/share/man/man4/ddb.4	Thu Jan 12 22:22:10 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.147 2011/10/23 22:02:45 jym Exp $
+.\"	$NetBSD: ddb.4,v 1.148 2012/01/12 22:22:10 skrll Exp $
 .\"
 .\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@
 .\" any improvements or extensions that they make and grant Carnegie Mellon
 .\" the rights to redistribute these changes.
 .\"
-.Dd October 23, 2011
+.Dd January 12, 2012
 .Dt DDB 4
 .Os
 .Sh NAME
@@ -120,8 +120,10 @@ from the keyboard:
 .It hp300
 \*[Lt]Shift\*[Gt]-\*[Lt]Reset\*[Gt]
 .It hp700
+\*[Lt]Ctrl\*[Gt]-\*[Lt]Alt\*[Gt]-\*[Lt]Esc\*[Gt] on PC style keyboards.
+.It ""
 +
-(five plus signs)
+(five plus signs) on PDC console
 .It ""
 \*[Lt]Break\*[Gt] on serial console.
 .It hpcarm



CVS commit: src/usr.sbin/npf/npfctl

2012-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 12 20:41:33 UTC 2012

Modified Files:
src/usr.sbin/npf/npfctl: npf_parse.y npf_var.c

Log Message:
handle variables that contain variables


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/npf/npfctl/npf_parse.y \
src/usr.sbin/npf/npfctl/npf_var.c

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

Modified files:

Index: src/usr.sbin/npf/npfctl/npf_parse.y
diff -u src/usr.sbin/npf/npfctl/npf_parse.y:1.1 src/usr.sbin/npf/npfctl/npf_parse.y:1.2
--- src/usr.sbin/npf/npfctl/npf_parse.y:1.1	Sun Jan  8 16:34:21 2012
+++ src/usr.sbin/npf/npfctl/npf_parse.y	Thu Jan 12 15:41:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_parse.y,v 1.1 2012/01/08 21:34:21 rmind Exp $	*/
+/*	$NetBSD: npf_parse.y,v 1.2 2012/01/12 20:41:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -661,6 +661,7 @@ iface
 		const int type = npfvar_get_type(vp);
 
 		switch (type) {
+		case NPFVAR_VAR_ID:
 		case NPFVAR_STRING:
 			$$ = npfctl_parse_iface(npfvar_expand_string(vp));
 			break;
@@ -690,6 +691,7 @@ ifindex
 		const int type = npfvar_get_type(vp);
 
 		switch (type) {
+		case NPFVAR_VAR_ID:
 		case NPFVAR_STRING:
 			$$ = npfctl_find_ifindex(npfvar_expand_string(vp));
 			break;
Index: src/usr.sbin/npf/npfctl/npf_var.c
diff -u src/usr.sbin/npf/npfctl/npf_var.c:1.1 src/usr.sbin/npf/npfctl/npf_var.c:1.2
--- src/usr.sbin/npf/npfctl/npf_var.c:1.1	Sun Jan  8 16:34:21 2012
+++ src/usr.sbin/npf/npfctl/npf_var.c	Thu Jan 12 15:41:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_var.c,v 1.1 2012/01/08 21:34:21 rmind Exp $	*/
+/*	$NetBSD: npf_var.c,v 1.2 2012/01/12 20:41:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: npf_var.c,v 1.1 2012/01/08 21:34:21 rmind Exp $");
+__RCSID("$NetBSD: npf_var.c,v 1.2 2012/01/12 20:41:33 christos Exp $");
 
 #include 
 #include 
@@ -54,6 +54,7 @@ struct npfvar {
 };
 
 static npfvar_t *	var_list = NULL;
+static size_t		var_num = 0;
 
 npfvar_t *
 npfvar_create(const char *name)
@@ -86,6 +87,7 @@ npfvar_add(npfvar_t *vp)
 {
 	vp->v_next = var_list;
 	var_list = vp;
+	var_num++;
 }
 
 npfvar_t *
@@ -185,11 +187,16 @@ npfvar_get_type(const npfvar_t *vp)
 	return vp ? vp->v_type : -1;
 }
 
-void *
-npfvar_get_data(const npfvar_t *vp, int type, size_t idx)
+static void *
+npfvar_get_data1(const npfvar_t *vp, int type, size_t idx, size_t level)
 {
 	npf_element_t *el;
 
+	if (level >= var_num) {
+		yyerror("variable loop for '%s'", vp->v_key);
+		return NULL;
+	}
+
 	if (vp == NULL)
 		return NULL;
 
@@ -209,5 +216,15 @@ npfvar_get_data(const npfvar_t *vp, int 
 	while (idx--) {
 		el = el->e_next;
 	}
+
+	if (vp->v_type == NPFVAR_VAR_ID)
+		return npfvar_get_data1(npfvar_lookup(el->e_data), type, 0,
+			level + 1);
 	return el->e_data;
 }
+
+void *
+npfvar_get_data(const npfvar_t *vp, int type, size_t idx)
+{
+	return npfvar_get_data1(vp, type, idx, 0);
+}



CVS commit: src/sys/arch

2012-01-12 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Jan 12 19:49:37 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
relocate pte_lock initialisation to the earliest points after %fs is first 
usable in the XEN bootpath


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.716 -r1.717 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/xen/x86/x86_xpmap.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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.173 src/sys/arch/amd64/amd64/machdep.c:1.174
--- src/sys/arch/amd64/amd64/machdep.c:1.173	Mon Dec 12 19:03:08 2011
+++ src/sys/arch/amd64/amd64/machdep.c	Thu Jan 12 19:49:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.173 2011/12/12 19:03:08 mrg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.174 2012/01/12 19:49:37 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.173 2011/12/12 19:03:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.174 2012/01/12 19:49:37 cherry Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1640,6 +1640,7 @@ init_x86_64(paddr_t first_avail)
 	use_pae = 1; /* PAE always enabled in long mode */
 
 #ifdef XEN
+	mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM);
 	pcb->pcb_cr3 = xen_start_info.pt_base - KERNBASE;
 	__PRINTK(("pcb_cr3 0x%lx\n", xen_start_info.pt_base - KERNBASE));
 #endif

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.716 src/sys/arch/i386/i386/machdep.c:1.717
--- src/sys/arch/i386/i386/machdep.c:1.716	Thu Jan 12 19:37:45 2012
+++ src/sys/arch/i386/i386/machdep.c	Thu Jan 12 19:49:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.716 2012/01/12 19:37:45 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.717 2012/01/12 19:49:37 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.716 2012/01/12 19:37:45 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.717 2012/01/12 19:49:37 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -1408,6 +1408,8 @@ init386(paddr_t first_avail)
 	 * before the above variables are set.
 	 */
 	initgdt(NULL);
+
+	mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM);
 #endif /* XEN */
 
 #if NISA > 0 || NPCI > 0

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.37 src/sys/arch/xen/x86/x86_xpmap.c:1.38
--- src/sys/arch/xen/x86/x86_xpmap.c:1.37	Mon Jan  9 13:04:13 2012
+++ src/sys/arch/xen/x86/x86_xpmap.c	Thu Jan 12 19:49:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.37 2012/01/09 13:04:13 cherry Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.38 2012/01/12 19:49:37 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert 
@@ -69,7 +69,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.37 2012/01/09 13:04:13 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.38 2012/01/12 19:49:37 cherry Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -77,7 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,
 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -653,8 +653,6 @@ bootstrap_again:
 	/* Finally, flush TLB. */
 	xpq_queue_tlb_flush();
 
-	mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM);
-	
 	return (init_tables + ((count + l2_4_count) * PAGE_SIZE));
 }
 



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

2012-01-12 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Jan 12 19:37:46 UTC 2012

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
re-order call to x86_bus_space_init() until after %fs is initialised via 
initgdt().

x86_bus_space_init() uses mutex(9) since it uses extent(9), which requires %fs 
to be setup before use.


To generate a diff of this commit:
cvs rdiff -u -r1.715 -r1.716 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.715 src/sys/arch/i386/i386/machdep.c:1.716
--- src/sys/arch/i386/i386/machdep.c:1.715	Fri Dec 30 17:57:49 2011
+++ src/sys/arch/i386/i386/machdep.c	Thu Jan 12 19:37:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.715 2011/12/30 17:57:49 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.716 2012/01/12 19:37:45 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.715 2011/12/30 17:57:49 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.716 2012/01/12 19:37:45 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -1354,9 +1354,6 @@ init386(paddr_t first_avail)
 	cpu_info_primary.ci_pae_l3_pdir = (pd_entry_t *)(rcr3() + KERNBASE);
 #endif /* PAE && !XEN */
 
-#if NISA > 0 || NPCI > 0
-	x86_bus_space_init();
-#endif
 #ifdef XEN
 	xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL);
 #endif
@@ -1412,6 +1409,11 @@ init386(paddr_t first_avail)
 	 */
 	initgdt(NULL);
 #endif /* XEN */
+
+#if NISA > 0 || NPCI > 0
+	x86_bus_space_init();
+#endif /* NISA > 0 || NPCI > 0 */
+	
 	consinit();	/* XXX SHOULD NOT BE DONE HERE */
 
 #ifdef DEBUG_MEMLOAD



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

2012-01-12 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jan 12 18:50:33 UTC 2012

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

Log Message:
Add an optimization for UP system with non-virtually tagged caches (which are
most of them these days).

If a page needs to be have an icache_sync performed and the page has a direct
map alias (XKPHYS or KSEG0), then don't do an index op; instead do a range op
on the XKPHYS or KSEG0 address.  This results in unneeded fewer cache line
invalidations.


To generate a diff of this commit:
cvs rdiff -u -r1.9.96.6 -r1.9.96.7 src/sys/arch/mips/include/cache.h
cvs rdiff -u -r1.33.96.10 -r1.33.96.11 src/sys/arch/mips/mips/cache.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/mips/mips/pmap_syncicache.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/cache.h
diff -u src/sys/arch/mips/include/cache.h:1.9.96.6 src/sys/arch/mips/include/cache.h:1.9.96.7
--- src/sys/arch/mips/include/cache.h:1.9.96.6	Tue Dec 27 01:56:32 2011
+++ src/sys/arch/mips/include/cache.h	Thu Jan 12 18:50:32 2012
@@ -170,6 +170,7 @@ struct mips_cache_info {
 	u_int mci_picache_ways;
 	u_int mci_picache_way_size;
 	u_int mci_picache_way_mask;
+	bool mci_picache_vivt;		/* virtually indexed and tagged */
 
 	u_int mci_pdcache_size;		/* and unified */
 	u_int mci_pdcache_line_size;

Index: src/sys/arch/mips/mips/cache.c
diff -u src/sys/arch/mips/mips/cache.c:1.33.96.10 src/sys/arch/mips/mips/cache.c:1.33.96.11
--- src/sys/arch/mips/mips/cache.c:1.33.96.10	Tue Dec 27 16:08:17 2011
+++ src/sys/arch/mips/mips/cache.c	Thu Jan 12 18:50:33 2012
@@ -965,6 +965,11 @@ mips_config_cache_modern(uint32_t cpu_id
 		mci->mci_picache_ways = MIPSNN_CFG1_IA(cfg1) + 1;
 
 		/*
+		 * Is this Icache virtually indexed and virtually tagged?
+		 */
+		mci->mci_picache_vivt = (cfg & MIPSNN_CFG_VI) != 0;
+
+		/*
 		 * Compute the total size and "way mask" for the
 		 * primary Dcache.
 		 */

Index: src/sys/arch/mips/mips/pmap_syncicache.c
diff -u src/sys/arch/mips/mips/pmap_syncicache.c:1.1.2.1 src/sys/arch/mips/mips/pmap_syncicache.c:1.1.2.2
--- src/sys/arch/mips/mips/pmap_syncicache.c:1.1.2.1	Fri Dec 23 22:31:30 2011
+++ src/sys/arch/mips/mips/pmap_syncicache.c	Thu Jan 12 18:50:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_syncicache.c,v 1.1.2.1 2011/12/23 22:31:30 matt Exp $	*/
+/*	$NetBSD: pmap_syncicache.c,v 1.1.2.2 2012/01/12 18:50:33 matt Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_syncicache.c,v 1.1.2.1 2011/12/23 22:31:30 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_syncicache.c,v 1.1.2.2 2012/01/12 18:50:33 matt Exp $");
 
 /*
  *
@@ -100,6 +100,26 @@ pmap_syncicache_page(struct vm_page *pg,
 		mips_icache_sync_range(MIPS_PHYS_TO_KSEG0(VM_PAGE_TO_PHYS(pg)),
 		PAGE_SIZE);
 	} else if (PG_MD_CACHED_P(md)) {
+		/*
+		 * The page may not be mapped so we can't use one of its
+		 * virtual addresses.  But if the cache is not vivt (meaning
+		 * it's physically tagged), we can use its XKPHYS cached or
+		 * KSEG0 (if it lies within) address to invalid it.
+		 */
+		if (__predict_true(!mips_cache_info.mci_picache_vivt)) {
+			const paddr_t pa = VM_PAGE_TO_PHYS(pg);
+#if _LP64
+			mips_icache_sync_range(MIPS_PHYS_TO_XKPHYS_CACHED(pa),
+			PAGE_SIZE);
+			return;
+#else
+			if (MIPS_KSEG0_P(pa)) {
+mips_icache_sync_range(MIPS_PHYS_TO_KSEG0(pa),
+PAGE_SIZE);
+return;
+			}
+#endif
+		}
 #if 0
 		struct cpu_info * const ci = curcpu();
 		colors >>= PG_MD_EXECPAGE_SHIFT;



CVS commit: src/gnu/usr.bin/rcs/lib

2012-01-12 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan 12 14:10:56 UTC 2012

Modified Files:
src/gnu/usr.bin/rcs/lib: rcsbase.h

Log Message:
Second try to sort out the dangling elses. Just use {} markers.
Produces identical on amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/gnu/usr.bin/rcs/lib/rcsbase.h

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

Modified files:

Index: src/gnu/usr.bin/rcs/lib/rcsbase.h
diff -u src/gnu/usr.bin/rcs/lib/rcsbase.h:1.11 src/gnu/usr.bin/rcs/lib/rcsbase.h:1.12
--- src/gnu/usr.bin/rcs/lib/rcsbase.h:1.11	Sun Jan  8 13:57:31 2012
+++ src/gnu/usr.bin/rcs/lib/rcsbase.h	Thu Jan 12 14:10:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rcsbase.h,v 1.11 2012/01/08 13:57:31 tron Exp $	*/
+/*	$NetBSD: rcsbase.h,v 1.12 2012/01/12 14:10:56 joerg Exp $	*/
 
 /* RCS common definitions and data structures */
 
@@ -33,6 +33,10 @@ Report problems and direct all questions
 
 /*
  * $Log: rcsbase.h,v $
+ * Revision 1.12  2012/01/12 14:10:56  joerg
+ * Second try to sort out the dangling elses. Just use {} markers.
+ * Produces identical on amd64.
+ *
  * Revision 1.11  2012/01/08 13:57:31  tron
  * Revert last change. The extra while loop intruced by the macro changes
  * causes an end-less loop in ci(1) which uses "break" inside one of the
@@ -291,14 +295,14 @@ Report problems and direct all questions
 #	if maps_memory
 #		define declarecache register Iptr_type ptr, lim
 #		define setupcache(f) (lim = (f)->lim)
-#		define Igeteof_(f,c,s) if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++;
-#		define cachegeteof_(c,s) if (ptr==lim) s else (c)= *ptr++;
+#		define Igeteof_(f,c,s) { if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++; }
+#		define cachegeteof_(c,s) { if (ptr==lim) s else (c)= *ptr++; }
 #	else
 		int Igetmore P((RILE*));
 #		define declarecache register Iptr_type ptr; register RILE *rRILE
 #		define setupcache(f) (rRILE = (f))
-#		define Igeteof_(f,c,s) if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++;
-#		define cachegeteof_(c,s) if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++;
+#		define Igeteof_(f,c,s) { if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++; }
+#		define cachegeteof_(c,s) { if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++; }
 #	endif
 #	define uncache(f) ((f)->ptr = ptr)
 #	define cache(f) (ptr = (f)->ptr)



CVS commit: src/sys/arch/usermode/dev

2012-01-12 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jan 12 13:28:54 UTC 2012

Modified Files:
src/sys/arch/usermode/dev: cpu.c

Log Message:
Remove old comment about space not being freed; it is now done correctly so
remove it to avoid confusion later.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/usermode/dev/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/usermode/dev/cpu.c
diff -u src/sys/arch/usermode/dev/cpu.c:1.62 src/sys/arch/usermode/dev/cpu.c:1.63
--- src/sys/arch/usermode/dev/cpu.c:1.62	Fri Jan  6 12:54:59 2012
+++ src/sys/arch/usermode/dev/cpu.c	Thu Jan 12 13:28:54 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.62 2012/01/06 12:54:59 reinoud Exp $ */
+/* $NetBSD: cpu.c,v 1.63 2012/01/12 13:28:54 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -30,7 +30,7 @@
 #include "opt_hz.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.62 2012/01/06 12:54:59 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.63 2012/01/12 13:28:54 reinoud Exp $");
 
 #include 
 #include 
@@ -345,7 +345,6 @@ cpu_lwp_fork(struct lwp *l1, struct lwp 
 		panic("getcontext failed");
 
 	/* set up the ucontext for the userland switch */
-	/* XXX BUG TODO when is this stack space freed? */
 	pcb2->pcb_ucp.uc_stack.ss_sp = pcb2->pcb_stack_userland;
 	pcb2->pcb_ucp.uc_stack.ss_size = stacksize;
 	pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU;