Date: Tue, 15 Dec 1998 19:17:18 +0100 (CET) From: "Walter C. Pelissero" <wcp@luppolo.lpds.sublink.org> To: hackers@FreeBSD.ORG Subject: Auto power off for poor people Message-ID: <13942.39950.631562.882793@luppolo.lpds.sublink.org>
next in thread | raw e-mail | index | archive | help
Since I think it might be of general interest (I saw a few requests in
freebsd-questions), here are the patches I made to a 2.2.7 system to
get the power-off-on-shutdown feature.
I have to admit this is a dirty hack made in hurry just to have my ATX
mainboard do power off on shutdown. It consists basically of code
cut'n'pasted from 3.0. BTW it introduces a warning message during
compilation of kern_shutdown.c. Who cares?
While at this. It would be nice to have a shutdown on power-off
switch in FreeBSD 3.0. Judging from the switch block in
apm_processevent() function it seems there is not even an hook for a
daemon doing this kind of job. PMEV_POWERSTATECHANGE is ignored. Am
I wrong?
*** /sys/kern/kern_shutdown.c.dist Tue Dec 15 18:22:15 1998
--- /sys/kern/kern_shutdown.c Tue Dec 15 18:22:15 1998
***************
*** 226,231 ****
--- 226,235 ----
}
splhigh();
if (howto & RB_HALT) {
+ /* Kludge for APM power off.
+ Waiting for FreeBSD 3.0 -wcp12/15/98. */
+ apm_power_off(0, 0);
+
printf("\n");
printf("The operating system has halted.\n");
printf("Please press any key to reboot.\n\n");
*** /sys/i386/apm/apm.c.dist Tue Dec 15 18:58:55 1998
--- /sys/i386/apm/apm.c Tue Dec 15 18:58:56 1998
***************
*** 237,242 ****
--- 237,259 ----
return 0;
}
+ /*
+ * Turn off the entire system.
+ */
+ void
+ apm_power_off(int howto, void *junk)
+ {
+ u_long eax, ebx, ecx;
+
+ /* Not halting powering off, or not active */
+ if (!apm_softc.active)
+ return;
+ eax = (APM_BIOS << 8) | APM_SETPWSTATE;
+ ebx = PMDV_ALLDEV;
+ ecx = PMST_OFF;
+ apm_int(&eax, &ebx, &ecx);
+ }
+
/* APM Battery low handler */
static void
apm_battery_low(struct apm_softc *sc)
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?13942.39950.631562.882793>
