reset.c 1009 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Reset a Jazz machine.
  3. *
  4. * We don't trust the firmware so we do it the classic way by poking and
  5. * stabbing at the keyboard controller ...
  6. */
  7. #include <linux/jiffies.h>
  8. #include <asm/jazz.h>
  9. #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
  10. static void jazz_write_output(unsigned char val)
  11. {
  12. int status;
  13. do {
  14. status = jazz_kh->command;
  15. } while (status & KBD_STAT_IBF);
  16. jazz_kh->data = val;
  17. }
  18. static void jazz_write_command(unsigned char val)
  19. {
  20. int status;
  21. do {
  22. status = jazz_kh->command;
  23. } while (status & KBD_STAT_IBF);
  24. jazz_kh->command = val;
  25. }
  26. static unsigned char jazz_read_status(void)
  27. {
  28. return jazz_kh->command;
  29. }
  30. static inline void kb_wait(void)
  31. {
  32. unsigned long start = jiffies;
  33. unsigned long timeout = start + HZ/2;
  34. do {
  35. if (! (jazz_read_status() & 0x02))
  36. return;
  37. } while (time_before_eq(jiffies, timeout));
  38. }
  39. void jazz_machine_restart(char *command)
  40. {
  41. while(1) {
  42. kb_wait();
  43. jazz_write_command(0xd1);
  44. kb_wait();
  45. jazz_write_output(0x00);
  46. }
  47. }