reboot.c 1.1 KB

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