From 2decd767716dac72fa72763cb6a2f8a70a92e786 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Fri, 16 Dec 1994 06:16:30 +0000 Subject: [PATCH] Be much more carefull about what we leave in unused registers when we call the APM-bios. This stabilizes a couple of APM bioses quite a bit. They all make the mistake of going into 16-bit mode, without clearing the top half of the 32bit registers. Later they do a | movw %si,$0x7331 | movw %ax,0x6(%si) or something along those lines and crash and burn, because their segment is already relocated, so adding 0xf0171ce9 to the base of it is bad news. At least SystemSoft is guilty of this bummer. --- sys/i386/apm/apm.c | 14 ++++++++++++-- sys/i386/bios/apm.c | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sys/i386/apm/apm.c b/sys/i386/apm/apm.c index d419da442b9..99c3582e995 100644 --- a/sys/i386/apm/apm.c +++ b/sys/i386/apm/apm.c @@ -13,7 +13,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.6 1994/11/07 04:23:58 phk Exp $ + * $Id: apm.c,v 1.7 1994/11/15 14:09:18 bde Exp $ */ #include "apm.h" @@ -92,11 +92,18 @@ apm_int(u_long *eax,u_long *ebx,u_long *ecx) u_long cf; __asm ("pushl %%ebp pushl %%edx + pushl %%esi + pushl %%edi xorl %3,%3 + movl %%edi,%3 + movl %%esi,%3 lcall _apm_addr jnc 1f incl %3 - 1: popl %%edx + 1: + popl %%edi + popl %%esi + popl %%edx popl %%ebp" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=D" (cf) : "0" (*eax), "1" (*ebx), "2" (*ecx) @@ -175,6 +182,8 @@ apm_getevent(void) eax = (APM_BIOS<<8) | APM_GETPMEVENT; + ebx = 0; + ecx = 0; if (apm_int(&eax,&ebx,&ecx)) return PMEV_NOEVENT; @@ -243,6 +252,7 @@ apm_get_info(apm_info_t aip) eax = (APM_BIOS<<8)|APM_GETPWSTATUS; ebx = PMDV_ALLDEV; + ecx = 0; if (apm_int(&eax,&ebx,&ecx)) return 1; diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index d419da442b9..99c3582e995 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -13,7 +13,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.6 1994/11/07 04:23:58 phk Exp $ + * $Id: apm.c,v 1.7 1994/11/15 14:09:18 bde Exp $ */ #include "apm.h" @@ -92,11 +92,18 @@ apm_int(u_long *eax,u_long *ebx,u_long *ecx) u_long cf; __asm ("pushl %%ebp pushl %%edx + pushl %%esi + pushl %%edi xorl %3,%3 + movl %%edi,%3 + movl %%esi,%3 lcall _apm_addr jnc 1f incl %3 - 1: popl %%edx + 1: + popl %%edi + popl %%esi + popl %%edx popl %%ebp" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=D" (cf) : "0" (*eax), "1" (*ebx), "2" (*ecx) @@ -175,6 +182,8 @@ apm_getevent(void) eax = (APM_BIOS<<8) | APM_GETPMEVENT; + ebx = 0; + ecx = 0; if (apm_int(&eax,&ebx,&ecx)) return PMEV_NOEVENT; @@ -243,6 +252,7 @@ apm_get_info(apm_info_t aip) eax = (APM_BIOS<<8)|APM_GETPWSTATUS; ebx = PMDV_ALLDEV; + ecx = 0; if (apm_int(&eax,&ebx,&ecx)) return 1;