Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - Introduce a new global kernel variable "shutting_down"...
details: https://anonhg.NetBSD.org/src/rev/256e74c896a9
branches: trunk
changeset: 466768:256e74c896a9
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Jan 01 22:57:16 2020 +0000
description:
- Introduce a new global kernel variable "shutting_down" to indicate that
the system is shutting down or rebooting.
- Set this global in a new function called kern_reboot(), which is currently
just a basic wrapper around cpu_reboot().
- Call kern_reboot() instead of cpu_reboot() almost everywhere; a few
places remain where it's still called directly, but those are in early
pre-main() machdep locations.
Eventually, all of the various cpu_reboot() functions should be re-factored
and common functionality moved to kern_reboot(), but that's for another day.
diffstat:
sys/arch/arm/sunxi/sunxi_thermal.c | 6 +++---
sys/arch/sparc64/dev/sbus.c | 6 +++---
sys/compat/common/kern_xxx_12.c | 6 +++---
sys/ddb/db_command.c | 8 ++++----
sys/dev/sysmon/swwdog.c | 6 +++---
sys/dev/sysmon/sysmon_power.c | 10 +++++-----
sys/external/bsd/drm2/include/linux/reboot.h | 4 ++--
sys/kern/init_main.c | 11 ++++++-----
sys/kern/kern_reboot.c | 24 +++++++++++++++++++++---
sys/kern/kern_subr.c | 12 ++++++------
sys/kern/subr_prf.c | 6 +++---
sys/sys/kernel.h | 3 ++-
sys/sys/reboot.h | 6 +++---
13 files changed, 64 insertions(+), 44 deletions(-)
diffs (truncated from 409 to 300 lines):
diff -r 9654f720a3cd -r 256e74c896a9 sys/arch/arm/sunxi/sunxi_thermal.c
--- a/sys/arch/arm/sunxi/sunxi_thermal.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/arch/arm/sunxi/sunxi_thermal.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_thermal.c,v 1.7 2019/01/02 19:32:41 jmcneill Exp $ */
+/* $NetBSD: sunxi_thermal.c,v 1.8 2020/01/01 22:57:16 thorpej Exp $ */
/*-
* Copyright (c) 2016-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.7 2019/01/02 19:32:41 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_thermal.c,v 1.8 2020/01/01 22:57:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -445,7 +445,7 @@
device_printf(sc->dev,
"WARNING - current temperature exceeds safe limits\n");
- cpu_reboot(RB_POWERDOWN, NULL);
+ kern_reboot(RB_POWERDOWN, NULL);
}
static void
diff -r 9654f720a3cd -r 256e74c896a9 sys/arch/sparc64/dev/sbus.c
--- a/sys/arch/sparc64/dev/sbus.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/arch/sparc64/dev/sbus.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sbus.c,v 1.97 2019/11/10 21:16:33 chs Exp $ */
+/* $NetBSD: sbus.c,v 1.98 2020/01/01 22:57:16 thorpej Exp $ */
/*
* Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.97 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.98 2020/01/01 22:57:16 thorpej Exp $");
#include "opt_ddb.h"
@@ -426,7 +426,7 @@
/* Should try a clean shutdown first */
printf("DANGER: OVER TEMPERATURE detected\nShutting down...\n");
delay(20);
- cpu_reboot(RB_POWERDOWN|RB_HALT, NULL);
+ kern_reboot(RB_POWERDOWN|RB_HALT, NULL);
}
/*
diff -r 9654f720a3cd -r 256e74c896a9 sys/compat/common/kern_xxx_12.c
--- a/sys/compat/common/kern_xxx_12.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/compat/common/kern_xxx_12.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_xxx_12.c,v 1.16 2019/01/27 02:08:39 pgoyette Exp $ */
+/* $NetBSD: kern_xxx_12.c,v 1.17 2020/01/01 22:57:17 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_xxx_12.c,v 1.16 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_xxx_12.c,v 1.17 2020/01/01 22:57:17 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -69,7 +69,7 @@
KAUTH_SYSTEM_REBOOT, 0, NULL, NULL, NULL)) != 0)
return (error);
KERNEL_LOCK(1, NULL);
- cpu_reboot(SCARG(uap, opt), NULL);
+ kern_reboot(SCARG(uap, opt), NULL);
KERNEL_UNLOCK_ONE(NULL);
return (0);
}
diff -r 9654f720a3cd -r 256e74c896a9 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/ddb/db_command.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_command.c,v 1.166 2019/12/27 12:51:56 ad Exp $ */
+/* $NetBSD: db_command.c,v 1.167 2020/01/01 22:57:17 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009, 2019
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.166 2019/12/27 12:51:56 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.167 2020/01/01 22:57:17 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_aio.h"
@@ -1397,7 +1397,7 @@
panicstr = "reboot forced via kernel debugger";
/* Make it possible to break into the debugger again */
spl0();
- cpu_reboot((int)bootflags, NULL);
+ kern_reboot((int)bootflags, NULL);
#else /* _KERNEL */
db_printf("This command can only be used in-kernel.\n");
#endif /* _KERNEL */
@@ -1464,7 +1464,7 @@
*/
db_recover = 0;
panicstr = "dump forced via kernel debugger";
- cpu_reboot(RB_DUMP, NULL);
+ kern_reboot(RB_DUMP, NULL);
#else /* _KERNEL */
db_printf("This command can only be used in-kernel.\n");
#endif /* _KERNEL */
diff -r 9654f720a3cd -r 256e74c896a9 sys/dev/sysmon/swwdog.c
--- a/sys/dev/sysmon/swwdog.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/dev/sysmon/swwdog.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: swwdog.c,v 1.20 2019/03/27 09:52:16 pgoyette Exp $ */
+/* $NetBSD: swwdog.c,v 1.21 2020/01/01 22:57:17 thorpej Exp $ */
/*
* Copyright (c) 2004, 2005 Steven M. Bellovin
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.20 2019/03/27 09:52:16 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.21 2020/01/01 22:57:17 thorpej Exp $");
/*
*
@@ -107,7 +107,7 @@
doreboot(struct work *wrkwrkwrk, void *p)
{
- cpu_reboot(0, NULL);
+ kern_reboot(0, NULL);
}
int
diff -r 9654f720a3cd -r 256e74c896a9 sys/dev/sysmon/sysmon_power.c
--- a/sys/dev/sysmon/sysmon_power.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/dev/sysmon/sysmon_power.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_power.c,v 1.61 2019/08/20 18:43:57 maxv Exp $ */
+/* $NetBSD: sysmon_power.c,v 1.62 2020/01/01 22:57:17 thorpej Exp $ */
/*-
* Copyright (c) 2007 Juan Romero Pardines.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.61 2019/08/20 18:43:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.62 2020/01/01 22:57:17 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -864,7 +864,7 @@
switch (event) {
case PENVSYS_EVENT_LOW_POWER:
printf("sysmon: LOW POWER! SHUTTING DOWN.\n");
- cpu_reboot(RB_POWERDOWN, NULL);
+ kern_reboot(RB_POWERDOWN, NULL);
break;
case PENVSYS_EVENT_STATE_CHANGED:
printf("%s: state changed on '%s' to '%s'\n",
@@ -1031,7 +1031,7 @@
*/
printf("%s: power button pressed, shutting down!\n",
smpsw->smpsw_name);
- cpu_reboot(RB_POWERDOWN, NULL);
+ kern_reboot(RB_POWERDOWN, NULL);
break;
case PSWITCH_TYPE_RESET:
@@ -1046,7 +1046,7 @@
*/
printf("%s: reset button pressed, rebooting!\n",
smpsw->smpsw_name);
- cpu_reboot(0, NULL);
+ kern_reboot(0, NULL);
break;
case PSWITCH_TYPE_SLEEP:
diff -r 9654f720a3cd -r 256e74c896a9 sys/external/bsd/drm2/include/linux/reboot.h
--- a/sys/external/bsd/drm2/include/linux/reboot.h Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/external/bsd/drm2/include/linux/reboot.h Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: reboot.h,v 1.5 2018/08/27 13:41:24 riastradh Exp $ */
+/* $NetBSD: reboot.h,v 1.6 2020/01/01 22:57:17 thorpej Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
orderly_poweroff(bool force __unused)
{
- cpu_reboot(RB_POWERDOWN, NULL);
+ kern_reboot(RB_POWERDOWN, NULL);
return 0;
}
diff -r 9654f720a3cd -r 256e74c896a9 sys/kern/init_main.c
--- a/sys/kern/init_main.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/kern/init_main.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: init_main.c,v 1.515 2020/01/01 21:09:11 thorpej Exp $ */
+/* $NetBSD: init_main.c,v 1.516 2020/01/01 22:57:17 thorpej Exp $ */
/*-
- * Copyright (c) 2008, 2009, 2019, The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.515 2020/01/01 21:09:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.516 2020/01/01 22:57:17 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@@ -241,6 +241,7 @@
struct vnode *rootvp, *swapdev_vp;
int boothowto;
int cold __read_mostly = 1; /* still working on startup */
+int shutting_down __read_mostly; /* system is shutting down */
struct timespec boottime; /* time at system startup - will only follow settime deltas */
int start_init_exec; /* semaphore for start_init() */
@@ -1015,9 +1016,9 @@
printf(": ");
len = cngetsn(ipath, sizeof(ipath)-1);
if (len == 4 && strcmp(ipath, "halt") == 0) {
- cpu_reboot(RB_HALT, NULL);
+ kern_reboot(RB_HALT, NULL);
} else if (len == 6 && strcmp(ipath, "reboot") == 0) {
- cpu_reboot(0, NULL);
+ kern_reboot(0, NULL);
#if defined(DDB)
} else if (len == 3 && strcmp(ipath, "ddb") == 0) {
console_debugger();
diff -r 9654f720a3cd -r 256e74c896a9 sys/kern/kern_reboot.c
--- a/sys/kern/kern_reboot.c Wed Jan 01 22:01:13 2020 +0000
+++ b/sys/kern/kern_reboot.c Wed Jan 01 22:57:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_reboot.c,v 1.1 2018/09/14 01:55:19 mrg Exp $ */
+/* $NetBSD: kern_reboot.c,v 1.2 2020/01/01 22:57:17 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_reboot.c,v 1.1 2018/09/14 01:55:19 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_reboot.c,v 1.2 2020/01/01 22:57:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -41,8 +41,26 @@
#include <sys/reboot.h>
#include <sys/syscall.h>
#include <sys/syscallargs.h>
+#include <sys/kernel.h>
#include <sys/kauth.h>
+/*
+ * Reboot / shutdown the system.
+ */
+void
+kern_reboot(int howto, char *bootstr)
+{
+
+ shutting_down = 1;
+
+ /*
+ * XXX We should re-factor out all of the common stuff
+ * that each and every cpu_reboot() does and put it here.
+ */
+
+ cpu_reboot(howto, bootstr);
+}
+
/* ARGSUSED */
int
sys_reboot(struct lwp *l, const struct sys_reboot_args *uap, register_t *retval)
@@ -70,7 +88,7 @@
* Not all ports use the bootstr currently.
*/
KERNEL_LOCK(1, NULL);
- cpu_reboot(SCARG(uap, opt), bootstr);
+ kern_reboot(SCARG(uap, opt), bootstr);
Home |
Main Index |
Thread Index |
Old Index