libacpi: libacpi.h Source File

- Main Page
- Classes
- Files

- File List
- File Members

# libacpi.h

Go to the documentation of this file.

    00001 /*
    00002  * (C)opyright 2007 Nico Golde <nico@ngolde.de>
    00003  * See LICENSE file for license details
    00004  */
    00005
    00011 #ifndef __LIBACPI_H__
    00012 #define __LIBACPI_H__
    00013
    00014 #define PROC_ACPI "/proc/acpi/"
    00015 #define LINE_MAX 256
    00016 #define MAX_NAME 512
    00017 #define MAX_BUF 1024
    00018 #define MAX_ITEMS 10
    00019
    00024 enum {
    00025         ITEM_EXCEED = -5,
    00026         DISABLED = -4,
    00027         NOT_PRESENT = -3,
    00028         ALLOC_ERR = -2,
    00029         NOT_SUPPORTED = -1,
    00030         SUCCESS
    00031 };
    00032
    00037 typedef enum {
    00038         P_AC,
    00039         P_BATT,
    00040         P_ERR
    00041 } power_state_t;
    00042
    00047 typedef enum {
    00048         T_CRIT,
    00049         T_HOT,
    00050         T_PASS,
    00051         T_ACT,
    00052         T_OK,
    00053         T_ERR
    00054 } thermal_state_t;
    00055
    00060 typedef enum {
    00061         C_CHARGE,
    00062         C_DISCHARGE,
    00063         C_CHARGED,
    00064         C_NOINFO,
    00065         C_ERR
    00066 } charge_state_t;
    00067
    00072 typedef enum {
    00073         B_HIGH,
    00074         B_MED,
    00075         B_LOW,
    00076         B_CRIT,
    00077         B_HARD_CRIT,
    00078         B_ERR
    00079 } batt_state_t;
    00080
    00085 typedef enum {
    00086         CO_ACT,
    00087         CO_PASS,
    00088         CO_CRIT,
    00089         CO_ERR
    00090 } thermal_mode_t;
    00091
    00096 typedef enum {
    00097         F_ON,
    00098         F_OFF,
    00099         F_ERR
    00100 } fan_state_t;
    00101
    00106 typedef struct {
    00107         char name[MAX_NAME];
    00108         char state_file[MAX_NAME];
    00109         fan_state_t fan_state;
    00110 } fan_t;
    00111
    00116 typedef struct {
    00117         char name[MAX_NAME];
    00118         char state_file[MAX_NAME];
    00119         char info_file[MAX_NAME];
    00120         char alarm_file[MAX_NAME];
    00121         int present;
    00122         int design_cap;
    00123         int last_full_cap;
    00124         int design_voltage;
    00125         int present_rate;
    00126         int remaining_cap;
    00127         int present_voltage;
    00128         int design_warn;
    00129         int design_low;
    00130         int design_level1;
    00131         int design_level2;
    00132         int alarm;
    00133         /* calculated states */
    00134         int percentage;
    00135         int charge_time;
    00136         int remaining_time;
    00138         /* state info */
    00139         charge_state_t charge_state;
    00140         batt_state_t batt_state;
    00141 } battery_t;
    00142
    00147 typedef struct {
    00148         char name[MAX_NAME];
    00149         int temperature;
    00150         int frequency;
    00151         char state_file[MAX_NAME];
    00152         char cooling_file[MAX_NAME];
    00153         char freq_file[MAX_NAME];
    00154         char trips_file[MAX_NAME];
    00155         char temp_file[MAX_NAME];
    00156         thermal_mode_t therm_mode;
    00157         thermal_state_t therm_state;
    00158 } thermal_t;
    00159
    00164 typedef struct {
    00165         char *name;
    00166         char state_file[MAX_NAME];
    00167         power_state_t ac_state;
    00168 } adapter_t;
    00169
    00174 typedef struct {
    00175         int batt_count;
    00176         int thermal_count;
    00177         int fan_count;
    00178         int temperature;
    00179         adapter_t adapt;
    00180 } global_t;
    00181
    00186 battery_t batteries[MAX_ITEMS];
    00191 thermal_t thermals[MAX_ITEMS];
    00196 fan_t fans[MAX_ITEMS];
    00203 int init_acpi_batt(global_t *globals);
    00210 int init_acpi_acadapt(global_t *globals);
    00217 int init_acpi_thermal(global_t *globals);
    00224 int init_acpi_fan(global_t *globals);
    00225
    00230 int check_acpi_support(void);
    00231
    00237 int read_acpi_batt(const int num);
    00243 void read_acpi_acstate(global_t *globals);
    00250 int read_acpi_zone(const int num, global_t *globals);
    00256 int read_acpi_fan(const int num);
    00257 #endif /* !__LIBACPI_H__ */