reset.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2001, 06 by Ralf Baechle (ralf@linux-mips.org)
  7. * Copyright (C) 2001 MIPS Technologies, Inc.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/export.h>
  11. #include <linux/pm.h>
  12. #include <linux/types.h>
  13. #include <linux/reboot.h>
  14. #include <linux/delay.h>
  15. #include <asm/reboot.h>
  16. /*
  17. * Urgs ... Too many MIPS machines to handle this in a generic way.
  18. * So handle all using function pointers to machine specific
  19. * functions.
  20. */
  21. void (*_machine_restart)(char *command);
  22. void (*_machine_halt)(void);
  23. void (*pm_power_off)(void);
  24. EXPORT_SYMBOL(pm_power_off);
  25. void machine_restart(char *command)
  26. {
  27. if (_machine_restart)
  28. _machine_restart(command);
  29. #ifdef CONFIG_SMP
  30. preempt_disable();
  31. smp_send_stop();
  32. #endif
  33. do_kernel_restart(command);
  34. mdelay(1000);
  35. pr_emerg("Reboot failed -- System halted\n");
  36. local_irq_disable();
  37. while (1);
  38. }
  39. void machine_halt(void)
  40. {
  41. if (_machine_halt)
  42. _machine_halt();
  43. #ifdef CONFIG_SMP
  44. preempt_disable();
  45. smp_send_stop();
  46. #endif
  47. local_irq_disable();
  48. while (1);
  49. }
  50. void machine_power_off(void)
  51. {
  52. if (pm_power_off)
  53. pm_power_off();
  54. #ifdef CONFIG_SMP
  55. preempt_disable();
  56. smp_send_stop();
  57. #endif
  58. local_irq_disable();
  59. while (1);
  60. }