misc_32.c 2.7 KB

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