| 1 | /* |
|---|
| 2 | data.h - Part of libsensors, a Linux library for reading sensor data. |
|---|
| 3 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| 4 | |
|---|
| 5 | This program is free software; you can redistribute it and/or modify |
|---|
| 6 | it under the terms of the GNU General Public License as published by |
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | (at your option) any later version. |
|---|
| 9 | |
|---|
| 10 | This program is distributed in the hope that it will be useful, |
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | GNU General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU General Public License |
|---|
| 16 | along with this program; if not, write to the Free Software |
|---|
| 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #ifndef LIB_SENSORS_DATA_H |
|---|
| 21 | #define LIB_SENSORS_DATA_H |
|---|
| 22 | |
|---|
| 23 | #include "sensors.h" |
|---|
| 24 | |
|---|
| 25 | /* This header file contains all kinds of data structures which are used |
|---|
| 26 | for the representation of the config file data and the /proc/... |
|---|
| 27 | data. */ |
|---|
| 28 | |
|---|
| 29 | /* Kinds of expression operators recognized */ |
|---|
| 30 | typedef enum sensors_operation { |
|---|
| 31 | sensors_add, sensors_sub, sensors_multiply, sensors_divide, |
|---|
| 32 | sensors_negate, sensors_exp, sensors_log } sensors_operation; |
|---|
| 33 | |
|---|
| 34 | /* An expression can have several forms */ |
|---|
| 35 | typedef enum sensors_expr_kind { |
|---|
| 36 | sensors_kind_val, sensors_kind_source, sensors_kind_var, |
|---|
| 37 | sensors_kind_sub } sensors_expr_kind; |
|---|
| 38 | |
|---|
| 39 | /* An expression. It is either a floating point value, a variable name, |
|---|
| 40 | an operation on subexpressions, or the special value 'sub' } */ |
|---|
| 41 | struct sensors_expr; |
|---|
| 42 | |
|---|
| 43 | typedef struct sensors_subexpr { |
|---|
| 44 | sensors_operation op; |
|---|
| 45 | struct sensors_expr *sub1; |
|---|
| 46 | struct sensors_expr *sub2; |
|---|
| 47 | } sensors_subexpr; |
|---|
| 48 | |
|---|
| 49 | typedef struct sensors_expr { |
|---|
| 50 | sensors_expr_kind kind; |
|---|
| 51 | union { |
|---|
| 52 | double val; |
|---|
| 53 | char *var; |
|---|
| 54 | sensors_subexpr subexpr; |
|---|
| 55 | } data; |
|---|
| 56 | } sensors_expr; |
|---|
| 57 | |
|---|
| 58 | /* Config file label declaration: a feature name, combined with the label |
|---|
| 59 | value */ |
|---|
| 60 | typedef struct sensors_label { |
|---|
| 61 | char *name; |
|---|
| 62 | char *value; |
|---|
| 63 | int lineno; |
|---|
| 64 | } sensors_label; |
|---|
| 65 | |
|---|
| 66 | /* Config file set declaration: a feature name, combined with an expression */ |
|---|
| 67 | typedef struct sensors_set { |
|---|
| 68 | char *name; |
|---|
| 69 | sensors_expr *value; |
|---|
| 70 | int lineno; |
|---|
| 71 | } sensors_set; |
|---|
| 72 | |
|---|
| 73 | /* Config file compute declaration: a feature name, combined with two |
|---|
| 74 | expressions */ |
|---|
| 75 | typedef struct sensors_compute { |
|---|
| 76 | char *name; |
|---|
| 77 | sensors_expr *from_proc; |
|---|
| 78 | sensors_expr *to_proc; |
|---|
| 79 | int lineno; |
|---|
| 80 | } sensors_compute; |
|---|
| 81 | |
|---|
| 82 | /* Config file ignore declaration: a feature name */ |
|---|
| 83 | typedef struct sensors_ignore { |
|---|
| 84 | char *name; |
|---|
| 85 | int lineno; |
|---|
| 86 | } sensors_ignore; |
|---|
| 87 | |
|---|
| 88 | /* A list of chip names, used to represent a config file chips declaration */ |
|---|
| 89 | typedef struct sensors_chip_name_list { |
|---|
| 90 | sensors_chip_name *fits; |
|---|
| 91 | int fits_count; |
|---|
| 92 | int fits_max; |
|---|
| 93 | } sensors_chip_name_list; |
|---|
| 94 | |
|---|
| 95 | /* A config file chip block */ |
|---|
| 96 | typedef struct sensors_chip { |
|---|
| 97 | sensors_chip_name_list chips; |
|---|
| 98 | sensors_label *labels; |
|---|
| 99 | int labels_count; |
|---|
| 100 | int labels_max; |
|---|
| 101 | sensors_set *sets; |
|---|
| 102 | int sets_count; |
|---|
| 103 | int sets_max; |
|---|
| 104 | sensors_compute *computes; |
|---|
| 105 | int computes_count; |
|---|
| 106 | int computes_max; |
|---|
| 107 | sensors_ignore *ignores; |
|---|
| 108 | int ignores_count; |
|---|
| 109 | int ignores_max; |
|---|
| 110 | int lineno; |
|---|
| 111 | } sensors_chip; |
|---|
| 112 | |
|---|
| 113 | /* Config file bus declaration: the i2c bus number, combined with adapter |
|---|
| 114 | and algorithm names */ |
|---|
| 115 | typedef struct sensors_bus { |
|---|
| 116 | int number; |
|---|
| 117 | char *adapter; |
|---|
| 118 | char *algorithm; |
|---|
| 119 | int lineno; |
|---|
| 120 | } sensors_bus; |
|---|
| 121 | |
|---|
| 122 | /* /proc/sys/dev/sensors/chips line representation */ |
|---|
| 123 | typedef struct sensors_proc_chips_entry { |
|---|
| 124 | int sysctl; |
|---|
| 125 | sensors_chip_name name; |
|---|
| 126 | } sensors_proc_chips_entry; |
|---|
| 127 | |
|---|
| 128 | /* Internal data about a single chip feature. |
|---|
| 129 | name is the string name used to refer to this feature (both in config |
|---|
| 130 | files and through user functions); |
|---|
| 131 | number is the internal feature number, used in many functions to refer |
|---|
| 132 | to this feature |
|---|
| 133 | logical_mapping is either SENSORS_NO_MAPPING if this is feature is the |
|---|
| 134 | main element of category; or it is the number of a feature with which |
|---|
| 135 | this feature is logically grouped (a group could be fan, fan_max and |
|---|
| 136 | fan_div) |
|---|
| 137 | compute_mapping is like logical_mapping, only it refers to another |
|---|
| 138 | feature whose compute line will be inherited (a group could be fan and |
|---|
| 139 | fan_max, but not fan_div) |
|---|
| 140 | mode is SENSORS_MODE_NO_RW, SENSORS_MODE_R, SENSORS_MODE_W or |
|---|
| 141 | SENSORS_MODE_RW, for unaccessible, readable, writable, and both readable |
|---|
| 142 | and writable. |
|---|
| 143 | sysctl is the SYSCTL id of the file the value can be found in. |
|---|
| 144 | offset is the (byte) offset of the place this feature can be found. |
|---|
| 145 | scaling is the number of decimal points to scale by. |
|---|
| 146 | This scaling is performed on the raw sysctl value, NOT the value |
|---|
| 147 | seen in /proc. Therefore the scaling value must be the same as |
|---|
| 148 | the value returned in nrels_mag by the SENSORS_PROC_REAL_INFO |
|---|
| 149 | operation in the chip drivers. |
|---|
| 150 | Divide the read value by 10**scaling to get the real value. |
|---|
| 151 | Scaling can be positive or negative but negative values aren't |
|---|
| 152 | very useful because the driver can scale that direction itself. */ |
|---|
| 153 | typedef struct sensors_chip_feature { |
|---|
| 154 | int number; |
|---|
| 155 | const char *name; |
|---|
| 156 | int logical_mapping; |
|---|
| 157 | int compute_mapping; |
|---|
| 158 | int mode; |
|---|
| 159 | int sysctl; |
|---|
| 160 | int offset; |
|---|
| 161 | int scaling; |
|---|
| 162 | const char *sysname; |
|---|
| 163 | int sysscaling; |
|---|
| 164 | const char *altsysname; |
|---|
| 165 | } sensors_chip_feature; |
|---|
| 166 | |
|---|
| 167 | /* Internal data about all features of a type of chip */ |
|---|
| 168 | typedef struct sensors_chip_features { |
|---|
| 169 | const char *prefix; |
|---|
| 170 | struct sensors_chip_feature *feature; |
|---|
| 171 | } sensors_chip_features; |
|---|
| 172 | |
|---|
| 173 | extern sensors_chip *sensors_config_chips; |
|---|
| 174 | extern int sensors_config_chips_count; |
|---|
| 175 | extern int sensors_config_chips_max; |
|---|
| 176 | |
|---|
| 177 | extern sensors_bus *sensors_config_busses; |
|---|
| 178 | extern int sensors_config_busses_count; |
|---|
| 179 | extern int sensors_config_busses_max; |
|---|
| 180 | |
|---|
| 181 | extern sensors_proc_chips_entry *sensors_proc_chips; |
|---|
| 182 | extern int sensors_proc_chips_count; |
|---|
| 183 | extern int sensors_proc_chips_max; |
|---|
| 184 | |
|---|
| 185 | extern sensors_bus *sensors_proc_bus; |
|---|
| 186 | extern int sensors_proc_bus_count; |
|---|
| 187 | extern int sensors_proc_bus_max; |
|---|
| 188 | |
|---|
| 189 | extern sensors_chip_features sensors_chip_features_list[]; |
|---|
| 190 | |
|---|
| 191 | #endif /* def LIB_SENSORS_DATA_H */ |
|---|