q-reset.c 655 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <linux/config.h>
  2. #include <asm/io.h>
  3. #include <asm/reboot.h>
  4. #include <asm/cacheflush.h>
  5. #include <asm/qemu.h>
  6. static void qemu_machine_restart(char *command)
  7. {
  8. volatile unsigned int *reg = (unsigned int *)QEMU_RESTART_REG;
  9. set_c0_status(ST0_BEV | ST0_ERL);
  10. change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
  11. flush_cache_all();
  12. write_c0_wired(0);
  13. *reg = 42;
  14. while (1)
  15. cpu_wait();
  16. }
  17. static void qemu_machine_halt(void)
  18. {
  19. volatile unsigned int *reg = (unsigned int *)QEMU_HALT_REG;
  20. *reg = 42;
  21. while (1)
  22. cpu_wait();
  23. }
  24. void qemu_reboot_setup(void)
  25. {
  26. _machine_restart = qemu_machine_restart;
  27. _machine_halt = qemu_machine_halt;
  28. }