reboot.c 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* reboot.c: reboot/shutdown/halt/poweroff handling
  2. *
  3. * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/reboot.h>
  7. #include <linux/export.h>
  8. #include <linux/pm.h>
  9. #include <asm/oplib.h>
  10. #include <asm/prom.h>
  11. #include <asm/setup.h>
  12. /* sysctl - toggle power-off restriction for serial console
  13. * systems in machine_power_off()
  14. */
  15. int scons_pwroff = 1;
  16. /* This isn't actually used, it exists merely to satisfy the
  17. * reference in kernel/sys.c
  18. */
  19. void (*pm_power_off)(void) = machine_power_off;
  20. EXPORT_SYMBOL(pm_power_off);
  21. void machine_power_off(void)
  22. {
  23. if (strcmp(of_console_device->type, "serial") || scons_pwroff)
  24. prom_halt_power_off();
  25. prom_halt();
  26. }
  27. void machine_halt(void)
  28. {
  29. prom_halt();
  30. panic("Halt failed!");
  31. }
  32. void machine_restart(char *cmd)
  33. {
  34. char *p;
  35. p = strchr(reboot_command, '\n');
  36. if (p)
  37. *p = 0;
  38. if (cmd)
  39. prom_reboot(cmd);
  40. if (*reboot_command)
  41. prom_reboot(reboot_command);
  42. prom_reboot("");
  43. panic("Reboot failed!");
  44. }