misc_32.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/openprom.h>
  11. #include <asm/oplib.h>
  12. #include <asm/auxio.h>
  13. #include <asm/system.h>
  14. extern void restore_current(void);
  15. DEFINE_SPINLOCK(prom_lock);
  16. /* Reset and reboot the machine with the command 'bcommand'. */
  17. void
  18. prom_reboot(char *bcommand)
  19. {
  20. unsigned long flags;
  21. spin_lock_irqsave(&prom_lock, flags);
  22. (*(romvec->pv_reboot))(bcommand);
  23. /* Never get here. */
  24. restore_current();
  25. spin_unlock_irqrestore(&prom_lock, flags);
  26. }
  27. /* Forth evaluate the expression contained in 'fstring'. */
  28. void
  29. prom_feval(char *fstring)
  30. {
  31. unsigned long flags;
  32. if(!fstring || fstring[0] == 0)
  33. return;
  34. spin_lock_irqsave(&prom_lock, flags);
  35. if(prom_vers == PROM_V0)
  36. (*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
  37. else
  38. (*(romvec->pv_fortheval.v2_eval))(fstring);
  39. restore_current();
  40. spin_unlock_irqrestore(&prom_lock, flags);
  41. }
  42. /* Drop into the prom, with the chance to continue with the 'go'
  43. * prom command.
  44. */
  45. void
  46. prom_cmdline(void)
  47. {
  48. extern void install_obp_ticker(void);
  49. extern void install_linux_ticker(void);
  50. unsigned long flags;
  51. spin_lock_irqsave(&prom_lock, flags);
  52. install_obp_ticker();
  53. (*(romvec->pv_abort))();
  54. restore_current();
  55. install_linux_ticker();
  56. spin_unlock_irqrestore(&prom_lock, flags);
  57. set_auxio(AUXIO_LED, 0);
  58. }
  59. /* Drop into the prom, but completely terminate the program.
  60. * No chance of continuing.
  61. */
  62. void
  63. prom_halt(void)
  64. {
  65. unsigned long flags;
  66. again:
  67. spin_lock_irqsave(&prom_lock, flags);
  68. (*(romvec->pv_halt))();
  69. /* Never get here. */
  70. restore_current();
  71. spin_unlock_irqrestore(&prom_lock, flags);
  72. goto again; /* PROM is out to get me -DaveM */
  73. }
  74. typedef void (*sfunc_t)(void);
  75. /* Set prom sync handler to call function 'funcp'. */
  76. void
  77. prom_setsync(sfunc_t funcp)
  78. {
  79. if(!funcp) return;
  80. *romvec->pv_synchook = funcp;
  81. }
  82. /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
  83. * format type. 'num_bytes' is the number of bytes that your idbuf
  84. * has space for. Returns 0xff on error.
  85. */
  86. unsigned char
  87. prom_get_idprom(char *idbuf, int num_bytes)
  88. {
  89. int len;
  90. len = prom_getproplen(prom_root_node, "idprom");
  91. if((len>num_bytes) || (len==-1)) return 0xff;
  92. if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
  93. return idbuf[0];
  94. return 0xff;
  95. }
  96. /* Get the major prom version number. */
  97. int
  98. prom_version(void)
  99. {
  100. return romvec->pv_romvers;
  101. }
  102. /* Get the prom plugin-revision. */
  103. int
  104. prom_getrev(void)
  105. {
  106. return prom_rev;
  107. }
  108. /* Get the prom firmware print revision. */
  109. int
  110. prom_getprev(void)
  111. {
  112. return prom_prev;
  113. }