From owner-freebsd-acpi@FreeBSD.ORG Wed Jun 16 20:40:08 2004 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF8DD16A4D1 for ; Wed, 16 Jun 2004 20:40:08 +0000 (GMT) Received: from moutvdomng.kundenserver.de (moutvdom.kundenserver.de [212.227.126.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0835243D62 for ; Wed, 16 Jun 2004 20:40:08 +0000 (GMT) (envelope-from liamfoy@sepulcrum.org) Received: from [212.227.126.224] (helo=mrvdomng.kundenserver.de) by moutvdomng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BahCL-00076i-00; Wed, 16 Jun 2004 22:39:53 +0200 Received: from [81.154.134.17] (helo=Anarion) by mrvdomng.kundenserver.de with smtp (Exim 3.35 #1) id 1BahCL-0003B4-00; Wed, 16 Jun 2004 22:39:53 +0200 Date: Wed, 16 Jun 2004 21:39:46 +0100 From: Liam Foy To: "M. Warner Losh" Message-Id: <20040616213946.6f7def3d.liamfoy@sepulcrum.org> In-Reply-To: <20040616.142323.91757134.imp@bsdimp.com> References: <20040616171408.0f88c928.liamfoy@sepulcrum.org> <20040616.135044.85075412.imp@bsdimp.com> <20040616.142323.91757134.imp@bsdimp.com> Organization: None X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i386-portbld-freebsd5.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: acpi@freebsd.org Subject: Re: apm problem X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2004 20:40:09 -0000 On Wed, 16 Jun 2004 14:23:23 -0600 (MDT) "M. Warner Losh" wrote: > Here's my revised apm(8) patches. They fix a few minor nits that I > introduced in the last pass. I have some similar fixes for the > kernel. > > Warner > > Index: apm.c > =================================================================== > RCS file: /home/ncvs/src/usr.sbin/apm/apm.c,v > retrieving revision 1.32 > diff -u -r1.32 apm.c > --- apm.c 27 May 2004 19:23:27 -0000 1.32 > +++ apm.c 16 Jun 2004 20:22:31 -0000 > @@ -34,6 +34,8 @@ > > #define APMDEV "/dev/apm" > > +#define APM_UNKNOWN 0xff /* Unknown in APM BIOS spec */ Do you not mean 0xffffffff ? > + > #define xh(a) (((a) & 0xff00) >> 8) > #define xl(a) ((a) & 0xff) > #define APMERR(a) xh(a) > @@ -156,7 +158,7 @@ > printf("APM version: %d.%d\n", aip->ai_major, aip->ai_minor); > printf("APM Management: %s\n", aip->ai_status ? "Enabled" : "Disabled"); > printf("AC Line status: "); > - if (aip->ai_acline >= 255) > + if (aip->ai_acline == APM_UNKNOWN) > printf("unknown"); > else if (aip->ai_acline > 1) > printf("invalid value (0x%x)", aip->ai_acline); > @@ -164,7 +166,7 @@ > printf("%s", line_msg[aip->ai_acline]); > printf("\n"); > printf("Battery status: "); > - if (aip->ai_batt_stat >= 255) > + if (aip->ai_batt_stat == APM_UNKNOWN) > printf("unknown"); > else if (aip->ai_batt_stat > 3) > printf("invalid value (0x%x)", aip->ai_batt_stat); > @@ -172,7 +174,7 @@ > printf("%s", batt_msg[aip->ai_batt_stat]); > printf("\n"); > printf("Remaining battery life: "); > - if (aip->ai_batt_life >= 255) > + if (aip->ai_batt_life == APM_UNKNOWN) > printf("unknown\n"); > else if (aip->ai_batt_life <= 100) > printf("%d%%\n", aip->ai_batt_life); > @@ -194,7 +196,7 @@ > } > if (aip->ai_infoversion >= 1) { > printf("Number of batteries: "); > - if (aip->ai_batteries >= 255) > + if (aip->ai_batteries == (u_int) -1) > printf("unknown\n"); > else { > u_int i; > @@ -208,12 +210,11 @@ > continue; > printf("Battery %d:\n", i); > printf("\tBattery status: "); > - if (aps.ap_batt_flag <= 255 && > - (aps.ap_batt_flag & APM_BATT_NOT_PRESENT)) { > + if (aps.ap_batt_flag & APM_BATT_NOT_PRESENT) { > printf("not present\n"); > continue; > } > - if (aps.ap_batt_stat >= 255) > + if (aps.ap_batt_stat == APM_UNKNOWN) > printf("unknown\n"); > else if (aps.ap_batt_stat > 3) > printf("invalid value (0x%x)\n", > @@ -222,7 +223,7 @@ > printf("%s\n", > batt_msg[aps.ap_batt_stat]); > printf("\tRemaining battery life: "); > - if (aps.ap_batt_life >= 255) > + if (aps.ap_batt_life == APM_UNKNOWN) > printf("unknown\n"); > else if (aps.ap_batt_life <= 100) > printf("%d%%\n", aps.ap_batt_life); > @@ -310,10 +311,8 @@ > } > } > > - if (aip->ai_infoversion >= 1) { > + if (aip->ai_infoversion >= 1 && aip->ai_capabilities != 0xff00) { > printf("APM Capabilities:\n"); > - if (aip->ai_capabilities == 0xff00) > - printf("\tunknown\n"); > if (aip->ai_capabilities & 0x01) > printf("\tglobal standby state\n"); > if (aip->ai_capabilities & 0x02) I agree with the ai_infoversion change above, and from your other mail about changing the number of batteries from 0 to -1. Has nate gave any feedback ? I have also made some recent changes which have been commited which have changed the structure of the apm code. I am willing to change the code from >= 255 to == APM_UNKNOWN if it is decided this is what the correct way and it is agreeded upon. - Liam J. Foy