CVS commit: src/sys/dev/ic

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 23:39:08 UTC 2017

Modified Files:
src/sys/dev/ic: lan9118.c

Log Message:
Trigger a software interrupt if any packets were transmitted in
lan9118_start to workaround a possible issue where completion interrupts
are missed and the watchdog timer fires.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/lan9118.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/ic/lan9118.c
diff -u src/sys/dev/ic/lan9118.c:1.25 src/sys/dev/ic/lan9118.c:1.26
--- src/sys/dev/ic/lan9118.c:1.25	Thu Jun  1 16:59:20 2017
+++ src/sys/dev/ic/lan9118.c	Fri Jun  2 23:39:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lan9118.c,v 1.25 2017/06/01 16:59:20 jmcneill Exp $	*/
+/*	$NetBSD: lan9118.c,v 1.26 2017/06/02 23:39:08 jmcneill Exp $	*/
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.25 2017/06/01 16:59:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.26 2017/06/02 23:39:08 jmcneill Exp $");
 
 /*
  * The LAN9118 Family
@@ -306,7 +306,8 @@ lan9118_intr(void *arg)
 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_STS,
 		int_sts);
 		int_en =
-		bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_EN);
+		bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_EN) |
+		LAN9118_INT_SW_INT;
 
 		DPRINTFN(3, ("%s: int_sts=0x%x, int_en=0x%x\n",
 		__func__, int_sts, int_en));
@@ -314,6 +315,7 @@ lan9118_intr(void *arg)
 		if (!(int_sts & int_en))
 			break;
 		datum = int_sts;
+		handled = 1;
 
 #if 0	/* not yet... */
 		if (int_sts & LAN9118_INT_PHY_INT) { /* PHY */
@@ -327,7 +329,7 @@ lan9118_intr(void *arg)
 			ifp->if_ierrors++;
 			aprint_error_ifnet(ifp, "Receive Error\n");
 		}
-		if (int_sts & LAN9118_INT_TSFL) /* TX Status FIFO Level */
+		if (int_sts & (LAN9118_INT_TSFL|LAN9118_INT_SW_INT)) /* TX Status FIFO Level */
 			lan9118_txintr(sc);
 		if (int_sts & LAN9118_INT_RXDF_INT) {
 			ifp->if_ierrors++;
@@ -338,10 +340,11 @@ lan9118_intr(void *arg)
 			aprint_error_ifnet(ifp, "RX Status FIFO Full\n");
 		}
 		if (int_sts & LAN9118_INT_RSFL) /* RX Status FIFO Level */
-			 lan9118_rxintr(sc);
+			lan9118_rxintr(sc);
 	}
-
-	if_schedule_deferred_start(ifp);
+ 
+	if (handled)
+		if_schedule_deferred_start(ifp);
 
 	rnd_add_uint32(>rnd_source, datum);
 
@@ -355,7 +358,7 @@ lan9118_start(struct ifnet *ifp)
 	struct lan9118_softc *sc = ifp->if_softc;
 	struct mbuf *m0, *m;
 	unsigned tdfree, totlen, dso;
-	uint32_t txa, txb;
+	uint32_t txa, txb, int_en;
 	uint8_t *p;
 	int n;
 
@@ -457,8 +460,18 @@ discard:
 
 		m_freem(m0);
 	}
-	if (totlen > 0)
+
+	if (totlen > 0) {
 		ifp->if_timer = 5;
+
+		/*
+		 * Trigger a software interrupt to catch any missed completion
+		 * interrupts.
+		 */
+		int_en = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_EN);
+		int_en |= LAN9118_INT_SW_INT;
+		bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_EN, int_en);
+	}
 }
 
 static int



CVS commit: src/etc/etc.evbarm

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 22:20:21 UTC 2017

Modified Files:
src/etc/etc.evbarm: MAKEDEV.conf

Log Message:
Create /dev/openfirm device for ofctl(8).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/etc/etc.evbarm/MAKEDEV.conf

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

Modified files:

Index: src/etc/etc.evbarm/MAKEDEV.conf
diff -u src/etc/etc.evbarm/MAKEDEV.conf:1.16 src/etc/etc.evbarm/MAKEDEV.conf:1.17
--- src/etc/etc.evbarm/MAKEDEV.conf:1.16	Thu Dec  8 11:31:13 2016
+++ src/etc/etc.evbarm/MAKEDEV.conf	Fri Jun  2 22:20:21 2017
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.16 2016/12/08 11:31:13 nat Exp $
+# $NetBSD: MAKEDEV.conf,v 1.17 2017/06/02 22:20:21 jmcneill Exp $
 
 all_md)
 	makedev wscons fd0 fd1 wd0 wd1 wd2 wd3 sd0 sd1 sd2 sd3
@@ -20,6 +20,7 @@ all_md)
 	makedev audio speaker
 	makedev spiflash0
 	makedev bpf
+	makedev openfirm
 	;;
 
 ramdisk|floppy)



CVS commit: src/sys/dev/pci

2017-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun  2 22:08:00 UTC 2017

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

Log Message:
enable font loading / screen resizing


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/pci/radeonfb.c

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

Modified files:

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.88 src/sys/dev/pci/radeonfb.c:1.89
--- src/sys/dev/pci/radeonfb.c:1.88	Wed Nov  5 19:39:17 2014
+++ src/sys/dev/pci/radeonfb.c	Fri Jun  2 22:08:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.88 2014/11/05 19:39:17 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.89 2017/06/02 22:08:00 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.88 2014/11/05 19:39:17 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.89 2017/06/02 22:08:00 macallan Exp $");
 
 #include 
 #include 
@@ -235,7 +235,7 @@ static struct wsscreen_descr radeonfb_st
 	0, 0,		/* ncols, nrows */
 	NULL,		/* textops */
 	8, 16,		/* fontwidth, fontheight */
-	WSSCREEN_WSCOLORS | WSSCREEN_UNDERLINE, /* capabilities */
+	WSSCREEN_WSCOLORS | WSSCREEN_UNDERLINE | WSSCREEN_RESIZE, /* capabilities */
 	0,		/* modecookie */
 };
 
@@ -598,7 +598,7 @@ radeonfb_attach(device_t parent, device_
 		RADEON_TMDS_TRANSMITTER_PLLEN,
 		~(RADEON_TMDS_TRANSMITTER_PLLEN | RADEON_TMDS_TRANSMITTER_PLLRST));
 	}
-	
+
 	radeonfb_i2c_init(sc);
 
 	radeonfb_loadbios(sc, pa);
@@ -939,6 +939,9 @@ radeonfb_attach(device_t parent, device_
 		ri->ri_font->fontwidth,
 		ri->ri_font->fontheight,
 		defattr);
+		dp->rd_vd.show_screen_cookie = >rd_gc;
+		dp->rd_vd.show_screen_cb = glyphcache_adapt;
+
 		if (dp->rd_console) {
 
 			radeonfb_modeswitch(dp);
@@ -2380,6 +2383,8 @@ radeonfb_init_screen(void *cookie, struc
 	/* initialize font subsystem */
 	wsfont_init();
 
+	scr->scr_flags |= VCONS_LOADFONT;
+
 	DPRINTF(("init screen called, existing %d\n", existing));
 
 	ri->ri_depth = dp->rd_bpp;
@@ -2389,10 +2394,10 @@ radeonfb_init_screen(void *cookie, struc
 	ri->ri_flg = RI_CENTER;
 	switch (ri->ri_depth) {
 		case 8:
-			ri->ri_flg |= RI_ENABLE_ALPHA | RI_8BIT_IS_RGB;
+			ri->ri_flg |= RI_ENABLE_ALPHA | RI_8BIT_IS_RGB | RI_PREFER_ALPHA;
 			break;
 		case 32:
-			ri->ri_flg |= RI_ENABLE_ALPHA;
+			ri->ri_flg |= RI_ENABLE_ALPHA | RI_PREFER_ALPHA;
 			/* we run radeons in RGB even on SPARC hardware */
 			ri->ri_rnum = 8;
 			ri->ri_gnum = 8;
@@ -2424,7 +2429,7 @@ radeonfb_init_screen(void *cookie, struc
 	/* initialize and look for an initial font */
 	rasops_init(ri, 0, 0);
 	ri->ri_caps = WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
-		WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
+		WSSCREEN_WSCOLORS | WSSCREEN_REVERSE | WSSCREEN_RESIZE;
 
 	rasops_reconfig(ri, dp->rd_virty / ri->ri_font->fontheight,
 		dp->rd_virtx / ri->ri_font->fontwidth);



CVS commit: src/sys/arch/arm/vexpress

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 21:26:20 UTC 2017

Modified Files:
src/sys/arch/arm/vexpress: vexpress_sysreg.c

Log Message:
Sleep before reboot/shutdown to let uart fifo flush


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/vexpress/vexpress_sysreg.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/arm/vexpress/vexpress_sysreg.c
diff -u src/sys/arch/arm/vexpress/vexpress_sysreg.c:1.1 src/sys/arch/arm/vexpress/vexpress_sysreg.c:1.2
--- src/sys/arch/arm/vexpress/vexpress_sysreg.c:1.1	Fri Jun  2 21:16:42 2017
+++ src/sys/arch/arm/vexpress/vexpress_sysreg.c	Fri Jun  2 21:26:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vexpress_sysreg.c,v 1.1 2017/06/02 21:16:42 jmcneill Exp $ */
+/* $NetBSD: vexpress_sysreg.c,v 1.2 2017/06/02 21:26:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vexpress_sysreg.c,v 1.1 2017/06/02 21:16:42 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vexpress_sysreg.c,v 1.2 2017/06/02 21:26:20 jmcneill Exp $");
 
 #include 
 #include 
@@ -79,12 +79,14 @@ vexpress_sysreg_write(device_t dev, u_in
 static void
 vexpress_sysreg_reset(device_t dev)
 {
+	delay(100);
 	vexpress_sysreg_write(dev, SYS_CFGCTRL_FUNCTION_REBOOT, SYS_CFGCTRL_SITE_MB);
 }
 
 static void
 vexpress_sysreg_poweroff(device_t dev)
 {
+	delay(100);
 	vexpress_sysreg_write(dev, SYS_CFGCTRL_FUNCTION_SHUTDOWN, SYS_CFGCTRL_SITE_MB);
 }
 



CVS commit: src/sys/arch/arm/arm

2017-06-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jun  2 21:20:47 UTC 2017

Modified Files:
src/sys/arch/arm/arm: disassem.c

Log Message:
Fix the fix by removing redundant lines.  Thanks chuq.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/arm/disassem.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/arm/arm/disassem.c
diff -u src/sys/arch/arm/arm/disassem.c:1.37 src/sys/arch/arm/arm/disassem.c:1.38
--- src/sys/arch/arm/arm/disassem.c:1.37	Fri Jun  2 19:58:31 2017
+++ src/sys/arch/arm/arm/disassem.c	Fri Jun  2 21:20:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: disassem.c,v 1.37 2017/06/02 19:58:31 skrll Exp $	*/
+/*	$NetBSD: disassem.c,v 1.38 2017/06/02 21:20:47 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Mark Brinicombe.
@@ -49,7 +49,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: disassem.c,v 1.37 2017/06/02 19:58:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disassem.c,v 1.38 2017/06/02 21:20:47 skrll Exp $");
 
 #include 
 
@@ -215,15 +215,11 @@ static const struct arm32_insn arm32_i[]
 { 0x0e1000f0, 0x00b0, "strh",	"de" },
 { 0x0e1000f0, 0x001000b0, "ldrh",	"de" },
 
-{ 0x0e5000f0, 0x00d0, "ldrd",	"de" },
-{ 0x0e1000f0, 0x001000d0, "ldrsb",	"de" },
 { 0x0e1000f0, 0x00d0, "ldrd",	"de" },
 { 0x0e1000f0, 0x001000d0, "ldrsb",	"de" },
 
 { 0x0e1000f0, 0x00f0, "strd",	"de" },
 { 0x0e1000f0, 0x001000f0, "ldrsh",	"de" },
-{ 0x0e1000f0, 0x00f0, "strd",	"de" },
-{ 0x0e1000f0, 0x001000f0, "ldrsh",	"de" },
 
 /* A5.2.11 MSR (immediate), and hints */
 { 0x0fff, 0x0320f000, "nop",	"" },



CVS commit: src/sys/arch

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 21:16:42 UTC 2017

Modified Files:
src/sys/arch/arm/vexpress: files.vexpress
src/sys/arch/evbarm/conf: VEXPRESS_A15
Added Files:
src/sys/arch/arm/vexpress: vexpress_sysreg.c

Log Message:
Add driver for ARM Motherboard Express uATX system control registers. Use
this to make "poweroff" DTRT in qemu (and hopefully on real hardware too).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/vexpress/files.vexpress
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/vexpress/vexpress_sysreg.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/conf/VEXPRESS_A15

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

Modified files:

Index: src/sys/arch/arm/vexpress/files.vexpress
diff -u src/sys/arch/arm/vexpress/files.vexpress:1.1 src/sys/arch/arm/vexpress/files.vexpress:1.2
--- src/sys/arch/arm/vexpress/files.vexpress:1.1	Fri Jun  2 15:22:47 2017
+++ src/sys/arch/arm/vexpress/files.vexpress	Fri Jun  2 21:16:42 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: files.vexpress,v 1.1 2017/06/02 15:22:47 jmcneill Exp $
+#	$NetBSD: files.vexpress,v 1.2 2017/06/02 21:16:42 jmcneill Exp $
 #
 # Configuration info for ARM Ltd. Versatile Express peripherals
 #
@@ -16,3 +16,7 @@ file	arch/arm/arm32/armv7_generic_dma.c
 file	arch/arm/arm/bus_space_a4x.S
 
 file	arch/arm/vexpress/vexpress_platform.c
+
+device	vxsysreg
+attach	vxsysreg at fdt with vexpress_sysreg
+file	arch/arm/vexpress/vexpress_sysreg.c	vexpress_sysreg	

Index: src/sys/arch/evbarm/conf/VEXPRESS_A15
diff -u src/sys/arch/evbarm/conf/VEXPRESS_A15:1.9 src/sys/arch/evbarm/conf/VEXPRESS_A15:1.10
--- src/sys/arch/evbarm/conf/VEXPRESS_A15:1.9	Fri Jun  2 20:16:05 2017
+++ src/sys/arch/evbarm/conf/VEXPRESS_A15	Fri Jun  2 21:16:42 2017
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: VEXPRESS_A15,v 1.9 2017/06/02 20:16:05 jmcneill Exp $
+#	$NetBSD: VEXPRESS_A15,v 1.10 2017/06/02 21:16:42 jmcneill Exp $
 #
 #	ARM Versatile Express A15
 #
@@ -44,6 +44,8 @@ armgtmr0	at gtmr?
 gic*		at fdt? pass 1		# GIC
 armgic0		at gic?
 
+# ARM Motherboard Express uATX system registers
+vxsysreg*	at fdt?
 
 # Ethernet
 smsh*		at fdt?			# SMSC LAN9118

Added files:

Index: src/sys/arch/arm/vexpress/vexpress_sysreg.c
diff -u /dev/null src/sys/arch/arm/vexpress/vexpress_sysreg.c:1.1
--- /dev/null	Fri Jun  2 21:16:42 2017
+++ src/sys/arch/arm/vexpress/vexpress_sysreg.c	Fri Jun  2 21:16:42 2017
@@ -0,0 +1,130 @@
+/* $NetBSD: vexpress_sysreg.c,v 1.1 2017/06/02 21:16:42 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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 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.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: vexpress_sysreg.c,v 1.1 2017/06/02 21:16:42 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define	SYS_CFGDATA	0x00a0
+#define	SYS_CFGCTRL	0x00a4
+#define	 SYS_CFGCTRL_START	__BIT(31)
+#define	 SYS_CFGCTRL_WRITE	__BIT(30)
+#define	 SYS_CFGCTRL_FUNCTION	__BITS(25,20)
+#define	  SYS_CFGCTRL_FUNCTION_SHUTDOWN	8
+#define	  SYS_CFGCTRL_FUNCTION_REBOOT	9
+#define	 SYS_CFGCTRL_SITE	__BITS(17,16)
+#define	  SYS_CFGCTRL_SITE_MB		0
+#define	SYS_CFGSTAT	0x00a8
+
+static int	vexpress_sysreg_match(device_t, cfdata_t, void *);
+static void	vexpress_sysreg_attach(device_t, device_t, void *);
+
+static const char * const compatible[] = { "arm,vexpress-sysreg", NULL };
+
+struct vexpress_sysreg_softc {
+	device_t		sc_dev;
+	bus_space_tag_t		sc_bst;
+	bus_space_handle_t	sc_bsh;
+};
+
+CFATTACH_DECL_NEW(vexpress_sysreg, sizeof(struct vexpress_sysreg_softc),
+	vexpress_sysreg_match, vexpress_sysreg_attach, NULL, NULL);
+
+static void
+vexpress_sysreg_write(device_t dev, 

CVS commit: src/sys/arch

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 20:16:06 UTC 2017

Modified Files:
src/sys/arch/arm/vexpress: vexpress_platform.c
src/sys/arch/evbarm/conf: VEXPRESS_A15
src/sys/arch/evbarm/vexpress: vexpress_start.S
Added Files:
src/sys/arch/arm/vexpress: vexpress_platform.h

Log Message:
Add SMP support to VEXPRESS_A15 kernel. Enable with '-smp 2' on qemu
command line.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/vexpress/vexpress_platform.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/vexpress/vexpress_platform.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/conf/VEXPRESS_A15
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/vexpress/vexpress_start.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/arm/vexpress/vexpress_platform.c
diff -u src/sys/arch/arm/vexpress/vexpress_platform.c:1.1 src/sys/arch/arm/vexpress/vexpress_platform.c:1.2
--- src/sys/arch/arm/vexpress/vexpress_platform.c:1.1	Fri Jun  2 15:22:47 2017
+++ src/sys/arch/arm/vexpress/vexpress_platform.c	Fri Jun  2 20:16:05 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vexpress_platform.c,v 1.1 2017/06/02 15:22:47 jmcneill Exp $ */
+/* $NetBSD: vexpress_platform.c,v 1.2 2017/06/02 20:16:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_fdt_arm.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vexpress_platform.c,v 1.1 2017/06/02 15:22:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vexpress_platform.c,v 1.2 2017/06/02 20:16:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -49,13 +49,13 @@ __KERNEL_RCSID(0, "$NetBSD: vexpress_pla
 
 #include 
 
+#include 
+
 #include 
 
-#define	VEXPRESS_REF_FREQ	2400
+#include 
 
-#define	VEXPRESS_CORE_VBASE	0xf000
-#define	VEXPRESS_CORE_PBASE	0x1000
-#define	VEXPRESS_CORE_SIZE	0x1000
+#define	VEXPRESS_REF_FREQ	2400
 
 #define	DEVMAP_ALIGN(a)	((a) & ~L1_S_OFFSET)
 #define	DEVMAP_SIZE(s)	roundup2((s), L1_S_SIZE)
@@ -100,6 +100,46 @@ static bus_space_handle_t sysreg_bsh;
 	bus_space_write_4(sysreg_bst, sysreg_bsh, (o), (v))
 
 
+static void
+vexpress_a15_smp_init(void)
+{
+	extern void cortex_mpstart(void);
+	bus_space_tag_t gicd_bst = _generic_bs_tag;
+	bus_space_handle_t gicd_bsh;
+	int started = 0;
+
+	/* Bitmask of CPUs (non-BSP) to start */
+	for (int i = 1; i < arm_cpu_max; i++)
+		started |= __BIT(i);
+
+	/* Write init vec to SYS_FLAGS register */
+	SYSREG_WRITE(SYS_FLAGSCLR, 0x);
+	SYSREG_WRITE(SYS_FLAGS, (uint32_t)cortex_mpstart);
+
+	/* Map GIC distributor */
+	bus_space_map(gicd_bst, VEXPRESS_GIC_PBASE + GICD_BASE,
+	0x1000, 0, _bsh);
+
+	/* Enable GIC distributor */
+	bus_space_write_4(gicd_bst, gicd_bsh,
+	GICD_CTRL, GICD_CTRL_Enable);
+
+	/* Send sw interrupt to APs */
+	const uint32_t sgir = GICD_SGIR_TargetListFilter_NotMe;
+	bus_space_write_4(gicd_bst, gicd_bsh, GICD_SGIR, sgir);
+
+	/* Wait for APs to start */
+	for (u_int i = 0x1000; i > 0; i--) {
+		arm_dmb();
+		if (arm_cpu_hatched == started)
+			break;
+	}
+
+	/* Disable GIC distributor */
+	bus_space_write_4(gicd_bst, gicd_bsh, GICD_CTRL, 0);
+}
+
+
 static const struct pmap_devmap *
 vexpress_platform_devmap(void)
 {
@@ -107,6 +147,9 @@ vexpress_platform_devmap(void)
 		DEVMAP_ENTRY(VEXPRESS_CORE_VBASE,
 			 VEXPRESS_CORE_PBASE,
 			 VEXPRESS_CORE_SIZE),
+		DEVMAP_ENTRY(VEXPRESS_GIC_VBASE,
+			 VEXPRESS_GIC_PBASE,
+			 VEXPRESS_GIC_SIZE),
 		DEVMAP_ENTRY_END
 	};	
 
@@ -118,6 +161,10 @@ vexpress_platform_bootstrap(void)
 {
 	bus_space_map(sysreg_bst, SYSREG_BASE, SYSREG_SIZE, 0,
 	_bsh);
+
+	arm_cpu_max = 1 + __SHIFTOUT(armreg_l2ctrl_read(), L2CTRL_NUMCPU);
+
+	vexpress_a15_smp_init();
 }
 
 static void

Index: src/sys/arch/evbarm/conf/VEXPRESS_A15
diff -u src/sys/arch/evbarm/conf/VEXPRESS_A15:1.8 src/sys/arch/evbarm/conf/VEXPRESS_A15:1.9
--- src/sys/arch/evbarm/conf/VEXPRESS_A15:1.8	Fri Jun  2 15:22:47 2017
+++ src/sys/arch/evbarm/conf/VEXPRESS_A15	Fri Jun  2 20:16:05 2017
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: VEXPRESS_A15,v 1.8 2017/06/02 15:22:47 jmcneill Exp $
+#	$NetBSD: VEXPRESS_A15,v 1.9 2017/06/02 20:16:05 jmcneill Exp $
 #
 #	ARM Versatile Express A15
 #
@@ -8,8 +8,7 @@ include	"arch/evbarm/conf/std.vexpress"
 include	"arch/evbarm/conf/GENERIC.common"
 
 options 	CPU_CORTEXA15
-options 	SOC_TEGRA124
-#options 	MULTIPROCESSOR
+options 	MULTIPROCESSOR
 
 pseudo-device 	openfirm	# /dev/openfirm
 

Index: src/sys/arch/evbarm/vexpress/vexpress_start.S
diff -u src/sys/arch/evbarm/vexpress/vexpress_start.S:1.3 src/sys/arch/evbarm/vexpress/vexpress_start.S:1.4
--- src/sys/arch/evbarm/vexpress/vexpress_start.S:1.3	Fri Jun  2 15:22:47 2017
+++ src/sys/arch/evbarm/vexpress/vexpress_start.S	Fri Jun  2 20:16:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vexpress_start.S,v 1.3 2017/06/02 15:22:47 jmcneill Exp $	*/
+/*	$NetBSD: vexpress_start.S,v 1.4 2017/06/02 20:16:05 

CVS commit: src/sys/arch/arm/arm

2017-06-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jun  2 19:58:31 UTC 2017

Modified Files:
src/sys/arch/arm/arm: disassem.c

Log Message:
Fix up some instructions.  Prompted by chuq.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/arm/disassem.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/arm/arm/disassem.c
diff -u src/sys/arch/arm/arm/disassem.c:1.36 src/sys/arch/arm/arm/disassem.c:1.37
--- src/sys/arch/arm/arm/disassem.c:1.36	Wed Apr 26 08:20:47 2017
+++ src/sys/arch/arm/arm/disassem.c	Fri Jun  2 19:58:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: disassem.c,v 1.36 2017/04/26 08:20:47 skrll Exp $	*/
+/*	$NetBSD: disassem.c,v 1.37 2017/06/02 19:58:31 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Mark Brinicombe.
@@ -49,7 +49,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: disassem.c,v 1.36 2017/04/26 08:20:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disassem.c,v 1.37 2017/06/02 19:58:31 skrll Exp $");
 
 #include 
 
@@ -203,6 +203,12 @@ static const struct arm32_insn arm32_i[]
 /* A5.2 exceptions */
 
 /* A5.2.7 Halfword multiply and multiply accumulate */
+/* A5.2.9 Extra load/store instructions, unprivileged */
+
+{ 0x0f3000f0, 0x002000b0, "strht",	"de" },
+{ 0x0f3000f0, 0x003000b0, "ldrht",	"de" },
+{ 0x0f3000f0, 0x003000d0, "ldrsbt",	"de" },
+{ 0x0f3000f0, 0x003000f0, "ldrsht",	"de" },
 
 /* A5.2.8 Extra load/store instructions */
 
@@ -210,12 +216,12 @@ static const struct arm32_insn arm32_i[]
 { 0x0e1000f0, 0x001000b0, "ldrh",	"de" },
 
 { 0x0e5000f0, 0x00d0, "ldrd",	"de" },
-{ 0x0e5000f0, 0x001000d0, "ldrsb",	"de" },
-{ 0x0e5000f0, 0x004000d0, "ldrd",	"de" },
-{ 0x0e5000f0, 0x005000d0, "ldrsb",	"de" },
+{ 0x0e1000f0, 0x001000d0, "ldrsb",	"de" },
+{ 0x0e1000f0, 0x00d0, "ldrd",	"de" },
+{ 0x0e1000f0, 0x001000d0, "ldrsb",	"de" },
 
-{ 0x0e1000f0, 0x00f0, "ldrd",	"de" },
-{ 0x0e1000f0, 0x001000f0, "ldrsb",	"de" },
+{ 0x0e1000f0, 0x00f0, "strd",	"de" },
+{ 0x0e1000f0, 0x001000f0, "ldrsh",	"de" },
 { 0x0e1000f0, 0x00f0, "strd",	"de" },
 { 0x0e1000f0, 0x001000f0, "ldrsh",	"de" },
 



CVS commit: src/sys/sys

2017-06-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Jun  2 19:44:06 UTC 2017

Modified Files:
src/sys/sys: event.h

Log Message:
Convert EV_SET(2) back into macro again

This retains compatibility with other moder BSDs if someone uses:
"#ifdef EV_SET".

This code also casts the last parameter to intptr_t, as other BSDs keep
this argument with a different type void*.

This change renames function EV_SET to EV_SET_, and calls it from EV_SET().

Credit to  and  for feedback.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/sys/event.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/sys/event.h
diff -u src/sys/sys/event.h:1.27 src/sys/sys/event.h:1.28
--- src/sys/sys/event.h:1.27	Wed May 31 00:45:59 2017
+++ src/sys/sys/event.h	Fri Jun  2 19:44:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.h,v 1.27 2017/05/31 00:45:59 kamil Exp $	*/
+/*	$NetBSD: event.h,v 1.28 2017/06/02 19:44:06 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon 
@@ -54,8 +54,11 @@ struct kevent {
 	intptr_t	udata;		/* opaque user data identifier */
 };
 
+#define EV_SET(kevp, a, b, c, d, e, f)	\
+	EV_SET_((kevp), (a), (b), (c), (d), (e), __CAST(intptr_t, (f)))
+
 static __inline void
-EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
+EV_SET_(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
uint32_t _flags, uint32_t _fflags, int64_t _data, intptr_t _udata)
 {
 	_kevp->ident = _ident;



CVS commit: src/sys/dev/pci

2017-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun  2 19:35:54 UTC 2017

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

Log Message:
enable font loading and screen resizing, now that the glyph cache can be
reconfigured whenever needed


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/machfb.c

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

Modified files:

Index: src/sys/dev/pci/machfb.c
diff -u src/sys/dev/pci/machfb.c:1.93 src/sys/dev/pci/machfb.c:1.94
--- src/sys/dev/pci/machfb.c:1.93	Sun May 28 05:27:13 2017
+++ src/sys/dev/pci/machfb.c	Fri Jun  2 19:35:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machfb.c,v 1.93 2017/05/28 05:27:13 macallan Exp $	*/
+/*	$NetBSD: machfb.c,v 1.94 2017/06/02 19:35:54 macallan Exp $	*/
 
 /*
  * Copyright (c) 2002 Bang Jun-Young
@@ -34,7 +34,7 @@
 
 #include 
 __KERNEL_RCSID(0,
-	"$NetBSD: machfb.c,v 1.93 2017/05/28 05:27:13 macallan Exp $");
+	"$NetBSD: machfb.c,v 1.94 2017/06/02 19:35:54 macallan Exp $");
 
 #include 
 #include 
@@ -66,6 +66,7 @@ __KERNEL_RCSID(0,
 
 #include "opt_wsemul.h"
 #include "opt_machfb.h"
+#include "opt_glyphcache.h"
 
 #define MACH64_REG_SIZE		0x800
 #define MACH64_REG_OFF		0x7ff800
@@ -275,7 +276,7 @@ static struct wsscreen_descr mach64_defa
 	NULL,
 	8, 16,
 	WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE
-	/* | WSSCREEN_RESIZE */,
+	 | WSSCREEN_RESIZE ,
 	NULL
 };
 
@@ -687,8 +688,15 @@ mach64_attach(device_t parent, device_t 
 
 	wsfont_init();
 
+#ifdef GLYPHCACHE_DEBUG
+	/* shrink the screen so we can see part of the glyph cache */
+	sc->sc_my_mode->vdisplay -= 200;
+#endif
+
 	vcons_init(>vd, sc, _defaultscreen, >sc_accessops);
 	sc->vd.init_screen = mach64_init_screen;
+	sc->vd.show_screen_cookie = >sc_gc;
+	sc->vd.show_screen_cb = glyphcache_adapt;
 
 	sc->sc_gc.gc_bitblt = mach64_bitblt;
 	sc->sc_gc.gc_blitcookie = sc;
@@ -800,9 +808,11 @@ mach64_init_screen(void *cookie, struct 
 #ifdef VCONS_DRAW_INTR
 	scr->scr_flags |= VCONS_DONT_READ;
 #endif
+	scr->scr_flags |= VCONS_LOADFONT;
 
 	rasops_init(ri, 0, 0);
-	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE;
+	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
+		  WSSCREEN_RESIZE;
 	rasops_reconfig(ri, sc->sc_my_mode->vdisplay / ri->ri_font->fontheight,
 		sc->sc_my_mode->hdisplay / ri->ri_font->fontwidth);
 



CVS commit: src/sys/dev/wscons

2017-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun  2 19:33:51 UTC 2017

Modified Files:
src/sys/dev/wscons: wsdisplay_vcons.c wsdisplay_vconsvar.h

Log Message:
- add a cookie to show_screen_cb()
- call show_screen_cb() when loading a font into a visible screen, so this can
  be used to track parameters by drivers that use the glyph cache


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/wscons/wsdisplay_vcons.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/wscons/wsdisplay_vconsvar.h

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

Modified files:

Index: src/sys/dev/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.37 src/sys/dev/wscons/wsdisplay_vcons.c:1.38
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.37	Fri May 19 19:22:33 2017
+++ src/sys/dev/wscons/wsdisplay_vcons.c	Fri Jun  2 19:33:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vcons.c,v 1.37 2017/05/19 19:22:33 macallan Exp $ */
+/*	$NetBSD: wsdisplay_vcons.c,v 1.38 2017/06/02 19:33:51 macallan Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.37 2017/05/19 19:22:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.38 2017/06/02 19:33:51 macallan Exp $");
 
 #include 
 #include 
@@ -438,6 +438,11 @@ vcons_load_font(void *v, void *cookie, s
 	ri->ri_ops.copycols  = vcons_copycols;
 	ri->ri_ops.copyrows  = vcons_copyrows;
 	vcons_unlock(vd->active);
+
+	/* notify things that we're about to redraw */
+	if (vd->show_screen_cb != NULL)
+		vd->show_screen_cb(scr, vd->show_screen_cookie);
+	
 #ifdef VCONS_DRAW_INTR
 	/*
 	 * XXX
@@ -515,7 +520,7 @@ vcons_do_switch(void *arg)
 #endif
 
 	if (vd->show_screen_cb != NULL)
-		vd->show_screen_cb(scr);
+		vd->show_screen_cb(scr, vd->show_screen_cookie);
 
 	if ((scr->scr_flags & VCONS_NO_REDRAW) == 0)
 		vcons_redraw_screen(scr);
@@ -1505,7 +1510,7 @@ vcons_hard_switch(struct vcons_screen *s
 	vd->wanted = NULL;
 
 	if (vd->show_screen_cb != NULL)
-		vd->show_screen_cb(scr);
+		vd->show_screen_cb(scr, vd->show_screen_cookie);
 }
 
 #ifdef VCONS_DRAW_INTR

Index: src/sys/dev/wscons/wsdisplay_vconsvar.h
diff -u src/sys/dev/wscons/wsdisplay_vconsvar.h:1.25 src/sys/dev/wscons/wsdisplay_vconsvar.h:1.26
--- src/sys/dev/wscons/wsdisplay_vconsvar.h:1.25	Fri May 19 19:22:33 2017
+++ src/sys/dev/wscons/wsdisplay_vconsvar.h	Fri Jun  2 19:33:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vconsvar.h,v 1.25 2017/05/19 19:22:33 macallan Exp $ */
+/*	$NetBSD: wsdisplay_vconsvar.h,v 1.26 2017/06/02 19:33:51 macallan Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -116,7 +116,8 @@ struct vcons_data {
 	void (*eraserows)(void *, int, int, long);
 	void (*cursor)(void *, int, int, int);
 	/* called before vcons_redraw_screen */
-	void (*show_screen_cb)(struct vcons_screen *);
+	void *show_screen_cookie;
+	void (*show_screen_cb)(struct vcons_screen *, void *);
 	/* virtual screen management stuff */
 	void (*switch_cb)(void *, int, int);
 	void *switch_cb_arg;



CVS commit: src/sys/dev/wscons

2017-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jun  2 19:30:10 UTC 2017

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

Log Message:
make glyph caches reconfigurable


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/wscons/wsdisplay_glyphcache.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/wscons/wsdisplay_glyphcachevar.h

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

Modified files:

Index: src/sys/dev/wscons/wsdisplay_glyphcache.c
diff -u src/sys/dev/wscons/wsdisplay_glyphcache.c:1.8 src/sys/dev/wscons/wsdisplay_glyphcache.c:1.9
--- src/sys/dev/wscons/wsdisplay_glyphcache.c:1.8	Thu Jun  1 02:45:12 2017
+++ src/sys/dev/wscons/wsdisplay_glyphcache.c	Fri Jun  2 19:30:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_glyphcache.c,v 1.8 2017/06/01 02:45:12 chs Exp $	*/
+/*	$NetBSD: wsdisplay_glyphcache.c,v 1.9 2017/06/02 19:30:10 macallan Exp $	*/
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -27,9 +27,6 @@
 
 /* 
  * a simple glyph cache in offscreen memory
- * For now it only caches glyphs with the default attribute ( assuming they're
- * the most commonly used glyphs ) but the API should at least not prevent
- * more sophisticated caching algorithms
  */
 
 #ifdef _KERNEL_OPT
@@ -40,6 +37,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 #ifdef GLYPHCACHE_DEBUG
@@ -48,6 +48,8 @@
 #define DPRINTF while (0) printf
 #endif
 
+#define NBUCKETS 32
+
 static inline int
 attr2idx(long attr)
 {
@@ -62,18 +64,42 @@ int
 glyphcache_init(glyphcache *gc, int first, int lines, int width,
 int cellwidth, int cellheight, long attr)
 {
-	int cache_lines, buckets, i, usedcells = 0, idx;
-	gc_bucket *b;
 
 	/* first the geometry stuff */
-	gc->gc_cellwidth = cellwidth;
-	gc->gc_cellheight = cellheight;
+	if (lines < 0) lines = 0;
+	gc->gc_width = width;
+	gc->gc_cellwidth = -1;
+	gc->gc_cellheight = -1;
 	gc->gc_firstline = first;
-	gc->gc_cellsperline = width / cellwidth;
+	gc->gc_lines = lines;
 	gc->gc_buckets = NULL;
 	gc->gc_numbuckets = 0;
-	if (lines < 0) lines = 0;
-	cache_lines = lines / cellheight;
+	gc->gc_buckets = kmem_alloc(sizeof(gc_bucket) * NBUCKETS, KM_SLEEP);
+	gc->gc_nbuckets = NBUCKETS;
+	return glyphcache_reconfig(gc, cellwidth, cellheight, attr);
+
+}
+
+int
+glyphcache_reconfig(glyphcache *gc, int cellwidth, int cellheight, long attr)
+{
+	int cache_lines, buckets, i, usedcells = 0, idx;
+	gc_bucket *b;
+
+	/* see if we actually need to reconfigure anything */
+	if ((gc->gc_cellwidth == cellwidth) &&
+	(gc->gc_cellheight == cellheight) &&
+	((gc->gc_buckets != NULL) &&
+	 (gc->gc_buckets[0].gb_index == attr2idx(attr {
+		return 0;
+	}
+
+	gc->gc_cellwidth = cellwidth;
+	gc->gc_cellheight = cellheight;
+
+	gc->gc_cellsperline = gc->gc_width / cellwidth;
+
+	cache_lines = gc->gc_lines / cellheight;
 	gc->gc_numcells = cache_lines * gc->gc_cellsperline;
 
 	/* now allocate buckets */
@@ -88,7 +114,7 @@ glyphcache_init(glyphcache *gc, int firs
 	if (buckets < 1)
 		return ENOMEM;
 
-	gc->gc_buckets = kmem_alloc(sizeof(gc_bucket) * buckets, KM_SLEEP);
+	buckets = min(buckets, gc->gc_nbuckets);
 	gc->gc_numbuckets = buckets;
 
 	DPRINTF("%s: using %d buckets\n", __func__, buckets);
@@ -120,6 +146,21 @@ glyphcache_init(glyphcache *gc, int firs
 }
 
 void
+glyphcache_adapt(struct vcons_screen *scr, void *cookie)
+{
+	glyphcache *gc = cookie;
+	struct rasops_info *ri = >scr_ri;
+
+	if (ri->ri_wsfcookie != gc->gc_fontcookie) {
+		glyphcache_wipe(gc);
+		gc->gc_fontcookie = ri->ri_wsfcookie;
+	}
+
+	glyphcache_reconfig(gc, ri->ri_font->fontwidth,
+			ri->ri_font->fontheight, scr->scr_defattr);
+} 
+
+void
 glyphcache_wipe(glyphcache *gc)
 {
 	gc_bucket *b;

Index: src/sys/dev/wscons/wsdisplay_glyphcachevar.h
diff -u src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.4 src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.5
--- src/sys/dev/wscons/wsdisplay_glyphcachevar.h:1.4	Thu Oct  4 10:26:32 2012
+++ src/sys/dev/wscons/wsdisplay_glyphcachevar.h	Fri Jun  2 19:30:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_glyphcachevar.h,v 1.4 2012/10/04 10:26:32 macallan Exp $	*/
+/*	$NetBSD: wsdisplay_glyphcachevar.h,v 1.5 2017/06/02 19:30:10 macallan Exp $	*/
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -48,8 +48,12 @@ typedef struct _glyphcache {
 	int gc_cellheight;
 	int gc_cellsperline;
 	int gc_firstline;	/* first line in vram to use for glyphs */
+	int gc_lines;
+	int gc_width;
+	int gc_fontcookie;
 	/* buckets */
-	int gc_numbuckets;
+	int gc_numbuckets;	/* buckets we can use */
+	int gc_nbuckets;	/* buckets allocated */
 	gc_bucket *gc_buckets;	/* we allocate as many as we can get into vram */
 	gc_bucket *gc_next;	/* bucket the next glyph goes into */
 	long gc_underline;	/* draw an underline in glyphcache_add() */
@@ -66,10 +70,19 @@ typedef struct _glyphcache {
 
 /* first line, lines, width, cellwidth, 

CVS commit: src/sys/netinet

2017-06-02 Thread Lars Reichardt
Module Name:src
Committed By:   para
Date:   Fri Jun  2 19:10:19 UTC 2017

Modified Files:
src/sys/netinet: wqinput.c

Log Message:
pool_init does not copy its name argument
therefore don't pass in a stack allocated buffer

vmstat -mv shows pool(s) with broken name(s)

use the name argument passed into wqinput_create directly
which is a static string in all 4 callee cases

(workqueue_create/workqueue_init copies the name argument)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/netinet/wqinput.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/netinet/wqinput.c
diff -u src/sys/netinet/wqinput.c:1.2 src/sys/netinet/wqinput.c:1.3
--- src/sys/netinet/wqinput.c:1.2	Sun May 21 08:36:22 2017
+++ src/sys/netinet/wqinput.c	Fri Jun  2 19:10:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: wqinput.c,v 1.2 2017/05/21 08:36:22 ozaki-r Exp $	*/
+/*	$NetBSD: wqinput.c,v 1.3 2017/06/02 19:10:19 para Exp $	*/
 
 /*-
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -160,7 +160,7 @@ wqinput_create(const char *name, void (*
 	if (error != 0)
 		panic("%s: workqueue_create failed (%d)\n", __func__, error);
 	pool_init(>wqi_work_pool, sizeof(struct wqinput_work), 0, 0, 0,
-	namebuf, NULL, IPL_SOFTNET);
+	name, NULL, IPL_SOFTNET);
 	wqi->wqi_worklists = percpu_alloc(sizeof(struct wqinput_worklist));
 	wqi->wqi_input = func;
 



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

2017-06-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jun  2 18:19:33 UTC 2017

Modified Files:
src/sys/arch/i386/stand/misc: rawr32.exe.uue

Log Message:
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/misc/rawr32.exe.uue

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

diffs are larger than 1MB and have been omitted


CVS commit: src/bin/sh

2017-06-02 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Fri Jun  2 17:42:51 UTC 2017

Modified Files:
src/bin/sh: sh.1

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/bin/sh/sh.1

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

Modified files:

Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.145 src/bin/sh/sh.1:1.146
--- src/bin/sh/sh.1:1.145	Sat May 27 11:19:57 2017
+++ src/bin/sh/sh.1	Fri Jun  2 17:42:51 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.145 2017/05/27 11:19:57 kre Exp $
+.\"	$NetBSD: sh.1,v 1.146 2017/06/02 17:42:51 abhinav Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -2102,7 +2102,7 @@ flag is also given, such variables are a
 The
 .Fl I
 flag, which is the default in this shell, causes
-the initial value and exported atribute
+the initial value and exported attribute
 of local variables
 to be inherited from the variable
 with the same name in the surrounding



CVS commit: src/sys/arch

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 15:22:47 UTC 2017

Modified Files:
src/sys/arch/evbarm/conf: VEXPRESS_A15 files.vexpress mk.vexpress
std.vexpress
src/sys/arch/evbarm/vexpress: vexpress_start.S
Added Files:
src/sys/arch/arm/vexpress: files.vexpress vexpress_platform.c
Removed Files:
src/sys/arch/evbarm/vexpress: if_smsh_axi.c platform.h vexpress_axi.c
vexpress_intr.h vexpress_machdep.c vexpress_plcom.c
vexpress_plmmc.c vexpress_space.c vexpress_var.h

Log Message:
Switch VEXPRESS_A15 kernel to use FDT and GENERIC.common. The dtb for this
kernel can be found in the sysutils/dtb-arm-vexpress package as
vexpress-v2p-ca15-tc1.dtb


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/vexpress/files.vexpress \
src/sys/arch/arm/vexpress/vexpress_platform.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/conf/VEXPRESS_A15
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/conf/files.vexpress
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/conf/mk.vexpress
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/conf/std.vexpress
cvs rdiff -u -r1.3 -r0 src/sys/arch/evbarm/vexpress/if_smsh_axi.c \
src/sys/arch/evbarm/vexpress/vexpress_machdep.c
cvs rdiff -u -r1.2 -r0 src/sys/arch/evbarm/vexpress/platform.h \
src/sys/arch/evbarm/vexpress/vexpress_axi.c \
src/sys/arch/evbarm/vexpress/vexpress_intr.h \
src/sys/arch/evbarm/vexpress/vexpress_plcom.c \
src/sys/arch/evbarm/vexpress/vexpress_plmmc.c \
src/sys/arch/evbarm/vexpress/vexpress_space.c \
src/sys/arch/evbarm/vexpress/vexpress_var.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/vexpress/vexpress_start.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/evbarm/conf/VEXPRESS_A15
diff -u src/sys/arch/evbarm/conf/VEXPRESS_A15:1.7 src/sys/arch/evbarm/conf/VEXPRESS_A15:1.8
--- src/sys/arch/evbarm/conf/VEXPRESS_A15:1.7	Sun Feb 19 07:47:00 2017
+++ src/sys/arch/evbarm/conf/VEXPRESS_A15	Fri Jun  2 15:22:47 2017
@@ -1,215 +1,65 @@
 #
-#	$NetBSD: VEXPRESS_A15,v 1.7 2017/02/19 07:47:00 rin Exp $
+#	$NetBSD: VEXPRESS_A15,v 1.8 2017/06/02 15:22:47 jmcneill Exp $
 #
-#	VEXPRESS_A15 -- Versatile Express A15 kernel
+#	ARM Versatile Express A15
 #
 
 include	"arch/evbarm/conf/std.vexpress"
+include	"arch/evbarm/conf/GENERIC.common"
 
-# estimated number of users
-
-maxusers	32
-
-# Standard system options
-
-options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
-#options 	NTP		# NTP phase/frequency locked loop
-
-# CPU options
-options 	CPU_CORTEX
 options 	CPU_CORTEXA15
+options 	SOC_TEGRA124
 #options 	MULTIPROCESSOR
 
-options 	PMAPCOUNTERS
-options 	BUSDMA_COUNTERS
-#options 	UVMHIST
-#options 	USB_DEBUG
-#options 	USBHIST_SIZE=10
-#options 	UVMHIST_PRINT,KERNHIST_DELAY=0
-options 	__HAVE_MM_MD_DIRECT_MAPPED_PHYS
-options 	PMAP_NEED_ALLOC_POOLPAGE
-
-# Specify the memory size in megabytes (optional).
-#options 	MEMSIZE=512
-
-# File systems
-file-system	FFS		# UFS
-#file-system	LFS		# log-structured file system
-file-system	MFS		# memory file system
-file-system	NFS		# Network file system
-#file-system 	ADOSFS		# AmigaDOS-compatible file system
-#file-system 	EXT2FS		# second extended file system (linux)
-#file-system	CD9660		# ISO 9660 + Rock Ridge file system
-file-system	MSDOSFS		# MS-DOS file system
-#file-system	FDESC		# /dev/fd
-file-system	KERNFS		# /kern
-#file-system	NULLFS		# loopback file system
-file-system	PROCFS		# /proc
-#file-system	PUFFS		# Userspace file systems (e.g. ntfs-3g & sshfs)
-#file-system	UMAPFS		# NULLFS + uid and gid remapping
-#file-system	UNION		# union file system
-file-system	TMPFS		# memory file system
-file-system	PTYFS		# /dev/pts/N support
-
-# File system options
-#options 	QUOTA		# legacy UFS quotas
-#options 	QUOTA2		# new, in-filesystem UFS quotas
-#options 	DISKLABEL_EI	# disklabel Endian Independent support
-#options 	FFS_EI		# FFS Endian Independent support
-#options 	NFSSERVER
-options 	WAPBL		# File system journaling support
-#options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
-
-# Networking options
-
-#options 	GATEWAY		# packet forwarding
-options 	INET		# IP + ICMP + TCP + UDP
-options 	INET6		# IPV6
-#options 	IPSEC		# IP security
-#options 	IPSEC_DEBUG	# debug for IP security
-#options 	MROUTING	# IP multicast routing
-#options 	PIM		# Protocol Independent Multicast
-#options 	NETATALK	# AppleTalk networking
-#options 	PPP_BSDCOMP	# BSD-Compress compression support for PPP
-#options 	PPP_DEFLATE	# Deflate compression support for PPP
-#options 	PPP_FILTER	# Active filter support for PPP (requires bpf)
-#options 	TCP_DEBUG	# Record last TCP_NDEBUG packets with SO_DEBUG
-
-options 	NFS_BOOT_BOOTP
-options 	NFS_BOOT_DHCP
-#options 	NFS_BOOT_BOOTSTATIC
-#options 	NFS_BOOTSTATIC_MYIP="\"192.168.1.4\""
-#options 	NFS_BOOTSTATIC_GWIP="\"192.168.1.1\""
-#options 	

CVS commit: src/sys/dev/fdt

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 15:09:16 UTC 2017

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

Log Message:
gpiokeys depends on sysmon_envsys and sysmon_power


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/fdt/files.fdt

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/fdt/files.fdt
diff -u src/sys/dev/fdt/files.fdt:1.14 src/sys/dev/fdt/files.fdt:1.15
--- src/sys/dev/fdt/files.fdt:1.14	Sun May 28 15:55:11 2017
+++ src/sys/dev/fdt/files.fdt	Fri Jun  2 15:09:16 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.14 2017/05/28 15:55:11 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.15 2017/06/02 15:09:16 jmcneill Exp $
 
 include	"external/bsd/libfdt/conf/files.libfdt"
 
@@ -18,7 +18,7 @@ device	fclock: clk
 attach	fclock at fdt
 file	dev/fdt/fixedclock.c			fclock
 
-device	gpiokeys
+device	gpiokeys: sysmon_envsys, sysmon_power
 attach	gpiokeys at fdt
 file	dev/fdt/gpiokeys.c			gpiokeys
 



CVS commit: src/sys/arch/arm/fdt

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 14:30:58 UTC 2017

Modified Files:
src/sys/arch/arm/fdt: files.fdt
Added Files:
src/sys/arch/arm/fdt: plcom_fdt.c

Log Message:
Add fdt glue for ARM PrimeCell UART (PL011).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/plcom_fdt.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/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.6 src/sys/arch/arm/fdt/files.fdt:1.7
--- src/sys/arch/arm/fdt/files.fdt:1.6	Fri Jun  2 11:04:01 2017
+++ src/sys/arch/arm/fdt/files.fdt	Fri Jun  2 14:30:58 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.6 2017/06/02 11:04:01 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.7 2017/06/02 14:30:58 jmcneill Exp $
 
 device	armfdt { }: bus_space_generic, fdtbus
 attach	armfdt at root with arm_fdt
@@ -15,6 +15,9 @@ device  gic: mpcorebus
 attach  gic at fdt with gic_fdt
 filearch/arm/fdt/gic_fdt.c 	gic_fdt
 
+attach	plcom at fdt with plcom_fdt
+file	arch/arm/fdt/plcom_fdt.c		plcom_fdt
+
 attach	plmmc at fdt with plmmc_fdt
 file	arch/arm/fdt/plmmc_fdt.c		plmmc_fdt
 

Added files:

Index: src/sys/arch/arm/fdt/plcom_fdt.c
diff -u /dev/null src/sys/arch/arm/fdt/plcom_fdt.c:1.1
--- /dev/null	Fri Jun  2 14:30:58 2017
+++ src/sys/arch/arm/fdt/plcom_fdt.c	Fri Jun  2 14:30:58 2017
@@ -0,0 +1,146 @@
+/* $NetBSD: plcom_fdt.c,v 1.1 2017/06/02 14:30:58 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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 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.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: plcom_fdt.c,v 1.1 2017/06/02 14:30:58 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static int	plcom_fdt_match(device_t, cfdata_t, void *);
+static void	plcom_fdt_attach(device_t, device_t, void *);
+
+static const char * const compatible[] = { "arm,pl011", NULL };
+
+CFATTACH_DECL_NEW(plcom_fdt, sizeof(struct plcom_softc),
+	plcom_fdt_match, plcom_fdt_attach, NULL, NULL);
+
+static int
+plcom_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_compatible(faa->faa_phandle, compatible) >= 0;
+}
+
+static void
+plcom_fdt_attach(device_t parent, device_t self, void *aux)
+{
+	struct plcom_softc * const sc = device_private(self);
+	struct fdt_attach_args * const faa = aux;
+	const int phandle = faa->faa_phandle;
+	struct clk *clk;
+	bus_addr_t addr;
+	bus_size_t size;
+	void *ih;
+
+	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
+		aprint_error(": missing 'reg' property\n");
+		return;
+	}
+
+	sc->sc_dev = self;
+
+	/* Enable clocks */
+	for (int i = 0; (clk = fdtbus_clock_get_index(phandle, i)); i++) {
+		if (clk_enable(clk) != 0) {
+			aprint_error(": failed to enable clock #%d\n", i);
+			return;
+		}
+		/* First clock is UARTCLK */
+		if (i == 0)
+			sc->sc_frequency = clk_get_rate(clk);
+	}
+
+	sc->sc_hwflags = PLCOM_HW_TXFIFO_DISABLE;
+	sc->sc_swflags = 0;
+
+	sc->sc_pi.pi_type = PLCOM_TYPE_PL011;
+	sc->sc_pi.pi_flags = PLC_FLAG_32BIT_ACCESS;
+	sc->sc_pi.pi_iot = faa->faa_bst;
+	sc->sc_pi.pi_iobase = addr;
+	if (bus_space_map(faa->faa_bst, addr, size, 0, >sc_pi.pi_ioh)) {
+		aprint_error(": couldn't map device\n");
+		return;
+	}
+	plcom_attach_subr(sc);
+
+	ih = fdtbus_intr_establish(phandle, 0, IPL_SERIAL, FDT_INTR_MPSAFE,
+	plcomintr, sc);
+	if (ih == NULL) {
+		aprint_error_dev(self, "couldn't install interrupt handler\n");
+		return;
+	}
+}
+
+static int
+plcom_fdt_console_match(int phandle)
+{
+	return 

CVS commit: src/sys

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 13:53:29 UTC 2017

Modified Files:
src/sys/arch/arm/fdt: arm_fdtvar.h
src/sys/arch/arm/nvidia: tegra_com.c tegra_platform.c
src/sys/arch/evbarm/fdt: fdt_machdep.c
src/sys/dev/fdt: fdtvar.h

Log Message:
Allow platform code to specify the UART frequency for consinit


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/arm_fdtvar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/nvidia/tegra_com.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/nvidia/tegra_platform.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/fdt/fdt_machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/fdt/fdtvar.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/arm/fdt/arm_fdtvar.h
diff -u src/sys/arch/arm/fdt/arm_fdtvar.h:1.4 src/sys/arch/arm/fdt/arm_fdtvar.h:1.5
--- src/sys/arch/arm/fdt/arm_fdtvar.h:1.4	Fri Jun  2 00:16:27 2017
+++ src/sys/arch/arm/fdt/arm_fdtvar.h	Fri Jun  2 13:53:28 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdtvar.h,v 1.4 2017/06/02 00:16:27 jmcneill Exp $ */
+/* $NetBSD: arm_fdtvar.h,v 1.5 2017/06/02 13:53:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -43,6 +43,7 @@ struct arm_platform {
 	void			(*device_register)(device_t, void *);
 	void			(*reset)(void);
 	void			(*delay)(u_int);
+	u_int			(*uart_freq)(void);
 };
 
 struct arm_platform_info {

Index: src/sys/arch/arm/nvidia/tegra_com.c
diff -u src/sys/arch/arm/nvidia/tegra_com.c:1.7 src/sys/arch/arm/nvidia/tegra_com.c:1.8
--- src/sys/arch/arm/nvidia/tegra_com.c:1.7	Mon May 29 23:13:03 2017
+++ src/sys/arch/arm/nvidia/tegra_com.c	Fri Jun  2 13:53:29 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_com.c,v 1.7 2017/05/29 23:13:03 jmcneill Exp $ */
+/* $NetBSD: tegra_com.c,v 1.8 2017/06/02 13:53:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.7 2017/05/29 23:13:03 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.8 2017/06/02 13:53:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -48,8 +48,6 @@ __KERNEL_RCSID(1, "$NetBSD: tegra_com.c,
 
 #include 
 
-#define	PLLP_OUT0_FREQ	40800
-
 static int tegra_com_match(device_t, cfdata_t, void *);
 static void tegra_com_attach(device_t, device_t, void *);
 
@@ -162,9 +160,8 @@ tegra_com_console_match(int phandle)
 }
 
 static void
-tegra_com_console_consinit(struct fdt_attach_args *faa)
+tegra_com_console_consinit(struct fdt_attach_args *faa, u_int uart_freq)
 {
-	const u_int freq = PLLP_OUT0_FREQ;
 	const int phandle = faa->faa_phandle;
 	bus_space_tag_t bst = faa->faa_a4x_bst;
 	bus_addr_t addr;
@@ -177,7 +174,7 @@ tegra_com_console_consinit(struct fdt_at
 		speed = 115200;	/* default */
 	flags = fdtbus_get_stdout_flags();
 
-	if (comcnattach(bst, addr, speed, freq, COM_TYPE_TEGRA, flags))
+	if (comcnattach(bst, addr, speed, uart_freq, COM_TYPE_TEGRA, flags))
 		panic("Cannot initialize tegra com console");
 }
 

Index: src/sys/arch/arm/nvidia/tegra_platform.c
diff -u src/sys/arch/arm/nvidia/tegra_platform.c:1.5 src/sys/arch/arm/nvidia/tegra_platform.c:1.6
--- src/sys/arch/arm/nvidia/tegra_platform.c:1.5	Fri Jun  2 00:16:27 2017
+++ src/sys/arch/arm/nvidia/tegra_platform.c	Fri Jun  2 13:53:29 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_platform.c,v 1.5 2017/06/02 00:16:27 jmcneill Exp $ */
+/* $NetBSD: tegra_platform.c,v 1.6 2017/06/02 13:53:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -33,7 +33,7 @@
 #include "ukbd.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.5 2017/06/02 00:16:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.6 2017/06/02 13:53:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_platfo
 #include 
 #include 
 
+#define	PLLP_OUT0_FREQ	40800
+
 #define	DEVMAP_ALIGN(a)	((a) & ~L1_S_OFFSET)
 #define	DEVMAP_SIZE(s)	roundup2((s), L1_S_SIZE)
 #define	DEVMAP_ENTRY(va, pa, sz)			\
@@ -188,6 +190,12 @@ tegra_platform_delay(u_int us)
 	tegra_timer_delay(us);
 }
 
+static u_int
+tegra_platform_uart_freq(void)
+{
+	return PLLP_OUT0_FREQ;
+}
+
 static const struct arm_platform tegra_platform = {
 	.devmap = tegra_platform_devmap,
 	.bootstrap = tegra_platform_bootstrap,
@@ -196,6 +204,7 @@ static const struct arm_platform tegra_p
 	.device_register = tegra_platform_device_register,
 	.reset = tegra_platform_reset,
 	.delay = tegra_platform_delay,
+	.uart_freq = tegra_platform_uart_freq,
 };
 
 ARM_PLATFORM(tegra124, "nvidia,tegra124", _platform);

Index: src/sys/arch/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.3 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.4
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.3	Fri Jun  2 00:16:28 2017
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Fri Jun  2 

CVS commit: src/sys/dev/fdt

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 13:12:33 UTC 2017

Modified Files:
src/sys/dev/fdt: fdt_intr.c

Log Message:
Fix interrupt-map support on vexpress-a15 and try to avoid unnecessary
calls to kmem_alloc.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_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/dev/fdt/fdt_intr.c
diff -u src/sys/dev/fdt/fdt_intr.c:1.9 src/sys/dev/fdt/fdt_intr.c:1.10
--- src/sys/dev/fdt/fdt_intr.c:1.9	Fri Jun  2 00:55:26 2017
+++ src/sys/dev/fdt/fdt_intr.c	Fri Jun  2 13:12:33 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.9 2017/06/02 00:55:26 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.10 2017/06/02 13:12:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.9 2017/06/02 00:55:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.10 2017/06/02 13:12:33 jmcneill Exp $");
 
 #include 
 #include 
@@ -46,9 +46,9 @@ struct fdtbus_interrupt_controller {
 
 static struct fdtbus_interrupt_controller *fdtbus_ic = NULL;
 
-static bool has_interrupt_map(int phandle);
-static u_int *get_specifier_by_index(int phandle, int pindex, u_int *spec);
-static u_int *get_specifier_from_map(int phandle, u_int *spec, u_int spec_len, int *piphandle);
+static bool	has_interrupt_map(int);
+static u_int *	get_specifier_by_index(int, int, int *);
+static u_int *	get_specifier_from_map(int, int, int *);
 
 static int
 fdtbus_get_interrupt_parent(int phandle)
@@ -123,14 +123,12 @@ fdtbus_intr_establish(int phandle, u_int
 int (*func)(void *), void *arg)
 {
 	struct fdtbus_interrupt_controller *ic;
-	int ihandle = phandle;
 	u_int *specifier;
-	u_int spec_length;
+	int ihandle;
 
-	specifier = get_specifier_by_index(phandle, index, _length);
-	if (has_interrupt_map(phandle))
-		specifier = get_specifier_from_map(phandle, specifier,
-		spec_length, );
+	specifier = get_specifier_by_index(phandle, index, );
+	if (specifier == NULL)
+		return NULL;
 
 	ic = fdtbus_get_interrupt_controller(ihandle);
 	if (ic == NULL)
@@ -155,14 +153,10 @@ bool
 fdtbus_intr_str(int phandle, u_int index, char *buf, size_t buflen)
 {
 	struct fdtbus_interrupt_controller *ic;
-	int ihandle = phandle;
 	u_int *specifier;
-	u_int spec_length;
+	int ihandle;
 
-	specifier = get_specifier_by_index(phandle, index, _length);
-	if (has_interrupt_map(phandle))
-		specifier = get_specifier_from_map(phandle, specifier,
-		spec_length, );
+	specifier = get_specifier_by_index(phandle, index, );
 
 	ic = fdtbus_get_interrupt_controller(ihandle);
 	if (ic == NULL)
@@ -213,24 +207,37 @@ has_interrupt_map(int phandle)
 }
 
 static u_int *
-get_specifier_from_map(int phandle, u_int *specifier, u_int spec_length, int *piphandle)
+get_specifier_from_map(int phandle, int pindex, int *piphandle)
 {
+	const u_int *node_specifier = NULL;
 	u_int *result = NULL;
+	int len, resid;
 
-	const int nexus_phandle = find_interrupt_map(phandle);
+	const u_int interrupt_cells = find_interrupt_cells(phandle);
+	if (interrupt_cells < 1)
+		return NULL;
 
-	int len = OF_getproplen(nexus_phandle, "interrupt-map");
-	if (len <= 0) {
-		printf("%s: no interrupt-map.\n", __func__);
+	node_specifier = fdt_getprop(fdtbus_get_data(), fdtbus_phandle2offset(phandle),
+	"interrupts", );
+	if (node_specifier == NULL)
 		return NULL;
-	}
-	int resid = len;
-	char *data = kmem_alloc(len, KM_SLEEP);
-	len = OF_getprop(nexus_phandle, "interrupt-map", data, len);
-	if (len <= 0) {
+
+	const u_int spec_length = len / 4;
+	const u_int nintr = spec_length / interrupt_cells;
+	if (pindex >= nintr)
+		return NULL;
+
+	node_specifier += (interrupt_cells * pindex);
+
+	const int nexus_phandle = find_interrupt_map(OF_parent(phandle));
+
+	const u_int *data = fdt_getprop(fdtbus_get_data(), fdtbus_phandle2offset(nexus_phandle),
+	"interrupt-map", );
+	if (data == NULL || len <= 0) {
 		printf("%s: can't get property interrupt-map.\n", __func__);
-		goto done;
+		return NULL;
 	}
+	resid = len;
 
 	/* child unit address: #address-cells prop of child bus node */
 	const int cua_cells = find_address_cells(nexus_phandle);
@@ -247,14 +254,17 @@ get_specifier_from_map(int phandle, u_in
 	const u_int pus_off = ip_off + 1;
 
 #ifdef FDT_INTR_DEBUG
+	printf("%s: phandle=%s nexus_phandle=%s\n", __func__,
+	fdt_get_name(fdtbus_get_data(), fdtbus_phandle2offset(phandle), NULL),
+	fdt_get_name(fdtbus_get_data(), fdtbus_phandle2offset(nexus_phandle), NULL));
 	printf("cua_cells: %d, cis_cells: %d, ip_off = %d\n", cua_cells, cis_cells, ip_off);
-	printf("searching for interrupt in map:");
-	for (int i = 0; i < spec_length; i++)
-		printf(" %08x", specifier[i]);
+	printf("searching for interrupt in map (data %p, len %d):", data, len);
+	for (int i = 0; i < interrupt_cells; i++)

CVS commit: src/sys/arch/arm/fdt

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 11:04:01 UTC 2017

Modified Files:
src/sys/arch/arm/fdt: files.fdt
Added Files:
src/sys/arch/arm/fdt: plmmc_fdt.c

Log Message:
Add fdt glue for ARM PrimeCell Multimedia Card Interface (MMCI).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/plmmc_fdt.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/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.5 src/sys/arch/arm/fdt/files.fdt:1.6
--- src/sys/arch/arm/fdt/files.fdt:1.5	Fri Jun  2 10:46:07 2017
+++ src/sys/arch/arm/fdt/files.fdt	Fri Jun  2 11:04:01 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.5 2017/06/02 10:46:07 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.6 2017/06/02 11:04:01 jmcneill Exp $
 
 device	armfdt { }: bus_space_generic, fdtbus
 attach	armfdt at root with arm_fdt
@@ -15,6 +15,9 @@ device  gic: mpcorebus
 attach  gic at fdt with gic_fdt
 filearch/arm/fdt/gic_fdt.c 	gic_fdt
 
+attach	plmmc at fdt with plmmc_fdt
+file	arch/arm/fdt/plmmc_fdt.c		plmmc_fdt
+
 attach	smsh at fdt with smsh_fdt
 file	arch/arm/fdt/smsh_fdt.c			smsh_fdt
 

Added files:

Index: src/sys/arch/arm/fdt/plmmc_fdt.c
diff -u /dev/null src/sys/arch/arm/fdt/plmmc_fdt.c:1.1
--- /dev/null	Fri Jun  2 11:04:01 2017
+++ src/sys/arch/arm/fdt/plmmc_fdt.c	Fri Jun  2 11:04:01 2017
@@ -0,0 +1,109 @@
+/* $NetBSD: plmmc_fdt.c,v 1.1 2017/06/02 11:04:01 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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 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.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: plmmc_fdt.c,v 1.1 2017/06/02 11:04:01 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static int	plmmc_fdt_match(device_t, cfdata_t, void *);
+static void	plmmc_fdt_attach(device_t, device_t, void *);
+
+static const char * const compatible[] = {
+	"arm,pl180",
+	"arm,pl181",
+	NULL
+};
+
+CFATTACH_DECL_NEW(plmmc_fdt, sizeof(struct plmmc_softc),
+	plmmc_fdt_match, plmmc_fdt_attach, NULL, NULL);
+
+static int
+plmmc_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_compatible(faa->faa_phandle, compatible) >= 0;
+}
+
+static void
+plmmc_fdt_attach(device_t parent, device_t self, void *aux)
+{
+	struct plmmc_softc * const sc = device_private(self);
+	struct fdt_attach_args * const faa = aux;
+	const int phandle = faa->faa_phandle;
+	struct clk *clk;
+	bus_addr_t addr;
+	bus_size_t size;
+	void *ih;
+
+	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
+		aprint_error(": missing 'reg' property\n");
+		return;
+	}
+
+	clk = fdtbus_clock_get_index(phandle, 0);
+	if (clk == NULL) {
+		aprint_error(": couldn't get clock\n");
+		return;
+	}
+
+	if (clk_enable(clk) != 0) {
+		aprint_error(": couldn't enable clock\n");
+		return;
+	}
+
+	sc->sc_dev = self;
+	sc->sc_clock_freq = clk_get_rate(clk);
+	of_getprop_uint32(phandle, "max-frequency", >sc_max_freq);
+	sc->sc_bst = faa->faa_bst;
+	if (bus_space_map(faa->faa_bst, addr, size, 0, >sc_bsh)) {
+		aprint_error(": couldn't map device\n");
+		return;
+	}
+
+	aprint_naive("\n");
+	aprint_normal("\n");
+
+	ih = fdtbus_intr_establish(phandle, 0, IPL_BIO, 0, plmmc_intr, sc);
+	if (ih == NULL) {
+		aprint_error_dev(self, "couldn't install interrupt handler\n");
+		return;
+	}
+
+	plmmc_init(sc);
+}



CVS commit: src/sys/dev/ic

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 11:01:15 UTC 2017

Modified Files:
src/sys/dev/ic: pl181.c pl181var.h

Log Message:
Separate clock frequency from maximum supported bus frequency.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/pl181.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/pl181var.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/ic/pl181.c
diff -u src/sys/dev/ic/pl181.c:1.2 src/sys/dev/ic/pl181.c:1.3
--- src/sys/dev/ic/pl181.c:1.2	Thu Jun  1 16:57:12 2017
+++ src/sys/dev/ic/pl181.c	Fri Jun  2 11:01:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pl181.c,v 1.2 2017/06/01 16:57:12 jmcneill Exp $ */
+/* $NetBSD: pl181.c,v 1.3 2017/06/02 11:01:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pl181.c,v 1.2 2017/06/01 16:57:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pl181.c,v 1.3 2017/06/02 11:01:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -117,7 +117,8 @@ plmmc_init(struct plmmc_softc *sc)
 	saa.saa_sct = _chip_functions;
 	saa.saa_sch = sc;
 	saa.saa_clkmin = 400;
-	saa.saa_clkmax = sc->sc_clock_freq / 1000;
+	saa.saa_clkmax = sc->sc_max_freq > 0 ?
+	sc->sc_max_freq / 1000 : sc->sc_clock_freq / 1000;
 	saa.saa_caps = SMC_CAPS_4BIT_MODE | SMC_CAPS_SINGLE_ONLY;
 
 	sc->sc_sdmmc_dev = config_found(sc->sc_dev, , NULL);

Index: src/sys/dev/ic/pl181var.h
diff -u src/sys/dev/ic/pl181var.h:1.1 src/sys/dev/ic/pl181var.h:1.2
--- src/sys/dev/ic/pl181var.h:1.1	Tue Jan 27 16:33:26 2015
+++ src/sys/dev/ic/pl181var.h	Fri Jun  2 11:01:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pl181var.h,v 1.1 2015/01/27 16:33:26 jmcneill Exp $ */
+/* $NetBSD: pl181var.h,v 1.2 2017/06/02 11:01:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -35,6 +35,7 @@ struct plmmc_softc {
 	bus_space_handle_t	sc_bsh;
 	void			*sc_ih;
 	unsigned int		sc_clock_freq;
+	unsigned int		sc_max_freq;
 
 	device_t		sc_sdmmc_dev;
 	kmutex_t		sc_intr_lock;



CVS commit: src/sys/arch/arm/fdt

2017-06-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jun  2 10:46:07 UTC 2017

Modified Files:
src/sys/arch/arm/fdt: files.fdt
Added Files:
src/sys/arch/arm/fdt: smsh_fdt.c

Log Message:
Add fdt glue for SMSC LAN9118 ethernet.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/smsh_fdt.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/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.4 src/sys/arch/arm/fdt/files.fdt:1.5
--- src/sys/arch/arm/fdt/files.fdt:1.4	Tue May 30 22:55:26 2017
+++ src/sys/arch/arm/fdt/files.fdt	Fri Jun  2 10:46:07 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.4 2017/05/30 22:55:26 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.5 2017/06/02 10:46:07 jmcneill Exp $
 
 device	armfdt { }: bus_space_generic, fdtbus
 attach	armfdt at root with arm_fdt
@@ -15,5 +15,8 @@ device  gic: mpcorebus
 attach  gic at fdt with gic_fdt
 filearch/arm/fdt/gic_fdt.c 	gic_fdt
 
+attach	smsh at fdt with smsh_fdt
+file	arch/arm/fdt/smsh_fdt.c			smsh_fdt
+
 # Console parameters
 defparam opt_fdt_arm.hCONSADDR

Added files:

Index: src/sys/arch/arm/fdt/smsh_fdt.c
diff -u /dev/null src/sys/arch/arm/fdt/smsh_fdt.c:1.1
--- /dev/null	Fri Jun  2 10:46:07 2017
+++ src/sys/arch/arm/fdt/smsh_fdt.c	Fri Jun  2 10:46:07 2017
@@ -0,0 +1,112 @@
+/* $NetBSD: smsh_fdt.c,v 1.1 2017/06/02 10:46:07 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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 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.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: smsh_fdt.c,v 1.1 2017/06/02 10:46:07 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static int	smsh_fdt_match(device_t, cfdata_t, void *);
+static void	smsh_fdt_attach(device_t, device_t, void *);
+
+static const char * const compatible[] = { "smsc,lan9118", NULL };
+
+CFATTACH_DECL_NEW(smsh_fdt, sizeof(struct lan9118_softc),
+	smsh_fdt_match, smsh_fdt_attach, NULL, NULL);
+
+static int
+smsh_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_compatible(faa->faa_phandle, compatible) >= 0;
+}
+
+static void
+smsh_fdt_attach(device_t parent, device_t self, void *aux)
+{
+	struct lan9118_softc * const sc = device_private(self);
+	struct fdt_attach_args * const faa = aux;
+	char intrstr[128];
+	const int phandle = faa->faa_phandle;
+	bus_addr_t addr;
+	bus_size_t size;
+	void *ih;
+
+	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
+		aprint_error(": missing 'reg' property\n");
+		return;
+	}
+
+	if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
+		aprint_error_dev(self, "failed to decode interrupt\n");
+		return;
+	}
+
+	sc->sc_dev = self;
+	sc->sc_iot = faa->faa_bst;
+	if (bus_space_map(faa->faa_bst, addr, size, 0, >sc_ioh)) {
+		aprint_error(": couldn't map device\n");
+		return;
+	}
+
+	if (of_hasprop(phandle, "smsc,irq-active-high"))
+		sc->sc_flags |= LAN9118_FLAGS_IRQ_ACTHI;
+	if (of_hasprop(phandle, "smsc,irq-push-pull"))
+		sc->sc_flags |= LAN9118_FLAGS_IRQ_PP;
+
+	if (lan9118_attach(sc) != 0)
+		goto unmap;
+
+	ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0, lan9118_intr, sc);
+	if (ih == NULL) {
+		aprint_error_dev(self, "couldn't install interrupt handler\n");
+		goto unmap;
+	}
+	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
+
+	return;
+
+unmap:
+	bus_space_unmap(sc->sc_iot, sc->sc_ioh, size);
+}



CVS commit: src/sys/opencrypto

2017-06-02 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Jun  2 09:46:57 UTC 2017

Modified Files:
src/sys/opencrypto: cryptodev.c cryptodev_internal.h ocryptodev.c

Log Message:
rename crypto_mtx to cryptodev_mtx

It is used by cryptodev.c and ocryptodev.c only.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.2 -r1.3 src/sys/opencrypto/cryptodev_internal.h
cvs rdiff -u -r1.7 -r1.8 src/sys/opencrypto/ocryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.91 src/sys/opencrypto/cryptodev.c:1.92
--- src/sys/opencrypto/cryptodev.c:1.91	Thu May 25 05:24:57 2017
+++ src/sys/opencrypto/cryptodev.c	Fri Jun  2 09:46:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.91 2017/05/25 05:24:57 knakahara Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.92 2017/06/02 09:46:57 knakahara Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.91 2017/05/25 05:24:57 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.92 2017/06/02 09:46:57 knakahara Exp $");
 
 #include 
 #include 
@@ -98,7 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: cryptodev.c,
 
 #include "ioconf.h"
 
-kmutex_t crypto_mtx;
+kmutex_t cryptodev_mtx;
 
 struct csession {
 	TAILQ_ENTRY(csession) next;
@@ -247,16 +247,16 @@ cryptof_ioctl(struct file *fp, u_long cm
 	struct fcrypt *criofcr;
 	int criofd;
 
-	mutex_enter(_mtx);
+	mutex_enter(_mtx);
 	getnanotime(>atime);
-	mutex_exit(_mtx);
+	mutex_exit(_mtx);
 
 	switch (cmd) {
 case CRIOGET:   /* XXX deprecated, remove after 5.0 */
 		if ((error = fd_allocfile(, )) != 0)
 			return error;
 		criofcr = pool_get(, PR_WAITOK);
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		TAILQ_INIT(>csessions);
 		TAILQ_INIT(>crp_ret_mq);
 		TAILQ_INIT(>crp_ret_mkq);
@@ -269,7 +269,7 @@ cryptof_ioctl(struct file *fp, u_long cm
 		criofcr->sesn = 1;
 		criofcr->requestid = 1;
 		crypto_refcount++;
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		(void)fd_clone(criofp, criofd, (FREAD|FWRITE),
 			  , criofcr);
 		*(u_int32_t *)data = criofd;
@@ -289,9 +289,9 @@ cryptof_ioctl(struct file *fp, u_long cm
 			goto mbail;
 		}
 
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		error = cryptodev_msession(fcr, snop, sgop->count);
 		if (error) {
 			goto mbail;
@@ -303,22 +303,22 @@ mbail:
 		kmem_free(snop, sgop->count * sizeof(struct session_n_op));
 		break;
 	case CIOCFSESSION:
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
 		ses = *(u_int32_t *)data;
 		cse = csefind(fcr, ses);
 		if (cse == NULL) {
-			mutex_exit(_mtx);
+			mutex_exit(_mtx);
 			return EINVAL;
 		}
 		csedelete(fcr, cse);
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		error = csefree(cse);
 		break;
 	case CIOCNFSESSION:
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		sfop = (struct crypt_sfop *)data;
 		sesid = kmem_alloc((sfop->count * sizeof(u_int32_t)), 
 		KM_SLEEP);
@@ -330,11 +330,11 @@ mbail:
 		kmem_free(sesid, (sfop->count * sizeof(u_int32_t)));
 		break;
 	case CIOCCRYPT:
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
 		cop = (struct crypt_op *)data;
 		cse = csefind(fcr, cop->ses);
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		if (cse == NULL) {
 			DPRINTF("csefind failed\n");
 			return EINVAL;
@@ -343,9 +343,9 @@ mbail:
 		DPRINTF("cryptodev_op error = %d\n", error);
 		break;
 	case CIOCNCRYPTM:
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		mop = (struct crypt_mop *)data;
 		cnop = kmem_alloc((mop->count * sizeof(struct crypt_n_op)),
 		KM_SLEEP);
@@ -365,9 +365,9 @@ mbail:
 		DPRINTF("cryptodev_key error = %d\n", error);
 		break;
 	case CIOCNFKEYM:
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		mkop = (struct crypt_mkop *)data;
 		knop = kmem_alloc((mkop->count * sizeof(struct crypt_n_kop)),
 		KM_SLEEP);
@@ -385,9 +385,9 @@ mbail:
 		error = crypto_getfeat((int *)data);
 		break;
 	case CIOCNCRYPTRETM:
-		mutex_enter(_mtx);
+		mutex_enter(_mtx);
 		fcr->mtime = fcr->atime;
-		mutex_exit(_mtx);
+		mutex_exit(_mtx);
 		crypt_ret = (struct cryptret *)data;
 		count = crypt_ret->count;
 		crypt_res = kmem_alloc((count * sizeof(struct crypt_result)),  
@@ -632,7 +632,7 @@ cryptodev_op(struct csession *cse, struc
 	 * XXX splcrypto() but needed to only if CRYPTO_F_CBIMM,
 	 * XXX disabled on NetBSD since 1.6O due to a race condition.
 	 * XXX But crypto_dispatch went to splcrypto() 

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

2017-06-02 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jun  2 08:16:52 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_type.h

Log Message:
- Print NVM Image Version, PHY FW Revision, NVM Map version and OEM NVM
  Image version
- s/TrackID/ETrackID/


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/ixgbe/ixgbe_type.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/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.87 src/sys/dev/pci/ixgbe/ixgbe.c:1.88
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.87	Fri May 26 09:17:32 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Jun  2 08:16:52 2017
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.87 2017/05/26 09:17:32 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.88 2017/06/02 08:16:52 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -466,7 +466,8 @@ ixgbe_attach(device_t parent, device_t d
 	struct adapter *adapter;
 	struct ixgbe_hw *hw;
 	int error = -1;
-	u16		csum, high, low;
+	u16		csum, high, low, nvmreg;
+	u8		id;
 	u32		ctrl_ext;
 	ixgbe_vendor_info_t *ent;
 	struct pci_attach_args *pa = aux;
@@ -630,10 +631,75 @@ ixgbe_attach(device_t parent, device_t d
 		goto err_late;
 	}
 
-	/* Print the TrackID */
-	hw->eeprom.ops.read(hw, IXGBE_TRACKID_H, );
-	hw->eeprom.ops.read(hw, IXGBE_TRACKID_L, );
-	aprint_normal_dev(dev, "TrackID %08x\n", ((uint32_t)high << 16) | low);
+	aprint_normal("%s:", device_xname(dev));
+	/* NVM Image Version */
+	switch (hw->mac.type) {
+	case ixgbe_mac_X540:
+		hw->eeprom.ops.read(hw, IXGBE_NVM_IMAGE_VER, );
+		if (nvmreg == 0x)
+			break;
+		high = (nvmreg >> 12) & 0x0f;
+		low = (nvmreg >> 4) & 0xff;
+		id = nvmreg & 0x0f;
+		aprint_normal(" NVM Image Version %u.%u ID 0x%x,", high, low,
+		id);
+		break;
+	case ixgbe_mac_X550EM_x:
+	case ixgbe_mac_X550:
+		hw->eeprom.ops.read(hw, IXGBE_NVM_IMAGE_VER, );
+		if (nvmreg == 0x)
+			break;
+		high = (nvmreg >> 12) & 0x0f;
+		low = nvmreg & 0xff;
+		aprint_normal(" NVM Image Version %u.%u,", high, low);
+		break;
+	default:
+		break;
+	}
+
+	/* PHY firmware revision */
+	switch (hw->mac.type) {
+	case ixgbe_mac_X540:
+	case ixgbe_mac_X550:
+		hw->eeprom.ops.read(hw, IXGBE_PHYFW_REV, );
+		if (nvmreg == 0x)
+			break;
+		high = (nvmreg >> 12) & 0x0f;
+		low = (nvmreg >> 4) & 0xff;
+		id = nvmreg & 0x000f;
+		aprint_normal(" PHY FW Revision %u.%u ID 0x%x,", high, low,
+		id);
+		break;
+	default:
+		break;
+	}
+
+	/* NVM Map version & OEM NVM Image version */
+	switch (hw->mac.type) {
+	case ixgbe_mac_X550:
+	case ixgbe_mac_X550EM_x:
+		hw->eeprom.ops.read(hw, IXGBE_NVM_MAP_VER, );
+		if (nvmreg != 0x) {
+			high = (nvmreg >> 12) & 0x0f;
+			low = nvmreg & 0x00ff;
+			aprint_normal(" NVM Map version %u.%02x,", high, low);
+		}
+		hw->eeprom.ops.read(hw, IXGBE_OEM_NVM_IMAGE_VER, );
+		if (nvmreg == 0x) {
+			high = (nvmreg >> 12) & 0x0f;
+			low = nvmreg & 0x00ff;
+			aprint_verbose(" OEM NVM Image version %u.%02x,", high,
+			low);
+		}
+		break;
+	default:
+		break;
+	}
+
+	/* Print the ETrackID */
+	hw->eeprom.ops.read(hw, IXGBE_ETRACKID_H, );
+	hw->eeprom.ops.read(hw, IXGBE_ETRACKID_L, );
+	aprint_normal(" ETrackID %08x\n", ((uint32_t)high << 16) | low);
 
 	error = ixgbe_init_hw(hw);
 	switch (error) {

Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.21 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.22
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.21	Fri May 26 08:36:42 2017
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h	Fri Jun  2 08:16:52 2017
@@ -31,7 +31,7 @@
 
 **/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_type.h 299200 2016-05-06 22:54:56Z pfg $*/
-/*$NetBSD: ixgbe_type.h,v 1.21 2017/05/26 08:36:42 msaitoh Exp $*/
+/*$NetBSD: ixgbe_type.h,v 1.22 2017/06/02 08:16:52 msaitoh Exp $*/
 
 #ifndef _IXGBE_TYPE_H_
 #define _IXGBE_TYPE_H_
@@ -2221,13 +2221,17 @@ enum {
 #define IXGBE_FW_PTR			0x0F
 #define IXGBE_PBANUM0_PTR		0x15
 #define IXGBE_PBANUM1_PTR		0x16
+#define IXGBE_NVM_IMAGE_VER		0x18
+#define IXGBE_PHYFW_REV			0x19
 #define IXGBE_ALT_MAC_ADDR_PTR		0x37
 #define IXGBE_FREE_SPACE_PTR		0X3E
 
 #define IXGBE_SAN_MAC_ADDR_PTR		0x28
+#define IXGBE_NVM_MAP_VER		0x29
+#define IXGBE_OEM_NVM_IMAGE_VER		0x2A
 #define IXGBE_DEVICE_CAPS		0x2C
-#define IXGBE_TRACKID_L			0x2d
-#define IXGBE_TRACKID_H			0x2e
+#define IXGBE_ETRACKID_L		0x2D
+#define IXGBE_ETRACKID_H		0x2E
 #define IXGBE_SERIAL_NUMBER_MAC_ADDR	0x11
 #define IXGBE_PCIE_MSIX_82599_CAPS	0x72
 #define IXGBE_MAX_MSIX_VECTORS_82599	0x40