summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-08-25 08:38:49 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-08-25 08:38:49 +0000
commite7bdaf7b9085ddf893c42d722c9392bac9ed6456 (patch)
tree6d65ca8171f53d0985116560812c71640a34433d
parent1819af27a48172c6658bdb220a4920839ae7c19d (diff)
Implement LED blinking as a run-time configurable option via the sysctl
machdep.led_blink. Rename auxreg.h because we need config to generate one now.
-rw-r--r--sys/arch/sparc/conf/files.sparc4
-rw-r--r--sys/arch/sparc/dev/fd.c4
-rw-r--r--sys/arch/sparc/dev/zs.c4
-rw-r--r--sys/arch/sparc/include/cpu.h8
-rw-r--r--sys/arch/sparc/sparc/auxioreg.h (renamed from sys/arch/sparc/sparc/auxreg.h)1
-rw-r--r--sys/arch/sparc/sparc/auxreg.c34
-rw-r--r--sys/arch/sparc/sparc/bsd_fdintr.s3
-rw-r--r--sys/arch/sparc/sparc/machdep.c27
8 files changed, 65 insertions, 20 deletions
diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc
index 2615ba65760..a2a926edeeb 100644
--- a/sys/arch/sparc/conf/files.sparc
+++ b/sys/arch/sparc/conf/files.sparc
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc,v 1.12 1997/08/08 08:24:35 downsj Exp $
+# $OpenBSD: files.sparc,v 1.13 1997/08/25 08:38:43 downsj Exp $
# $NetBSD: files.sparc,v 1.40 1997/07/07 21:53:43 pk Exp $
# @(#)files.sparc 8.1 (Berkeley) 7/19/93
@@ -30,7 +30,7 @@ file arch/sparc/dev/obio.c obio | vmel | vmes | vme
device auxreg
attach auxreg at mainbus, obio
-file arch/sparc/sparc/auxreg.c
+file arch/sparc/sparc/auxreg.c auxreg needs-count
device clock
attach clock at mainbus, obio
diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c
index 1643db5b031..9597bb47ebc 100644
--- a/sys/arch/sparc/dev/fd.c
+++ b/sys/arch/sparc/dev/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.20 1997/08/08 08:25:06 downsj Exp $ */
+/* $OpenBSD: fd.c,v 1.21 1997/08/25 08:38:44 downsj Exp $ */
/* $NetBSD: fd.c,v 1.51 1997/05/24 20:16:19 pk Exp $ */
/*-
@@ -73,7 +73,7 @@
#include <machine/conf.h>
#include <machine/ioctl_fd.h>
-#include <sparc/sparc/auxreg.h>
+#include <sparc/sparc/auxioreg.h>
#include <sparc/dev/fdreg.h>
#include <sparc/dev/fdvar.h>
diff --git a/sys/arch/sparc/dev/zs.c b/sys/arch/sparc/dev/zs.c
index b9cb8b8eb56..2361c3ea61e 100644
--- a/sys/arch/sparc/dev/zs.c
+++ b/sys/arch/sparc/dev/zs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zs.c,v 1.15 1997/08/08 08:25:43 downsj Exp $ */
+/* $OpenBSD: zs.c,v 1.16 1997/08/25 08:38:45 downsj Exp $ */
/* $NetBSD: zs.c,v 1.48 1997/07/29 09:58:18 fair Exp $ */
/*
@@ -75,7 +75,7 @@
#include <machine/kbd.h>
#include <sparc/sparc/vaddrs.h>
-#include <sparc/sparc/auxreg.h>
+#include <sparc/sparc/auxioreg.h>
#include <dev/ic/z8530reg.h>
#include <sparc/dev/zsvar.h>
diff --git a/sys/arch/sparc/include/cpu.h b/sys/arch/sparc/include/cpu.h
index 7f743246e7a..60e158da345 100644
--- a/sys/arch/sparc/include/cpu.h
+++ b/sys/arch/sparc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.3 1997/08/08 08:26:11 downsj Exp $ */
+/* $OpenBSD: cpu.h,v 1.4 1997/08/25 08:38:45 downsj Exp $ */
/* $NetBSD: cpu.h,v 1.24 1997/03/15 22:25:15 pk Exp $ */
/*
@@ -51,10 +51,12 @@
/*
* CTL_MACHDEP definitions.
*/
-#define CPU_MAXID 1 /* no valid machdep ids */
+#define CPU_LED_BLINK 1 /* int: twiddle the power LED */
+#define CPU_MAXID 2 /* 1 valid machdep ID */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
+ { "led_blink", CTLTYPE_INT }, \
}
#ifdef _KERNEL
@@ -172,6 +174,8 @@ void vmeintr_establish __P((int vec, int level, struct intrhand *));
*/
void intr_fasttrap __P((int level, void (*vec)(void)));
+/* auxreg.c */
+void led_blink __P((void *));
/* disksubr.c */
struct dkbad;
int isbad __P((struct dkbad *bt, int, int, int));
diff --git a/sys/arch/sparc/sparc/auxreg.h b/sys/arch/sparc/sparc/auxioreg.h
index 477028390d6..82dc31b45b4 100644
--- a/sys/arch/sparc/sparc/auxreg.h
+++ b/sys/arch/sparc/sparc/auxioreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: auxioreg.h,v 1.1 1997/08/25 08:38:46 downsj Exp $ */
/* $NetBSD: auxreg.h,v 1.7 1997/05/17 17:52:52 pk Exp $ */
/*
diff --git a/sys/arch/sparc/sparc/auxreg.c b/sys/arch/sparc/sparc/auxreg.c
index 0aa296a7ce6..f783f0bc79a 100644
--- a/sys/arch/sparc/sparc/auxreg.c
+++ b/sys/arch/sparc/sparc/auxreg.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: auxreg.c,v 1.7 1997/08/25 08:38:47 downsj Exp $ */
/* $NetBSD: auxreg.c,v 1.21 1997/05/24 20:15:59 pk Exp $ */
/*
@@ -52,7 +53,7 @@
#include <machine/autoconf.h>
#include <sparc/sparc/vaddrs.h>
-#include <sparc/sparc/auxreg.h>
+#include <sparc/sparc/auxioreg.h>
static int auxregmatch __P((struct device *, void *, void *));
static void auxregattach __P((struct device *, struct device *, void *));
@@ -65,15 +66,27 @@ struct cfdriver auxreg_cd = {
0, "auxreg", DV_DULL
};
-#ifdef BLINK
-static void blink __P((void *zero));
+extern int sparc_led_blink; /* from machdep */
-static void
-blink(zero)
+void
+led_blink(zero)
void *zero;
{
register int s;
+ /* Don't do anything if there's no auxreg, ok? */
+ if (auxio_reg == 0)
+ return;
+
+ if (!sparc_led_blink) {
+ /* If blink has been disabled, make sure it goes back on... */
+ s = splhigh();
+ LED_ON;
+ splx(s);
+
+ return;
+ }
+
s = splhigh();
LED_FLIP;
splx(s);
@@ -85,9 +98,9 @@ blink(zero)
* etc.
*/
s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1));
- timeout(blink, (caddr_t)0, s);
+
+ timeout(led_blink, (caddr_t)0, s);
}
-#endif
/*
* The OPENPROM calls this "auxiliary-io".
@@ -130,9 +143,10 @@ auxregattach(parent, self, aux)
}
printf("\n");
-#ifdef BLINK
- blink((caddr_t)0);
-#endif
+
+ /* In case it's initialized to true... */
+ if (sparc_led_blink)
+ led_blink((caddr_t)0);
}
unsigned int
diff --git a/sys/arch/sparc/sparc/bsd_fdintr.s b/sys/arch/sparc/sparc/bsd_fdintr.s
index e4e92a8e6d2..fca43afc9fc 100644
--- a/sys/arch/sparc/sparc/bsd_fdintr.s
+++ b/sys/arch/sparc/sparc/bsd_fdintr.s
@@ -1,3 +1,4 @@
+/* $OpenBSD: bsd_fdintr.s,v 1.4 1997/08/25 08:38:47 downsj Exp $ */
/* $NetBSD: bsd_fdintr.s,v 1.11 1997/04/07 21:00:36 pk Exp $ */
/*
@@ -36,7 +37,7 @@
#include <machine/param.h>
#include <machine/psl.h>
#include <sparc/sparc/intreg.h>
-#include <sparc/sparc/auxreg.h>
+#include <sparc/sparc/auxioreg.h>
#include <sparc/sparc/vaddrs.h>
#include <sparc/dev/fdreg.h>
#include <sparc/dev/fdvar.h>
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index 02fb423eec4..27d65d8868e 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.27 1997/08/08 08:27:30 downsj Exp $ */
+/* $OpenBSD: machdep.c,v 1.28 1997/08/25 08:38:48 downsj Exp $ */
/* $NetBSD: machdep.c,v 1.83 1997/07/29 10:04:44 fair Exp $ */
/*
@@ -96,6 +96,8 @@
#include "power.h"
#endif
+#include "auxreg.h"
+
vm_map_t buffer_map;
extern vm_offset_t avail_end;
@@ -120,6 +122,9 @@ extern struct msgbuf msgbuf;
struct msgbuf *msgbufp = &msgbuf;
int msgbufmapped = 0; /* not mapped until pmap_bootstrap */
+/* sysctl settable */
+int sparc_led_blink = 0;
+
/*
* safepri is a safe priority for sleep to set for a spin-wait
* during autoconfiguration or after a panic.
@@ -458,12 +463,32 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
+#if NAUXREG > 0
+ int ret, oldval;
+#endif
/* all sysctl names are this level are terminal */
if (namelen != 1)
return (ENOTDIR); /* overloaded */
switch (name[0]) {
+ case CPU_LED_BLINK:
+#if NAUXREG > 0
+ oldval = sparc_led_blink;
+ ret = sysctl_int(oldp, oldlenp, newp, newlen,
+ &sparc_led_blink);
+
+ /*
+ * If we were false and are now true, call led_blink().
+ * led_blink() itself will catch the other case.
+ */
+ if (!oldval && sparc_led_blink > oldval)
+ led_blink((caddr_t *)0);
+
+ return (ret);
+#else
+ return (EOPNOTSUPP);
+#endif
default:
return (EOPNOTSUPP);
}