diff options
author | Nikolay Sturm <sturm@cvs.openbsd.org> | 2006-01-19 19:17:11 +0000 |
---|---|---|
committer | Nikolay Sturm <sturm@cvs.openbsd.org> | 2006-01-19 19:17:11 +0000 |
commit | 53769234f5d2cc789eb38bca329575b464650468 (patch) | |
tree | 839913333629e5b30db2e42e8a55af900fce30e5 /usr.sbin/apmd | |
parent | 2e4638218f93e5d831689bab4325ab3a409e4c8a (diff) |
prompted by deraadt:
manual performance mode -> low/high performance mode
show cpuspeed in apm output
ok beck, weingart
man page bits ok jmc
Diffstat (limited to 'usr.sbin/apmd')
-rw-r--r-- | usr.sbin/apmd/apm-proto.h | 8 | ||||
-rw-r--r-- | usr.sbin/apmd/apmd.8 | 6 | ||||
-rw-r--r-- | usr.sbin/apmd/apmd.c | 17 | ||||
-rw-r--r-- | usr.sbin/apmd/apmsubr.c | 8 |
4 files changed, 25 insertions, 14 deletions
diff --git a/usr.sbin/apmd/apm-proto.h b/usr.sbin/apmd/apm-proto.h index 8f8726bb323..ce63843bc34 100644 --- a/usr.sbin/apmd/apm-proto.h +++ b/usr.sbin/apmd/apm-proto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apm-proto.h,v 1.6 2005/12/02 04:27:52 beck Exp $ */ +/* $OpenBSD: apm-proto.h,v 1.7 2006/01/19 19:17:10 sturm Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -48,7 +48,8 @@ enum apm_state { enum apm_perfstate { PERF_NONE, - PERF_MANUAL, + PERF_LOW, + PERF_HIGH, PERF_AUTO, PERF_COOL }; @@ -62,10 +63,11 @@ struct apm_reply { int vno; enum apm_state newstate; enum apm_perfstate perfstate; + int cpuspeed; struct apm_power_info batterystate; }; -#define APMD_VNO 2 +#define APMD_VNO 3 extern const char *battstate(int state); extern const char *ac_state(int state); diff --git a/usr.sbin/apmd/apmd.8 b/usr.sbin/apmd/apmd.8 index b7f5dc35ef0..5ed555c7d5a 100644 --- a/usr.sbin/apmd/apmd.8 +++ b/usr.sbin/apmd/apmd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: apmd.8,v 1.32 2005/12/02 09:19:39 jmc Exp $ +.\" $OpenBSD: apmd.8,v 1.33 2006/01/19 19:17:10 sturm Exp $ .\" .\" Copyright (c) 1995 John T. Kohl .\" All rights reserved. @@ -112,13 +112,13 @@ Specify an alternate device file name, .It Fl H Start .Nm -in manual performance adjustment mode, initialising +in high performance mode, initialising .Va hw.setperf to 100. .It Fl L Start .Nm -in manual performance adjustment mode, initialising +in low performance mode, initialising .Va hw.setperf to 0. .It Fl m diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index e23f0895d80..13f8ba8a407 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.40 2005/12/02 04:35:49 deraadt Exp $ */ +/* $OpenBSD: apmd.c,v 1.41 2006/01/19 19:17:10 sturm Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -306,6 +306,9 @@ handle_client(int sock_fd, int ctl_fd) socklen_t fromlen; struct apm_command cmd; struct apm_reply reply; + int cpuspeed_mib[] = {CTL_HW, HW_CPUSPEED}; + int cpuspeed; + size_t cpuspeed_sz = sizeof(cpuspeed); fromlen = sizeof(from); cli_fd = accept(sock_fd, (struct sockaddr *)&from, &fromlen); @@ -335,13 +338,13 @@ handle_client(int sock_fd, int ctl_fd) reply.newstate = STANDING_BY; break; case SETPERF_LOW: - doperf = PERF_MANUAL; + doperf = PERF_LOW; reply.newstate = NORMAL; syslog(LOG_NOTICE, "setting hw.setperf to %d", PERFMIN); setperf(PERFMIN); break; case SETPERF_HIGH: - doperf = PERF_MANUAL; + doperf = PERF_HIGH; reply.newstate = NORMAL; syslog(LOG_NOTICE, "setting hw.setperf to %d", PERFMAX); setperf(PERFMAX); @@ -361,6 +364,10 @@ handle_client(int sock_fd, int ctl_fd) break; } + if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) < 0) + syslog(LOG_INFO, "cannot read hw.cpuspeed"); + + reply.cpuspeed = cpuspeed; reply.perfstate = doperf; reply.vno = APMD_VNO; if (send(cli_fd, &reply, sizeof(reply), 0) != sizeof(reply)) @@ -453,13 +460,13 @@ main(int argc, char *argv[]) case 'L': if (doperf != PERF_NONE) usage(); - doperf = PERF_MANUAL; + doperf = PERF_LOW; setperf(PERFMIN); break; case 'H': if (doperf != PERF_NONE) usage(); - doperf = PERF_MANUAL; + doperf = PERF_HIGH; setperf(PERFMAX); break; case 'm': diff --git a/usr.sbin/apmd/apmsubr.c b/usr.sbin/apmd/apmsubr.c index 1686ea6a9a1..836a333bf11 100644 --- a/usr.sbin/apmd/apmsubr.c +++ b/usr.sbin/apmd/apmsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmsubr.c,v 1.5 2005/12/02 04:27:52 beck Exp $ */ +/* $OpenBSD: apmsubr.c,v 1.6 2006/01/19 19:17:10 sturm Exp $ */ /* * Copyright (c) 1995,1996 John T. Kohl @@ -77,8 +77,10 @@ perf_state(int state) switch (state) { case PERF_NONE: return "uninitialized"; - case PERF_MANUAL: - return "manual"; + case PERF_LOW: + return "low"; + case PERF_HIGH: + return "high"; case PERF_AUTO: return "auto"; case PERF_COOL: |