summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2018-11-24 01:12:52 -0500
committerDamien Zammit <damien@zamaudio.com>2018-11-24 01:20:08 -0500
commitf2f3fc9356bfba3b45588ddbbd96b0a80464b14d (patch)
treeb47561091f79286b6476deb6eadfd0cd533c0d40
parent7fec54630e8c17d5714c3d48ab41b7fb22ad65d5 (diff)
Add to startup relevant shutdown rpc callacpi-backup
-rw-r--r--startup/Makefile1
-rw-r--r--startup/startup.c30
2 files changed, 28 insertions, 3 deletions
diff --git a/startup/Makefile b/startup/Makefile
index bda3ffb3..8df0bd85 100644
--- a/startup/Makefile
+++ b/startup/Makefile
@@ -20,6 +20,7 @@ makemode := server
SRCS = startup.c
OBJS = $(SRCS:.c=.o) \
+ shutdownUser.o \
startupServer.o notifyServer.o startup_replyUser.o msgServer.o \
startup_notifyUser.o fsysServer.o fsServer.o ioServer.o
target = startup
diff --git a/startup/startup.c b/startup/startup.c
index 3679ebc9..3ca38e64 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -52,7 +52,9 @@
#include <argp.h>
#include <pids.h>
#include <idvec.h>
+#include <stdlib.h>
+#include "shutdown_U.h"
#include "startup_notify_U.h"
#include "startup_reply_U.h"
#include "startup_S.h"
@@ -74,6 +76,8 @@ const char *argp_program_version = STANDARD_HURD_VERSION (startup);
#define OPT_KERNEL_TASK -1
+#define _SERVERS_SHUTDOWN _SERVERS "/shutdown"
+
static struct argp_option
options[] =
{
@@ -173,6 +177,22 @@ getstring (char *buf, size_t bufsize)
/** System shutdown **/
+/* Do an RPC to /servers/shutdown
+ * to call platform specific shutdown routine
+ */
+error_t
+do_shutdown (void)
+{
+ shutdown_t pc;
+
+ pc = file_name_lookup (_SERVERS_SHUTDOWN, O_READ, 0);
+ if (! MACH_PORT_VALID (pc))
+ return errno;
+
+ shutdown (pc);
+ return 0;
+}
+
/* Reboot the microkernel. */
void
reboot_mach (int flags)
@@ -189,9 +209,13 @@ reboot_mach (int flags)
fprintf (stderr, "%s: %sing Mach (flags %#x)...\n",
program_invocation_short_name, BOOT (flags), flags);
sleep (5);
- err = host_reboot (host_priv, flags);
- if (err)
- error (1, err, "reboot");
+ if (flags & RB_HALT) {
+ do_shutdown();
+ } else {
+ err = host_reboot (host_priv, flags);
+ if (err)
+ error (1, err, "reboot");
+ }
for (;;) sleep (1);
}
}