Main Page | File List

src/libproc/acpi.h

00001 /* 00002 *libproc 00003 * 00004 *ACPI interface header file 00005 * 00006 *A library interface for finding process information from /proc. 00007 *This is also an interface into various things which haven't yet been integrated into sysfs, 00008 * as appropriate. 00009 00010 Copyright (C) 2004 Joseph Pingenot 00011 00012 This library is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU Lesser General Public 00014 License as published by the Free Software Foundation; either 00015 version 2.1 of the License, or (at your option) any later 00016 version. 00017 00018 This library is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 Lesser General Public License for more details. 00022 00023 You should have received a copy of the GNU Lesser General Public 00024 License along with this library; if not, write to the Free Software 00025 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 00027 */ 00028 00029 /*NOTES: 00030 *Sub-structure pointers may be NULL! This can happen if an error occurs while 00031 * reading in the information, for example. 00032 */ 00033 00034 #ifndef LIBPROC_ACPI_H_FJIAO9GH430Q8FZUJN 00035 #define LIBPROC_ACPI_H_FJIAO9GH430Q8FZUJN 00036 00037 #define LIBPROC_BATTERY_OK 0 00038 #define LIBPROC_BATTERY_CRITICAL 1 00039 #define LIBPROC_BATTERY_CHARGED 0 00040 #define LIBPROC_BATTERY_CHARGING 1 00041 #define LIBPROC_BATTERY_DISCHARGING 2 00042 #define LIBPROC_BATTERY_CHARGING_DISCHARGING 2 00043 00044 struct libproc_acpi_battstate { 00045 /*Flag; 0 if not inserted; 1 if battery is inserted.*/ 00046 int present; 00047 /*Capcity state; 0 if not OK; 1 if OK*/ 00048 int capstate; 00049 /*Charging state: 0 if unknown, 1 if charging, 2 if discharging*/ 00050 int chargestate; 00051 /*Rate of charge/discharge*/ 00052 unsigned long int rate; 00053 /*Capacity, mWh*/ 00054 unsigned long int capacity; 00055 /*Voltage, mV*/ 00056 unsigned long int voltage; 00057 }; 00058 00059 #define LIBPROC_BATTERY_TECHLEN 64 00060 #define LIBPROC_BATTERY_MODELLEN 64 00061 #define LIBPROC_BATTERY_SERIALLEN 64 00062 #define LIBPROC_BATTERY_TYPELEN 64 00063 #define LIBPROC_BATTERY_OEMLEN 64 00064 00065 /*Battery information*/ 00066 struct libproc_acpi_battery { 00067 /*Battery number*/ 00068 unsigned int battnum; 00069 00070 /*Low battery alarm*/ 00071 unsigned long int alarm; 00072 00073 /*Flag; 0 if not inserted; 1 if battery is inserted.*/ 00074 int present; 00075 /*Designed capacity of the battery*/ 00076 unsigned long int descap; 00077 /*Last full capacity*/ 00078 unsigned long int lastfullcap; 00079 /*Battery technology*/ 00080 char tech[LIBPROC_BATTERY_TECHLEN]; 00081 /*Design voltage*/ 00082 unsigned long int desvolt; 00083 /*Design capacity warning*/ 00084 unsigned long int deswarn; 00085 /*Design capcity low*/ 00086 unsigned long int deslow; 00087 /*Capacity granularity 1,2*/ 00088 unsigned long int capgran1; 00089 unsigned long int capgran2; 00090 /*Model*/ 00091 char model[LIBPROC_BATTERY_MODELLEN]; 00092 /*Serial #*/ 00093 char serial[LIBPROC_BATTERY_SERIALLEN]; 00094 /*Type*/ 00095 char type[LIBPROC_BATTERY_TYPELEN]; 00096 /*OEM*/ 00097 char oem[LIBPROC_BATTERY_OEMLEN]; 00098 00099 /*Battery state*/ 00100 struct libproc_acpi_battstate *state; 00101 00102 /*Next battery*/ 00103 struct libproc_acpi_battery *next; 00104 }; 00105 00106 00107 struct libproc_acpi_cpulimit { 00108 /*Active limit P-state*/ 00109 unsigned int activep; 00110 /*Active limit T-state*/ 00111 unsigned int activet; 00112 /*User limit P-state*/ 00113 unsigned int userp; 00114 /*User limit T-state*/ 00115 unsigned int usert; 00116 /*Thermal limit P-state*/ 00117 unsigned int thermp; 00118 /*Thermal limit T-state*/ 00119 unsigned int thermt; 00120 }; 00121 00122 /*Information about the C-states*/ 00123 struct libproc_acpi_cstate { 00124 /*Which C-state*/ 00125 unsigned int state; 00126 unsigned int p; 00127 unsigned int d; 00128 unsigned int latency; 00129 unsigned long int usage; 00130 struct libproc_acpi_cstate *next; 00131 }; 00132 00133 struct libproc_acpi_cpupower { 00134 /*Active C-state*/ 00135 unsigned int activec; 00136 /*Default C-state*/ 00137 unsigned int defaultc; 00138 /*busmaster activity*/ 00139 unsigned int busmaster; 00140 /*Head of a linked-list of C-states*/ 00141 struct libproc_acpi_cstate *cstates; 00142 }; 00143 00144 struct libproc_acpi_tstate { 00145 unsigned int state; 00146 unsigned int throttling; /*percent, 0-100*/ 00147 /*Flagged if active*/ 00148 int active; 00149 /*linked list linkage*/ 00150 struct libproc_acpi_tstate* next; 00151 }; 00152 00153 struct libproc_acpi_cputhrottling { 00154 /*Number of T-states available*/ 00155 unsigned int numstates; 00156 /*Active state*/ 00157 unsigned int active; 00158 /*Singly-linked list of t-states*/ 00159 struct libproc_acpi_tstate *tstates; 00160 }; 00161 00162 struct libproc_acpi_cpu { 00163 /*ID*/ 00164 unsigned int id; 00165 /*ACPI ID*/ 00166 unsigned int acpiId; 00167 /*Bus mastering control flag*/ 00168 int busmastering; 00169 /*power management flag*/ 00170 int powerman; 00171 /*throttling flag*/ 00172 int throttling; 00173 /*limiting flag*/ 00174 int limitflag; 00175 00176 struct libproc_acpi_cpulimit* limit; 00177 struct libproc_acpi_cpupower* power; 00178 struct libproc_acpi_cputhrottling* throttle; 00179 00180 struct libproc_acpi_cpu* next; 00181 }; 00182 00183 00184 00185 /*BATTERY MANAGEMENT*/ 00186 /*Get the batteries in this machine 00187 *ARGS: 00188 * pointer to contain error 00189 *RETURNS: 00190 * NULL if error (likely no batteries or acpi) 00191 * pointer to the head of a singly-linked list of battery structs 00192 */ 00193 struct libproc_acpi_battery* libproc_acpi_get_batteries(int *err); 00194 /*Get the state of a battery (battery number) 00195 *ARGS: 00196 * battery: battery number 00197 * pointer to contain error 00198 *RETURNS: 00199 * NULL if error (likely no such battery or no acpi) 00200 * pointer to battstate struct 00201 */ 00202 struct libproc_acpi_battstate* libproc_acpi_get_battery_state(unsigned int battery, int *err); 00203 struct libproc_acpi_battery* libproc_acpi_get_battery(unsigned int battery, int *err); 00204 unsigned long int libproc_acpi_get_battery_alarm(unsigned int battery, int *err); 00205 00206 00207 /*PROCESSOR MANAGEMENT*/ 00208 /*Get the cpus on the system 00209 *ARGS: 00210 * pointer to contain error 00211 *RETURNS: 00212 * NULL if error (no cpus?! Probably no ACPI) 00213 * pointer to head of singly-linked list of cpu info structures 00214 */ 00215 struct libproc_acpi_cpu* libproc_acpi_get_cpus(int *err); 00216 struct libproc_acpi_cpu* libproc_acpi_get_cpu(unsigned int cpu, int *err); 00217 /*Get the current limits for a cpu 00218 *ARGS: 00219 * cpu: the cpu index 00220 * pointer to contain error 00221 *RETURNS: 00222 * NULL if error 00223 * pointer to struct containing cpu limit info 00224 */ 00225 struct libproc_acpi_cpulimit* libproc_acpi_get_cpulimit(unsigned int cpu, int *err); 00226 /*Set the user limit for a cpu 00227 *ARGS: 00228 * cpu: the cpu index 00229 * p: the p-state (-1 if no change) 00230 * t: the t-state (-1 if no change) 00231 */ 00232 int libproc_acpi_set_cpulimit(unsigned int cpu, int p, int t); 00233 /*Get the current power info for a cpu 00234 *ARGS: 00235 * cpu: the cpu index 00236 * pointer to contain error 00237 *RETURNS: 00238 * NULL if error 00239 * pointer to struct containing cpu power info 00240 */ 00241 struct libproc_acpi_cpupower* libproc_acpi_get_cpupower(unsigned int cpu, int *err); 00242 /*Get the current throttling info for a cpu 00243 *ARGS: 00244 * cpu: the cpu index 00245 * pointer to contain error 00246 *RETURNS: 00247 * NULL if error 00248 * pointer to struct containing cpu throttling info 00249 */ 00250 struct libproc_acpi_cputhrottling* libproc_acpi_get_cputhrottling(unsigned int cpu, int *err); 00251 00252 /*Helper functions.*/ 00253 void libproc_acpi_freethrottling(struct libproc_acpi_cputhrottling* throttle); 00254 void libproc_acpi_freepower(struct libproc_acpi_cpupower* power); 00255 void libproc_acpi_freelimit(struct libproc_acpi_cpulimit* limit); 00256 void libproc_acpi_freecpu(struct libproc_acpi_cpu* cpu); 00257 void libproc_acpi_freebattery(struct libproc_acpi_battery* state); 00258 void libproc_acpi_freebattstate(struct libproc_acpi_battstate* state); 00259 00260 #endif //LIBPROC_ACPI_H_FJIAO9GH430Q8FZUJN

Generated on Thu Dec 30 21:48:53 2004 for The Versatile Governor by doxygen 1.3.8