Re: APM minutes/seconds confusion

看板DFBSD_kernel作者時間21年前 (2005/02/20 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
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
文章代碼(AID): #125ty800 (DFBSD_kernel)
文章代碼(AID): #125ty800 (DFBSD_kernel)