1 /* $NetBSD: leds.c,v 1.7 2008/04/28 20:23:39 martin Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gordon W. Ross and der Mouse.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Functions to flash the LEDs with some pattern.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: leds.c,v 1.7 2008/04/28 20:23:39 martin Exp $");
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
44 #include <sys/malloc.h>
47 #include <machine/cpu.h>
48 #include <machine/sid.h>
49 #include <machine/leds.h>
51 #include "opt_cputype.h"
53 static volatile u_short
*diagreg
= 0;
54 static u_char led_countdown
= 0;
55 static u_char led_px
= 0;
58 * Initial value is the default pattern set.
60 struct led_patterns ledpat
= {
64 0x03, 0x06, 0x0c, 0x18,
65 0x30, 0x60, 0xc0, 0x60,
66 0x30, 0x18, 0x0c, 0x06,
73 switch (vax_boardtype
) {
76 extern struct vs_cpu
*ka46_cpu
;
77 diagreg
= (volatile u_short
*)(&ka46_cpu
->vc_diagdsp
);
83 extern struct vs_cpu
*ka48_cpu
;
84 diagreg
= (volatile u_short
*)(&ka48_cpu
->vc_diagdsp
);
90 diagreg
= (volatile u_short
*)vax_map_physmem(0x25800000, 1);
98 /* Turn on some lights. */
103 * This is called by the clock interrupt.
118 led_countdown
= ledpat
.divisor
- 1;
121 *diagreg
= ~ledpat
.pat
[i
];
124 if (i
== ledpat
.patlen
)
130 * This is called by mem.c to handle /dev/leds
133 leds_uio(struct uio
*uio
)
136 int off
; /* NOT off_t */
139 off
= uio
->uio_offset
;
140 if ((off
< 0) || (off
> sizeof(ledpat
)))
143 cnt
= min(uio
->uio_resid
, (sizeof(ledpat
) - off
));
145 return (0); /* EOF */
148 va
= (char *)&ledpat
;
150 error
= uiomove(va
, cnt
, uio
);