q-reset.c 629 B

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