diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index 4ad4b1747bd1..016d924caaa4 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -119,6 +120,7 @@ static struct cdevsw apm_cdevsw = { static int apm_suspend_delay = 1; static int apm_standby_delay = 1; +static int apm_swab_batt_minutes = 0; static int apm_debug = 0; #define APM_DPRINT(args...) do { \ @@ -131,6 +133,10 @@ SYSCTL_INT(_machdep, OID_AUTO, apm_suspend_delay, CTLFLAG_RW, &apm_suspend_delay SYSCTL_INT(_machdep, OID_AUTO, apm_standby_delay, CTLFLAG_RW, &apm_standby_delay, 1, ""); SYSCTL_INT(_debug, OID_AUTO, apm_debug, CTLFLAG_RW, &apm_debug, 0, ""); +TUNABLE_INT("machdep.apm_swab_batt_minutes", &apm_swab_batt_minutes); +SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RW, + &apm_swab_batt_minutes, 0, "Byte swap battery time value."); + #ifdef PC98 static __inline void apm_enable_smm(sc) @@ -629,6 +635,8 @@ apm_get_pwstatus(apm_pwstatus_t app) app->ap_batt_flag = (sc->bios.r.ecx >> 8) & 0xff; app->ap_batt_life = sc->bios.r.ecx & 0xff; sc->bios.r.edx &= 0xffff; + if (apm_swab_batt_minutes) + sc->bios.r.edx = __bswap16(sc->bios.r.edx) | 0x8000; if (sc->bios.r.edx == 0xffff) /* Time is unknown */ app->ap_batt_time = -1; else if (sc->bios.r.edx & 0x8000) /* Time is in minutes */