From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andi Kleen <ak@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Virtualization Mailing List <virtualization@lists.osdl.org>,
Jan Beulich <jbeulich@novell.com>,
Stephane Eranian <eranian@hpl.hp.com>,
Ingo Molnar <mingo@elte.hu>,
"Randy.Dunlap" <rdunlap@xenotime.net>
Subject: [PATCH] Add machine_ops interface to abstract halting and rebooting
Date: Wed, 28 Mar 2007 12:32:22 -0700 [thread overview]
Message-ID: <460AC2C6.9040406@goop.org> (raw)
In-Reply-To: <200703282122.22869.ak@suse.de>
machine_ops is an interface for the machine_* functions defined in
<linux/reboot.h>. This is intended to allow hypervisors to intercept
the reboot process, but it could be used to implement other x86
subarchtecture reboots.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
---
arch/i386/kernel/apm.c | 3 --
arch/i386/kernel/reboot.c | 49 +++++++++++++++++++++++++++++++++++++--------
include/asm-i386/reboot.h | 20 ++++++++++++++++++
3 files changed, 62 insertions(+), 10 deletions(-)
===================================================================
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -233,10 +233,9 @@
#include <asm/desc.h>
#include <asm/i8253.h>
#include <asm/paravirt.h>
+#include <asm/reboot.h>
#include "io_ports.h"
-
-extern void machine_real_restart(unsigned char *, int);
#if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
extern int (*console_blank_hook)(int);
===================================================================
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -18,6 +18,7 @@
#include <asm/desc.h>
#include "mach_reboot.h"
#include <asm/reboot_fixups.h>
+#include <asm/reboot.h>
/*
* Power off function, if any
@@ -280,7 +281,7 @@ EXPORT_SYMBOL(machine_real_restart);
EXPORT_SYMBOL(machine_real_restart);
#endif
-void machine_shutdown(void)
+static void native_machine_shutdown(void)
{
#ifdef CONFIG_SMP
int reboot_cpu_id;
@@ -320,7 +321,7 @@ void __attribute__((weak)) mach_reboot_f
{
}
-void machine_emergency_restart(void)
+static void native_machine_emergency_restart(void)
{
if (!reboot_thru_bios) {
if (efi_enabled) {
@@ -344,17 +345,17 @@ void machine_emergency_restart(void)
machine_real_restart(jump_to_bios, sizeof(jump_to_bios));
}
-void machine_restart(char * __unused)
+static void native_machine_restart(char * __unused)
{
machine_shutdown();
machine_emergency_restart();
}
-void machine_halt(void)
-{
-}
-
-void machine_power_off(void)
+static void native_machine_halt(void)
+{
+}
+
+static void native_machine_power_off(void)
{
if (pm_power_off) {
machine_shutdown();
@@ -363,3 +364,35 @@ void machine_power_off(void)
}
+struct machine_ops machine_ops = {
+ .power_off = native_machine_power_off,
+ .shutdown = native_machine_shutdown,
+ .emergency_restart = native_machine_emergency_restart,
+ .restart = native_machine_restart,
+ .halt = native_machine_halt,
+};
+
+void machine_power_off(void)
+{
+ machine_ops.power_off();
+}
+
+void machine_shutdown(void)
+{
+ machine_ops.shutdown();
+}
+
+void machine_emergency_restart(void)
+{
+ machine_ops.emergency_restart();
+}
+
+void machine_restart(char *cmd)
+{
+ machine_ops.restart(cmd);
+}
+
+void machine_halt(void)
+{
+ machine_ops.halt();
+}
===================================================================
--- /dev/null
+++ b/include/asm-i386/reboot.h
@@ -0,0 +1,20 @@
+#ifndef _ASM_REBOOT_H
+#define _ASM_REBOOT_H
+
+struct pt_regs;
+
+struct machine_ops
+{
+ void (*restart)(char *cmd);
+ void (*halt)(void);
+ void (*power_off)(void);
+ void (*shutdown)(void);
+ void (*crash_shutdown)(struct pt_regs *);
+ void (*emergency_restart)(void);
+};
+
+extern struct machine_ops machine_ops;
+
+void machine_real_restart(unsigned char *code, int length);
+
+#endif /* _ASM_REBOOT_H */
next prev parent reply other threads:[~2007-03-28 19:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-27 22:13 [PATCH] Simplify smp_call_function*() by using common implementation Jeremy Fitzhardinge
2007-03-27 22:43 ` Randy Dunlap
2007-03-27 22:46 ` Jeremy Fitzhardinge
2007-03-28 19:03 ` Andi Kleen
2007-03-28 19:18 ` Jeremy Fitzhardinge
2007-03-28 19:22 ` Andi Kleen
2007-03-28 19:31 ` [PATCH] Add smp_ops interface Jeremy Fitzhardinge
2007-03-28 19:32 ` Jeremy Fitzhardinge [this message]
2007-03-28 19:43 ` [PATCH] Add machine_ops interface to abstract halting and rebooting Andi Kleen
2007-03-28 19:47 ` Jeremy Fitzhardinge
2007-03-28 19:54 ` Andi Kleen
2007-03-28 20:11 ` [PATCH] Clean up mach_reboot_fixups Jeremy Fitzhardinge
2007-03-28 20:14 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=460AC2C6.9040406@goop.org \
--to=jeremy@goop.org \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=eranian@hpl.hp.com \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rdunlap@xenotime.net \
--cc=virtualization@lists.osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).