summaryrefslogtreecommitdiffstats
path: root/sys/i386/bios
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-06-22 05:08:10 +0000
committermdodd <mdodd@FreeBSD.org>2003-06-22 05:08:10 +0000
commitfa74d565f1d2449ff39d71733ad38e86bd7c66a0 (patch)
tree571973a03acfbd5be863356734e2e4d2bcdb4dcc /sys/i386/bios
parent768b08c167a71febe6dfe07d6208897dff50feb7 (diff)
downloadFreeBSD-src-fa74d565f1d2449ff39d71733ad38e86bd7c66a0.zip
FreeBSD-src-fa74d565f1d2449ff39d71733ad38e86bd7c66a0.tar.gz
Implement a loader tunable/sysctl to allow the user to request that
the APM driver byte-swap battery time values. (For broken laptops.) PR: i386/42439 Submitted by: Bruce M Simpson <bms@spc.org>
Diffstat (limited to 'sys/i386/bios')
-rw-r--r--sys/i386/bios/apm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c
index 4ad4b17..016d924 100644
--- a/sys/i386/bios/apm.c
+++ b/sys/i386/bios/apm.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <machine/apm_bios.h>
#include <machine/clock.h>
+#include <machine/endian.h>
#include <machine/pc/bios.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
@@ -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 */
OpenPOWER on IntegriCloud