From owner-FreeBSD-tech-jp@jp.freebsd.org  Wed Jun 14 12:56:20 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id MAA19896;
	Wed, 14 Jun 2000 12:56:20 +0900 (JST)
	(envelope-from owner-FreeBSD-tech-jp@jp.FreeBSD.org)
Received: from TYO9.gate.nec.co.jp (TYO9-2.gate.nec.co.jp [202.247.6.44])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id MAA19889
	for <FreeBSD-tech-jp@jp.freebsd.org>; Wed, 14 Jun 2000 12:56:20 +0900 (JST)
	(envelope-from sumitani@bd2.hnes.nec.co.jp)
Received: from mailsv.nec.co.jp (mailsv-le1 [192.168.1.90])
	by TYO9.gate.nec.co.jp (8.9.3/3.7W00052210) with ESMTP id MAA19849
	for <FreeBSD-tech-jp@jp.freebsd.org>; Wed, 14 Jun 2000 12:56:19 +0900 (JST)
Received: from msv1.hnes.nec.co.jp (msv1.hnes.nec.co.jp [133.208.29.138]) by mailsv.nec.co.jp (8.9.3/3.7W-MAILSV-NEC) with ESMTP
	id MAA09161 for <FreeBSD-tech-jp@jp.freebsd.org>; Wed, 14 Jun 2000 12:56:18 +0900 (JST)
Received: from bd2.hnes.nec.co.jp
	by msv1.hnes.nec.co.jp (8.8.8/3.6Wpre2-HNES) with ESMTP id MAA08851;
	Wed, 14 Jun 2000 12:56:18 +0900 (JST)
Received: from bd2.hnes.nec.co.jp ([133.208.184.223]) by bd2.hnes.nec.co.jp (8.8.8+2.7Wbeta7/3.4W3) with ESMTP id MAA22438 for <FreeBSD-tech-jp@jp.freebsd.org>; Wed, 14 Jun 2000 12:55:54 +0900 (JST)
Message-ID: <39470260.F54E9261@bd2.hnes.nec.co.jp>
Date: Wed, 14 Jun 2000 12:56:16 +0900
From: "K.Sumitani" <sumitani@bd2.hnes.nec.co.jp>
X-Mailer: Mozilla 4.7 [ja] (WinNT; I)
X-Accept-Language: ja,en
MIME-Version: 1.0
To: FreeBSD-tech-jp@jp.freebsd.org
Content-Type: multipart/mixed;
 boundary="------------070F742E750AE8F64C7EE0B7"
Reply-To: FreeBSD-tech-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: FreeBSD-tech-jp 2819
Subject: [FreeBSD-tech-jp 2819] APM-BIOS not work on SMP
Errors-To: owner-FreeBSD-tech-jp@jp.freebsd.org
Sender: owner-FreeBSD-tech-jp@jp.freebsd.org
X-Originator: sumitani@bd2.hnes.nec.co.jp

This is a multi-part message in MIME format.
--------------070F742E750AE8F64C7EE0B7
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B$9$_$?$K!w(BNEC$B%=%U%H%&%'%"KLN&$G$9!#(B

$B!t(B $B$^$@(BAPM$B<~$j$G$D$+$^$C$F$$$^$9!#(B

$B@hF|$N=$@5$G(BPower-Off$B$G$-$k$h$&$K$J$C$?$H;W$C$F$$$?$N$G$9$,!"(B
$BEE8;$,Mn$A$J$$$3$H$,$"$k$N$K5$$E$-$^$7$?!#(B
              $B!0!0!0!0!0(B
$BD4$Y$F$_$?$H$3$m!"(BTyan Tiger100$B$N(BAPM-BIOS$B$O!"(BCPU0$B0J30$+$i$N(B
$B8F$S=P$7$G$OAGLa$j$7$F$$$^$7$?!#(B

suspend$B$b6vA3(BCPU0$B$+$i(BAPM-BIOS$B$r8F$s$@;~$O@5$7$/F0$$$F(Bresume
$B$G$-$k$N$G$9$,!"(BCPU1$B$+$i$@$H2?$b$7$J$$>uBV$G$9!#(B

$B5$$KF~$i$J$$$N$GE:IU$N$h$&$K!V(BAPM-BIOS$B$r8F$V$N$OI,$:(BCPU0$B!W(B
$B$K$7$F$_$^$7$?!#(B
/sys/i386/apm/apm.c $B$N:9J,$G$9!#(B

$B!V;~!9!WF0$+$J$$>l9g$O$3$l$G$&$^$/$$$/$+$b$7$l$^$;$s!#(B

[FreeBSD-tech-jp 2809]$B$N$$$o$5$-$5$s$N%Q%C%A$OITMW$G$9!#(B
[FreeBSD-tech-jp 2791]$B$N;d$N=$@5$OI,MW$G$9!#(B

$B$5$i$K?J$a$F!"(Bsuspend$BA0$K(BAP(CPU0$B0J30(B)$B$r;_$a$F$7$^$($PNI$$$N(B
$B$G$9$,!V$&$D$/$7$$!W<jCJ$,8+$D$+$i$J$+$C$?$N$G!D(B
--------------070F742E750AE8F64C7EE0B7
Content-Type: text/plain; charset=iso-2022-jp;
 name="apm.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="apm.c.diff"

*** apm.c.orig	Sun Feb  6 23:57:05 2000
--- apm.c	Wed Jun 14 09:19:27 2000
***************
*** 44,49 ****
--- 44,53 ----
  #include <machine/pc/bios.h>
  #include <machine/vm86.h>
  
+ #ifdef SMP
+ #include <machine/smp.h>		/* cpuid, smp_rendezvous() */
+ #endif
+ 
  #include <i386/apm/apm.h>
  
  /* Used by the apm_saver screen saver module */
***************
*** 237,243 ****
   
  /* suspend entire system */
  static int
! apm_suspend_system(int state)
  {
  	struct apm_softc *sc = &apm_softc;
   
--- 241,247 ----
   
  /* suspend entire system */
  static int
! apm_do_suspend_system(int state)
  {
  	struct apm_softc *sc = &apm_softc;
   
***************
*** 254,259 ****
--- 258,295 ----
   	return 0;
  }
  
+ #ifdef SMP
+ static volatile int apm_smp_suspend_flag;
+ 
+ static void
+ apm_smp_suspend_system(void *p)
+ {
+ 	if (cpuid == 0) {
+ 		*(int *)p = apm_do_suspend_system( *(int *)p );
+ 		apm_smp_suspend_flag = 0;
+ 	} else {
+ 		while (apm_smp_suspend_flag)
+ 			;
+ 	}
+ 	return;
+ }
+ #endif
+ 
+ static int
+ apm_suspend_system(int state)
+ {
+ #ifdef SMP
+ 	int r;
+ 
+ 	apm_smp_suspend_flag = 1;
+ 	smp_rendezvous( NULL, apm_smp_suspend_system, NULL, (void *)&state );
+ 
+ 	return r;
+ #else
+ 	return apm_do_suspend_system(state);
+ #endif
+ }
+ 
  /* Display control */
  /*
   * Experimental implementation: My laptop machine can't handle this function
***************
*** 281,298 ****
   * Turn off the entire system.
   */
  static void
! apm_power_off(void *junk, int howto)
  {
  	struct apm_softc *sc = &apm_softc;
  
- 	/* Not halting powering off, or not active */
- 	if (!(howto & RB_POWEROFF) || !apm_softc.active)
- 		return;
  	sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
  	sc->bios.r.ebx = PMDV_ALLDEV;
  	sc->bios.r.ecx = PMST_OFF;
  	sc->bios.r.edx = 0;
  	(void) apm_bioscall();
  }
  
  /* APM Battery low handler */
--- 317,358 ----
   * Turn off the entire system.
   */
  static void
! apm_do_power_off(void)
  {
  	struct apm_softc *sc = &apm_softc;
  
  	sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
  	sc->bios.r.ebx = PMDV_ALLDEV;
  	sc->bios.r.ecx = PMST_OFF;
  	sc->bios.r.edx = 0;
  	(void) apm_bioscall();
+ 	printf("power off failure: returned from APM-BIOS\n");
+ }
+ 
+ #ifdef SMP
+ static void
+ apm_smp_power_off(void *arg)
+ {
+ 	if (cpuid != 0) {
+ 		for ( ; ; ) ;
+ 	}
+  	apm_do_power_off();
+ }
+ #endif
+ 
+ static void
+ apm_power_off(void *junk, int howto)
+ {
+ 	/* Not halting powering off, or not active */
+ 	if (!(howto & RB_POWEROFF) || !apm_softc.active)
+ 		return;
+ 
+ #ifdef SMP
+ 	smp_rendezvous( NULL, apm_smp_power_off, NULL, NULL );
+ 	return;
+ #else
+ 	apm_do_power_off();
+ #endif
  }
  
  /* APM Battery low handler */

--------------070F742E750AE8F64C7EE0B7--

