misc.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 ([email protected])
  7. */
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/sched.h>
  11. #include <asm/sun3-head.h>
  12. #include <asm/idprom.h>
  13. #include <asm/openprom.h>
  14. #include <asm/oplib.h>
  15. #include <asm/movs.h>
  16. /* Reset and reboot the machine with the command 'bcommand'. */
  17. void
  18. prom_reboot(char *bcommand)
  19. {
  20. unsigned long flags;
  21. local_irq_save(flags);
  22. (*(romvec->pv_reboot))(bcommand);
  23. local_irq_restore(flags);
  24. }
  25. /* Drop into the prom, with the chance to continue with the 'go'
  26. * prom command.
  27. */
  28. void
  29. prom_cmdline(void)
  30. {
  31. }
  32. /* Drop into the prom, but completely terminate the program.
  33. * No chance of continuing.
  34. */
  35. void
  36. prom_halt(void)
  37. {
  38. unsigned long flags;
  39. again:
  40. local_irq_save(flags);
  41. (*(romvec->pv_halt))();
  42. local_irq_restore(flags);
  43. goto again; /* PROM is out to get me -DaveM */
  44. }
  45. typedef void (*sfunc_t)(void);
  46. /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
  47. * format type. 'num_bytes' is the number of bytes that your idbuf
  48. * has space for. Returns 0xff on error.
  49. */
  50. unsigned char
  51. prom_get_idprom(char *idbuf, int num_bytes)
  52. {
  53. int i, oldsfc;
  54. GET_SFC(oldsfc);
  55. SET_SFC(FC_CONTROL);
  56. for(i=0;i<num_bytes; i++)
  57. {
  58. /* There is a problem with the GET_CONTROL_BYTE
  59. macro; defining the extra variable
  60. gets around it.
  61. */
  62. int c;
  63. GET_CONTROL_BYTE(SUN3_IDPROM_BASE + i, c);
  64. idbuf[i] = c;
  65. }
  66. SET_SFC(oldsfc);
  67. return idbuf[0];
  68. }
  69. /* Get the major prom version number. */
  70. int
  71. prom_version(void)
  72. {
  73. return romvec->pv_romvers;
  74. }
  75. /* Get the prom plugin-revision. */
  76. int
  77. prom_getrev(void)
  78. {
  79. return prom_rev;
  80. }
  81. /* Get the prom firmware print revision. */
  82. int
  83. prom_getprev(void)
  84. {
  85. return prom_prev;
  86. }