- Test m_pkthdr.fw_flags against DUMMYNET_MBUF_TAGGED before trying to locate
[dragonfly/netmp.git] / sys / sys / sensors.h
blob554cfc22b52bc03138af14bfb60445039de527a6
1 /* $OpenBSD: sensors.h,v 1.23 2007/03/22 16:55:31 deraadt Exp $ */
2 /* $DragonFly: src/sys/sys/sensors.h,v 1.1 2007/10/02 12:57:01 hasso Exp $ */
4 /*
5 * Copyright (c) 2003, 2004 Alexander Yurchenko <grange@openbsd.org>
6 * Copyright (c) 2006 Constantine A. Murenin <cnst+openbsd@bugmail.mojo.ru>
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _SYS_SENSORS_H_
31 #define _SYS_SENSORS_H_
33 #define SENSORS_DEBUG
35 /* Sensor types */
36 enum sensor_type {
37 SENSOR_TEMP, /* temperature (muK) */
38 SENSOR_FANRPM, /* fan revolution speed */
39 SENSOR_VOLTS_DC, /* voltage (muV DC) */
40 SENSOR_VOLTS_AC, /* voltage (muV AC) */
41 SENSOR_OHMS, /* resistance */
42 SENSOR_WATTS, /* power */
43 SENSOR_AMPS, /* current (muA) */
44 SENSOR_WATTHOUR, /* power capacity */
45 SENSOR_AMPHOUR, /* power capacity */
46 SENSOR_INDICATOR, /* boolean indicator */
47 SENSOR_INTEGER, /* generic integer value */
48 SENSOR_PERCENT, /* percent */
49 SENSOR_LUX, /* illuminance (mulx) */
50 SENSOR_DRIVE, /* disk */
51 SENSOR_TIMEDELTA, /* system time error (nSec) */
52 SENSOR_MAX_TYPES
55 static const char * const sensor_type_s[SENSOR_MAX_TYPES + 1] = {
56 "temp",
57 "fan",
58 "volt",
59 "acvolt",
60 "resistance",
61 "power",
62 "current",
63 "watthour",
64 "amphour",
65 "indicator",
66 "raw",
67 "percent",
68 "illuminance",
69 "drive",
70 "timedelta",
71 "undefined"
74 #define SENSOR_DRIVE_EMPTY 1
75 #define SENSOR_DRIVE_READY 2
76 #define SENSOR_DRIVE_POWERUP 3
77 #define SENSOR_DRIVE_ONLINE 4
78 #define SENSOR_DRIVE_IDLE 5
79 #define SENSOR_DRIVE_ACTIVE 6
80 #define SENSOR_DRIVE_REBUILD 7
81 #define SENSOR_DRIVE_POWERDOWN 8
82 #define SENSOR_DRIVE_FAIL 9
83 #define SENSOR_DRIVE_PFAIL 10
85 /* Sensor states */
86 enum sensor_status {
87 SENSOR_S_UNSPEC, /* status is unspecified */
88 SENSOR_S_OK, /* status is ok */
89 SENSOR_S_WARN, /* status is warning */
90 SENSOR_S_CRIT, /* status is critical */
91 SENSOR_S_UNKNOWN /* status is unknown */
94 /* Sensor data:
95 * New fields should be added at the end to encourage backwards compat
97 struct sensor {
98 char desc[32]; /* sensor description, may be empty */
99 struct timeval tv; /* sensor value last change time */
100 int64_t value; /* current value */
101 enum sensor_type type; /* sensor type */
102 enum sensor_status status; /* sensor status */
103 int numt; /* sensor number of .type type */
104 int flags; /* sensor flags */
105 #define SENSOR_FINVALID 0x0001 /* sensor is invalid */
106 #define SENSOR_FUNKNOWN 0x0002 /* sensor value is unknown */
109 /* Sensor device data:
110 * New fields should be added at the end to encourage backwards compat
112 struct sensordev {
113 int num; /* sensordev number */
114 char xname[16]; /* unix device name */
115 int maxnumt[SENSOR_MAX_TYPES];
116 int sensors_count;
119 #define MAXSENSORDEVICES 32
121 #ifdef _KERNEL
122 #include <sys/queue.h>
123 #ifndef NOSYSCTL8HACK
124 #include <sys/sysctl.h>
125 #endif
127 /* Sensor data */
128 struct ksensor {
129 SLIST_ENTRY(ksensor) list; /* device-scope list */
130 char desc[32]; /* sensor description, may be empty */
131 struct timeval tv; /* sensor value last change time */
132 int64_t value; /* current value */
133 enum sensor_type type; /* sensor type */
134 enum sensor_status status; /* sensor status */
135 int numt; /* sensor number of .type type */
136 int flags; /* sensor flags, ie. SENSOR_FINVALID */
138 SLIST_HEAD(ksensors_head, ksensor);
140 /* Sensor device data */
141 struct ksensordev {
142 SLIST_ENTRY(ksensordev) list;
143 int num; /* sensordev number */
144 char xname[16]; /* unix device name */
145 int maxnumt[SENSOR_MAX_TYPES];
146 int sensors_count;
147 struct ksensors_head sensors_list;
148 #ifndef NOSYSCTL8HACK
149 struct sysctl_ctx_list clist; /* XXX: sysctl(9) .oid_handler() for
150 * CTLTYPE_NODE type doesn't support
151 * the undocumented sysctl magic.
153 #endif /* !NOSYSCTL8HACK */
156 /* struct ksensordev */
157 void sensordev_install(struct ksensordev *);
158 void sensordev_deinstall(struct ksensordev *);
160 /* struct ksensor */
161 void sensor_attach(struct ksensordev *, struct ksensor *);
162 void sensor_detach(struct ksensordev *, struct ksensor *);
164 /* task scheduling */
165 int sensor_task_register(void *, void (*)(void *), int);
166 void sensor_task_unregister(void *);
168 #endif /* _KERNEL */
170 #endif /* !_SYS_SENSORS_H_ */