reboot.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2011 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/machine/ec.h>
  19. #include <grub/machine/kernel.h>
  20. #include <grub/machine/memory.h>
  21. #include <grub/misc.h>
  22. #include <grub/pci.h>
  23. #include <grub/cs5536.h>
  24. #include <grub/time.h>
  25. #include <grub/term.h>
  26. #include <grub/i18n.h>
  27. void
  28. grub_reboot (void)
  29. {
  30. switch (grub_arch_machine)
  31. {
  32. case GRUB_ARCH_MACHINE_FULOONG2E:
  33. grub_outl (grub_inl (0xbfe00104) & ~4, 0xbfe00104);
  34. grub_outl (grub_inl (0xbfe00104) | 4, 0xbfe00104);
  35. break;
  36. case GRUB_ARCH_MACHINE_FULOONG2F:
  37. {
  38. grub_pci_device_t dev;
  39. if (!grub_cs5536_find (&dev))
  40. break;
  41. grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_DIVIL_RESET,
  42. grub_cs5536_read_msr (dev,
  43. GRUB_CS5536_MSR_DIVIL_RESET)
  44. | 1);
  45. break;
  46. }
  47. case GRUB_ARCH_MACHINE_YEELOONG:
  48. grub_write_ec (GRUB_MACHINE_EC_COMMAND_REBOOT);
  49. break;
  50. case GRUB_ARCH_MACHINE_YEELOONG_3A:
  51. grub_millisleep (1);
  52. grub_outb (0x4e, GRUB_MACHINE_PCI_IO_BASE_3A | 0x66);
  53. grub_millisleep (1);
  54. grub_outb (1, GRUB_MACHINE_PCI_IO_BASE_3A | 0x62);
  55. grub_millisleep (5000);
  56. }
  57. grub_millisleep (1500);
  58. grub_puts_ (N_("Reboot failed"));
  59. grub_refresh ();
  60. while (1);
  61. }