sysmon_envsys_tables.c revision 1.1.6.2 1 /* $NetBSD: sysmon_envsys_tables.c,v 1.1.6.2 2007/10/02 18:28:41 joerg Exp $ */
2
3 /*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Juan Romero Pardines.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by Juan Romero Pardines
21 * for the NetBSD Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.1.6.2 2007/10/02 18:28:41 joerg Exp $");
41
42 #include <sys/types.h>
43
44 #include <dev/sysmon/sysmonvar.h>
45 #include <dev/sysmon/sysmon_envsysvar.h>
46
47 /*
48 * Available units type descriptions.
49 */
50 static const struct sme_description_table sme_units_description[] = {
51 { ENVSYS_STEMP, PENVSYS_TYPE_TEMP, "Temperature" },
52 { ENVSYS_SFANRPM, PENVSYS_TYPE_FAN, "Fan" },
53 { ENVSYS_SVOLTS_AC, PENVSYS_TYPE_VOLTAGE, "Voltage AC" },
54 { ENVSYS_SVOLTS_DC, PENVSYS_TYPE_VOLTAGE, "Voltage DC" },
55 { ENVSYS_SOHMS, PENVSYS_TYPE_RESISTANCE,"Ohms" },
56 { ENVSYS_SWATTS, PENVSYS_TYPE_POWER, "Watts" },
57 { ENVSYS_SAMPS, PENVSYS_TYPE_POWER, "Ampere" },
58 { ENVSYS_SWATTHOUR, PENVSYS_TYPE_BATTERY, "Watt hour" },
59 { ENVSYS_SAMPHOUR, PENVSYS_TYPE_BATTERY, "Ampere hour" },
60 { ENVSYS_INDICATOR, PENVSYS_TYPE_INDICATOR, "Indicator" },
61 { ENVSYS_INTEGER, PENVSYS_TYPE_INDICATOR, "Integer" },
62 { ENVSYS_DRIVE, PENVSYS_TYPE_DRIVE, "Drive" },
63 { ENVSYS_BATTERY_STATE, PENVSYS_TYPE_BATTERY, "Battery state" },
64 { -1, -1, "unknown" }
65 };
66
67 /*
68 * Available sensor state descriptions.
69 */
70 static const struct sme_description_table sme_state_description[] = {
71 { ENVSYS_SVALID, -1, "valid" },
72 { ENVSYS_SINVALID, -1, "invalid" },
73 { ENVSYS_SCRITICAL, -1, "critical" },
74 { ENVSYS_SCRITUNDER, -1, "critical-under" },
75 { ENVSYS_SCRITOVER, -1, "critical-over" },
76 { ENVSYS_SWARNUNDER, -1, "warning-under" },
77 { ENVSYS_SWARNOVER, -1, "warning-over" },
78 { -1, -1, "unknown" }
79 };
80
81 /*
82 * Available drive state descriptions.
83 */
84 static const struct sme_description_table sme_drivestate_description[] = {
85 { ENVSYS_DRIVE_EMPTY, -1, "drive state is unknown" },
86 { ENVSYS_DRIVE_READY, -1, "drive is ready" },
87 { ENVSYS_DRIVE_POWERUP, -1, "drive is powering up" },
88 { ENVSYS_DRIVE_ONLINE, -1, "drive is online" },
89 { ENVSYS_DRIVE_IDLE, -1, "drive is idle" },
90 { ENVSYS_DRIVE_ACTIVE, -1, "drive is active" },
91 { ENVSYS_DRIVE_REBUILD, -1, "drive is rebuilding" },
92 { ENVSYS_DRIVE_POWERDOWN, -1, "drive is powering down" },
93 { ENVSYS_DRIVE_FAIL, -1, "drive failed" },
94 { ENVSYS_DRIVE_PFAIL, -1, "drive degraded" },
95 { -1, -1, "unknown" }
96 };
97
98 /*
99 * Available battery state descriptions.
100 */
101 static const struct sme_description_table sme_batterystate_description[] = {
102 { ENVSYS_BATTERY_STATE_NORMAL, -1, "NORMAL" },
103 { ENVSYS_BATTERY_STATE_WARNING, -1, "WARNING" },
104 { ENVSYS_BATTERY_STATE_CRITICAL, -1, "CRITICAL" },
105 { ENVSYS_BATTERY_STATE_LOW, -1, "LOW" },
106 { -1, -1, "UNKNOWN" }
107 };
108
109 /*
110 * Returns the table associated with type.
111 */
112 const struct sme_description_table *
113 sme_get_description_table(int type)
114 {
115 const struct sme_description_table *ud = sme_units_description;
116 const struct sme_description_table *sd = sme_state_description;
117 const struct sme_description_table *dd = sme_drivestate_description;
118 const struct sme_description_table *bd = sme_batterystate_description;
119
120 switch (type) {
121 case SME_DESC_UNITS:
122 return ud;
123 case SME_DESC_STATES:
124 return sd;
125 case SME_DESC_DRIVE_STATES:
126 return dd;
127 case SME_DESC_BATTERY_STATES:
128 return bd;
129 default:
130 return NULL;
131 }
132 }
133