misc_32.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 <linux/module.h>
  11. #include <asm/openprom.h>
  12. #include <asm/oplib.h>
  13. #include <asm/auxio.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. EXPORT_SYMBOL(prom_feval);
  43. /* Drop into the prom, with the chance to continue with the 'go'
  44. * prom command.
  45. */
  46. void
  47. prom_cmdline(void)
  48. {
  49. unsigned long flags;
  50. spin_lock_irqsave(&prom_lock, flags);
  51. (*(romvec->pv_abort))();
  52. restore_current();
  53. spin_unlock_irqrestore(&prom_lock, flags);
  54. set_auxio(AUXIO_LED, 0);
  55. }
  56. /* Drop into the prom, but completely terminate the program.
  57. * No chance of continuing.
  58. */
  59. void __noreturn
  60. prom_halt(void)
  61. {
  62. unsigned long flags;
  63. again:
  64. spin_lock_irqsave(&prom_lock, flags);
  65. (*(romvec->pv_halt))();
  66. /* Never get here. */
  67. restore_current();
  68. spin_unlock_irqrestore(&prom_lock, flags);
  69. goto again; /* PROM is out to get me -DaveM */
  70. }
  71. typedef void (*sfunc_t)(void);
  72. /* Set prom sync handler to call function 'funcp'. */
  73. void
  74. prom_setsync(sfunc_t funcp)
  75. {
  76. if(!funcp) return;
  77. *romvec->pv_synchook = funcp;
  78. }
  79. /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
  80. * format type. 'num_bytes' is the number of bytes that your idbuf
  81. * has space for. Returns 0xff on error.
  82. */
  83. unsigned char
  84. prom_get_idprom(char *idbuf, int num_bytes)
  85. {
  86. int len;
  87. len = prom_getproplen(prom_root_node, "idprom");
  88. if((len>num_bytes) || (len==-1)) return 0xff;
  89. if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
  90. return idbuf[0];
  91. return 0xff;
  92. }
  93. /* Get the major prom version number. */
  94. int
  95. prom_version(void)
  96. {
  97. return romvec->pv_romvers;
  98. }
  99. /* Get the prom plugin-revision. */
  100. int
  101. prom_getrev(void)
  102. {
  103. return prom_rev;
  104. }
  105. /* Get the prom firmware print revision. */
  106. int
  107. prom_getprev(void)
  108. {
  109. return prom_prev;
  110. }