misc.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* $Id: misc.c,v 1.18 2000/08/26 02:38:03 anton Exp $
  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. /* We want to do this more nicely some day. */
  43. extern void (*prom_palette)(int);
  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. if (prom_palette)
  54. prom_palette (1);
  55. spin_lock_irqsave(&prom_lock, flags);
  56. install_obp_ticker();
  57. (*(romvec->pv_abort))();
  58. restore_current();
  59. install_linux_ticker();
  60. spin_unlock_irqrestore(&prom_lock, flags);
  61. #ifdef CONFIG_SUN_AUXIO
  62. set_auxio(AUXIO_LED, 0);
  63. #endif
  64. if (prom_palette)
  65. prom_palette (0);
  66. }
  67. /* Drop into the prom, but completely terminate the program.
  68. * No chance of continuing.
  69. */
  70. void
  71. prom_halt(void)
  72. {
  73. unsigned long flags;
  74. again:
  75. spin_lock_irqsave(&prom_lock, flags);
  76. (*(romvec->pv_halt))();
  77. /* Never get here. */
  78. restore_current();
  79. spin_unlock_irqrestore(&prom_lock, flags);
  80. goto again; /* PROM is out to get me -DaveM */
  81. }
  82. typedef void (*sfunc_t)(void);
  83. /* Set prom sync handler to call function 'funcp'. */
  84. void
  85. prom_setsync(sfunc_t funcp)
  86. {
  87. if(!funcp) return;
  88. *romvec->pv_synchook = funcp;
  89. }
  90. /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
  91. * format type. 'num_bytes' is the number of bytes that your idbuf
  92. * has space for. Returns 0xff on error.
  93. */
  94. unsigned char
  95. prom_get_idprom(char *idbuf, int num_bytes)
  96. {
  97. int len;
  98. len = prom_getproplen(prom_root_node, "idprom");
  99. if((len>num_bytes) || (len==-1)) return 0xff;
  100. if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
  101. return idbuf[0];
  102. return 0xff;
  103. }
  104. /* Get the major prom version number. */
  105. int
  106. prom_version(void)
  107. {
  108. return romvec->pv_romvers;
  109. }
  110. /* Get the prom plugin-revision. */
  111. int
  112. prom_getrev(void)
  113. {
  114. return prom_rev;
  115. }
  116. /* Get the prom firmware print revision. */
  117. int
  118. prom_getprev(void)
  119. {
  120. return prom_prev;
  121. }