From sec@42.org Tue Mar 23 05:07:18 1999
Return-Path: <sec@42.org>
Received: from matrix.42.org (matrix.42.org [194.246.250.200])
	by hub.freebsd.org (Postfix) with ESMTP id 232BC14C2B
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 23 Mar 1999 05:07:14 -0800 (PST)
	(envelope-from sec@42.org)
Received: (from sec@localhost)
	by matrix.42.org (8.8.8/8.8.5) id OAA13360
	(sender <sec>); Tue, 23 Mar 1999 14:06:54 +0100 (CET)
Message-Id: <199903231306.OAA13360@matrix.42.org>
Date: Tue, 23 Mar 1999 14:06:54 +0100 (CET)
From: Stefan `Sec` Zehl <sec@42.org>
Reply-To: sec@42.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: apm poweroff fails on 3.1 (worked on 2.2.6)
X-Send-Pr-Version: 3.2

>Number:         10746
>Category:       kern
>Synopsis:       apm poweroff fails on 3.1 (worked on 2.2.6)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 23 05:10:00 PST 1999
>Closed-Date:    Sat May 1 12:07:31 PDT 1999
>Last-Modified:  Sat May  1 12:08:42 PDT 1999
>Originator:     Stefan `Sec` Zehl
>Release:        FreeBSD 2.2.7-STABLE i386
>Organization:
>Environment:

My 3.1-STable box. make world'ed 2 days ago.

FreeBSD btl.42.org 3.1-STABLE FreeBSD 3.1-STABLE #0: Tue Mar 23 02:25:33 CET 1999     sec@btl.42.org:/usr/src/sys/compile/BTL  i386

>Description:

on 2.2.6 I applied the apm_poweroff patch, and my box would power off on 
"halt -p" without problem.

This is what i used on 2.2.6:

--- sys/i386/apm/apm.c.orig	Mon Nov 10 15:40:40 1997
+++ sys/i386/apm/apm.c	Tue May 12 16:39:02 1998
@@ -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


now on 3.1 (where the code is already there) it doesn't work anymore.

I added a few debug statements liek that: 
/*
 * Turn off the entire system.
 */
static void
apm_power_off(int howto, void *junk)
{
        u_long eax, ebx, ecx, edx;

        printf("trying to shutdown\n");
        /* Not halting powering off, or not active */
        if (!(howto & RB_POWEROFF) || !apm_softc.active)
                return;
        eax = (APM_BIOS << 8) | APM_SETPWSTATE;
        ebx = PMDV_ALLDEV;
        ecx = PMST_OFF;
        edx = 0;
        printf("actually trying to shutdown\n");
        if(apm_int(&eax, &ebx, &ecx, &edx))
                printf("Entire system shutdown failure: errcode = %ld\n",
                                0xff & (eax >> 8));

}

and all I get on 'halt -p' is:

syncing disks... 10 10 done
trying to shutdown
actually trying to shutdown
Entire system shutdown failure: errcode = 96

The operating system has halted.
Plese press any key to reboot.

>How-To-Repeat:

halt -p

>Fix:
	
none known.

>Release-Note:
>Audit-Trail:

From: Sheldon Hearn <sheldonh@iafrica.com>
To: sec@42.org
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/10746: apm poweroff fails on 3.1 (worked on 2.2.6)
Date: Tue, 23 Mar 1999 21:39:24 +0200

 Hi Stefan,
 
 What deos dmesg have to say about apm0?
 
 Ciao,
 Sheldon.
 

From: Stefan `Sec` Zehl <sec@42.org>
To: Sheldon Hearn <sheldonh@iafrica.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/10746: apm poweroff fails on 3.1 (worked on 2.2.6)
Date: Tue, 23 Mar 1999 23:42:23 +0100

 On Tue, Mar 23, 1999 at 09:39:24PM +0200, Sheldon Hearn wrote:
 > 
 > Hi Stefan,
 > 
 > What deos dmesg have to say about apm0?
 
 Whoops, i forogt to add this:
 
 btl:~>dmesg|grep apm
 apm0 flags 0x31 on isa
 apm: found APM BIOS version 1.2
 btl:~>apm
 APM version: 1.2
 APM Managment: Enabled
 AC Line status: on-line
 Battery status: unknown
 Remaining battery life: unknown
 Remaining battery time: unknown
 Number of batteries: 0
 Resume timer: disabled
 Resume on ring indicator: disabled
 APM Capacities:
         global standby state
         global suspend state
         resume timer from standby
         resume timer from suspend
 
 CU,
     Sec
 -- 
 In 1968 it took the computing-Power of 2 C-64 to fly a rocket to the moon.
 Now, 1997 it takes the Power of a Pentium 133 to run Microsoft Windows 95.
                     Something must have gone wrong.
 

From: Stefan `Sec` Zehl <sec@42.org>
To: Sheldon Hearn <sheldonh@iafrica.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/10746: apm poweroff fails on 3.1 (worked on 2.2.6)
Date: Thu, 29 Apr 1999 19:46:48 +0200

 X-Sec-Matche default
 
 I recompiled my kernel with the source from yesterday, AND modified my
 apm config line to: 
 
 btl:~>grep apm /usr/src/sys/i386/conf/BTL
 device          apm0    at isa? # Advanced Power Management
 
 
 Now everything works again. You can close the PR now.
 
 CU,
     Sec
 -- 
 The Feynman problem solving Algorithm
 			1) Write down the problem
 			2) Think real hard
 			3) Write down the answer
 
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sat May 1 12:07:31 PDT 1999 
State-Changed-Why:  
Originator notes he fixed the problem by changing the apm entry 
in his kernel config file and rebuilding. 
>Unformatted:
