summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-04-29 17:53:38 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-04-29 17:53:38 +0000
commit00a30e5c13a44b1b983447dcb4eb2e0edc45f659 (patch)
tree3768d7a8a5f1ac77f9d2383748a9040842d13775 /sys
parent1b286df3ed9277fd99eeec31bf110a7a98d330b6 (diff)
machdep.led_blink sysctl for landisk, also move cpu_sysctl() code and related
variables from arch/sh/ to arch/landisk/. ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/landisk/include/cpu.h17
-rw-r--r--sys/arch/landisk/landisk/landiskreg.h8
-rw-r--r--sys/arch/landisk/landisk/machdep.c66
-rw-r--r--sys/arch/sh/include/cpu.h15
-rw-r--r--sys/arch/sh/sh/sh_machdep.c35
5 files changed, 90 insertions, 51 deletions
diff --git a/sys/arch/landisk/include/cpu.h b/sys/arch/landisk/include/cpu.h
index 44d1b43efe8..47e51585e47 100644
--- a/sys/arch/landisk/include/cpu.h
+++ b/sys/arch/landisk/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.1 2006/10/06 21:16:15 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.2 2007/04/29 17:53:37 miod Exp $ */
/* $NetBSD: cpu.h,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
#ifndef _LANDISK_CPU_H_
@@ -8,4 +8,19 @@ void machine_reset(void);
#include <sh/cpu.h>
+/*
+ * CTL_MACHDEP definitions.
+ */
+#define CPU_CONSDEV 1 /* dev_t: console terminal device */
+#define CPU_KBDRESET 2 /* keyboard reset */
+#define CPU_LED_BLINK 3 /* keyboard reset */
+#define CPU_MAXID 4 /* number of valid machdep ids */
+
+#define CTL_MACHDEP_NAMES { \
+ { 0, 0 }, \
+ { "console_device", CTLTYPE_STRUCT }, \
+ { "kbdreset", CTLTYPE_INT }, \
+ { "led_blink", CTLTYPE_INT } \
+}
+
#endif /* _LANDISK_CPU_H_ */
diff --git a/sys/arch/landisk/landisk/landiskreg.h b/sys/arch/landisk/landisk/landiskreg.h
index 67d4fa1bacb..431e0513a5f 100644
--- a/sys/arch/landisk/landisk/landiskreg.h
+++ b/sys/arch/landisk/landisk/landiskreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: landiskreg.h,v 1.3 2007/01/15 22:22:19 martin Exp $ */
+/* $OpenBSD: landiskreg.h,v 1.4 2007/04/29 17:53:37 miod Exp $ */
/* $NetBSD: landiskreg.h,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -30,11 +30,17 @@
#ifndef LANDISKREG_H__
#define LANDISKREG_H__
+#define LANDISK_LEDCTRL 0xb0000001
#define LANDISK_BTNSTAT 0xb0000002
#define LANDISK_PWRMNG 0xb0000003 /* write-only */
#define LANDISK_INTEN 0xb0000005
#define LANDISK_PWRSW_INTCLR 0xb0000006
+#define LED_POWER_VALUE 0x01
+#define LED_ACCESS_VALUE 0x02
+#define LED_POWER_CHANGE 0x04
+#define LED_ACCESS_CHANGE 0x08
+
#define BTN_SELECT_BIT (1 << 0)
#define BTN_COPY_BIT (1 << 1)
#define BTN_REMOVE_BIT (1 << 2)
diff --git a/sys/arch/landisk/landisk/machdep.c b/sys/arch/landisk/landisk/machdep.c
index 5ac4fc0611d..2aa4240280d 100644
--- a/sys/arch/landisk/landisk/machdep.c
+++ b/sys/arch/landisk/landisk/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.10 2007/03/13 19:30:36 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.11 2007/04/29 17:53:37 miod Exp $ */
/* $NetBSD: machdep.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -114,6 +114,10 @@ char machine[] = MACHINE; /* landisk */
__dead void landisk_startup(int, char *);
__dead void main(void);
void cpu_init_kcore_hdr(void);
+void blink_led(void *);
+
+int kbd_reset;
+int led_blink;
extern u_int32_t getramsize(void);
@@ -447,3 +451,63 @@ cpu_init_kcore_hdr()
physseg++;
}
}
+
+int
+cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
+ size_t newlen, struct proc *p)
+{
+ int oldval, ret;
+
+ /* all sysctl names at this level are terminal */
+ if (namelen != 1)
+ return (ENOTDIR); /* overloaded */
+
+ switch (name[0]) {
+ case CPU_CONSDEV: {
+ dev_t consdev;
+ if (cn_tab != NULL)
+ consdev = cn_tab->cn_dev;
+ else
+ consdev = NODEV;
+ return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
+ sizeof consdev));
+ }
+
+ case CPU_KBDRESET:
+ if (securelevel > 0)
+ return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
+ return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
+
+ case CPU_LED_BLINK:
+ oldval = led_blink;
+ ret = sysctl_int(oldp, oldlenp, newp, newlen, &led_blink);
+ if (oldval != led_blink)
+ blink_led(NULL);
+ return (ret);
+
+ default:
+ return (EOPNOTSUPP);
+ }
+ /* NOTREACHED */
+}
+
+void
+blink_led(void *whatever)
+{
+ static struct timeout blink_tmo;
+ u_int8_t ledctrl;
+
+ if (led_blink == 0) {
+ _reg_write_1(LANDISK_LEDCTRL,
+ LED_POWER_CHANGE | LED_POWER_VALUE);
+ return;
+ }
+
+ ledctrl = (u_int8_t)_reg_read_1(LANDISK_LEDCTRL) & LED_POWER_VALUE;
+ ledctrl ^= (LED_POWER_CHANGE | LED_POWER_VALUE);
+ _reg_write_1(LANDISK_LEDCTRL, ledctrl);
+
+ timeout_set(&blink_tmo, blink_led, NULL);
+ timeout_add(&blink_tmo,
+ ((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 3));
+}
diff --git a/sys/arch/sh/include/cpu.h b/sys/arch/sh/include/cpu.h
index 61f0faf3f89..5b3478eed30 100644
--- a/sys/arch/sh/include/cpu.h
+++ b/sys/arch/sh/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.7 2007/03/15 10:22:29 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.8 2007/04/29 17:53:37 miod Exp $ */
/* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */
/*-
@@ -179,19 +179,6 @@ extern int want_resched; /* need_resched() was called */
*/
#include <machine/cputypes.h>
-/*
- * CTL_MACHDEP definitions.
- */
-#define CPU_CONSDEV 1 /* dev_t: console terminal device */
-#define CPU_KBDRESET 2 /* keyboard reset */
-#define CPU_MAXID 3 /* number of valid machdep ids */
-
-#define CTL_MACHDEP_NAMES { \
- { 0, 0 }, \
- { "console_device", CTLTYPE_STRUCT }, \
- { "kbdreset", CTLTYPE_INT }, \
-}
-
#ifdef _KERNEL
void sh_cpu_init(int, int);
void sh_startup(void);
diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c
index 5ca32c9f4a9..f609cf7cb47 100644
--- a/sys/arch/sh/sh/sh_machdep.c
+++ b/sys/arch/sh/sh/sh_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh_machdep.c,v 1.11 2007/03/13 19:30:38 miod Exp $ */
+/* $OpenBSD: sh_machdep.c,v 1.12 2007/04/29 17:53:37 miod Exp $ */
/* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */
/*
@@ -170,8 +170,6 @@ u_int dumpsize; /* pages */
long dumplo; /* blocks */
cpu_kcore_hdr_t cpu_kcore_hdr;
-int kbd_reset;
-
void
sh_cpu_init(int arch, int product)
{
@@ -849,34 +847,3 @@ cpu_reset()
#endif
/* NOTREACHED */
}
-
-int
-cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
- size_t newlen, struct proc *p)
-{
-
- /* all sysctl names at this level are terminal */
- if (namelen != 1)
- return (ENOTDIR); /* overloaded */
-
- switch (name[0]) {
- case CPU_CONSDEV: {
- dev_t consdev;
- if (cn_tab != NULL)
- consdev = cn_tab->cn_dev;
- else
- consdev = NODEV;
- return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
- sizeof consdev));
- }
-
- case CPU_KBDRESET:
- if (securelevel > 0)
- return (sysctl_rdint(oldp, oldlenp, newp, kbd_reset));
- return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset));
-
- default:
- return (EOPNOTSUPP);
- }
- /* NOTREACHED */
-}