Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / envsys.h @ 14

History | View | Annotate | Download (6.84 KB)

1 13 up20180614
/* $NetBSD: envsys.h,v 1.34 2014/05/18 11:46:24 kardel Exp $ */
2
3
/*-
4
 * Copyright (c) 1999, 2007, 2014 The NetBSD Foundation, Inc.
5
 * All rights reserved.
6
 *
7
 * This code is derived from software contributed to The NetBSD Foundation
8
 * by Tim Rightnour, Juan Romero Pardines and Bill Squier.
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
 *
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.
30
 */
31
32
#ifndef _SYS_ENVSYS_H_
33
#define _SYS_ENVSYS_H_
34
35
#ifndef _KERNEL
36
#include <stdbool.h>
37
#endif
38
39
#include <sys/ioccom.h>
40
#include <sys/power.h>
41
#include <sys/queue.h>
42
43
/*
44
 * ENVironmental SYStem version 2 (aka ENVSYS 2)
45
 */
46
47
#define ENVSYS_MAXSENSORS        512
48
#define ENVSYS_DESCLEN                32
49
50
/* sensor units */
51
enum envsys_units {
52
        ENVSYS_STEMP                = 0,        /* Temperature (microkelvins) */
53
        ENVSYS_SFANRPM,                        /* Fan RPM */
54
        ENVSYS_SVOLTS_AC,                /* AC Volts */
55
        ENVSYS_SVOLTS_DC,                /* DC Volts */
56
        ENVSYS_SOHMS,                        /* Ohms */
57
        ENVSYS_SWATTS,                        /* Watts */
58
        ENVSYS_SAMPS,                        /* Ampere */
59
        ENVSYS_SWATTHOUR,                /* Watt hour */
60
        ENVSYS_SAMPHOUR,                /* Ampere hour */
61
        ENVSYS_INDICATOR,                /* Indicator */
62
        ENVSYS_INTEGER,                        /* Integer */
63
        ENVSYS_DRIVE,                        /* Drive */
64
        ENVSYS_BATTERY_CAPACITY,        /* Battery capacity */
65
        ENVSYS_BATTERY_CHARGE,                /* Battery charging/discharging */
66
        ENVSYS_SRELHUMIDITY,                /* relative humidity */
67
        ENVSYS_NSENSORS
68
};
69
70
/* sensor states */
71
enum envsys_states {
72
        ENVSYS_SVALID                = 10,        /* sensor state is valid */
73
        ENVSYS_SINVALID,                /* sensor state is invalid */
74
        ENVSYS_SCRITICAL,                /* sensor state is critical */
75
        ENVSYS_SCRITUNDER,                /* sensor state is critical under */
76
        ENVSYS_SCRITOVER,                /* sensor state is critical over */
77
        ENVSYS_SWARNUNDER,                /* sensor state is warn under */
78
        ENVSYS_SWARNOVER                /* sensor state is warn over */
79
};
80
81
/* sensor drive states */
82
enum envsys_drive_states {
83
        ENVSYS_DRIVE_EMPTY        = 1,        /* drive is empty */
84
        ENVSYS_DRIVE_READY,                /* drive is ready */
85
        ENVSYS_DRIVE_POWERUP,                /* drive is powered up */
86
        ENVSYS_DRIVE_ONLINE,                /* drive is online */
87
        ENVSYS_DRIVE_IDLE,                /* drive is idle */
88
        ENVSYS_DRIVE_ACTIVE,                /* drive is active */
89
        ENVSYS_DRIVE_REBUILD,                /* drive is rebuilding */
90
        ENVSYS_DRIVE_POWERDOWN,                /* drive is powered down */
91
        ENVSYS_DRIVE_FAIL,                /* drive failed */
92
        ENVSYS_DRIVE_PFAIL,                /* drive is degraded */
93
        ENVSYS_DRIVE_MIGRATING,                /* drive is migrating */
94
        ENVSYS_DRIVE_OFFLINE,                /* drive is offline */
95
        ENVSYS_DRIVE_BUILD,                /* drive is building */
96
        ENVSYS_DRIVE_CHECK                /* drive is checking its state */
97
};
98
99
/* sensor battery capacity states */
100
enum envsys_battery_capacity_states {
101
        ENVSYS_BATTERY_CAPACITY_NORMAL        = 1,        /* normal cap in battery */
102
        ENVSYS_BATTERY_CAPACITY_WARNING,        /* warning cap in battery */
103
        ENVSYS_BATTERY_CAPACITY_CRITICAL,        /* critical cap in battery */
104
        ENVSYS_BATTERY_CAPACITY_HIGH,                /* high cap in battery */
105
        ENVSYS_BATTERY_CAPACITY_MAX,                /* maximum cap in battery */
106
        ENVSYS_BATTERY_CAPACITY_LOW                /* low cap in battery */
107
};
108
109
/* sensor indicator states */
110
enum envsys_indicator_states {
111
        ENVSYS_INDICATOR_FALSE                = 0,
112
        ENVSYS_INDICATOR_TRUE                = 1
113
};
114
115
/*
116
 * IOCTLs
117
 */
118
#define ENVSYS_GETDICTIONARY        _IOWR('E', 0, struct plistref)
119
#define ENVSYS_SETDICTIONARY        _IOWR('E', 1, struct plistref)
120
#define ENVSYS_REMOVEPROPS        _IOWR('E', 2, struct plistref)
121
122
/*
123
 * Compatibility with old interface. Only ENVSYS_GTREDATA
124
 * and ENVSYS_GTREINFO ioctls are supported.
125
 */
126
127
/* get sensor data */
128
129
struct envsys_tre_data {
130
        u_int sensor;
131
        union {                                /* all data is given */
132
                uint32_t data_us;        /* in microKelvins, */
133
                int32_t data_s;                /* rpms, volts, amps, */
134
        } cur, min, max, avg;                /* ohms, watts, etc */
135
                                        /* see units below */
136
137
        uint32_t        warnflags;        /* warning flags */
138
        uint32_t        validflags;        /* sensor valid flags */
139
        u_int                units;                /* type of sensor */
140
};
141
typedef struct envsys_tre_data envsys_tre_data_t;
142
143
/* flags for warnflags */
144
#define ENVSYS_WARN_OK                0x00000000  /* All is well */
145
#define ENVSYS_WARN_UNDER        0x00000001  /* an under condition */
146
#define ENVSYS_WARN_CRITUNDER        0x00000002  /* a critical under condition */
147
#define ENVSYS_WARN_OVER        0x00000004  /* an over condition */
148
#define ENVSYS_WARN_CRITOVER        0x00000008  /* a critical over condition */
149
150
/* drive status */
151
#define ENVSYS_DRIVE_EMPTY      1
152
#define ENVSYS_DRIVE_READY      2
153
#define ENVSYS_DRIVE_POWERUP    3
154
#define ENVSYS_DRIVE_ONLINE     4
155
#define ENVSYS_DRIVE_IDLE       5
156
#define ENVSYS_DRIVE_ACTIVE     6
157
#define ENVSYS_DRIVE_REBUILD    7
158
#define ENVSYS_DRIVE_POWERDOWN  8
159
#define ENVSYS_DRIVE_FAIL       9
160
#define ENVSYS_DRIVE_PFAIL      10
161
162
#ifdef ENVSYSUNITNAMES
163
static const char * const envsysunitnames[] = {
164
    "degC", "RPM", "VAC", "V", "Ohms", "W",
165
    "A", "Wh", "Ah", "bool", "integer", "drive", "%rH", "Unk"
166
};
167
static const char * const envsysdrivestatus[] = {
168
    "unknown", "empty", "ready", "powering up", "online", "idle", "active",
169
    "rebuilding", "powering down", "failed", "degraded"
170
};
171
#endif
172
173
174
/* flags for validflags */
175
#define ENVSYS_FVALID                0x00000001  /* sensor is valid */
176
#define ENVSYS_FCURVALID        0x00000002  /* cur for this sens is valid */
177
#define ENVSYS_FMINVALID        0x00000004  /* min for this sens is valid */
178
#define ENVSYS_FMAXVALID        0x00000008  /* max for this sens is valid */
179
#define ENVSYS_FAVGVALID        0x00000010  /* avg for this sens is valid */
180
#define ENVSYS_FFRACVALID        0x00000020  /* display fraction of max */
181
182
#define ENVSYS_GTREDATA         _IOWR('E', 2, envsys_tre_data_t)
183
184
/* set and check sensor info */
185
186
struct envsys_basic_info {
187
        u_int        sensor;                /* sensor number */
188
        u_int        units;                /* type of sensor */
189
        char        desc[33];        /* sensor description */
190
        u_int        rfact;                /* for volts, (int)(factor x 10^4) */
191
        u_int        rpms;                /* for fans, set nominal RPMs */
192
        uint32_t validflags;        /* sensor valid flags */
193
};
194
typedef struct envsys_basic_info envsys_basic_info_t;
195
196
#define ENVSYS_GTREINFO         _IOWR('E', 4, envsys_basic_info_t)
197
198
#endif /* _SYS_ENVSYS_H_ */