diff options
author | kstailey <kstailey@cvs.openbsd.org> | 1997-01-13 00:29:29 +0000 |
---|---|---|
committer | kstailey <kstailey@cvs.openbsd.org> | 1997-01-13 00:29:29 +0000 |
commit | 4ee7d65d63fd7c44c12e5fd045fde86b7ca648ef (patch) | |
tree | c4d333c0348e4eb1a5acc266988517619c2ce48c /sys | |
parent | aa1d7761d73e912c4a251a0b59620889e8f157c7 (diff) |
back-panel LED control device derived from code by der Mouse
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sun3/conf/files.sun3 | 2 | ||||
-rw-r--r-- | sys/arch/sun3/sun3/clock.c | 22 | ||||
-rw-r--r-- | sys/arch/sun3/sun3/leds.c | 59 | ||||
-rw-r--r-- | sys/arch/sun3/sun3/ledsvar.h | 7 | ||||
-rw-r--r-- | sys/arch/sun3/sun3/mem.c | 5 |
5 files changed, 86 insertions, 9 deletions
diff --git a/sys/arch/sun3/conf/files.sun3 b/sys/arch/sun3/conf/files.sun3 index 6556ae46e84..e57043dd152 100644 --- a/sys/arch/sun3/conf/files.sun3 +++ b/sys/arch/sun3/conf/files.sun3 @@ -1,3 +1,4 @@ +# $OpenBSD: files.sun3,v 1.9 1997/01/13 00:29:26 kstailey Exp $ # $NetBSD: files.sun3,v 1.26 1996/10/29 19:58:14 gwr Exp $ # @@ -22,6 +23,7 @@ file arch/sun3/sun3/disksubr.c file arch/sun3/sun3/fpu.c file arch/sun3/sun3/isr.c file arch/sun3/sun3/kgdb_stub.c kgdb +file arch/sun3/sun3/leds.c file arch/sun3/sun3/machdep.c file arch/sun3/sun3/mem.c file arch/sun3/sun3/pmap.c diff --git a/sys/arch/sun3/sun3/clock.c b/sys/arch/sun3/sun3/clock.c index 6517f3bf051..0e06fb0b7b7 100644 --- a/sys/arch/sun3/sun3/clock.c +++ b/sys/arch/sun3/sun3/clock.c @@ -1,3 +1,4 @@ +/* $OpenBSD: clock.c,v 1.6 1997/01/13 00:29:23 kstailey Exp $ */ /* $NetBSD: clock.c,v 1.31 1996/10/30 00:24:42 gwr Exp $ */ /* @@ -64,6 +65,7 @@ #include "intersil7170.h" #include "interreg.h" +#include "ledsvar.h" #define CLOCK_PRI 5 @@ -255,11 +257,10 @@ setstatclockrate(newhz) * This is is called by the "custom" interrupt handler * after it has reset the pending bit in the clock. */ -int clock_count = 0; void clock_intr(frame) struct clockframe *frame; { - static unsigned char led_pattern = 0xFE; + unsigned int i; #ifdef DIAGNOSTIC if (!clk_intr_ready) @@ -267,13 +268,16 @@ void clock_intr(frame) #endif /* XXX - Move this LED frobbing to the idle loop? */ - clock_count++; - if ((clock_count & 7) == 0) { - led_pattern = (led_pattern << 1) | 1; - if (led_pattern == 0xFF) - led_pattern = 0xFE; - set_control_byte((char *) DIAG_REG, led_pattern); - } + i = led_countdown; + if (i == 0) { + led_countdown = led_countmax; + i = led_px; + set_control_byte((char *) DIAG_REG, led_patterns[i]); + if (i == 0) + i = led_n_patterns; + led_px = i - 1; + } else + led_countdown = i - 1; hardclock(frame); } diff --git a/sys/arch/sun3/sun3/leds.c b/sys/arch/sun3/sun3/leds.c new file mode 100644 index 00000000000..41136e0f52a --- /dev/null +++ b/sys/arch/sun3/sun3/leds.c @@ -0,0 +1,59 @@ +/* $OpenBSD: leds.c,v 1.1 1997/01/13 00:29:24 kstailey Exp $ */ + +#include <sys/types.h> +#include <sys/uio.h> +#include <sys/systm.h> +#include <sys/errno.h> +#include <machine/psl.h> + +#include "leds-extern.h" + +#define MAXPVLEN 10240 +#define MAXCDOWN 128 + +static volatile unsigned char pattern[MAXPVLEN] = + { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f + }; + +volatile unsigned int led_n_patterns = 16; +volatile const unsigned char * volatile led_patterns = &pattern[0]; +volatile unsigned int led_countmax = 5; +volatile unsigned int led_countdown = 0; +volatile unsigned int led_px = 0; + +int ledrw(struct uio *uio) +{ + unsigned int v[2]; + int s; + unsigned int o; + int err; + + if (uio->uio_offset > MAXPVLEN+sizeof(v)) return(0); + s = splhigh(); + v[0] = led_countmax; + v[1] = led_n_patterns; + splx(s); + o = uio->uio_offset; + if (o < sizeof(v)) + { err = uiomove(((caddr_t)&v[0])+o,sizeof(v)-o,uio); + if (err) return(err); + o = sizeof(v); + if (uio->uio_rw == UIO_WRITE) + { if ((v[0] > MAXCDOWN) || (v[1] < 1) || (v[1] > MAXPVLEN)) return(EIO); + s = splhigh(); + led_countmax = v[0]; + led_n_patterns = v[1]; + led_countdown = 0; + led_px = 0; + splx(s); + } + } + o -= sizeof(v); + if (o >= v[1]) return(0); + if (uio->uio_resid > 0) + { err = uiomove((caddr_t)&pattern[o],v[1]-o,uio); + if (err) return(err); + } + return(0); +} diff --git a/sys/arch/sun3/sun3/ledsvar.h b/sys/arch/sun3/sun3/ledsvar.h new file mode 100644 index 00000000000..4a96c435567 --- /dev/null +++ b/sys/arch/sun3/sun3/ledsvar.h @@ -0,0 +1,7 @@ +/* $OpenBSD: ledsvar.h,v 1.1 1997/01/13 00:29:25 kstailey Exp $ */ + +extern volatile unsigned int led_n_patterns; +extern volatile unsigned int led_countmax; +extern volatile const unsigned char * volatile led_patterns; +extern volatile unsigned int led_countdown; +extern volatile unsigned int led_px; diff --git a/sys/arch/sun3/sun3/mem.c b/sys/arch/sun3/sun3/mem.c index ab82bf26877..9469d1316c9 100644 --- a/sys/arch/sun3/sun3/mem.c +++ b/sys/arch/sun3/sun3/mem.c @@ -217,6 +217,11 @@ mmrw(dev, uio, flags) error = uiomove(zeropage, c, uio); continue; +/* minor device 13 (/dev/leds) accesses the blinkenlights */ + case 13: + error = ledrw(uio); + return(error); + default: return (ENXIO); } |