Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Make fault LED and alarms status changeable via sysctl(8).
details: https://anonhg.NetBSD.org/src/rev/a69e3f5b0794
branches: trunk
changeset: 750367:a69e3f5b0794
user: nakayama <nakayama%NetBSD.org@localhost>
date: Mon Dec 28 18:25:44 2009 +0000
description:
Make fault LED and alarms status changeable via sysctl(8).
The sysctl entries are created under the hw.lomN MIB.
diffstat:
share/man/man4/man4.sparc64/lom.4 | 14 ++++-
sys/arch/sparc64/dev/lom.c | 95 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 105 insertions(+), 4 deletions(-)
diffs (197 lines):
diff -r 2189268d9d4c -r a69e3f5b0794 share/man/man4/man4.sparc64/lom.4
--- a/share/man/man4/man4.sparc64/lom.4 Mon Dec 28 15:13:57 2009 +0000
+++ b/share/man/man4/man4.sparc64/lom.4 Mon Dec 28 18:25:44 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: lom.4,v 1.3 2009/11/28 04:14:27 nakayama Exp $
+.\" $NetBSD: lom.4,v 1.4 2009/12/28 18:25:44 nakayama Exp $
.\" $OpenBSD: lom.4,v 1.4 2009/09/23 22:08:07 kettenis Exp $
.\"
.\" Copyright (c) 2009 Mark Kettenis <kettenis%openbsd.org@localhost>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd November 28, 2009
+.Dd December 28, 2009
.Dt LOM 4 sparc64
.Os
.Sh NAME
@@ -38,6 +38,15 @@
interface.
The watchdog timer supports timeouts between 1 and 126 seconds.
.Pp
+Fault LED and alarms status can be changed through the
+.Xr sysctl 8
+interface.
+An entry for the
+.Nm
+driver is created under the
+.Va hw.lom Ns Em N
+MIB.
+.Pp
The
.Nm
driver will update the hostname stored in the LOM whenever the
@@ -46,6 +55,7 @@
.Xr hostname 1 ,
.Xr envsys 4 ,
.Xr envstat 8 ,
+.Xr sysctl 8 ,
.Xr wdogctl 8
.Sh HISTORY
The
diff -r 2189268d9d4c -r a69e3f5b0794 sys/arch/sparc64/dev/lom.c
--- a/sys/arch/sparc64/dev/lom.c Mon Dec 28 15:13:57 2009 +0000
+++ b/sys/arch/sparc64/dev/lom.c Mon Dec 28 18:25:44 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lom.c,v 1.4 2009/12/13 05:21:06 nakayama Exp $ */
+/* $NetBSD: lom.c,v 1.5 2009/12/28 18:25:44 nakayama Exp $ */
/* $OpenBSD: lom.c,v 1.20 2009/12/12 13:01:00 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.4 2009/12/13 05:21:06 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.5 2009/12/28 18:25:44 nakayama Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -26,6 +26,7 @@
#include <sys/envsys.h>
#include <sys/systm.h>
#include <sys/callout.h>
+#include <sys/sysctl.h>
#include <machine/autoconf.h>
@@ -168,6 +169,8 @@
int sc_num_psu;
int sc_num_temp;
+ int32_t sc_sysctl_num[LOM_MAX_ALARM];
+
uint8_t sc_fan_cal[LOM_MAX_FAN];
uint8_t sc_fan_low[LOM_MAX_FAN];
@@ -222,6 +225,17 @@
static bool lom_shutdown(device_t, int);
+SYSCTL_SETUP_PROTO(sysctl_lom_setup);
+static int lom_sysctl_alarm(SYSCTLFN_PROTO);
+
+static int hw_node = CTL_EOL;
+static const char *nodename[LOM_MAX_ALARM] =
+ { "fault_led", "alarm1", "alarm2", "alarm3" };
+#ifdef SYSCTL_INCLUDE_DESCR
+static const char *nodedesc[LOM_MAX_ALARM] =
+ { "Fault LED status", "Alarm1 status", "Alarm2 status ", "Alarm3 status" };
+#endif
+
static int
lom_match(device_t parent, cfdata_t match, void *aux)
{
@@ -242,6 +256,7 @@
uint8_t reg, fw_rev, config, config2, config3;
uint8_t cal, low;
int i;
+ const struct sysctlnode *node = NULL, *newnode;
if (strcmp(ea->ea_name, "SUNW,lomh") == 0) {
if (ea->ea_nintr < 1) {
@@ -315,6 +330,12 @@
sc->sc_fan_low[i] = low;
}
+ /* Setup our sysctl subtree, hw.lomN */
+ if (hw_node != CTL_EOL)
+ sysctl_createv(NULL, 0, NULL, &node,
+ 0, CTLTYPE_NODE, device_xname(self), NULL,
+ NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
/* Initialize sensor data. */
sc->sc_sme = sysmon_envsys_create();
for (i = 0; i < sc->sc_num_alarm; i++) {
@@ -326,6 +347,17 @@
aprint_error_dev(self, "can't attach alarm sensor\n");
return;
}
+ if (node != NULL) {
+ sysctl_createv(NULL, 0, NULL, &newnode,
+ CTLFLAG_READWRITE, CTLTYPE_INT, nodename[i],
+ SYSCTL_DESCR(nodedesc[i]),
+ lom_sysctl_alarm, 0, sc, 0,
+ CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+ if (newnode != NULL)
+ sc->sc_sysctl_num[i] = newnode->sysctl_num;
+ else
+ sc->sc_sysctl_num[i] = 0;
+ }
}
for (i = 0; i < sc->sc_num_fan; i++) {
sc->sc_fan[i].units = ENVSYS_SFANRPM;
@@ -1084,3 +1116,62 @@
lom_write(sc, LOM_IDX_WDOG_CTL, sc->sc_wdog_ctl);
return true;
}
+
+SYSCTL_SETUP(sysctl_lom_setup, "sysctl hw.lom subtree setup")
+{
+ const struct sysctlnode *node;
+
+ if (sysctl_createv(clog, 0, NULL, &node,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL,
+ NULL, 0, NULL, 0, CTL_HW, CTL_EOL) != 0)
+ return;
+
+ hw_node = node->sysctl_num;
+}
+
+static int
+lom_sysctl_alarm(SYSCTLFN_ARGS)
+{
+ struct sysctlnode node;
+ struct lom_softc *sc;
+ int i, tmp, error;
+ uint8_t val;
+
+ node = *rnode;
+ sc = node.sysctl_data;
+
+ for (i = 0; i < sc->sc_num_alarm; i++) {
+ if (node.sysctl_num == sc->sc_sysctl_num[i]) {
+ tmp = sc->sc_alarm[i].value_cur;
+ node.sysctl_data = &tmp;
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error || newp == NULL)
+ return error;
+ if (tmp < 0 || tmp > 1)
+ return EINVAL;
+
+ if (lom_read(sc, LOM_IDX_ALARM, &val))
+ return EINVAL;
+ if (i == 0) {
+ /* Fault LED */
+ if (tmp != 0)
+ val &= ~LOM_ALARM_FAULT;
+ else
+ val |= LOM_ALARM_FAULT;
+ } else {
+ /* Alarms */
+ if (tmp != 0)
+ val |= LOM_ALARM_1 << (i - 1);
+ else
+ val &= ~(LOM_ALARM_1 << (i - 1));
+ }
+ if (lom_write(sc, LOM_IDX_ALARM, val))
+ return EINVAL;
+
+ sc->sc_alarm[i].value_cur = tmp;
+ return 0;
+ }
+ }
+
+ return ENOENT;
+}
Home |
Main Index |
Thread Index |
Old Index