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:46:04 -0500
commitb31590aca88a0a372cfd6f681aef353794d376ff (patch)
tree34f7bbc9243191dc751dc1a3320287138ff50e22
parent2be6b5cab503e4358d60b4d97d1705cbf06bdf44 (diff)
Add to startup relevant shutdown rpc callacpi-translator
-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);
}
}