summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorNikolay Sturm <sturm@cvs.openbsd.org>2006-01-19 19:17:11 +0000
committerNikolay Sturm <sturm@cvs.openbsd.org>2006-01-19 19:17:11 +0000
commit53769234f5d2cc789eb38bca329575b464650468 (patch)
tree839913333629e5b30db2e42e8a55af900fce30e5 /usr.sbin
parent2e4638218f93e5d831689bab4325ab3a409e4c8a (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')
-rw-r--r--usr.sbin/apm/apm.810
-rw-r--r--usr.sbin/apm/apm.c10
-rw-r--r--usr.sbin/apmd/apm-proto.h8
-rw-r--r--usr.sbin/apmd/apmd.86
-rw-r--r--usr.sbin/apmd/apmd.c17
-rw-r--r--usr.sbin/apmd/apmsubr.c8
6 files changed, 35 insertions, 24 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8
index d2df7ad6d9e..ec81a2156b6 100644
--- a/usr.sbin/apm/apm.8
+++ b/usr.sbin/apm/apm.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: apm.8,v 1.25 2005/12/02 09:22:52 jmc Exp $
+.\" $OpenBSD: apm.8,v 1.26 2006/01/19 19:17:10 sturm Exp $
.\"
.\" Copyright (c) 1996 John T. Kohl
.\" All rights reserved.
@@ -76,13 +76,13 @@ to
.It Fl H
Set
.Xr apmd 8
-to manual performance adjustment mode and
+to high performance mode and
.Va hw.setperf
to 100.
.It Fl L
Set
.Xr apmd 8
-to manual performance adjustment mode and
+to low performance mode and
.Va hw.setperf
to 0.
.It Fl l
@@ -91,8 +91,8 @@ Display the estimated battery lifetime (in percent).
Display the estimated battery lifetime (in minutes).
.It Fl P
Display the performance adjustment mode.
-0 means uninitialized, 1 means manual, 2 means automatic mode, and 3
-means cool running mode.
+0 means uninitialized, 1 means low performance mode, 2 means high performance
+mode, 3 means automatic mode, and 4 means cool running mode.
.It Fl S
Put the system into stand-by (light sleep) mode.
.It Fl s
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index e328a999dc1..11b1d97bacc 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.15 2005/12/02 04:33:27 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.16 2006/01/19 19:17:10 sturm Exp $ */
/*
* Copyright (c) 1996 John T. Kohl
@@ -238,7 +238,7 @@ main(int argc, char *argv[])
action = GETSTATUS;
verbose = doac = dopct = dobstate = dostatus = domin = TRUE;
doperf = TRUE;
- /* fallthrough */
+ /* FALLTHROUGH */
case GETSTATUS:
if (fd == -1) {
/* open the device directly and get status */
@@ -247,7 +247,7 @@ main(int argc, char *argv[])
&reply.batterystate) == 0)
goto printval;
}
- /* fallthrough */
+ /* FALLTHROUGH */
case SUSPEND:
case STANDBY:
case SETPERF_LOW:
@@ -323,8 +323,8 @@ main(int argc, char *argv[])
printf("A/C adapter state: %s\n",
ac_state(reply.batterystate.ac_state));
if (doperf)
- printf("Performance state: %s\n",
- perf_state(reply.perfstate));
+ printf("Performance state: %s (%d MHz)\n",
+ perf_state(reply.perfstate), reply.cpuspeed);
if (dostatus)
printf("Power management enabled\n");
break;
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: