From owner-freebsd-hackers Tue Dec 15 19:31:00 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA13241 for freebsd-hackers-outgoing; Tue, 15 Dec 1998 19:31:00 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from systemy.systemy.it (systemy.systemy.it [194.20.140.20]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id TAA13236 for ; Tue, 15 Dec 1998 19:30:56 -0800 (PST) (envelope-from luppolo.lpds.sublink.org!wcp@systemy.systemy.it) Received: by systemy.systemy.it (Smail3.1.29.1 #4) id m0zq7fk-0003zBC; Wed, 16 Dec 98 04:30 MET Received: from luppolo.lpds.sublink.org (luppolo.lpds.sublink.org [192.9.200.50]) by radikkio.lpds.sublink.org (8.8.7/8.8.7) with ESMTP id TAA16130 for ; Tue, 15 Dec 1998 19:11:38 +0100 (CET) (envelope-from wcp@luppolo.lpds.sublink.org) Received: (from wcp@localhost) by luppolo.lpds.sublink.org (8.8.5/8.8.5) id TAA00393; Tue, 15 Dec 1998 19:17:18 +0100 (CET) From: "Walter C. Pelissero" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 15 Dec 1998 19:17:18 +0100 (CET) To: hackers@FreeBSD.ORG Subject: Auto power off for poor people X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <13942.39950.631562.882793@luppolo.lpds.sublink.org> Reply-To: wcp@lpds.sublink.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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