diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-05-02 13:27:11 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:11 -0400 |
commit | 07f3331c6bfd27a06dfb0ca9fa4f06dec6606876 (patch) | |
tree | e68ced26e1c1bebef4c1eb75f5a4a6a1ac0d3805 /arch | |
parent | 01a2f435564b4baab61328b4018d36464468f57b (diff) |
[PATCH] i386: Add machine_ops interface to abstract halting and rebooting
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>
Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/kernel/apm.c | 3 | ||||
-rw-r--r-- | arch/i386/kernel/reboot.c | 43 |
2 files changed, 39 insertions, 7 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 4d073d390715..367ff1d930cb 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c | |||
@@ -233,11 +233,10 @@ | |||
233 | #include <asm/desc.h> | 233 | #include <asm/desc.h> |
234 | #include <asm/i8253.h> | 234 | #include <asm/i8253.h> |
235 | #include <asm/paravirt.h> | 235 | #include <asm/paravirt.h> |
236 | #include <asm/reboot.h> | ||
236 | 237 | ||
237 | #include "io_ports.h" | 238 | #include "io_ports.h" |
238 | 239 | ||
239 | extern void machine_real_restart(unsigned char *, int); | ||
240 | |||
241 | #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT) | 240 | #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT) |
242 | extern int (*console_blank_hook)(int); | 241 | extern int (*console_blank_hook)(int); |
243 | #endif | 242 | #endif |
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c index 8b5ff6e15412..14b4de2882be 100644 --- a/arch/i386/kernel/reboot.c +++ b/arch/i386/kernel/reboot.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <asm/desc.h> | 18 | #include <asm/desc.h> |
19 | #include "mach_reboot.h" | 19 | #include "mach_reboot.h" |
20 | #include <asm/reboot_fixups.h> | 20 | #include <asm/reboot_fixups.h> |
21 | #include <asm/reboot.h> | ||
21 | 22 | ||
22 | /* | 23 | /* |
23 | * Power off function, if any | 24 | * Power off function, if any |
@@ -280,7 +281,7 @@ void machine_real_restart(unsigned char *code, int length) | |||
280 | EXPORT_SYMBOL(machine_real_restart); | 281 | EXPORT_SYMBOL(machine_real_restart); |
281 | #endif | 282 | #endif |
282 | 283 | ||
283 | void machine_shutdown(void) | 284 | static void native_machine_shutdown(void) |
284 | { | 285 | { |
285 | #ifdef CONFIG_SMP | 286 | #ifdef CONFIG_SMP |
286 | int reboot_cpu_id; | 287 | int reboot_cpu_id; |
@@ -320,7 +321,7 @@ void __attribute__((weak)) mach_reboot_fixups(void) | |||
320 | { | 321 | { |
321 | } | 322 | } |
322 | 323 | ||
323 | void machine_emergency_restart(void) | 324 | static void native_machine_emergency_restart(void) |
324 | { | 325 | { |
325 | if (!reboot_thru_bios) { | 326 | if (!reboot_thru_bios) { |
326 | if (efi_enabled) { | 327 | if (efi_enabled) { |
@@ -344,17 +345,17 @@ void machine_emergency_restart(void) | |||
344 | machine_real_restart(jump_to_bios, sizeof(jump_to_bios)); | 345 | machine_real_restart(jump_to_bios, sizeof(jump_to_bios)); |
345 | } | 346 | } |
346 | 347 | ||
347 | void machine_restart(char * __unused) | 348 | static void native_machine_restart(char * __unused) |
348 | { | 349 | { |
349 | machine_shutdown(); | 350 | machine_shutdown(); |
350 | machine_emergency_restart(); | 351 | machine_emergency_restart(); |
351 | } | 352 | } |
352 | 353 | ||
353 | void machine_halt(void) | 354 | static void native_machine_halt(void) |
354 | { | 355 | { |
355 | } | 356 | } |
356 | 357 | ||
357 | void machine_power_off(void) | 358 | static void native_machine_power_off(void) |
358 | { | 359 | { |
359 | if (pm_power_off) { | 360 | if (pm_power_off) { |
360 | machine_shutdown(); | 361 | machine_shutdown(); |
@@ -363,3 +364,35 @@ void machine_power_off(void) | |||
363 | } | 364 | } |
364 | 365 | ||
365 | 366 | ||
367 | struct machine_ops machine_ops = { | ||
368 | .power_off = native_machine_power_off, | ||
369 | .shutdown = native_machine_shutdown, | ||
370 | .emergency_restart = native_machine_emergency_restart, | ||
371 | .restart = native_machine_restart, | ||
372 | .halt = native_machine_halt, | ||
373 | }; | ||
374 | |||
375 | void machine_power_off(void) | ||
376 | { | ||
377 | machine_ops.power_off(); | ||
378 | } | ||
379 | |||
380 | void machine_shutdown(void) | ||
381 | { | ||
382 | machine_ops.shutdown(); | ||
383 | } | ||
384 | |||
385 | void machine_emergency_restart(void) | ||
386 | { | ||
387 | machine_ops.emergency_restart(); | ||
388 | } | ||
389 | |||
390 | void machine_restart(char *cmd) | ||
391 | { | ||
392 | machine_ops.restart(cmd); | ||
393 | } | ||
394 | |||
395 | void machine_halt(void) | ||
396 | { | ||
397 | machine_ops.halt(); | ||
398 | } | ||