sysmon_envsys_tables.c revision 1.2.6.3 1 1.2.6.3 yamt /* $NetBSD: sysmon_envsys_tables.c,v 1.2.6.3 2007/11/15 11:44:32 yamt Exp $ */
2 1.2.6.2 yamt
3 1.2.6.2 yamt /*-
4 1.2.6.2 yamt * Copyright (c) 2007 Juan Romero Pardines.
5 1.2.6.2 yamt * All rights reserved.
6 1.2.6.2 yamt *
7 1.2.6.2 yamt * Redistribution and use in source and binary forms, with or without
8 1.2.6.2 yamt * modification, are permitted provided that the following conditions
9 1.2.6.2 yamt * are met:
10 1.2.6.2 yamt * 1. Redistributions of source code must retain the above copyright
11 1.2.6.2 yamt * notice, this list of conditions and the following disclaimer.
12 1.2.6.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.6.2 yamt * notice, this list of conditions and the following disclaimer in the
14 1.2.6.2 yamt * documentation and/or other materials provided with the distribution.
15 1.2.6.2 yamt *
16 1.2.6.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.2.6.2 yamt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.2.6.2 yamt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.2.6.2 yamt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.2.6.2 yamt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.2.6.2 yamt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.2.6.2 yamt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.2.6.2 yamt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.2.6.2 yamt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.2.6.2 yamt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.2.6.2 yamt */
27 1.2.6.2 yamt
28 1.2.6.2 yamt #include <sys/cdefs.h>
29 1.2.6.3 yamt __KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.2.6.3 2007/11/15 11:44:32 yamt Exp $");
30 1.2.6.2 yamt
31 1.2.6.2 yamt #include <sys/types.h>
32 1.2.6.2 yamt
33 1.2.6.2 yamt #include <dev/sysmon/sysmonvar.h>
34 1.2.6.2 yamt #include <dev/sysmon/sysmon_envsysvar.h>
35 1.2.6.2 yamt
36 1.2.6.2 yamt /*
37 1.2.6.2 yamt * Available units type descriptions.
38 1.2.6.2 yamt */
39 1.2.6.2 yamt static const struct sme_description_table sme_units_description[] = {
40 1.2.6.2 yamt { ENVSYS_STEMP, PENVSYS_TYPE_TEMP, "Temperature" },
41 1.2.6.2 yamt { ENVSYS_SFANRPM, PENVSYS_TYPE_FAN, "Fan" },
42 1.2.6.2 yamt { ENVSYS_SVOLTS_AC, PENVSYS_TYPE_VOLTAGE, "Voltage AC" },
43 1.2.6.2 yamt { ENVSYS_SVOLTS_DC, PENVSYS_TYPE_VOLTAGE, "Voltage DC" },
44 1.2.6.2 yamt { ENVSYS_SOHMS, PENVSYS_TYPE_RESISTANCE,"Ohms" },
45 1.2.6.2 yamt { ENVSYS_SWATTS, PENVSYS_TYPE_POWER, "Watts" },
46 1.2.6.2 yamt { ENVSYS_SAMPS, PENVSYS_TYPE_POWER, "Ampere" },
47 1.2.6.2 yamt { ENVSYS_SWATTHOUR, PENVSYS_TYPE_BATTERY, "Watt hour" },
48 1.2.6.2 yamt { ENVSYS_SAMPHOUR, PENVSYS_TYPE_BATTERY, "Ampere hour" },
49 1.2.6.2 yamt { ENVSYS_INDICATOR, PENVSYS_TYPE_INDICATOR, "Indicator" },
50 1.2.6.2 yamt { ENVSYS_INTEGER, PENVSYS_TYPE_INDICATOR, "Integer" },
51 1.2.6.2 yamt { ENVSYS_DRIVE, PENVSYS_TYPE_DRIVE, "Drive" },
52 1.2.6.3 yamt { ENVSYS_BATTERY_CAPACITY, PENVSYS_TYPE_BATTERY,"Battery capacity" },
53 1.2.6.3 yamt { ENVSYS_BATTERY_CHARGE, -1, "Battery charge" },
54 1.2.6.2 yamt { -1, -1, "unknown" }
55 1.2.6.2 yamt };
56 1.2.6.2 yamt
57 1.2.6.2 yamt /*
58 1.2.6.2 yamt * Available sensor state descriptions.
59 1.2.6.2 yamt */
60 1.2.6.2 yamt static const struct sme_description_table sme_state_description[] = {
61 1.2.6.2 yamt { ENVSYS_SVALID, -1, "valid" },
62 1.2.6.2 yamt { ENVSYS_SINVALID, -1, "invalid" },
63 1.2.6.2 yamt { ENVSYS_SCRITICAL, -1, "critical" },
64 1.2.6.2 yamt { ENVSYS_SCRITUNDER, -1, "critical-under" },
65 1.2.6.2 yamt { ENVSYS_SCRITOVER, -1, "critical-over" },
66 1.2.6.2 yamt { ENVSYS_SWARNUNDER, -1, "warning-under" },
67 1.2.6.2 yamt { ENVSYS_SWARNOVER, -1, "warning-over" },
68 1.2.6.2 yamt { -1, -1, "unknown" }
69 1.2.6.2 yamt };
70 1.2.6.2 yamt
71 1.2.6.2 yamt /*
72 1.2.6.2 yamt * Available drive state descriptions.
73 1.2.6.2 yamt */
74 1.2.6.2 yamt static const struct sme_description_table sme_drivestate_description[] = {
75 1.2.6.2 yamt { ENVSYS_DRIVE_EMPTY, -1, "drive state is unknown" },
76 1.2.6.2 yamt { ENVSYS_DRIVE_READY, -1, "drive is ready" },
77 1.2.6.2 yamt { ENVSYS_DRIVE_POWERUP, -1, "drive is powering up" },
78 1.2.6.2 yamt { ENVSYS_DRIVE_ONLINE, -1, "drive is online" },
79 1.2.6.2 yamt { ENVSYS_DRIVE_IDLE, -1, "drive is idle" },
80 1.2.6.2 yamt { ENVSYS_DRIVE_ACTIVE, -1, "drive is active" },
81 1.2.6.2 yamt { ENVSYS_DRIVE_REBUILD, -1, "drive is rebuilding" },
82 1.2.6.2 yamt { ENVSYS_DRIVE_POWERDOWN, -1, "drive is powering down" },
83 1.2.6.2 yamt { ENVSYS_DRIVE_FAIL, -1, "drive failed" },
84 1.2.6.2 yamt { ENVSYS_DRIVE_PFAIL, -1, "drive degraded" },
85 1.2.6.2 yamt { -1, -1, "unknown" }
86 1.2.6.2 yamt };
87 1.2.6.2 yamt
88 1.2.6.2 yamt /*
89 1.2.6.3 yamt * Available battery capacity descriptions.
90 1.2.6.2 yamt */
91 1.2.6.3 yamt static const struct sme_description_table sme_batterycap_description[] = {
92 1.2.6.3 yamt { ENVSYS_BATTERY_CAPACITY_NORMAL, -1, "NORMAL" },
93 1.2.6.3 yamt { ENVSYS_BATTERY_CAPACITY_WARNING, -1, "WARNING" },
94 1.2.6.3 yamt { ENVSYS_BATTERY_CAPACITY_CRITICAL, -1, "CRITICAL" },
95 1.2.6.3 yamt { ENVSYS_BATTERY_CAPACITY_LOW, -1, "LOW" },
96 1.2.6.2 yamt { -1, -1, "UNKNOWN" }
97 1.2.6.2 yamt };
98 1.2.6.2 yamt
99 1.2.6.2 yamt /*
100 1.2.6.2 yamt * Returns the table associated with type.
101 1.2.6.2 yamt */
102 1.2.6.2 yamt const struct sme_description_table *
103 1.2.6.2 yamt sme_get_description_table(int type)
104 1.2.6.2 yamt {
105 1.2.6.2 yamt const struct sme_description_table *ud = sme_units_description;
106 1.2.6.2 yamt const struct sme_description_table *sd = sme_state_description;
107 1.2.6.2 yamt const struct sme_description_table *dd = sme_drivestate_description;
108 1.2.6.3 yamt const struct sme_description_table *bd = sme_batterycap_description;
109 1.2.6.2 yamt switch (type) {
110 1.2.6.2 yamt case SME_DESC_UNITS:
111 1.2.6.2 yamt return ud;
112 1.2.6.2 yamt case SME_DESC_STATES:
113 1.2.6.2 yamt return sd;
114 1.2.6.2 yamt case SME_DESC_DRIVE_STATES:
115 1.2.6.2 yamt return dd;
116 1.2.6.3 yamt case SME_DESC_BATTERY_CAPACITY:
117 1.2.6.2 yamt return bd;
118 1.2.6.2 yamt default:
119 1.2.6.2 yamt return NULL;
120 1.2.6.2 yamt }
121 1.2.6.2 yamt }
122