1998-12-20 16:54:03 +00:00
|
|
|
/*
|
|
|
|
data.h - Part of libsensors, a Linux library for reading sensor data.
|
1999-02-08 22:50:29 +00:00
|
|
|
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
|
2007-09-29 19:18:15 +00:00
|
|
|
Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>
|
1998-12-20 16:54:03 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2008-03-26 13:37:12 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301 USA.
|
1998-12-20 16:54:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIB_SENSORS_DATA_H
|
|
|
|
#define LIB_SENSORS_DATA_H
|
|
|
|
|
|
|
|
#include "sensors.h"
|
2009-02-11 10:12:45 +00:00
|
|
|
#include "general.h"
|
1998-12-20 16:54:03 +00:00
|
|
|
|
1998-12-20 21:57:39 +00:00
|
|
|
/* This header file contains all kinds of data structures which are used
|
2009-01-29 08:58:36 +00:00
|
|
|
for the representation of the config file data and the sensors
|
1998-12-20 21:57:39 +00:00
|
|
|
data. */
|
1998-12-20 16:54:03 +00:00
|
|
|
|
1998-12-25 21:51:59 +00:00
|
|
|
/* Kinds of expression operators recognized */
|
2007-08-31 14:42:20 +00:00
|
|
|
typedef enum sensors_operation {
|
|
|
|
sensors_add, sensors_sub, sensors_multiply, sensors_divide,
|
|
|
|
sensors_negate, sensors_exp, sensors_log,
|
|
|
|
} sensors_operation;
|
1998-12-20 16:54:03 +00:00
|
|
|
|
1998-12-25 21:51:59 +00:00
|
|
|
/* An expression can have several forms */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef enum sensors_expr_kind {
|
2007-08-31 14:42:20 +00:00
|
|
|
sensors_kind_val, sensors_kind_source, sensors_kind_var,
|
|
|
|
sensors_kind_sub
|
|
|
|
} sensors_expr_kind;
|
1998-12-20 16:54:03 +00:00
|
|
|
|
1998-12-25 21:51:59 +00:00
|
|
|
/* An expression. It is either a floating point value, a variable name,
|
|
|
|
an operation on subexpressions, or the special value 'sub' } */
|
1998-12-20 16:54:03 +00:00
|
|
|
struct sensors_expr;
|
|
|
|
|
|
|
|
typedef struct sensors_subexpr {
|
2007-08-31 14:42:20 +00:00
|
|
|
sensors_operation op;
|
|
|
|
struct sensors_expr *sub1;
|
|
|
|
struct sensors_expr *sub2;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_subexpr;
|
|
|
|
|
|
|
|
typedef struct sensors_expr {
|
2007-08-31 14:42:20 +00:00
|
|
|
sensors_expr_kind kind;
|
|
|
|
union {
|
|
|
|
double val;
|
|
|
|
char *var;
|
|
|
|
sensors_subexpr subexpr;
|
|
|
|
} data;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_expr;
|
|
|
|
|
1998-12-25 21:51:59 +00:00
|
|
|
/* Config file label declaration: a feature name, combined with the label
|
|
|
|
value */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef struct sensors_label {
|
2007-08-31 14:42:20 +00:00
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
int lineno;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_label;
|
|
|
|
|
2007-09-23 12:07:53 +00:00
|
|
|
/* Config file set declaration: a subfeature name, combined with an
|
|
|
|
expression */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef struct sensors_set {
|
2007-08-31 14:42:20 +00:00
|
|
|
char *name;
|
|
|
|
sensors_expr *value;
|
|
|
|
int lineno;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_set;
|
|
|
|
|
2007-08-31 14:42:20 +00:00
|
|
|
/* Config file compute declaration: a feature name, combined with two
|
1998-12-25 21:51:59 +00:00
|
|
|
expressions */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef struct sensors_compute {
|
2007-08-31 14:42:20 +00:00
|
|
|
char *name;
|
|
|
|
sensors_expr *from_proc;
|
|
|
|
sensors_expr *to_proc;
|
|
|
|
int lineno;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_compute;
|
|
|
|
|
1999-12-24 22:44:41 +00:00
|
|
|
/* Config file ignore declaration: a feature name */
|
|
|
|
typedef struct sensors_ignore {
|
2007-08-31 14:42:20 +00:00
|
|
|
char *name;
|
|
|
|
int lineno;
|
1999-12-24 22:44:41 +00:00
|
|
|
} sensors_ignore;
|
|
|
|
|
1998-12-25 21:51:59 +00:00
|
|
|
/* A list of chip names, used to represent a config file chips declaration */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef struct sensors_chip_name_list {
|
2007-08-31 14:42:20 +00:00
|
|
|
sensors_chip_name *fits;
|
|
|
|
int fits_count;
|
|
|
|
int fits_max;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_chip_name_list;
|
|
|
|
|
1998-12-25 21:51:59 +00:00
|
|
|
/* A config file chip block */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef struct sensors_chip {
|
2007-08-31 14:42:20 +00:00
|
|
|
sensors_chip_name_list chips;
|
|
|
|
sensors_label *labels;
|
|
|
|
int labels_count;
|
|
|
|
int labels_max;
|
|
|
|
sensors_set *sets;
|
|
|
|
int sets_count;
|
|
|
|
int sets_max;
|
|
|
|
sensors_compute *computes;
|
|
|
|
int computes_count;
|
|
|
|
int computes_max;
|
|
|
|
sensors_ignore *ignores;
|
|
|
|
int ignores_count;
|
|
|
|
int ignores_max;
|
|
|
|
int lineno;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_chip;
|
|
|
|
|
2007-08-19 15:04:29 +00:00
|
|
|
/* Config file bus declaration: the bus type and number, combined with adapter
|
2006-10-13 19:55:41 +00:00
|
|
|
name */
|
1998-12-20 16:54:03 +00:00
|
|
|
typedef struct sensors_bus {
|
2007-08-31 14:42:20 +00:00
|
|
|
char *adapter;
|
|
|
|
sensors_bus_id bus;
|
|
|
|
int lineno;
|
1998-12-20 16:54:03 +00:00
|
|
|
} sensors_bus;
|
|
|
|
|
2007-09-23 12:07:53 +00:00
|
|
|
/* Internal data about all features and subfeatures of a chip */
|
1998-12-25 21:51:59 +00:00
|
|
|
typedef struct sensors_chip_features {
|
2007-08-31 14:42:20 +00:00
|
|
|
struct sensors_chip_name chip;
|
2007-09-23 12:05:16 +00:00
|
|
|
struct sensors_feature *feature;
|
2007-09-23 12:02:22 +00:00
|
|
|
struct sensors_subfeature *subfeature;
|
2007-09-23 12:05:16 +00:00
|
|
|
int feature_count;
|
2007-09-23 12:02:22 +00:00
|
|
|
int subfeature_count;
|
1998-12-25 21:51:59 +00:00
|
|
|
} sensors_chip_features;
|
1998-12-21 14:14:25 +00:00
|
|
|
|
1998-12-20 16:54:03 +00:00
|
|
|
extern sensors_chip *sensors_config_chips;
|
|
|
|
extern int sensors_config_chips_count;
|
|
|
|
extern int sensors_config_chips_max;
|
|
|
|
|
|
|
|
extern sensors_bus *sensors_config_busses;
|
|
|
|
extern int sensors_config_busses_count;
|
|
|
|
extern int sensors_config_busses_max;
|
|
|
|
|
2007-06-28 14:39:34 +00:00
|
|
|
extern sensors_chip_features *sensors_proc_chips;
|
1998-12-20 16:54:03 +00:00
|
|
|
extern int sensors_proc_chips_count;
|
|
|
|
extern int sensors_proc_chips_max;
|
|
|
|
|
2005-09-18 18:30:16 +00:00
|
|
|
#define sensors_add_proc_chips(el) sensors_add_array_el( \
|
|
|
|
(el), &sensors_proc_chips, &sensors_proc_chips_count,\
|
2007-06-28 14:39:34 +00:00
|
|
|
&sensors_proc_chips_max, sizeof(struct sensors_chip_features))
|
2005-09-18 18:30:16 +00:00
|
|
|
|
1998-12-21 14:14:25 +00:00
|
|
|
extern sensors_bus *sensors_proc_bus;
|
|
|
|
extern int sensors_proc_bus_count;
|
|
|
|
extern int sensors_proc_bus_max;
|
|
|
|
|
2005-09-18 18:30:16 +00:00
|
|
|
#define sensors_add_proc_bus(el) sensors_add_array_el( \
|
|
|
|
(el), &sensors_proc_bus, &sensors_proc_bus_count,\
|
|
|
|
&sensors_proc_bus_max, sizeof(struct sensors_bus))
|
|
|
|
|
2009-01-29 08:58:36 +00:00
|
|
|
/* Substitute configuration bus numbers with real-world bus numbers
|
2007-07-03 16:03:22 +00:00
|
|
|
in the chips lists */
|
|
|
|
int sensors_substitute_busses(void);
|
|
|
|
|
|
|
|
|
2009-02-12 16:21:34 +00:00
|
|
|
/* Parse a bus id into its components. Returns 0 on success, a value from
|
2007-07-03 16:03:22 +00:00
|
|
|
error.h on failure. */
|
2007-08-19 15:04:29 +00:00
|
|
|
int sensors_parse_bus_id(const char *name, sensors_bus_id *bus);
|
2007-07-03 16:03:22 +00:00
|
|
|
|
1998-12-20 16:54:03 +00:00
|
|
|
#endif /* def LIB_SENSORS_DATA_H */
|