Module Name:    src
Committed By:   ragge
Date:           Thu Jul  1 19:50:12 UTC 2010

Modified Files:
        src/sys/arch/vax/conf: GENERIC files.vax
        src/sys/arch/vax/include: cpu.h ioa.h nexus.h
        src/sys/arch/vax/uba: uba_sbi.c
        src/sys/arch/vax/vax: autoconf.c clock.c cmi.c crl.c intvec.S ka860.c
            lock_stubs.S pmap.c sbi.c ubi.c

Log Message:
A big bunch of bugfixes from Johnny Billquist. Highlights:
- Makes the VAX8600 work as expected (500kg of hardware :-)
- Fix a hard-tracked bug causing VAXen to hang at splhigh.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/vax/conf/GENERIC
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/vax/conf/files.vax
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/vax/include/cpu.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/vax/include/ioa.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/vax/include/nexus.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/vax/uba/uba_sbi.c
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/vax/vax/autoconf.c
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/vax/vax/clock.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/vax/vax/cmi.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/vax/vax/crl.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/vax/vax/intvec.S
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/vax/vax/ka860.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/vax/vax/lock_stubs.S
cvs rdiff -u -r1.175 -r1.176 src/sys/arch/vax/vax/pmap.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/vax/vax/sbi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/vax/vax/ubi.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/vax/conf/GENERIC
diff -u src/sys/arch/vax/conf/GENERIC:1.173 src/sys/arch/vax/conf/GENERIC:1.174
--- src/sys/arch/vax/conf/GENERIC:1.173	Sat May  8 22:16:30 2010
+++ src/sys/arch/vax/conf/GENERIC	Thu Jul  1 19:50:11 2010
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.173 2010/05/08 22:16:30 mrg Exp $
+# $NetBSD: GENERIC,v 1.174 2010/07/01 19:50:11 ragge Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.173 $"
+#ident 		"GENERIC-$Revision: 1.174 $"
 
 # Here are all different supported CPU types listed.
 #options 	VAX8800		# VAX 8500, 8530, 8550, 8700, 8800
@@ -176,7 +176,8 @@
 cpu*		at mainbus0
 
 # All buses; from the beginning attached to mainbus.
-sbi0		at mainbus0		# SBI, master bus on 11/780, 8600.
+abus0		at mainbus0		# Master bus on VAX 86x0
+sbi0		at mainbus0		# SBI, master bus on 11/78x.
 cmi0		at mainbus0		# 11/750 internal bus.
 bi0		at mainbus0		# VAX 8200
 vsbus0		at mainbus0		# All VAXstations
@@ -232,6 +233,9 @@
 uba*		at cmi? tr?		# Unibus adapters
 mba*		at cmi? tr?		# Massbus adapters
 
+# ABUS (VAX 86x0)
+sbi*		at abus0		# VAX 86x0 can have up to 2 SBI's.
+
 # SBI (VAX 11/780, VAX 8600)
 mem*		at sbi? tr?		# Memory subsystems
 uba*		at sbi? tr?		# Unibus adapters
@@ -301,10 +305,10 @@
 pseudo-device	bpfilter
 #pseudo-device	carp			# Common Address Redundancy Protocol
 pseudo-device	ipfilter		# IP filter (firewall) and NAT
-#pseudo-device	sl	
-pseudo-device	ppp	
+#pseudo-device	sl
+pseudo-device	ppp
 #pseudo-device	pppoe			# PPP over Ethernet (RFC 2516)
-pseudo-device	tun	
+pseudo-device	tun
 pseudo-device	tap			# virtual Ethernet
 #pseudo-device	gre			# generic L3 over IP tunnel
 pseudo-device	gif			# IPv[46] over IPv[46] tunnel (RFC1933)
@@ -314,7 +318,7 @@
 pseudo-device	bridge			# simple inter-network bridging
 #options	BRIDGE_IPF		# bridge uses IP/IPv6 pfil hooks too
 pseudo-device	agr			# IEEE 802.3ad link aggregation
-pseudo-device	vnd	
+pseudo-device	vnd
 #options 	VND_COMPRESSION		# compressed vnd(4)
 pseudo-device	ccd	4
 #pseudo-device	cgd	4		# cryptographic disk devices

Index: src/sys/arch/vax/conf/files.vax
diff -u src/sys/arch/vax/conf/files.vax:1.116 src/sys/arch/vax/conf/files.vax:1.117
--- src/sys/arch/vax/conf/files.vax:1.116	Mon Feb 16 23:55:31 2009
+++ src/sys/arch/vax/conf/files.vax	Thu Jul  1 19:50:11 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: files.vax,v 1.116 2009/02/16 23:55:31 christos Exp $
+#	$NetBSD: files.vax,v 1.117 2010/07/01 19:50:11 ragge Exp $
 #
 # new style config file for vax architecture
 #
@@ -35,19 +35,22 @@
 attach	nmi at mainbus with nmi_mainbus
 file	arch/vax/vax/nmi_mainbus.c	nmi
 
+# Abus and related devices
+device  abus {}: bus
+attach  abus at mainbus with abus_mainbus
+file	arch/vax/vax/ka860.c		vax8600
+file	arch/vax/vax/crl.c		vax8600
+
 # SBI and related devices
 device	sbi { tr=-1 }: bus
 attach	sbi at mainbus with sbi_mainbus
+attach  sbi at abus with sbi_abus
 file	arch/vax/vax/sbi.c		sbi
 
 attach	mem at sbi with mem_sbi
 file	arch/vax/vax/ka780.c		vax780 | mem_sbi | vaxany
 file	arch/vax/vax/cfl.c		vax780 | mem_sbi | vaxany
 
-# Abus and related devices
-file	arch/vax/vax/ka860.c		vax8600
-file	arch/vax/vax/crl.c		vax8600
-
 # CMI and related devices
 device	cmi { tr=-1 }: bus
 attach	cmi at mainbus

Index: src/sys/arch/vax/include/cpu.h
diff -u src/sys/arch/vax/include/cpu.h:1.88 src/sys/arch/vax/include/cpu.h:1.89
--- src/sys/arch/vax/include/cpu.h:1.88	Tue Jun 22 18:29:02 2010
+++ src/sys/arch/vax/include/cpu.h	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*      $NetBSD: cpu.h,v 1.88 2010/06/22 18:29:02 rmind Exp $      */
+/*      $NetBSD: cpu.h,v 1.89 2010/07/01 19:50:12 ragge Exp $      */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden
@@ -79,7 +79,6 @@
 	void	(*cpu_clrf)(void);	/* Clear cold/warm start flags */
 	const char * const *cpu_devs;	/* mainbus devices */
 	void	(*cpu_attach_cpu)(device_t);	/* print CPU info */
-	void	(*cpu_subconf)(device_t, void *, cfprint_t);	/* attach dep. dev */
 	int     cpu_flags;
 	void	(*cpu_badaddr)(void);	/* cpu-specific badaddr() */
 };

Index: src/sys/arch/vax/include/ioa.h
diff -u src/sys/arch/vax/include/ioa.h:1.12 src/sys/arch/vax/include/ioa.h:1.13
--- src/sys/arch/vax/include/ioa.h:1.12	Sun Mar  4 06:00:57 2007
+++ src/sys/arch/vax/include/ioa.h	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ioa.h,v 1.12 2007/03/04 06:00:57 christos Exp $	*/
+/*	$NetBSD: ioa.h,v 1.13 2010/07/01 19:50:12 ragge Exp $	*/
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
  * All rights reserved.
@@ -30,6 +30,10 @@
  *	@(#)ioa.h	7.3 (Berkeley) 5/9/91
  */
 
+/*
+ * ABus support added by Johnny Billquist 2010
+ */
+
 /****************************************************************
  *                                                              *
  *        Licensed from Digital Equipment Corporation           *
@@ -57,9 +61,10 @@
 #include "opt_cputype.h"
 #if VAX8600 || VAXANY
 #define	NIOA8600	2	/* Number of SBI possible on a VAX86x0 */
-#define IOASIZE		0x2000000
+#define IOASIZE		0x2000000 /* Size of one SBI memory area */
 #define IOAMAPSIZ 	512		/* Map one page to get at SBIA regs */
-#define	IOA8600(i)	((void *)(0x20080000+IOASIZE*i))
+#define SBIA8600(i)     ((void *)(0x20000000+IOASIZE*i)) /* Base address for SBI */
+#define	IOA8600(i)	((void *)((bus_addr_t)(SBIA8600(i))+0x80000)) /* Address of SBIA registers */
 
 struct	sbia_regs
 {
@@ -102,7 +107,7 @@
 	int sbi_unused2[17];
 };
 
-#define IOA_TYPMSK 0xf0
-#define IOA_SBIA	0x10
+#define IOA_TYPMSK 0xf0         /* Mask for type information in sbi_cfg */
+#define IOA_SBIA	0x10    /* Value for SBIA type on ABus */
 
 #endif /* VAX8600 */

Index: src/sys/arch/vax/include/nexus.h
diff -u src/sys/arch/vax/include/nexus.h:1.25 src/sys/arch/vax/include/nexus.h:1.26
--- src/sys/arch/vax/include/nexus.h:1.25	Tue Mar 11 05:34:02 2008
+++ src/sys/arch/vax/include/nexus.h	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nexus.h,v 1.25 2008/03/11 05:34:02 matt Exp $	*/
+/*	$NetBSD: nexus.h,v 1.26 2010/07/01 19:50:12 ragge Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -31,6 +31,10 @@
  *	@(#)nexus.h	7.3 (Berkeley) 5/9/91
  */
 
+/*
+ * ABus support added by Johnny Billquist 2010.
+ */
+
 #ifndef _VAX_NEXUS_H_
 #define _VAX_NEXUS_H_
 
@@ -46,7 +50,7 @@
 	VAX_SBIBUS,		/* SBI parent (780) */
 	VAX_CMIBUS,		/* CMI backplane (750) */
 	VAX_UNIBUS,		/* Direct backplane (730) */
-	VAX_ABUS,		/* SBI placeholder (8600) */
+	VAX_ABUS,		/* ABus (8600) */
 	VAX_BIBUS,		/* BI bus (8200) */
 	VAX_NMIBUS,		/* NMI backplane (8800) */
 	VAX_VSBUS,		/* Virtual vaxstation bus */
@@ -61,16 +65,13 @@
  * byte of the first word of the adapter address space.
  * At boot time the system looks through the array of available
  * slots and finds the interconnects for the machine.
+ *
+ * VAX8600 nexus information is located in ioa.h
  */
 #define IO_CMI750       2
 #define MAXNMCR         1
 
 #define	NNEXSBI		16
-#if VAX8600 || VAXANY
-#define	NNEX8600	NNEXSBI
-#define	NEXA8600	((struct nexus *)(0x20000000))
-#define	NEXB8600	((struct nexus *)(0x22000000))
-#endif
 #if VAX780 || VAXANY
 #define	NNEX780	NNEXSBI
 #define	NEX780	((struct nexus *)0x20000000)
@@ -81,12 +82,6 @@
 #endif
 #define	NEXSIZE	0x2000
 
-#if VAX8600 || VAXANY
-#define	MAXNNEXUS (2 * NNEXSBI)
-#else 
-#define	MAXNNEXUS NNEXSBI
-#endif
-
 #ifdef _KERNEL
 
 struct	nexus {
@@ -97,6 +92,16 @@
 	long	nex_pad[NEXSIZE / sizeof (long) - 1];
 };
 
+struct abus_attach_args {
+        const char *aa_name;
+        int aa_type;
+        bus_addr_t aa_base;
+        int aa_num;
+	bus_space_tag_t aa_iot;
+	bus_space_handle_t aa_ioh;
+	bus_dma_tag_t aa_dmat;
+};
+
 struct sbi_attach_args {
 	int sa_nexnum; 		/* This nexus TR number */
 	int sa_type;		/* This nexus type */
@@ -104,6 +109,7 @@
 	bus_space_tag_t sa_iot;
 	bus_space_handle_t sa_ioh;
 	bus_dma_tag_t sa_dmat;
+        bus_addr_t sa_base;
 };
 
 /* Memory device struct. This should be somewhere else */

Index: src/sys/arch/vax/uba/uba_sbi.c
diff -u src/sys/arch/vax/uba/uba_sbi.c:1.27 src/sys/arch/vax/uba/uba_sbi.c:1.28
--- src/sys/arch/vax/uba/uba_sbi.c:1.27	Sat Mar 14 15:36:14 2009
+++ src/sys/arch/vax/uba/uba_sbi.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uba_sbi.c,v 1.27 2009/03/14 15:36:14 dsl Exp $	   */
+/*	$NetBSD: uba_sbi.c,v 1.28 2010/07/01 19:50:12 ragge Exp $	   */
 /*
  * Copyright (c) 1982, 1986 The Regents of the University of California.
  * All rights reserved.
@@ -67,8 +67,15 @@
  *	@(#)autoconf.c	7.20 (Berkeley) 5/9/91
  */
 
+/*
+ * Abus support added by Johnny Billquist 2010
+ * Changed UBA code to need to know less of the innards of the
+ * actual machine at the same time. Information passed down from
+ * the SBI bus instead.
+ */
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uba_sbi.c,v 1.27 2009/03/14 15:36:14 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uba_sbi.c,v 1.28 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -92,8 +99,7 @@
 
 /* Some SBI-specific defines */
 #define UBASIZE		(UBAPAGES * VAX_NBPG)
-#define UMEMA8600(i)   	(0x20100000+(i)*0x40000)
-#define	UMEMB8600(i)	(0x22100000+(i)*0x40000)
+#define UMEM(sa,i) ((sa->sa_base)+0x100000+(i)*0x40000)
 
 /*
  * Some status registers.
@@ -169,6 +175,7 @@
 	struct sbi_attach_args * const sa = aux;
 	int ubaddr = sa->sa_type & 3;
 
+	aprint_naive(": DW780\n");
 	aprint_normal(": DW780\n");
 
 	/*
@@ -214,8 +221,7 @@
 	sc->uv_size = UBASIZE;		/* Size in bytes of Unibus space */
 
 	uba_dma_init(sc);
-	uba_attach(&sc->uv_sc, (sa->sa_sbinum ? UMEMB8600(ubaddr) :
-	    UMEMA8600(ubaddr)) + (UBAPAGES * VAX_NBPG));
+	uba_attach(&sc->uv_sc, UMEM(sa,ubaddr) + (UBAPAGES * VAX_NBPG));
 }
 
 void

Index: src/sys/arch/vax/vax/autoconf.c
diff -u src/sys/arch/vax/vax/autoconf.c:1.90 src/sys/arch/vax/vax/autoconf.c:1.91
--- src/sys/arch/vax/vax/autoconf.c:1.90	Tue Mar 11 05:34:03 2008
+++ src/sys/arch/vax/vax/autoconf.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.90 2008/03/11 05:34:03 matt Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.91 2010/07/01 19:50:12 ragge Exp $	*/
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.90 2008/03/11 05:34:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.91 2010/07/01 19:50:12 ragge Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_cputype.h"
@@ -120,8 +120,10 @@
 mainbus_print(void *aux, const char *name)
 {
 	struct mainbus_attach_args * const ma = aux;
-	if (name)
-		aprint_normal("%s at %s", ma->ma_type, name);
+	if (name) {
+		aprint_naive("%s at %s\n", ma->ma_type, name);
+		aprint_normal("%s at %s\n", ma->ma_type, name);
+        }
 	return UNCONF;
 }
 
@@ -137,6 +139,7 @@
 	struct mainbus_attach_args ma;
 	const char * const * devp;
 
+	aprint_naive("\n");
 	aprint_normal("\n");
 
 	for (devp = dep_call->cpu_devs; *devp != NULL; devp++) {
@@ -151,10 +154,6 @@
 	 * Maybe should have this as master instead of mainbus.
 	 */
 
-	if (dep_call->cpu_subconf != NULL)
-		(*dep_call->cpu_subconf)(self, &ma, mainbus_print);
-
-
 #if defined(COMPAT_14)
 	if (rpb.rpb_base == (void *)-1)
 		printf("\nWARNING: you must update your boot blocks.\n\n");
@@ -189,10 +188,13 @@
 
 	if (dep_call->cpu_attach_cpu != NULL)
 		(*dep_call->cpu_attach_cpu)(self);
-	else if (ci->ci_cpustr)
+	else if (ci->ci_cpustr) {
+		aprint_naive(": %s\n", ci->ci_cpustr);
 		aprint_normal(": %s\n", ci->ci_cpustr);
-	else
+        } else {
+		aprint_naive("\n");
 		aprint_normal("\n");
+        }
 }
 
 CFATTACH_DECL_NEW(cpu_mainbus, 0,

Index: src/sys/arch/vax/vax/clock.c
diff -u src/sys/arch/vax/vax/clock.c:1.52 src/sys/arch/vax/vax/clock.c:1.53
--- src/sys/arch/vax/vax/clock.c:1.52	Sat Dec 12 14:44:09 2009
+++ src/sys/arch/vax/vax/clock.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.52 2009/12/12 14:44:09 tsutsui Exp $	 */
+/*	$NetBSD: clock.c,v 1.53 2010/07/01 19:50:12 ragge Exp $	 */
 /*
  * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.52 2009/12/12 14:44:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.53 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -46,6 +46,11 @@
 
 #include "opt_cputype.h"
 
+struct evcnt clock_misscnt =
+	EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "clock", "intr miss");
+
+EVCNT_ATTACH_STATIC(clock_misscnt);
+
 struct evcnt clock_intrcnt =
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "clock", "intr");
 

Index: src/sys/arch/vax/vax/cmi.c
diff -u src/sys/arch/vax/vax/cmi.c:1.11 src/sys/arch/vax/vax/cmi.c:1.12
--- src/sys/arch/vax/vax/cmi.c:1.11	Tue Mar 11 05:34:03 2008
+++ src/sys/arch/vax/vax/cmi.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmi.c,v 1.11 2008/03/11 05:34:03 matt Exp $ */
+/*	$NetBSD: cmi.c,v 1.12 2010/07/01 19:50:12 ragge Exp $ */
 /*
  * Copyright (c) 1999 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cmi.c,v 1.11 2008/03/11 05:34:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmi.c,v 1.12 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -77,6 +77,8 @@
 {
 	struct sbi_attach_args sa;
 
+        sa.sa_base = NEX750;
+
 	aprint_normal("\n");
 	/*
 	 * Probe for memory, can be in the first 4 slots.

Index: src/sys/arch/vax/vax/crl.c
diff -u src/sys/arch/vax/vax/crl.c:1.27 src/sys/arch/vax/vax/crl.c:1.28
--- src/sys/arch/vax/vax/crl.c:1.27	Sat Nov 21 04:45:39 2009
+++ src/sys/arch/vax/vax/crl.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: crl.c,v 1.27 2009/11/21 04:45:39 rmind Exp $	*/
+/*	$NetBSD: crl.c,v 1.28 2010/07/01 19:50:12 ragge Exp $	*/
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
  * All rights reserved.
@@ -31,12 +31,16 @@
  */
 
 /*
+ * Bugfix by Johnny Billquist 2010
+ */
+
+/*
  * TO DO (tef  7/18/85):
  *	1) change printf's to log() instead???
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crl.c,v 1.27 2009/11/21 04:45:39 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crl.c,v 1.28 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -149,7 +153,8 @@
 		}
 		s = splconsmedia(); 
 		crlstart();
-		biowait(bp);
+                while ((bp->b_oflags & BO_DONE) == 0)
+                  (void) tsleep(bp, PRIBIO, "crlxfer", 0);
 		splx(s);
 		if (bp->b_error != 0) {
 			error = bp->b_error;
@@ -223,7 +228,7 @@
 			bp->b_oflags |= BO_DONE;
 		}
 		crltab.crl_active = 0;
-		wakeup((void *)bp);
+		wakeup(bp);
 		break;
 
 	case CRL_S_XCONT:

Index: src/sys/arch/vax/vax/intvec.S
diff -u src/sys/arch/vax/vax/intvec.S:1.17 src/sys/arch/vax/vax/intvec.S:1.18
--- src/sys/arch/vax/vax/intvec.S:1.17	Thu Mar  5 01:38:12 2009
+++ src/sys/arch/vax/vax/intvec.S	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: intvec.S,v 1.17 2009/03/05 01:38:12 msaitoh Exp $   */
+/*	$NetBSD: intvec.S,v 1.18 2010/07/01 19:50:12 ragge Exp $   */
 
 /*
  * Copyright (c) 1994, 1997 Ludd, University of Lule}, Sweden.
@@ -297,7 +297,6 @@
 TRAPCALL(ddbtrap, T_KDBTRAP)
 
 SCBENTRY(hardclock)
-	mtpr	$0xc1,$PR_ICCS		# Reset interrupt flag
 #ifdef DDB
 	tstl	0x80000100		# rpb wait element
 	beql	1f			# set, jmp to debugger
@@ -306,6 +305,12 @@
 	jbr	Xtrap
 #endif
 1:	pushr	$0x3f
+        mfpr    $PR_ICCS,%r0
+        tstl    %r0
+        bgeq    2f
+	incl    _C_LABEL(clock_misscnt)+EV_COUNT
+        adwc    $0,_C_LABEL(clock_misscnt)+EV_COUNT+4
+2:      mtpr	$0x800000c1,$PR_ICCS		# Reset interrupt flag
 	incl	_C_LABEL(clock_intrcnt)+EV_COUNT	# count the number of clock interrupts
 	adwc	$0,_C_LABEL(clock_intrcnt)+EV_COUNT+4
 	incl	_C_LABEL(uvmexp)+UVME_INTRS

Index: src/sys/arch/vax/vax/ka860.c
diff -u src/sys/arch/vax/vax/ka860.c:1.32 src/sys/arch/vax/vax/ka860.c:1.33
--- src/sys/arch/vax/vax/ka860.c:1.32	Tue Dec 16 22:35:28 2008
+++ src/sys/arch/vax/vax/ka860.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ka860.c,v 1.32 2008/12/16 22:35:28 christos Exp $	*/
+/*	$NetBSD: ka860.c,v 1.33 2010/07/01 19:50:12 ragge Exp $	*/
 /*
  * Copyright (c) 1986, 1988 Regents of the University of California.
  * All rights reserved.
@@ -36,10 +36,12 @@
  *
  * Todo: Set up all four console lines in a VAX8600.
  * This is: local, remote, EMM and logical.
+ *
+ * ABus code added by Johnny Billquist 2010
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ka860.c,v 1.32 2008/12/16 22:35:28 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ka860.c,v 1.33 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -63,9 +65,11 @@
 static	void	ka86_clrf(void);
 static	void	ka860_conf(void);
 static	void	ka86_attach_cpu(device_t);
-static	void	ka86_subconf(device_t, void *, cfprint_t);
+static int abus_mainbus_match(device_t, cfdata_t, void *);
+static void abus_mainbus_attach(device_t, device_t, void*);
+static int abus_print(void *, const char *);
 
-static const char * const ka86_devs[] = { "cpu", NULL };
+static const char * const ka86_devs[] = { "cpu", "abus", NULL };
 
 const struct cpu_dep ka860_calls = {
 	.cpu_mchk	= ka86_mchk,
@@ -79,7 +83,6 @@
 	.cpu_clrf	= ka86_clrf,
 	.cpu_devs	= ka86_devs,
 	.cpu_attach_cpu	= ka86_attach_cpu,
-	.cpu_subconf	= ka86_subconf,
 };
 
 /*
@@ -299,17 +302,32 @@
 	struct ka86 * const ka86 = (void *)&vax_cpudata;
 	int fpa;
 
-	aprint_normal("KA86%d, S/N %d, Rev. %c, manufactured in %s.\n",
+	aprint_naive(": KA86%d, S/N %d, Rev. %c, manufactured in %s.\n",
+	    ka86->v8650 ? 5 : 0, ka86->snr, ka86->eco+64,
+	    manuf[mindex[ka86->plant]]);
+	aprint_normal(": KA86%d, S/N %d, Rev. %c, manufactured in %s.\n",
 	    ka86->v8650 ? 5 : 0, ka86->snr, ka86->eco+64,
 	    manuf[mindex[ka86->plant]]);
 	fpa = mfpr(PR_ACCS);
 	if (fpa & 255) {
+		aprint_naive_dev(self,
+		    "FPA present: type %d, serial number %d\n", 
+		    fpa & 255, fpa >> 16);
 		aprint_normal_dev(self,
-		    "FPA present: type %d, serial number %d", 
+		    "FPA present: type %d, serial number %d\n", 
 		    fpa & 255, fpa >> 16);
 		mtpr(0x8000, PR_ACCS);
-	} else
-		aprint_normal_dev(self, "no FPA");
+	} else {
+		aprint_naive_dev(self, "no FPA\n");
+		aprint_normal_dev(self, "no FPA\n");
+        }
+
+	/*
+	 * Init CPU.
+	 * Attach crl first.
+	 */
+
+	crlattach();
 }
 
 /*
@@ -360,21 +378,27 @@
 	__asm("halt");
 }
 
-void
-ka86_subconf(device_t self, void * aux, cfprint_t cfprint)
+
+CFATTACH_DECL_NEW(abus_mainbus, 0,
+                  abus_mainbus_match, abus_mainbus_attach, NULL, NULL);
+
+int abus_mainbus_match(device_t parent, cfdata_t self, void *aux)
+{
+  return (vax_bustype == VAX_ABUS);
+}
+
+void abus_mainbus_attach(device_t parent, device_t self, void *aux)
 {
-	struct mainbus_attach_args * const ma = aux;
-	bus_addr_t tmp;
+        struct mainbus_attach_args * const ma = aux;
+        struct abus_attach_args aa;
+
+        unsigned int tmp;
 	volatile struct sbia_regs *sbiar;
-	int     type, i;
-	char	typebuf[13];
 
-	/*
-	 * Init CPU.
-	 * Attach crl first.
-	 */
+        int     type, i;
 
-	crlattach();
+        aprint_naive("\n");
+        aprint_normal("\n");
 
 	for (i = 0; i < NIOA8600; i++) {
 		sbiar = (struct sbia_regs *)vax_map_physmem((paddr_t)IOA8600(i),
@@ -384,27 +408,44 @@
 			    (IOAMAPSIZ / VAX_NBPG));
 			continue;
 		}
+
 		tmp = sbiar->sbi_cfg;
 		type = tmp & IOA_TYPMSK;
 
-		ma->ma_type = NULL;
-		if (type == IOA_SBIA)
-			ma->ma_type = "sbi";
-
-		if (ma->ma_type == NULL) {
-			snprintf(typebuf, sizeof(typebuf), "%#x", type);
-			ma->ma_type = typebuf;
-		}
+                switch (type) {
 
-		ma->ma_num = i;
-		ma->ma_addr = tmp;
-		config_found(self, ma, cfprint);
+                case IOA_SBIA:
+
+                        aa.aa_base = (bus_addr_t)(SBIA8600(i));
+                        aa.aa_num = i;
+                        aa.aa_name = "sbi";
+                        aa.aa_type = tmp;
+                        aa.aa_iot = ma->ma_iot;
+                        aa.aa_dmat = ma->ma_dmat;
 
-		if (type == IOA_SBIA) {
 			sbiar->sbi_errsum = -1;
 			sbiar->sbi_error = 0x1000;
 			sbiar->sbi_fltsts = 0xc0000;
+
+                        config_found(self, &aa, abus_print);
+                        break;
+
+                default:
+                  aprint_naive("IOAdapter %#x unsupported\n", type);
+                  aprint_normal("IOAdapter %#x unsupported\n", type);
 		}
+
 		vax_unmap_physmem((vaddr_t)sbiar, (IOAMAPSIZ / VAX_NBPG));
 	}
 }
+
+int abus_print(void *aux, const char *name)
+{
+  struct abus_attach_args *aa = aux;
+
+  if (name) {
+    aprint_naive("%s%d at %s\n", aa->aa_name, aa->aa_num, name);
+    aprint_normal("%s%d at %s\n", aa->aa_name, aa->aa_num, name);
+  }
+  return UNSUPP;
+}

Index: src/sys/arch/vax/vax/lock_stubs.S
diff -u src/sys/arch/vax/vax/lock_stubs.S:1.15 src/sys/arch/vax/vax/lock_stubs.S:1.16
--- src/sys/arch/vax/vax/lock_stubs.S:1.15	Sun May 25 15:56:12 2008
+++ src/sys/arch/vax/vax/lock_stubs.S	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.S,v 1.15 2008/05/25 15:56:12 chs Exp $	*/
+/*	$NetBSD: lock_stubs.S,v 1.16 2010/07/01 19:50:12 ragge Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@@ -29,6 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * Bugfix for mutex_spin_enter, which wasn't reentrant.
+ *
+ * Fixed by Johnny Billquist and Chuck Silvers
+ */
+
 #include "opt_lockdebug.h"
 #include "opt_multiprocessor.h"
 #include <machine/asm.h>
@@ -93,10 +99,10 @@
 	mtpr	%r3, $PR_IPL			/*   yes, raise IPL */
 1:	mfpr	$PR_SSP, %r4			/* get curlwp */
 	movl	L_CPU(%r4),%r4			/* get cpu_info */
-	tstl	CI_MTX_COUNT(%r4)		/* any spin mutexes active? */
-	bneq	3f				/*   yep, don't save IPL */
+	decl	CI_MTX_COUNT(%r4)		/* decr muntex count */
+	bcc	3f				/* previous active - don't save IPL */
 	movl	%r2, CI_MTX_OLDSPL(%r4)		/*   nope, save old IPL */
-3:	decl	CI_MTX_COUNT(%r4)		/* decr mutex count */
+3:
 #if defined(DIAGNOSTIC) || defined(MULTIPROCESSOR)
 	bbssi	$0, MTX_LOCK(%r0), 4f		/* take out mutex */
 	ret

Index: src/sys/arch/vax/vax/pmap.c
diff -u src/sys/arch/vax/vax/pmap.c:1.175 src/sys/arch/vax/vax/pmap.c:1.176
--- src/sys/arch/vax/vax/pmap.c:1.175	Fri Nov 27 03:23:14 2009
+++ src/sys/arch/vax/vax/pmap.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.175 2009/11/27 03:23:14 rmind Exp $	   */
+/*	$NetBSD: pmap.c,v 1.176 2010/07/01 19:50:12 ragge Exp $	   */
 /*
  * Copyright (c) 1994, 1998, 1999, 2003 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.175 2009/11/27 03:23:14 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.176 2010/07/01 19:50:12 ragge Exp $");
 
 #include "opt_ddb.h"
 #include "opt_cputype.h"
@@ -326,7 +326,7 @@
 	scratch = istack + USPACE;
 
 	/* Physical-to-virtual translation table */
-	pv_table = (struct pv_entry *)(scratch + 3 * VAX_NBPG);
+	pv_table = (struct pv_entry *)(scratch + SCRATCHPAGES * VAX_NBPG);
 
 	avail_start = (vaddr_t)pv_table + (round_page(avail_end >> PGSHIFT)) *
 	    sizeof(struct pv_entry) - KERNBASE;

Index: src/sys/arch/vax/vax/sbi.c
diff -u src/sys/arch/vax/vax/sbi.c:1.34 src/sys/arch/vax/vax/sbi.c:1.35
--- src/sys/arch/vax/vax/sbi.c:1.34	Wed Nov 19 22:54:16 2008
+++ src/sys/arch/vax/vax/sbi.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbi.c,v 1.34 2008/11/19 22:54:16 hans Exp $ */
+/*	$NetBSD: sbi.c,v 1.35 2010/07/01 19:50:12 ragge Exp $ */
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -30,11 +30,15 @@
  */
 
 /*
+ * ABus code added by Johnny Billquist 2010
+ */
+
+/*
  * Still to do: Write all SBI error handling.
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbi.c,v 1.34 2008/11/19 22:54:16 hans Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbi.c,v 1.35 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -46,10 +50,17 @@
 #include <machine/cpu.h>
 #include <machine/nexus.h>
 #include <machine/mainbus.h>
+#include <machine/ioa.h>
 
 static int sbi_print(void *, const char *);
+#if VAX780 || VAXANY
 static int sbi_mainbus_match(device_t, cfdata_t, void *);
 static void sbi_mainbus_attach(device_t, device_t, void*);
+#endif
+#if VAX8600 || VAXANY
+static int sbi_abus_match(device_t, cfdata_t, void *);
+static void sbi_abus_attach(device_t, device_t, void*);
+#endif
 
 int
 sbi_print(void *aux, const char *name)
@@ -60,22 +71,28 @@
 	if (name) {
 		switch (sa->sa_type) {
 		case NEX_MBA:
+			aprint_naive("mba at %s", name);
 			aprint_normal("mba at %s", name);
 			break;
 		case NEX_CI:
+			aprint_naive("ci at %s", name);
 			aprint_normal("ci at %s", name);
 			unsupp++;
 			break;
 		default:
+			aprint_naive("unknown device 0x%x at %s",
+			    sa->sa_type, name);
 			aprint_normal("unknown device 0x%x at %s",
 			    sa->sa_type, name);
 			unsupp = true;
 		}		
 	}
+	aprint_naive(" tr%d", sa->sa_nexnum);
 	aprint_normal(" tr%d", sa->sa_nexnum);
 	return (unsupp ? UNSUPP : UNCONF);
 }
 
+#if VAX780 || VAXANY
 int
 sbi_mainbus_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -89,33 +106,74 @@
 {
 	struct mainbus_attach_args * const ma = aux;
 	struct sbi_attach_args sa;
-	u_int nexnum, minnex = 0;	/* default only one SBI, as on 780 */
-	paddr_t nexbase;
+	u_int nexnum;
 
+	aprint_naive("\n");
 	aprint_normal("\n");
 
 	sa.sa_iot = ma->ma_iot;
 	sa.sa_dmat = ma->ma_dmat;
 
 #define NEXPAGES (sizeof(struct nexus) / VAX_NBPG)
-#if VAX780 || VAXANY
-	if (vax_boardtype == VAX_BTYP_780) {
-		nexbase = (paddr_t) NEX780;
-		sa.sa_sbinum = 0;
+        sa.sa_sbinum = 0;
+
+	for (nexnum = 0; nexnum < NNEXSBI; nexnum++) {
+		struct nexus *nexusP = 0;
+		volatile int tmp;
+
+		nexusP = (struct nexus *)vax_map_physmem((paddr_t)(NEX780) +
+		    sizeof(struct nexus) * nexnum, NEXPAGES);
+		if (badaddr((void *)nexusP, 4)) {
+			vax_unmap_physmem((vaddr_t)nexusP, NEXPAGES);
+		} else {
+			tmp = nexusP->nexcsr.nex_csr; /* no byte reads */
+			sa.sa_type = tmp & 255;
+
+			sa.sa_nexnum = nexnum;
+			sa.sa_ioh = (vaddr_t)nexusP;
+                        sa.sa_base = (bus_addr_t)NEX780;
+			config_found(self, (void*)&sa, sbi_print);
+		}
 	}
+}
+
+CFATTACH_DECL_NEW(sbi_mainbus, 0,
+    sbi_mainbus_match, sbi_mainbus_attach, NULL, NULL);
+
 #endif
+
 #if VAX8600 || VAXANY
-	if (vax_boardtype == VAX_BTYP_790) {
-		nexbase = (paddr_t) NEXA8600;
-		minnex = ma->ma_num * NNEXSBI;
-		sa.sa_sbinum = ma->ma_num;
-	}
-#endif
+int
+sbi_abus_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct abus_attach_args * const aa = aux;
+
+	return ((aa->aa_type & IOA_TYPMSK) == IOA_SBIA);
+}
+
+void
+sbi_abus_attach(device_t parent, device_t self, void *aux)
+{
+	struct abus_attach_args * const aa = aux;
+	struct sbi_attach_args sa;
+	u_int nexnum, minnex;
+
+	aprint_naive(": SBIA Rev. %d, base address %#x\n", aa->aa_type & 0xf, (unsigned int)aa->aa_base);
+	aprint_normal(": SBIA Rev. %d, base address %#x\n", aa->aa_type & 0xf, (unsigned int)aa->aa_base);
+
+	sa.sa_iot = aa->aa_iot;
+	sa.sa_dmat = aa->aa_dmat;
+        sa.sa_base = aa->aa_base;
+
+#define NEXPAGES (sizeof(struct nexus) / VAX_NBPG)
+        minnex = aa->aa_num * NNEXSBI;
+        sa.sa_sbinum = aa->aa_num;
+
 	for (nexnum = minnex; nexnum < minnex + NNEXSBI; nexnum++) {
 		struct nexus *nexusP = 0;
 		volatile int tmp;
 
-		nexusP = (struct nexus *)vax_map_physmem(nexbase +
+		nexusP = (struct nexus *)vax_map_physmem(sa.sa_base +
 		    sizeof(struct nexus) * nexnum, NEXPAGES);
 		if (badaddr((void *)nexusP, 4)) {
 			vax_unmap_physmem((vaddr_t)nexusP, NEXPAGES);
@@ -130,5 +188,8 @@
 	}
 }
 
-CFATTACH_DECL_NEW(sbi_mainbus, 0,
-    sbi_mainbus_match, sbi_mainbus_attach, NULL, NULL);
+
+CFATTACH_DECL_NEW(sbi_abus, 0,
+                  sbi_abus_match, sbi_abus_attach, NULL, NULL);
+
+#endif

Index: src/sys/arch/vax/vax/ubi.c
diff -u src/sys/arch/vax/vax/ubi.c:1.1 src/sys/arch/vax/vax/ubi.c:1.2
--- src/sys/arch/vax/vax/ubi.c:1.1	Thu Jan 22 18:49:03 2009
+++ src/sys/arch/vax/vax/ubi.c	Thu Jul  1 19:50:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubi.c,v 1.1 2009/01/22 18:49:03 christos Exp $ */
+/*	$NetBSD: ubi.c,v 1.2 2010/07/01 19:50:12 ragge Exp $ */
 /*
  * Copyright (c) 1999 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubi.c,v 1.1 2009/01/22 18:49:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubi.c,v 1.2 2010/07/01 19:50:12 ragge Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -78,6 +78,8 @@
 
 	printf("\n");
 
+        sa.sa_base = NEX730;
+
 #define NEXPAGES (sizeof(struct nexus) / VAX_NBPG)
 
 #if 0

Reply via email to