misc_32.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * misc.c: Miscellaneous prom functions that don't belong
  4. * anywhere else.
  5. *
  6. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  7. */
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/sched.h>
  11. #include <linux/module.h>
  12. #include <asm/openprom.h>
  13. #include <asm/oplib.h>
  14. #include <asm/auxio.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. unsigned long flags;
  51. spin_lock_irqsave(&prom_lock, flags);
  52. (*(romvec->pv_abort))();
  53. restore_current();
  54. spin_unlock_irqrestore(&prom_lock, flags);
  55. set_auxio(AUXIO_LED, 0);
  56. }
  57. /* Drop into the prom, but completely terminate the program.
  58. * No chance of continuing.
  59. */
  60. void __noreturn
  61. prom_halt(void)
  62. {
  63. unsigned long flags;
  64. again:
  65. spin_lock_irqsave(&prom_lock, flags);
  66. (*(romvec->pv_halt))();
  67. /* Never get here. */
  68. restore_current();
  69. spin_unlock_irqrestore(&prom_lock, flags);
  70. goto again; /* PROM is out to get me -DaveM */
  71. }
  72. typedef void (*sfunc_t)(void);
  73. /* Set prom sync handler to call function 'funcp'. */
  74. void
  75. prom_setsync(sfunc_t funcp)
  76. {
  77. if(!funcp) return;
  78. *romvec->pv_synchook = funcp;
  79. }
  80. /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
  81. * format type. 'num_bytes' is the number of bytes that your idbuf
  82. * has space for. Returns 0xff on error.
  83. */
  84. unsigned char
  85. prom_get_idprom(char *idbuf, int num_bytes)
  86. {
  87. int len;
  88. len = prom_getproplen(prom_root_node, "idprom");
  89. if((len>num_bytes) || (len==-1)) return 0xff;
  90. if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
  91. return idbuf[0];
  92. return 0xff;
  93. }
  94. /* Get the major prom version number. */
  95. int
  96. prom_version(void)
  97. {
  98. return romvec->pv_romvers;
  99. }
  100. /* Get the prom plugin-revision. */
  101. int
  102. prom_getrev(void)
  103. {
  104. return prom_rev;
  105. }
  106. /* Get the prom firmware print revision. */
  107. int
  108. prom_getprev(void)
  109. {
  110. return prom_prev;
  111. }