Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 May 1998 14:30:08 +0200 (MET DST)
From:      Ugo Paternostro <paterno@dsi.UNIFI.IT>
To:        Stefan `Sec` Zehl <sec@42.org>
Cc:        stable@FreeBSD.ORG
Subject:   RE: apm
Message-ID:  <XFMail.980501143008.paterno@dsi.unifi.it>
In-Reply-To: <19980427101124.A28649@matrix.42.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
[moved from -mobile to -stable as I think no mobile computer has an ATX M/B :-)]

On 27-Apr-98 Stefan `Sec` Zehl wrote about "apm":
> I just bought a new Computer with an ATX Board inside. This board
> supports apm. I installed 2.2.6-STABLE and enabled apm and all worked
> fine, so far. However "halt -p" doesn't work, and i found no possibility

It is not suppoted on -STABLE. You may want to try my patches, that implement
"shutdown -h" soft power off (attached below). This requires an APM BIOS and an
ATX M/B+PS. I'm running with this patches since 26th, and I found no problems.

To apply the patches, cd /usr/src and issue a "patch <apm-power-off.diff", than
rebuild your kernel and reboot with your new kernel. That's all.

Maybe someone should commit the patches to the -stable tree, in this ATX
days... :-)

> for setting the 'power up on timer' feature, which i can access when
> booting.

Isn't that feature a BIOS related one? I mean: don't you have to instruct the
BIOS about the time on which the machine will be powered on?

I have a section on my BIOS that does that, but I didn't try it yet. BTW, my
M/B is an ASUS SP98AGP-X, with Award BIOS.

> Last, but not least, would it be better if I switched to 3.0 when doing
> someting in that area ?

Yes: I grabbed the soft power off code directly from -current... :-)

>     Sec

Bye, UP


[-- Attachment #2 --]
Index: sys/i386/apm/apm.c
===================================================================
RCS file: /mnt/xchange_2/ncvs/src/sys/i386/apm/apm.c,v
retrieving revision 1.49.2.2
diff -u -r1.49.2.2 apm.c
--- apm.c	1997/11/10 14:40:40	1.49.2.2
+++ apm.c	1998/04/26 17:45:47
@@ -229,6 +229,21 @@
 	return 0;
 }
 
+/*
+ * Turn off the entire system.
+ */
+void
+apm_power_off(void)
+{
+	u_long eax, ebx, ecx;
+
+	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
Index: sys/i386/include/apm_bios.h
===================================================================
RCS file: /mnt/xchange_2/ncvs/src/sys/i386/include/apm_bios.h,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 apm_bios.h
--- apm_bios.h	1997/11/04 19:02:35	1.12.2.2
+++ apm_bios.h	1998/04/26 17:16:40
@@ -156,6 +156,7 @@
 void apm_hook_disestablish (int apmh, struct apmhook *);
 void apm_cpu_idle(void);
 void apm_cpu_busy(void);
+void apm_power_off(void);
 
 #endif /* !ASSEMBLER && !INITIALIZER */
 
Index: sys/i386/include/md_var.h
===================================================================
RCS file: /mnt/xchange_2/ncvs/src/sys/i386/include/md_var.h,v
retrieving revision 1.10.2.3
diff -u -r1.10.2.3 md_var.h
--- md_var.h	1998/03/06 23:44:45	1.10.2.3
+++ md_var.h	1998/04/26 17:22:24
@@ -60,6 +60,7 @@
 void	bcopyb __P((const void *from, void *to, size_t len));
 void	cpu_reset __P((void));
 void	cpu_halt __P((void));
+void	cpu_power_down __P((void));
 void	doreti_iret __P((void)) __asm(__STRING(doreti_iret));
 void	doreti_iret_fault __P((void)) __asm(__STRING(doreti_iret_fault));
 void	doreti_popl_ds __P((void)) __asm(__STRING(doreti_popl_ds));
Index: sys/i386/i386/machdep.c
===================================================================
RCS file: /mnt/xchange_2/ncvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.209.2.22
diff -u -r1.209.2.22 machdep.c
--- machdep.c	1998/03/23 05:30:29	1.209.2.22
+++ machdep.c	1998/04/26 17:20:11
@@ -38,6 +38,7 @@
  *	$Id: machdep.c,v 1.209.2.22 1998/03/23 05:30:29 jkh Exp $
  */
 
+#include "apm.h"
 #include "npx.h"
 #include "opt_bounce.h"
 #include "opt_cpu.h"
@@ -685,6 +686,17 @@
 {
 	for (;;)
 		__asm__ ("hlt");
+}
+
+/*
+ * Turn the power off.
+ */
+void
+cpu_power_down(void)
+{
+#if NAPM > 0
+	apm_power_off();
+#endif
 }
 
 /*
Index: sys/kern/kern_shutdown.c
===================================================================
RCS file: /mnt/xchange_2/ncvs/src/sys/kern/kern_shutdown.c,v
retrieving revision 1.10.2.1
diff -u -r1.10.2.1 kern_shutdown.c
--- kern_shutdown.c	1997/08/11 02:04:14	1.10.2.1
+++ kern_shutdown.c	1998/04/26 17:24:44
@@ -249,6 +249,7 @@
 	}
 	splhigh();
 	if (howto & RB_HALT) {
+		cpu_power_down();
 		printf("\n");
 		printf("The operating system has halted.\n");
 		printf("Please press any key to reboot.\n\n");
help

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