/* *libacpi testing file. * *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 */ #include #include "acpi.h" int main (void) { int err; struct libproc_acpi_battery* battlist; struct libproc_acpi_battery* current; struct libproc_acpi_cpu* cpulist; struct libproc_acpi_cpu* cpu; struct libproc_acpi_cstate* cstate; struct libproc_acpi_tstate* tstate; printf("batteries:\n"); battlist = libproc_acpi_get_batteries(&err); printf("battlist=%x, err=%d\n", (int)battlist, err); if(battlist != NULL) { for(current = battlist; current != NULL; current = current->next) { /*Walk through the list, printing off the batteries.*/ printf("battery %d:\n * present: %c\n", current->battnum, (current->present == 1)? 'Y':'N'); if(current->present == 1){ printf(" * descap:%ld\n * lastfullcap:%ld\n * tech:%s\n * desvolt:%ld\n * deswarn:%ld\n * deslow:%ld\n * capgran1:%ld\n * capgran2:%ld\n * model:%s\n * serial:%s\n * type:%s\n * oem:%s\n * alarm:%ld\n", current->descap, current->lastfullcap, current->tech, current->desvolt, current->deswarn, current->deslow, current->capgran1, current->capgran2, current->model, current->serial, current->type, current->oem, current->alarm); if(current->state != NULL){ printf(" * state:\n * present:%s\n * capstate:%d\n * chargestate:%d\n * rate:%ld\n * capacity:%ld\n * voltage:%ld\n", (current->state->present)? "yes":"no", current->state->capstate, current->state->chargestate, current->state->rate, current->state->capacity, current->state->voltage); } } } }else{ printf(" battlist was NULL!\n"); } printf("cpus:\n"); cpulist = libproc_acpi_get_cpus(&err); printf("cpulist=%x, err=%d\n", (int)cpulist, err); if(cpulist != NULL) { for(cpu = cpulist; cpu != NULL; cpu = cpu->next) { printf("cpu %d:\n ID=%d\n acpi ID:%d\n busmastering: %s\n power management: %s\n throttling: %s\n limiting: %s\n", cpu->id, cpu->id, cpu->acpiId, (cpu->busmastering)? "yes":"no", (cpu->powerman)? "yes":"no", (cpu->throttling)? "yes":"no", (cpu->limitflag)? "yes":"no"); if((cpu->limit) != NULL) { printf(" limit (%x):\n active: P%d:T%d\n user: P%d:T%d\n therm: P%d:T%d\n", (int)cpu->limit, cpu->limit->activep, cpu->limit->activet, cpu->limit->userp, cpu->limit->usert, cpu->limit->thermp, cpu->limit->thermt); }else{ printf(" limit (%x) is NULL\n", (int)cpu->limit); } if((cpu->power) != NULL) { printf(" power (%x):\n active cstate: %d\n default cstate: %d\n busmaster: %x\n", (int)cpu->power, cpu->power->activec, cpu->power->defaultc, cpu->power->busmaster); if((cpu->power->cstates) != NULL) { printf(" cstates (%x):\n", (int)cpu->power->cstates); for(cstate = cpu->power->cstates; cstate != NULL; cstate = cstate->next) { /*We have to care about promotion/demotion value*/ if(cstate->p == 65535){ /*No promotion.*/ printf(" cstate: C%d\n promotion: None\n demotion: C%d\n latency: %d\n usage: %ld\n", cstate->state, cstate->d, cstate->latency, cstate->usage); }else if(cstate->d == 65535){ printf(" cstate: C%d\n promotion: C%d\n demotion: None\n latency: %d\n usage: %ld\n", cstate->state, cstate->p, cstate->latency, cstate->usage); }else{ printf(" cstate: C%d\n promotion: C%d\n demotion: C%d\n latency: %d\n usage: %ld\n", cstate->state, cstate->p, cstate->d, cstate->latency, cstate->usage); } } }else{ printf(" cstates (%x) is NULL\n", (int)cpu->power->cstates); } }else{ printf(" power (%x) is NULL\n", (int)cpu->power); } if((cpu->throttle) != NULL) { printf(" throttle (%x):\n state count: %d\n active state: T%d\n", (int)cpu->throttle, cpu->throttle->numstates, cpu->throttle->active); printf(" tstates (%x):\n", (int)cpu->throttle->tstates); for(tstate = cpu->throttle->tstates; tstate != NULL; tstate = tstate->next) { printf(" tstate T%d:\n throttling: %d/100\n active: %s\n", tstate->state, tstate->throttling, (tstate->active)? "yes":"no"); } }else{ printf(" throttle (%x) is NULL\n", (int)cpu->throttle); } } }else{ printf(" cpulist was NULL!\n"); } return 0; }