reboot.c 1.0 KB

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