Module Name:    src
Committed By:   isaki
Date:           Sat Jul 16 04:55:35 UTC 2022

Modified Files:
        src/sys/arch/x68k/dev: powsw.c
        src/sys/arch/x68k/x68k: machdep.c

Log Message:
The system should halt if the powerdown fails.
On X680x0 hardware, front power button is an alternate switch.
If the power button is left on, the power will not turn off.
In addition, with this change, power_switch_is_off in powsw.c is
no longer necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x68k/dev/powsw.c
cvs rdiff -u -r1.208 -r1.209 src/sys/arch/x68k/x68k/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x68k/dev/powsw.c
diff -u src/sys/arch/x68k/dev/powsw.c:1.3 src/sys/arch/x68k/dev/powsw.c:1.4
--- src/sys/arch/x68k/dev/powsw.c:1.3	Sat Jul 16 04:49:07 2022
+++ src/sys/arch/x68k/dev/powsw.c	Sat Jul 16 04:55:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: powsw.c,v 1.3 2022/07/16 04:49:07 isaki Exp $	*/
+/*	$NetBSD: powsw.c,v 1.4 2022/07/16 04:55:35 isaki Exp $	*/
 
 /*
  * Copyright (c) 2011 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: powsw.c,v 1.3 2022/07/16 04:49:07 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: powsw.c,v 1.4 2022/07/16 04:55:35 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,8 +50,6 @@ __KERNEL_RCSID(0, "$NetBSD: powsw.c,v 1.
 
 #include "ioconf.h"
 
-extern int power_switch_is_off;		/* XXX should be in .h */
-
 //#define POWSW_DEBUG
 
 #if defined(POWSW_DEBUG)
@@ -96,7 +94,6 @@ static void powsw_attach(device_t, devic
 static int  powsw_intr(void *);
 static void powsw_softintr(void *);
 static void powsw_pswitch_event(void *);
-static void powsw_shutdown_check(void *);
 static void powsw_reset_counter(struct powsw_softc *);
 static void powsw_set_aer(struct powsw_softc *, int);
 
@@ -152,9 +149,6 @@ powsw_attach(device_t parent, device_t s
 	callout_init(&sc->sc_callout, 0);
 	callout_setfunc(&sc->sc_callout, powsw_softintr, sc);
 
-	if (shutdownhook_establish(powsw_shutdown_check, sc) == NULL)
-		panic("%s: can't establish shutdown hook", xname);
-
 	if (intio_intr_establish(desc->vector, xname, powsw_intr, sc) < 0)
 		panic("%s: can't establish interrupt", xname);
 
@@ -256,19 +250,6 @@ powsw_pswitch_event(void *arg)
 }
 
 static void
-powsw_shutdown_check(void *arg)
-{
-	struct powsw_softc *sc = arg;
-	int poweroff;
-
-	poweroff = sc->sc_prev;
-	if (poweroff)
-		power_switch_is_off = 1;
-	DPRINTF("powsw_shutdown_check %s = %d\n",
-	    device_xname(sc->sc_dev), power_switch_is_off);
-}
-
-static void
 powsw_reset_counter(struct powsw_softc *sc)
 {
 

Index: src/sys/arch/x68k/x68k/machdep.c
diff -u src/sys/arch/x68k/x68k/machdep.c:1.208 src/sys/arch/x68k/x68k/machdep.c:1.209
--- src/sys/arch/x68k/x68k/machdep.c:1.208	Sat Jun 25 08:19:01 2022
+++ src/sys/arch/x68k/x68k/machdep.c	Sat Jul 16 04:55:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.208 2022/06/25 08:19:01 isaki Exp $	*/
+/*	$NetBSD: machdep.c,v 1.209 2022/07/16 04:55:35 isaki Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.208 2022/06/25 08:19:01 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.209 2022/07/16 04:55:35 isaki Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -482,7 +482,6 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
 }
 
 int	waittime = -1;
-int	power_switch_is_off = 0;
 
 void
 cpu_reboot(int howto, char *bootstr)
@@ -529,7 +528,6 @@ cpu_reboot(int howto, char *bootstr)
 	/* a) RB_POWERDOWN
 	 *  a1: the power switch is still on
 	 *	Power cannot be removed; simply halt the system (b)
-	 *	Power switch state is checked in shutdown hook
 	 *  a2: the power switch is off
 	 *	Remove the power
 	 * b) RB_HALT
@@ -537,7 +535,7 @@ cpu_reboot(int howto, char *bootstr)
 	 * c) otherwise
 	 *	Reboot
 	 */
-	if (((howto & RB_POWERDOWN) == RB_POWERDOWN) && power_switch_is_off) {
+	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
 		printf("powering off...\n");
 		delay(1000000);
 
@@ -548,10 +546,8 @@ cpu_reboot(int howto, char *bootstr)
 		intio_set_sysport_powoff(0x0f);
 		intio_set_sysport_powoff(0x0f);
 		delay(1000000);
-		printf("WARNING: powerdown failed\n");
-		delay(1000000);
-		/* PASSTHROUGH even if came back */
-	} else if ((howto & RB_HALT) == RB_HALT) {
+	}
+	if ((howto & RB_HALT) != 0) {
 		printf("System halted.  Hit any key to reboot.\n\n");
 		cnpollc(1);
 		(void)cngetc();

Reply via email to