From asaddi@trantor.philosophysw.com  Sat Apr 22 10:42:03 2000
Return-Path: <asaddi@trantor.philosophysw.com>
Received: from trantor.philosophysw.com (adsl-63-194-91-95.dsl.snfc21.pacbell.net [63.194.91.95])
	by hub.freebsd.org (Postfix) with ESMTP id 063A737B64E
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 22 Apr 2000 10:42:02 -0700 (PDT)
	(envelope-from asaddi@trantor.philosophysw.com)
Received: (from asaddi@localhost)
	by trantor.philosophysw.com (8.9.3/8.9.3) id KAA00536;
	Sat, 22 Apr 2000 10:42:02 -0700 (PDT)
	(envelope-from asaddi)
Message-Id: <200004221742.KAA00536@trantor.philosophysw.com>
Date: Sat, 22 Apr 2000 10:42:02 -0700 (PDT)
From: asaddi@philosophysw.com
Sender: asaddi@trantor.philosophysw.com
Reply-To: asaddi@philosophysw.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: APM: Add flag to disable timer-based BIOS requests [PATCH]
X-Send-Pr-Version: 3.2

>Number:         18162
>Category:       i386
>Synopsis:       APM: Add flag to disable timer-based BIOS requests [PATCH]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          wish
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 22 10:50:02 PDT 2000
>Closed-Date:    Sun Apr 23 10:25:13 PDT 2000
>Last-Modified:  Sun Apr 23 10:25:44 PDT 2000
>Originator:     Allan Saddi
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
Philosophy SoftWorks
>Environment:

FreeBSD trantor.philosophysw.com 4.0-STABLE FreeBSD 4.0-STABLE #42: Sat Apr 22 03:46:31 PDT 2000     root@utopia.philosophysw.com:/usr/src/sys/compile/TRANTOR  i386

>Description:

On my Compaq Presario 1215, the timer-based suspend/standby requests
from BIOS interfere with normal APM operation. For example, when I use
'zzz' to suspend, my laptop will wake up on its own after 15 minutes
due to a BIOS request. (I can only assume it's attempting a suspend-to-
disk operation, which I really haven't gotten to work yet.)

I cannot disable these requests from BIOS setup, hence this patch. I am
using device flag 0x40, which does not appear to be used, to signify
that BIOS timer requests should be disabled from apm_attach().

>How-To-Repeat:

Suspend using 'zzz' when on battery power. Wait 15 minutes.

>Fix:

--- sys/i386/apm/apm.c.orig	Sun Feb  6 06:57:05 2000
+++ sys/i386/apm/apm.c	Sat Apr 22 04:17:55 2000
@@ -219,6 +219,19 @@
 	return (apm_bioscall());
 }
  
+/* enable/disable timer-based standby/suspend requests (APM 1.2 or later) */
+static int
+apm_enable_disable_timer_req(int enable)
+{
+	struct apm_softc *sc = &apm_softc;
+
+	sc->bios.r.eax = (APM_BIOS << 8) | APM_TIMERREQUESTS;
+	sc->bios.r.ebx = PMDV_APMBIOS;
+	sc->bios.r.ecx = enable;
+	sc->bios.r.edx = 0;
+	return (apm_bioscall());
+}
+
 /* get PM event */
 static u_int
 apm_getevent(void)
@@ -1072,6 +1085,16 @@
 			printf("apm: *Warning* engage function failed err=[%x]",
 				(sc->bios.r.eax >> 8) & 0xff);
 			printf(" (Docked or using external power?).\n");
+#endif
+		}
+	}
+
+	/* disable timer requests, if flag 0x40 is set (APM 1.2 or later) */
+	if (sc->intversion >= INTVERSION(1, 2) && (flags & 0x40)) {
+		if (apm_enable_disable_timer_req(0)) {
+#ifdef APM_DEBUG
+			printf("apm: *Warning* timer request function failed! [%x]\n",
+				(sc->bios.r.eax >> 8) & 0xff);
 #endif
 		}
 	}

>Release-Note:
>Audit-Trail:

From: Allan Saddi <asaddi@philosophysw.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: i386/18162: APM: Add flag to disable timer-based BIOS requests
 [PATCH]
Date: Sat, 22 Apr 2000 18:11:12 -0700 (PDT)

 Please close this PR for now. After more extensive testing, I've found
 that it doesn't quite fix the problem.
 
 -- 
 Allan Saddi                         "The Earth is the cradle of mankind,
 asaddi@philosophysw.com              but we cannot live in the cradle
 http://www.philosophysw.com/asaddi/  forever." - K.E. Tsiolkovsky
 
 
State-Changed-From-To: open->closed 
State-Changed-By: nrahlstr 
State-Changed-When: Sun Apr 23 10:25:13 PDT 2000 
State-Changed-Why:  
Closed at submitters request. 
>Unformatted:
