[BACK]Return to sensors.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/sensors.h, Revision 1.1

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

CVSweb