summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-07-20 19:15:36 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-07-20 19:15:36 +0000
commit35bce366d067f8f84d3c285916f738301870c524 (patch)
tree6116e7dd8aa0ce67af57ccb109f93389ab5711f8
parent2b3c1d70a2889fa5083418e85d93e2f80d783d02 (diff)
Here cometh the blinkenlichten on VAXens.
Register information from NetBSD (except for KA53), logic from OpenBSD/sparc.
-rw-r--r--etc/etc.vax/sysctl.conf1
-rw-r--r--share/man/man4/man4.vax/Makefile4
-rw-r--r--share/man/man4/man4.vax/led.454
-rw-r--r--sys/arch/vax/conf/GENERIC5
-rw-r--r--sys/arch/vax/conf/files.vax7
-rw-r--r--sys/arch/vax/include/cpu.h6
-rw-r--r--sys/arch/vax/include/nexus.h4
-rw-r--r--sys/arch/vax/vax/autoconf.c8
-rw-r--r--sys/arch/vax/vax/led.c218
-rw-r--r--sys/arch/vax/vax/machdep.c24
10 files changed, 321 insertions, 10 deletions
diff --git a/etc/etc.vax/sysctl.conf b/etc/etc.vax/sysctl.conf
index c9f4a049d1d..5cbb790b062 100644
--- a/etc/etc.vax/sysctl.conf
+++ b/etc/etc.vax/sysctl.conf
@@ -1 +1,2 @@
+#machdep.led_blink=1 # display a moving pattern on the machine leds
#kern.emul.ultrix=1 # enable running Ultrix binaries
diff --git a/share/man/man4/man4.vax/Makefile b/share/man/man4/man4.vax/Makefile
index 4a665e0ee0d..e41f1e4a264 100644
--- a/share/man/man4/man4.vax/Makefile
+++ b/share/man/man4/man4.vax/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.19 2003/03/06 22:57:29 jason Exp $
+# $OpenBSD: Makefile,v 1.20 2006/07/20 19:15:34 miod Exp $
# $NetBSD: Makefile,v 1.6 1996/03/03 17:13:09 thorpej Exp $
# from: @(#)Makefile 5.4 (Berkeley) 5/11/90
@@ -7,7 +7,7 @@
# ec.4 en.4 ex.4 fl.4 hdh.4 hk.4 ht.4 hy.4 ik.4 il.4 ix.4 kg.4 lp.4 np.4
# pcl.4 ps.4 tm.4 tmscp.4 tu.4 up.4 ut.4 uu.4 va.4 vp.4 vv.4
MAN= asc.4 autoconf.4 cons.4 de.4 dhu.4 dz.4 hp.4 ibus.4 intro.4 \
- le.4 lkkbd.4 lkms.4 mem.4 mscpbus.4 mt.4 mtc.4 ncr.4 \
+ le.4 led.4 lkkbd.4 lkms.4 mem.4 mscpbus.4 mt.4 mtc.4 ncr.4 \
qe.4 ra.4 rx.4 smg.4 ts.4 uba.4 uda.4 vsbus.4 ze.4
MLINKS= mem.4 kmem.4
MANSUBDIR=vax
diff --git a/share/man/man4/man4.vax/led.4 b/share/man/man4/man4.vax/led.4
new file mode 100644
index 00000000000..7eee6ef3f8a
--- /dev/null
+++ b/share/man/man4/man4.vax/led.4
@@ -0,0 +1,54 @@
+.\" $OpenBSD: led.4,v 1.1 2006/07/20 19:15:34 miod Exp $
+.\"
+.\" Copyright (c) 2001 Jason L. Wright (jason@thought.net)
+.\" 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.
+.\"
+.Dd July 20, 2006
+.Dt LED 4 vax
+.Os
+.Sh NAME
+.Nm led
+.Nd VAX LED driver
+.Sh SYNOPSIS
+.Cd led0 at mainbus0
+.Sh DESCRIPTION
+The
+.Nm
+driver provides an indicator of load average based on blinking of the
+LEDs on some systems.
+The pattern takes one second per whole number of load average to repeat.
+The LED must be explicitly enabled with the
+.Xr sysctl 3
+variable
+.Nm machdep.led_blink .
+.Sh SEE ALSO
+.Xr sysctl 3 ,
+.Xr intro 4 ,
+.Xr sysctl 8
+.Sh HISTORY
+.Ox
+support for the
+.Nm
+first appeared in
+.Ox 4.0 .
diff --git a/sys/arch/vax/conf/GENERIC b/sys/arch/vax/conf/GENERIC
index 49464e6d1cd..0d4c9c45f9e 100644
--- a/sys/arch/vax/conf/GENERIC
+++ b/sys/arch/vax/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.40 2005/08/03 02:10:44 dlg Exp $
+# $OpenBSD: GENERIC,v 1.41 2006/07/20 19:15:34 miod Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -152,3 +152,6 @@ lkkbd0 at dz0 line 0
wskbd* at lkkbd?
lkms0 at dz0 line 1
wsmouse* at lkms?
+
+# Machine leds
+led0 at mainbus0
diff --git a/sys/arch/vax/conf/files.vax b/sys/arch/vax/conf/files.vax
index c576ee925a3..b1f8018807f 100644
--- a/sys/arch/vax/conf/files.vax
+++ b/sys/arch/vax/conf/files.vax
@@ -1,4 +1,4 @@
-# $OpenBSD: files.vax,v 1.34 2006/06/19 15:13:35 deraadt Exp $
+# $OpenBSD: files.vax,v 1.35 2006/07/20 19:15:34 miod Exp $
# $NetBSD: files.vax,v 1.60 1999/08/27 20:04:32 ragge Exp $
#
# new style config file for vax architecture
@@ -307,6 +307,11 @@ device dh # XXX?
attach dh at uba
file arch/vax/uba/dh.c dh needs-flag
+# Blinkenlichten
+device led
+attach led at mainbus
+file arch/vax/vax/led.c led needs-flag
+
# These are general files needed for compilation.
file dev/cninit.c
file arch/vax/vax/locore.c
diff --git a/sys/arch/vax/include/cpu.h b/sys/arch/vax/include/cpu.h
index 8e2cee19909..28355727005 100644
--- a/sys/arch/vax/include/cpu.h
+++ b/sys/arch/vax/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.19 2006/01/04 15:41:29 martin Exp $ */
+/* $OpenBSD: cpu.h,v 1.20 2006/07/20 19:15:34 miod Exp $ */
/* $NetBSD: cpu.h,v 1.41 1999/10/21 20:01:36 ragge Exp $ */
/*
@@ -140,11 +140,13 @@ int kdbrint(int);
* CTL_MACHDEP definitions.
*/
#define CPU_CONSDEV 1 /* dev_t: console terminal device */
-#define CPU_MAXID 2 /* number of valid machdep ids */
+#define CPU_LED_BLINK 2 /* int: display led patterns */
+#define CPU_MAXID 3 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
{ "console_device", CTLTYPE_STRUCT }, \
+ { "led_blink", CTLTYPE_INT } \
}
#endif /* _VAX_CPU_H_ */
diff --git a/sys/arch/vax/include/nexus.h b/sys/arch/vax/include/nexus.h
index 0ecb9609b7c..62fddaa2e72 100644
--- a/sys/arch/vax/include/nexus.h
+++ b/sys/arch/vax/include/nexus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nexus.h,v 1.11 2006/07/20 19:08:14 miod Exp $ */
+/* $OpenBSD: nexus.h,v 1.12 2006/07/20 19:15:34 miod Exp $ */
/* $NetBSD: nexus.h,v 1.17 2000/06/04 17:58:19 ragge Exp $ */
/*-
@@ -54,6 +54,8 @@ struct mainbus_attach_args {
#define VAX_IBUS 8 /* Internal Microvax bus */
#define VAX_XMIBUS 9 /* XMI master bus (6000) */
+#define VAX_LEDS 0x42 /* pseudo value to attach led0 */
+
/*
* Information about nexus's.
*
diff --git a/sys/arch/vax/vax/autoconf.c b/sys/arch/vax/vax/autoconf.c
index ea9d81d05f2..461efa06320 100644
--- a/sys/arch/vax/vax/autoconf.c
+++ b/sys/arch/vax/vax/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.21 2006/07/20 19:08:15 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.22 2006/07/20 19:15:35 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.45 1999/10/23 14:56:05 ragge Exp $ */
/*
@@ -52,6 +52,7 @@
#include <machine/clock.h>
#include <machine/rpb.h>
+#include "led.h"
#include <vax/vax/gencons.h>
@@ -135,6 +136,11 @@ mainbus_attach(parent, self, hej)
if (dep_call->cpu_subconf)
(*dep_call->cpu_subconf)(self);
+#if NLED > 0
+ maa.maa_bustype = VAX_LEDS;
+ config_found(self, &maa, mainbus_print);
+#endif
+
#if 1 /* boot blocks too old */
if (rpb.rpb_base == (void *)-1)
printf("\nWARNING: you must update your boot blocks.\n\n");
diff --git a/sys/arch/vax/vax/led.c b/sys/arch/vax/vax/led.c
new file mode 100644
index 00000000000..cf9e3028ed5
--- /dev/null
+++ b/sys/arch/vax/vax/led.c
@@ -0,0 +1,218 @@
+/* $OpenBSD: led.c,v 1.1 2006/07/20 19:15:35 miod Exp $ */
+/* $NetBSD: leds.c,v 1.4 2005/12/11 12:19:37 christos Exp $ */
+
+/*
+ * Copyright (c) 1998 Jason L. Wright (jason@thought.net)
+ * 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.
+ */
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Gordon W. Ross and der Mouse.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Functions to flash the LEDs with some pattern.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/timeout.h>
+
+#include <machine/cpu.h>
+#include <machine/nexus.h>
+#include <machine/sid.h>
+
+struct led_softc {
+ struct device sc_dev;
+ struct timeout sc_tmo;
+ volatile u_short *sc_reg;
+ const u_int8_t *sc_pat, *sc_patpos;
+};
+
+/*
+ * Patterns for 8 and 4 led displays.
+ */
+static const u_int8_t led_pattern8[] = {
+ 0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f,
+ 0xff, 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe, 0x00
+};
+static const u_int8_t led_pattern4[] = {
+ 0x0f, 0x0e, 0x0d, 0x0b, 0x07,
+ 0x0f, 0x07, 0x0b, 0x0d, 0x0e, 0x00
+};
+
+int ledmatch(struct device *, void *, void *);
+void ledattach(struct device *, struct device *, void *);
+void led_blink(void *);
+
+struct cfattach led_ca = {
+ sizeof(struct led_softc), ledmatch, ledattach
+};
+
+struct cfdriver led_cd = {
+ NULL, "led", DV_DULL
+};
+
+int
+ledmatch(struct device *parent, void *cf, void *aux)
+{
+ struct mainbus_attach_args *maa = aux;
+
+ if (maa->maa_bustype != VAX_LEDS)
+ return (0);
+
+ switch (vax_boardtype) {
+#if VAX46 || VAX48 || VAX49 || VAX53
+#if VAX46
+ case VAX_BTYP_46:
+#endif
+#if VAX48
+ case VAX_BTYP_48:
+#endif
+#if VAX49
+ case VAX_BTYP_49:
+#endif
+#if VAX53
+ case VAX_BTYP_1303:
+#endif
+ return (1);
+#endif
+ default:
+ return (0);
+ }
+}
+
+void
+ledattach(struct device *parent, struct device *self, void *aux)
+{
+ struct led_softc *sc = (void *)self;
+#if VAX49 || VAX53
+ vaddr_t pgva;
+#endif
+
+ printf("\n");
+
+ switch (vax_boardtype) {
+#if VAX46
+ case VAX_BTYP_46:
+ {
+ extern struct vs_cpu *ka46_cpu;
+ sc->sc_reg = (volatile u_short *)(&ka46_cpu->vc_diagdsp);
+ sc->sc_pat = led_pattern8;
+ }
+ break;
+#endif
+#if VAX48
+ case VAX_BTYP_48:
+ {
+ extern struct vs_cpu *ka48_cpu;
+ sc->sc_reg = (volatile u_short *)(&ka48_cpu->vc_diagdsp);
+ sc->sc_pat = led_pattern8;
+ }
+ break;
+#endif
+#if VAX49
+ case VAX_BTYP_49:
+ pgva = vax_map_physmem(0x25800000, 1);
+ sc->sc_reg = (volatile u_short *)(pgva + 4);
+ sc->sc_pat = led_pattern8;
+ break;
+#endif
+#if VAX53
+ case VAX_BTYP_1303:
+ pgva = vax_map_physmem(0x20140000, 1);
+ sc->sc_reg = (volatile u_short *)(pgva + 0x30);
+ sc->sc_pat = led_pattern4;
+ break;
+#endif
+ }
+
+ sc->sc_patpos = sc->sc_pat;
+ timeout_set(&sc->sc_tmo, led_blink, sc);
+ led_blink(sc);
+}
+
+/*
+ * This is called by the clock interrupt.
+ */
+void
+led_blink(void *v)
+{
+ struct led_softc *sc = v;
+ extern int vax_led_blink;
+
+ if (sc == NULL) {
+ /* find our softc if we come from cpu_sysctl */
+ if (led_cd.cd_ndevs != 0)
+ sc = (struct led_softc *)led_cd.cd_devs[0];
+ if (sc == NULL)
+ return;
+ }
+
+ if (vax_led_blink == 0) {
+ *sc->sc_reg = 0xff;
+ return;
+ }
+
+ *sc->sc_reg = ~*sc->sc_patpos++;
+ if (*sc->sc_patpos == 0)
+ sc->sc_patpos = sc->sc_pat;
+
+ timeout_add(&sc->sc_tmo,
+ (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 3)));
+}
diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c
index 1ae3f85ec82..5116593d07c 100644
--- a/sys/arch/vax/vax/machdep.c
+++ b/sys/arch/vax/vax/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.83 2006/07/19 20:41:34 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.84 2006/07/20 19:15:35 miod Exp $ */
/* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */
/*
@@ -115,7 +115,7 @@
#endif
#include <vax/vax/db_disasm.h>
-#include "smg.h"
+#include "led.h"
caddr_t allocsys(caddr_t);
@@ -163,6 +163,11 @@ struct vm_map *phys_map = NULL;
int iospace_inited = 0;
#endif
+/* sysctl settable */
+#if NLED > 0
+int vax_led_blink = 0;
+#endif
+
void cpu_dumpconf(void);
void
@@ -342,6 +347,9 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
+#if NLED > 0
+ int oldval, ret;
+#endif
dev_t consdev;
/* all sysctl names at this level are terminal */
@@ -356,6 +364,18 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
consdev = NODEV;
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
sizeof consdev));
+ case CPU_LED_BLINK:
+#if NLED > 0
+ oldval = vax_led_blink;
+ ret = sysctl_int(oldp, oldlenp, newp, newlen, &vax_led_blink);
+ if (oldval != vax_led_blink) {
+ extern void led_blink(void *);
+ led_blink(NULL);
+ }
+ return (ret);
+#else
+ return (EOPNOTSUPP);
+#endif
default:
return (EOPNOTSUPP);
}