misc.c 3.0 KB

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