DragonFly BSD
DragonFly kernel List (threaded) for 2005-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: APM minutes/seconds confusion


From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Sat, 19 Feb 2005 23:09:58 +0900

On Sat, Feb 19, 2005 at 12:46:05PM +0000, Liam J. Foy wrote:
> 	Before I start, I am no APM expert =)

Neither am I :)

> 	If I am correct, this applies to both DragonFly BSD and FreeBSD.
> The problem is that most applications which call upon APM for battery
> information such as time remaining assume it to always be in seconds.
> 
> However, in i386/apm/apm.c we see:
> 
> /* get power status per battery */
> static int
> apm_get_pwstatus(apm_pwstatus_t app)
> {

				:

> 	sc->bios.r.edx &= 0xffff;
> 	if (sc->bios.r.edx == 0xffff)	/* Time is unknown */
> 		app->ap_batt_time = -1;
> 
> 	<-LOOK HERE->
> 	else if (sc->bios.r.edx & 0x8000)	/* Time is in minutes */
> 		app->ap_batt_time = (sc->bios.r.edx & 0x7fff) * 60;
> 	<-LOOK HERE->
> 	else				/* Time is in seconds */
> 		app->ap_batt_time = sc->bios.r.edx;
> 
> 	return 0;
> }
> 
> From what I see, the time can be returned in minutes. Do you all agree?
> 
> If this is returned in minutes, it will lead to the incorrect time being
> shown and calculated (most things assume seconds e.g apm).

The BIOS can return the time either in minutes or seconds. When it
returns the time in minutes, the bit 15 of DX register is set to 1
and bits [14..0] represents the remaining time in minutes(so you have to
multiply it by 60 to get the time in seconds). Otherwise the time returned
in bits[14..0] is in seconds, and you need no conversion.

I'm talking based on the following document(too bad it's an .rtf file).
http://www.osdever.net/cottontail/downloads/docs/APMV12.zip



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]