From 22062c0c34dd2eed6f2769bafbb554edbc227624 Mon Sep 17 00:00:00 2001 From: Michael Shalayeff Date: Sun, 22 Dec 2002 17:12:45 +0000 Subject: better handling of bigendian batteries; problem noticed by blovett@bsdguru.com --- sys/arch/i386/i386/apm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/arch/i386') 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(®s)) { powerp->minutes_left = BATT_REMAINING(®s); - if (apm_flags & APM_BEBATT) + if (apm_bebatt) powerp->minutes_left = swap16(powerp->minutes_left); } -- cgit v1.2.3