#include <mini-os/hypervisor.h>
void init_shutdown(start_info_t *si);
-
-void kernel_shutdown(int reason) __attribute__((noreturn));
+void fini_shutdown(void);
void kernel_suspend(void);
#endif
#include <unistd.h>
#include <xenbus.h>
#include <events.h>
+#include <shutdown.h>
#include <mini-os/lib.h>
extern int main(int argc, char *argv[], char *envp[]);
printk("main returned %d\n", ret);
#if defined(HAVE_LWIP) && defined(CONFIG_NETFRONT)
stop_networking();
+#endif
+#ifdef CONFIG_XENBUS
+ fini_shutdown();
#endif
stop_kernel();
if (!ret) {
}
}
-static void fini_shutdown(void)
-{
- char *err;
-
- end_shutdown_thread = 1;
- xenbus_release_wait_for_watch(&events);
- err = xenbus_unwatch_path_token(XBT_NIL, path, token);
- if (err) {
- free(err);
- do_exit();
- }
-}
-
void init_shutdown(start_info_t *si)
{
start_info_ptr = si;
end_shutdown_thread = 0;
create_thread("shutdown", shutdown_thread, NULL);
}
-#endif
-void kernel_shutdown(int reason)
+void fini_shutdown(void)
{
- char* reason_str = NULL;
-
- switch(reason) {
- case SHUTDOWN_poweroff:
- reason_str = "poweroff";
- break;
- case SHUTDOWN_reboot:
- reason_str = "reboot";
- break;
- case SHUTDOWN_crash:
- reason_str = "crash";
- break;
- default:
- do_exit();
- break;
- }
-
- printk("MiniOS will shutdown (reason = %s) ...\n", reason_str);
-
-#ifdef CONFIG_XENBUS
- fini_shutdown();
-#endif
-
- stop_kernel();
+ char *err;
- for ( ;; ) {
- struct sched_shutdown sched_shutdown = { .reason = reason };
- HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+ end_shutdown_thread = 1;
+ xenbus_release_wait_for_watch(&events);
+ err = xenbus_unwatch_path_token(XBT_NIL, path, token);
+ if (err) {
+ free(err);
+ do_exit();
}
}
+#endif
void kernel_suspend(void)
{