00001
00002
00003
00004
00005
00011 #define PROC_ACPI "/proc/acpi/"
00012 #define LINE_MAX 256
00013 #define MAX_NAME 512
00014 #define MAX_BUF 1024
00015 #define MAX_ITEMS 10
00016
00021 enum {
00022 ITEM_EXCEED = -5,
00023 DISABLED = -4,
00024 NOT_PRESENT = -3,
00025 ALLOC_ERR = -2,
00026 NOT_SUPPORTED = -1,
00027 SUCCESS
00028 };
00029
00034 typedef enum {
00035 P_AC,
00036 P_BATT,
00037 P_ERR
00038 } power_state_t;
00039
00044 typedef enum {
00045 T_CRIT,
00046 T_HOT,
00047 T_PASS,
00048 T_ACT,
00049 T_OK,
00050 T_ERR
00051 } thermal_state_t;
00052
00057 typedef enum {
00058 C_CHARGE,
00059 C_DISCHARGE,
00060 C_CHARGED,
00061 C_NOINFO,
00062 C_ERR
00063 } charge_state_t;
00064
00069 typedef enum {
00070 B_HIGH,
00071 B_MED,
00072 B_LOW,
00073 B_CRIT,
00074 B_HARD_CRIT,
00075 B_ERR
00076 } batt_state_t;
00077
00082 typedef enum {
00083 CO_ACT,
00084 CO_PASS,
00085 CO_CRIT,
00086 CO_ERR
00087 } thermal_mode_t;
00088
00093 typedef enum {
00094 F_ON,
00095 F_OFF,
00096 F_ERR
00097 } fan_state_t;
00098
00103 typedef struct {
00104 char name[MAX_NAME];
00105 char state_file[MAX_NAME];
00106 fan_state_t fan_state;
00107 } fan_t;
00108
00113 typedef struct {
00114 char name[MAX_NAME];
00115 char state_file[MAX_NAME];
00116 char info_file[MAX_NAME];
00117 char alarm_file[MAX_NAME];
00118 int present;
00119 int design_cap;
00120 int last_full_cap;
00121 int design_voltage;
00122 int present_rate;
00123 int remaining_cap;
00124 int present_voltage;
00125 int design_warn;
00126 int design_low;
00127 int design_level1;
00128 int design_level2;
00129 int alarm;
00130
00131 int percentage;
00132 int charge_time;
00133 int remaining_time;
00135
00136 charge_state_t charge_state;
00137 batt_state_t batt_state;
00138 } battery_t;
00139
00144 typedef struct {
00145 char name[MAX_NAME];
00146 int temperature;
00147 int frequency;
00148 char state_file[MAX_NAME];
00149 char cooling_file[MAX_NAME];
00150 char freq_file[MAX_NAME];
00151 char trips_file[MAX_NAME];
00152 char temp_file[MAX_NAME];
00153 thermal_mode_t therm_mode;
00154 thermal_state_t therm_state;
00155 } thermal_t;
00156
00161 typedef struct {
00162 char *name;
00163 char state_file[MAX_NAME];
00164 power_state_t ac_state;
00165 } adapter_t;
00166
00171 typedef struct {
00172 int batt_count;
00173 int thermal_count;
00174 int fan_count;
00175 int temperature;
00176 adapter_t adapt;
00177 } global_t;
00178
00183 battery_t batteries[MAX_ITEMS];
00188 thermal_t thermals[MAX_ITEMS];
00193 fan_t fans[MAX_ITEMS];
00200 int init_acpi_batt(global_t *globals);
00207 int init_acpi_acadapt(global_t *globals);
00214 int init_acpi_thermal(global_t *globals);
00221 int init_acpi_fan(global_t *globals);
00222
00227 int check_acpi_support(void);
00228
00234 int read_acpi_batt(const int num);
00240 void read_acpi_acstate(global_t *globals);
00247 int read_acpi_zone(const int num, global_t *globals);
00253 int read_acpi_fan(const int num);