misc.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * misc.c: Miscellaneous prom functions that don't belong
  3. * anywhere else.
  4. *
  5. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6. */
  7. #include <linux/types.h>
  8. #include <linux/kernel.h>
  9. #include <linux/sched.h>
  10. #include <asm/sun3-head.h>
  11. #include <asm/idprom.h>
  12. #include <asm/openprom.h>
  13. #include <asm/oplib.h>
  14. #include <asm/movs.h>
  15. /* Reset and reboot the machine with the command 'bcommand'. */
  16. void
  17. prom_reboot(char *bcommand)
  18. {
  19. unsigned long flags;
  20. local_irq_save(flags);
  21. (*(romvec->pv_reboot))(bcommand);
  22. local_irq_restore(flags);
  23. }
  24. /* Drop into the prom, with the chance to continue with the 'go'
  25. * prom command.
  26. */
  27. void
  28. prom_cmdline(void)
  29. {
  30. }
  31. /* Drop into the prom, but completely terminate the program.
  32. * No chance of continuing.
  33. */
  34. void
  35. prom_halt(void)
  36. {
  37. unsigned long flags;
  38. again:
  39. local_irq_save(flags);
  40. (*(romvec->pv_halt))();
  41. local_irq_restore(flags);
  42. goto again; /* PROM is out to get me -DaveM */
  43. }
  44. typedef void (*sfunc_t)(void);
  45. /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
  46. * format type. 'num_bytes' is the number of bytes that your idbuf
  47. * has space for. Returns 0xff on error.
  48. */
  49. unsigned char
  50. prom_get_idprom(char *idbuf, int num_bytes)
  51. {
  52. int i, oldsfc;
  53. GET_SFC(oldsfc);
  54. SET_SFC(FC_CONTROL);
  55. for(i=0;i<num_bytes; i++)
  56. {
  57. /* There is a problem with the GET_CONTROL_BYTE
  58. macro; defining the extra variable
  59. gets around it.
  60. */
  61. int c;
  62. GET_CONTROL_BYTE(SUN3_IDPROM_BASE + i, c);
  63. idbuf[i] = c;
  64. }
  65. SET_SFC(oldsfc);
  66. return idbuf[0];
  67. }
  68. /* Get the major prom version number. */
  69. int
  70. prom_version(void)
  71. {
  72. return romvec->pv_romvers;
  73. }
  74. /* Get the prom plugin-revision. */
  75. int
  76. prom_getrev(void)
  77. {
  78. return prom_rev;
  79. }
  80. /* Get the prom firmware print revision. */
  81. int
  82. prom_getprev(void)
  83. {
  84. return prom_prev;
  85. }