summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-12-22 17:12:45 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-12-22 17:12:45 +0000
commit22062c0c34dd2eed6f2769bafbb554edbc227624 (patch)
treed5d38a9ef7f8e43d73c9aab56dd031e83a1f79cf /sys/arch/i386
parent0aa084c1341bb31f2aa3ea7e9b8e1e5c4480e7b5 (diff)
better handling of bigendian batteries; problem noticed by blovett@bsdguru.com
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/apm.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c
index 86dde60358e..90f9753966a 100644
--- a/sys/arch/i386/i386/apm.c
+++ b/sys/arch/i386/i386/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.55 2002/12/18 22:53:06 mickey Exp $ */
+/* $OpenBSD: apm.c,v 1.56 2002/12/22 17:12:44 mickey Exp $ */
/*-
* Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved.
@@ -146,6 +146,7 @@ u_char apm_majver;
u_char apm_minver;
int apm_dobusy = 1;
int apm_doidle = 1;
+int apm_bebatt = 0;
struct {
u_int32_t entry;
@@ -307,7 +308,7 @@ apm_power_print (sc, regs)
printf(", charging");
if (BATT_REM_VALID(regs)) {
int life = BATT_REMAINING(regs);
- if (apm_flags & APM_BEBATT)
+ if (apm_bebatt)
life = swap16(life);
printf(", estimated %d:%02d hours",
life / 60, life % 60);
@@ -801,6 +802,8 @@ apmattach(parent, self, aux)
extern int apm_cli; /* from apmcall.S */
apm_cli = 0;
}
+ if (sc->sc_dev.dv_cfdata->cf_flags & APM_BEBATT)
+ apm_bebatt = 1;
apm_ep.seg = GSEL(GAPM32CODE_SEL,SEL_KPL);
apm_ep.entry = ap->apm_entry;
cbase = min(ap->apm_code32_base, ap->apm_code16_base);
@@ -1086,7 +1089,7 @@ apmioctl(dev, cmd, data, flag, p)
powerp->battery_state = APM_BATT_UNKNOWN;
if (BATT_REM_VALID(&regs)) {
powerp->minutes_left = BATT_REMAINING(&regs);
- if (apm_flags & APM_BEBATT)
+ if (apm_bebatt)
powerp->minutes_left =
swap16(powerp->minutes_left);
}