Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Sep 1998 10:05:43 -0700 (PDT)
From:      Nick Sayer <nsayer@quack.kfu.com>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/7812: APM machines should attempt to power down at halt
Message-ID:  <199809021705.KAA24303@quack.kfu.com>

next in thread | raw e-mail | index | archive | help

>Number:         7812
>Category:       kern
>Synopsis:       APM machines should attempt to power down at halt
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep  2 10:10:00 PDT 1998
>Last-Modified:
>Originator:     Nick Sayer
>Organization:
Just me
>Release:        FreeBSD 2.2.7-RELEASE i386
>Environment:

>Description:

Some laptops and ATX machines can power themselves off under APM
control. When such machines are halted, they should at least try
to power themselves off if APM events are enabled. If the attempt
fails, this code will fall through to the traditional 'press any
key to reboot' prompt.

>How-To-Repeat:

>Fix:

--- apm.c-	Mon Jul  6 22:22:36 1998
+++ apm.c	Wed Sep  2 10:00:07 1998
@@ -24,6 +24,7 @@
 #include <sys/devfsext.h>
 #endif /*DEVFS*/
 #include <sys/systm.h>
+#include <sys/reboot.h>
 #include <sys/time.h>
 #include <i386/isa/isa_device.h>
 #include <machine/apm_bios.h>
@@ -38,6 +39,7 @@
 static int apm_display __P((int newstate));
 static int apm_int __P((u_long *eax, u_long *ebx, u_long *ecx));
 static void apm_resume __P((void));
+static void apm_powerdown __P((int howlong,void *ignore));
 
 /* static data */
 struct apm_softc {
@@ -408,6 +410,23 @@
 		apm_execute_hook(hook[APM_HOOK_RESUME]);
 }
 
+/*
+ * Some latops and ATX machines can power themselves off.
+ */
+void
+apm_powerdown(int howto, void *ignore)
+{
+	u_long eax, ebx, ecx;
+
+	if (howto & RB_HALT)
+	{
+		eax = (APM_BIOS << 8) | APM_SETPWSTATE;
+		ebx = PMDV_ALLDEV;
+		ecx = PMST_OFF;
+
+		apm_int(&eax, &ebx, &ecx); /* ignore errors */
+	}
+}
 
 /* get APM information */
 static int
@@ -511,6 +530,7 @@
 	if (sc->initialized) {
 		sc->active = 1;
 		apm_timeout(sc);
+		at_shutdown(apm_powerdown,NULL,SHUTDOWN_POST_SYNC);
 	}
 }
 
@@ -526,6 +546,7 @@
 	if (sc->initialized) {
 		untimeout(apm_timeout, NULL);
 		sc->active = 0;
+		rm_at_shutdown(apm_powerdown,NULL);
 	}
 }
 
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809021705.KAA24303>