/* *libproc * *ACPI interface header file * *A library interface for finding process information from /proc. *This is also an interface into various things which haven't yet been integrated into sysfs, * as appropriate. Copyright (C) 2004 Joseph Pingenot This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /*NOTES: *Sub-structure pointers may be NULL! This can happen if an error occurs while * reading in the information, for example. */ #ifndef LIBPROC_ACPI_H_FJIAO9GH430Q8FZUJN #define LIBPROC_ACPI_H_FJIAO9GH430Q8FZUJN #define LIBPROC_BATTERY_OK 0 #define LIBPROC_BATTERY_CRITICAL 1 #define LIBPROC_BATTERY_CHARGED 0 #define LIBPROC_BATTERY_CHARGING 1 #define LIBPROC_BATTERY_DISCHARGING 2 #define LIBPROC_BATTERY_CHARGING_DISCHARGING 2 struct libproc_acpi_battstate { /*Flag; 0 if not inserted; 1 if battery is inserted.*/ int present; /*Capcity state; 0 if not OK; 1 if OK*/ int capstate; /*Charging state: 0 if unknown, 1 if charging, 2 if discharging*/ int chargestate; /*Rate of charge/discharge*/ unsigned long int rate; /*Capacity, mWh*/ unsigned long int capacity; /*Voltage, mV*/ unsigned long int voltage; }; #define LIBPROC_BATTERY_TECHLEN 64 #define LIBPROC_BATTERY_MODELLEN 64 #define LIBPROC_BATTERY_SERIALLEN 64 #define LIBPROC_BATTERY_TYPELEN 64 #define LIBPROC_BATTERY_OEMLEN 64 /*Battery information*/ struct libproc_acpi_battery { /*Battery number*/ unsigned int battnum; /*Low battery alarm*/ unsigned long int alarm; /*Flag; 0 if not inserted; 1 if battery is inserted.*/ int present; /*Designed capacity of the battery*/ unsigned long int descap; /*Last full capacity*/ unsigned long int lastfullcap; /*Battery technology*/ char tech[LIBPROC_BATTERY_TECHLEN]; /*Design voltage*/ unsigned long int desvolt; /*Design capacity warning*/ unsigned long int deswarn; /*Design capcity low*/ unsigned long int deslow; /*Capacity granularity 1,2*/ unsigned long int capgran1; unsigned long int capgran2; /*Model*/ char model[LIBPROC_BATTERY_MODELLEN]; /*Serial #*/ char serial[LIBPROC_BATTERY_SERIALLEN]; /*Type*/ char type[LIBPROC_BATTERY_TYPELEN]; /*OEM*/ char oem[LIBPROC_BATTERY_OEMLEN]; /*Battery state*/ struct libproc_acpi_battstate *state; /*Next battery*/ struct libproc_acpi_battery *next; }; struct libproc_acpi_cpulimit { /*Active limit P-state*/ unsigned int activep; /*Active limit T-state*/ unsigned int activet; /*User limit P-state*/ unsigned int userp; /*User limit T-state*/ unsigned int usert; /*Thermal limit P-state*/ unsigned int thermp; /*Thermal limit T-state*/ unsigned int thermt; }; /*Information about the C-states*/ struct libproc_acpi_cstate { /*Which C-state*/ unsigned int state; unsigned int p; unsigned int d; unsigned int latency; unsigned long int usage; struct libproc_acpi_cstate *next; }; struct libproc_acpi_cpupower { /*Active C-state*/ unsigned int activec; /*Default C-state*/ unsigned int defaultc; /*busmaster activity*/ unsigned int busmaster; /*Head of a linked-list of C-states*/ struct libproc_acpi_cstate *cstates; }; struct libproc_acpi_tstate { unsigned int state; unsigned int throttling; /*percent, 0-100*/ /*Flagged if active*/ int active; /*linked list linkage*/ struct libproc_acpi_tstate* next; }; struct libproc_acpi_cputhrottling { /*Number of T-states available*/ unsigned int numstates; /*Active state*/ unsigned int active; /*Singly-linked list of t-states*/ struct libproc_acpi_tstate *tstates; }; struct libproc_acpi_cpu { /*ID*/ unsigned int id; /*ACPI ID*/ unsigned int acpiId; /*Bus mastering control flag*/ int busmastering; /*power management flag*/ int powerman; /*throttling flag*/ int throttling; /*limiting flag*/ int limitflag; struct libproc_acpi_cpulimit* limit; struct libproc_acpi_cpupower* power; struct libproc_acpi_cputhrottling* throttle; struct libproc_acpi_cpu* next; }; /*BATTERY MANAGEMENT*/ /*Get the batteries in this machine *ARGS: * pointer to contain error *RETURNS: * NULL if error (likely no batteries or acpi) * pointer to the head of a singly-linked list of battery structs */ struct libproc_acpi_battery* libproc_acpi_get_batteries(int *err); /*Get the state of a battery (battery number) *ARGS: * battery: battery number * pointer to contain error *RETURNS: * NULL if error (likely no such battery or no acpi) * pointer to battstate struct */ struct libproc_acpi_battstate* libproc_acpi_get_battery_state(unsigned int battery, int *err); struct libproc_acpi_battery* libproc_acpi_get_battery(unsigned int battery, int *err); unsigned long int libproc_acpi_get_battery_alarm(unsigned int battery, int *err); /*PROCESSOR MANAGEMENT*/ /*Get the cpus on the system *ARGS: * pointer to contain error *RETURNS: * NULL if error (no cpus?! Probably no ACPI) * pointer to head of singly-linked list of cpu info structures */ struct libproc_acpi_cpu* libproc_acpi_get_cpus(int *err); struct libproc_acpi_cpu* libproc_acpi_get_cpu(unsigned int cpu, int *err); /*Get the current limits for a cpu *ARGS: * cpu: the cpu index * pointer to contain error *RETURNS: * NULL if error * pointer to struct containing cpu limit info */ struct libproc_acpi_cpulimit* libproc_acpi_get_cpulimit(unsigned int cpu, int *err); /*Set the user limit for a cpu *ARGS: * cpu: the cpu index * p: the p-state (-1 if no change) * t: the t-state (-1 if no change) */ int libproc_acpi_set_cpulimit(unsigned int cpu, int p, int t); /*Get the current power info for a cpu *ARGS: * cpu: the cpu index * pointer to contain error *RETURNS: * NULL if error * pointer to struct containing cpu power info */ struct libproc_acpi_cpupower* libproc_acpi_get_cpupower(unsigned int cpu, int *err); /*Get the current throttling info for a cpu *ARGS: * cpu: the cpu index * pointer to contain error *RETURNS: * NULL if error * pointer to struct containing cpu throttling info */ struct libproc_acpi_cputhrottling* libproc_acpi_get_cputhrottling(unsigned int cpu, int *err); /*Helper functions.*/ void libproc_acpi_freethrottling(struct libproc_acpi_cputhrottling* throttle); void libproc_acpi_freepower(struct libproc_acpi_cpupower* power); void libproc_acpi_freelimit(struct libproc_acpi_cpulimit* limit); void libproc_acpi_freecpu(struct libproc_acpi_cpu* cpu); void libproc_acpi_freebattery(struct libproc_acpi_battery* state); void libproc_acpi_freebattstate(struct libproc_acpi_battstate* state); #endif //LIBPROC_ACPI_H_FJIAO9GH430Q8FZUJN