summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-07-01 22:40:54 +0000
committerkettenis <kettenis@openbsd.org>2020-07-01 22:40:54 +0000
commit0453b3413a6c0eed45eb4fd2c7dcc106c60ad964 (patch)
tree60f046d71030d80f9d5b56be8e0d0c6fdc524961
parentatomic_swap_uint should still use a lwarx/stwcx. pair. (diff)
downloadwireguard-openbsd-0453b3413a6c0eed45eb4fd2c7dcc106c60ad964.tar.xz
wireguard-openbsd-0453b3413a6c0eed45eb4fd2c7dcc106c60ad964.zip
Bring boot() in line with other architectures such that we actually
sync disks when we reboot and don't end up with dirty filesystems.
-rw-r--r--sys/arch/powerpc64/powerpc64/machdep.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c
index d05c5232f50..1efb102e852 100644
--- a/sys/arch/powerpc64/powerpc64/machdep.c
+++ b/sys/arch/powerpc64/powerpc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.39 2020/07/01 16:05:48 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.40 2020/07/01 22:40:54 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -36,6 +36,7 @@
#include <machine/psl.h>
#include <machine/trap.h>
+#include <net/if.h>
#include <uvm/uvm_extern.h>
#include <dev/ofw/fdt.h>
@@ -769,14 +770,51 @@ opal_powerdown(void)
opal_poll_events(NULL);
}
+int waittime = -1;
+
__dead void
boot(int howto)
{
+ if ((howto & RB_RESET) != 0)
+ goto doreset;
+
+ if (cold) {
+ if ((howto & RB_USERREQ) == 0)
+ howto |= RB_HALT;
+ goto haltsys;
+ }
+
+ boothowto = howto;
+ if ((howto & RB_NOSYNC) == 0 && waittime < 0) {
+ waittime = 0;
+ vfs_shutdown(curproc);
+
+ if ((howto & RB_TIMEBAD) == 0) {
+ resettodr();
+ } else {
+ printf("WARNING: not updating battery clock\n");
+ }
+ }
+ if_downall();
+
+ uvm_shutdown();
+ splhigh();
+ cold = 1;
+
+haltsys:
+ config_suspend_all(DVACT_POWERDOWN);
+
if ((howto & RB_HALT) != 0) {
if ((howto & RB_POWERDOWN) != 0)
opal_powerdown();
+
+ printf("\n");
+ printf("The operating system has halted.\n");
+ printf("Please press any key to reboot.\n\n");
+ cngetc();
}
+doreset:
printf("rebooting...\n");
opal_cec_reboot();