From 861570bb45ef42ce7e658ebb46a5261d164606ac Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 4 Dec 1997 02:40:00 +0000 Subject: [PATCH] The Libretto's BIOS doesn't set edx on the APM_GETPWSTATUS call, so the barrery time remaining is reported as a random number. Initialize edx to 0xffff in this case, and to 0 in all other cases. This change should be benign on other machines. Reviewed by: jdp --- sys/i386/apm/apm.c | 14 +++++++++++--- sys/i386/bios/apm.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sys/i386/apm/apm.c b/sys/i386/apm/apm.c index 39c16018231..372efdf5dbc 100644 --- a/sys/i386/apm/apm.c +++ b/sys/i386/apm/apm.c @@ -15,7 +15,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.64 1997/11/10 14:38:08 nate Exp $ + * $Id: apm.c,v 1.65 1997/11/12 04:12:43 jdp Exp $ */ #include @@ -144,6 +144,7 @@ apm_enable_disable_pm(int enable) else ebx = 0xffff; /* APM version 1.0 only */ ecx = enable; + edx = 0; return apm_int(&eax, &ebx, &ecx, &edx); } @@ -156,6 +157,7 @@ apm_driver_version(int version) eax = (APM_BIOS << 8) | APM_DRVVERSION; ebx = 0x0; ecx = version; + edx = 0; if(!apm_int(&eax, &ebx, &ecx, &edx)) apm_version = eax & 0xffff; } @@ -169,6 +171,7 @@ apm_engage_disengage_pm(int engage) eax = (APM_BIOS << 8) | APM_ENGAGEDISENGAGEPM; ebx = PMDV_ALLDEV; ecx = engage; + edx = 0; return(apm_int(&eax, &ebx, &ecx, &edx)); } @@ -182,6 +185,7 @@ apm_getevent(void) ebx = 0; ecx = 0; + edx = 0; if (apm_int(&eax, &ebx, &ecx, &edx)) return PMEV_NOEVENT; @@ -197,6 +201,7 @@ apm_suspend_system(void) eax = (APM_BIOS << 8) | APM_SETPWSTATE; ebx = PMDV_ALLDEV; ecx = PMST_SUSPEND; + edx = 0; if (apm_int(&eax, &ebx, &ecx, &edx)) { printf("Entire system suspend failure: errcode = %ld\n", @@ -220,6 +225,7 @@ apm_display(int newstate) eax = (APM_BIOS << 8) | APM_SETPWSTATE; ebx = PMDV_DISP0; ecx = newstate ? PMST_APMENABLED:PMST_SUSPEND; + edx = 0; if (apm_int(&eax, &ebx, &ecx, &edx)) { printf("Display off failure: errcode = %ld\n", 0xff & (eax >> 8)); @@ -241,6 +247,7 @@ apm_power_off(void) eax = (APM_BIOS << 8) | APM_SETPWSTATE; ebx = PMDV_ALLDEV; ecx = PMST_OFF; + edx = 0; apm_int(&eax, &ebx, &ecx, &edx); } @@ -433,6 +440,7 @@ apm_get_info(apm_info_t aip) eax = (APM_BIOS << 8) | APM_GETPWSTATUS; ebx = PMDV_ALLDEV; ecx = 0; + edx = 0xffff; /* default to unknown battery time */ if (apm_int(&eax, &ebx, &ecx, &edx)) return 1; @@ -467,7 +475,7 @@ apm_cpu_idle(void) u_long eax, ebx, ecx, edx; eax = (APM_BIOS <<8) | APM_CPUIDLE; - ecx = ebx = 0; + edx = ecx = ebx = 0; apm_int(&eax, &ebx, &ecx, &edx); } /* @@ -499,7 +507,7 @@ apm_cpu_busy(void) u_long eax, ebx, ecx, edx; eax = (APM_BIOS <<8) | APM_CPUBUSY; - ecx = ebx = 0; + edx = ecx = ebx = 0; apm_int(&eax, &ebx, &ecx, &edx); } } diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index 39c16018231..372efdf5dbc 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -15,7 +15,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.64 1997/11/10 14:38:08 nate Exp $ + * $Id: apm.c,v 1.65 1997/11/12 04:12:43 jdp Exp $ */ #include @@ -144,6 +144,7 @@ apm_enable_disable_pm(int enable) else ebx = 0xffff; /* APM version 1.0 only */ ecx = enable; + edx = 0; return apm_int(&eax, &ebx, &ecx, &edx); } @@ -156,6 +157,7 @@ apm_driver_version(int version) eax = (APM_BIOS << 8) | APM_DRVVERSION; ebx = 0x0; ecx = version; + edx = 0; if(!apm_int(&eax, &ebx, &ecx, &edx)) apm_version = eax & 0xffff; } @@ -169,6 +171,7 @@ apm_engage_disengage_pm(int engage) eax = (APM_BIOS << 8) | APM_ENGAGEDISENGAGEPM; ebx = PMDV_ALLDEV; ecx = engage; + edx = 0; return(apm_int(&eax, &ebx, &ecx, &edx)); } @@ -182,6 +185,7 @@ apm_getevent(void) ebx = 0; ecx = 0; + edx = 0; if (apm_int(&eax, &ebx, &ecx, &edx)) return PMEV_NOEVENT; @@ -197,6 +201,7 @@ apm_suspend_system(void) eax = (APM_BIOS << 8) | APM_SETPWSTATE; ebx = PMDV_ALLDEV; ecx = PMST_SUSPEND; + edx = 0; if (apm_int(&eax, &ebx, &ecx, &edx)) { printf("Entire system suspend failure: errcode = %ld\n", @@ -220,6 +225,7 @@ apm_display(int newstate) eax = (APM_BIOS << 8) | APM_SETPWSTATE; ebx = PMDV_DISP0; ecx = newstate ? PMST_APMENABLED:PMST_SUSPEND; + edx = 0; if (apm_int(&eax, &ebx, &ecx, &edx)) { printf("Display off failure: errcode = %ld\n", 0xff & (eax >> 8)); @@ -241,6 +247,7 @@ apm_power_off(void) eax = (APM_BIOS << 8) | APM_SETPWSTATE; ebx = PMDV_ALLDEV; ecx = PMST_OFF; + edx = 0; apm_int(&eax, &ebx, &ecx, &edx); } @@ -433,6 +440,7 @@ apm_get_info(apm_info_t aip) eax = (APM_BIOS << 8) | APM_GETPWSTATUS; ebx = PMDV_ALLDEV; ecx = 0; + edx = 0xffff; /* default to unknown battery time */ if (apm_int(&eax, &ebx, &ecx, &edx)) return 1; @@ -467,7 +475,7 @@ apm_cpu_idle(void) u_long eax, ebx, ecx, edx; eax = (APM_BIOS <<8) | APM_CPUIDLE; - ecx = ebx = 0; + edx = ecx = ebx = 0; apm_int(&eax, &ebx, &ecx, &edx); } /* @@ -499,7 +507,7 @@ apm_cpu_busy(void) u_long eax, ebx, ecx, edx; eax = (APM_BIOS <<8) | APM_CPUBUSY; - ecx = ebx = 0; + edx = ecx = ebx = 0; apm_int(&eax, &ebx, &ecx, &edx); } }