diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index da24bc1292db..9a24374c23bc 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/highuid.h> | 17 | #include <linux/highuid.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/kernel.h> | ||
20 | #include <linux/kexec.h> | ||
19 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
20 | #include <linux/device.h> | 22 | #include <linux/device.h> |
21 | #include <linux/key.h> | 23 | #include <linux/key.h> |
@@ -405,6 +407,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user | |||
405 | case LINUX_REBOOT_CMD_HALT: | 407 | case LINUX_REBOOT_CMD_HALT: |
406 | notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); | 408 | notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); |
407 | system_state = SYSTEM_HALT; | 409 | system_state = SYSTEM_HALT; |
410 | device_suspend(PMSG_SUSPEND); | ||
408 | device_shutdown(); | 411 | device_shutdown(); |
409 | printk(KERN_EMERG "System halted.\n"); | 412 | printk(KERN_EMERG "System halted.\n"); |
410 | machine_halt(); | 413 | machine_halt(); |
@@ -415,6 +418,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user | |||
415 | case LINUX_REBOOT_CMD_POWER_OFF: | 418 | case LINUX_REBOOT_CMD_POWER_OFF: |
416 | notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); | 419 | notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); |
417 | system_state = SYSTEM_POWER_OFF; | 420 | system_state = SYSTEM_POWER_OFF; |
421 | device_suspend(PMSG_SUSPEND); | ||
418 | device_shutdown(); | 422 | device_shutdown(); |
419 | printk(KERN_EMERG "Power down.\n"); | 423 | printk(KERN_EMERG "Power down.\n"); |
420 | machine_power_off(); | 424 | machine_power_off(); |
@@ -431,11 +435,30 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user | |||
431 | 435 | ||
432 | notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); | 436 | notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); |
433 | system_state = SYSTEM_RESTART; | 437 | system_state = SYSTEM_RESTART; |
438 | device_suspend(PMSG_FREEZE); | ||
434 | device_shutdown(); | 439 | device_shutdown(); |
435 | printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); | 440 | printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); |
436 | machine_restart(buffer); | 441 | machine_restart(buffer); |
437 | break; | 442 | break; |
438 | 443 | ||
444 | #ifdef CONFIG_KEXEC | ||
445 | case LINUX_REBOOT_CMD_KEXEC: | ||
446 | { | ||
447 | struct kimage *image; | ||
448 | image = xchg(&kexec_image, 0); | ||
449 | if (!image) { | ||
450 | unlock_kernel(); | ||
451 | return -EINVAL; | ||
452 | } | ||
453 | notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); | ||
454 | system_state = SYSTEM_RESTART; | ||
455 | device_shutdown(); | ||
456 | printk(KERN_EMERG "Starting new kernel\n"); | ||
457 | machine_shutdown(); | ||
458 | machine_kexec(image); | ||
459 | break; | ||
460 | } | ||
461 | #endif | ||
439 | #ifdef CONFIG_SOFTWARE_SUSPEND | 462 | #ifdef CONFIG_SOFTWARE_SUSPEND |
440 | case LINUX_REBOOT_CMD_SW_SUSPEND: | 463 | case LINUX_REBOOT_CMD_SW_SUSPEND: |
441 | { | 464 | { |