mp.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * mp.c: OpenBoot Prom Multiprocessor support routines. Don't call
  3. * these on a UP or else you will halt and catch fire. ;)
  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. extern void restore_current(void);
  13. /* Start cpu with prom-tree node 'cpunode' using context described
  14. * by 'ctable_reg' in context 'ctx' at program counter 'pc'.
  15. *
  16. * XXX Have to look into what the return values mean. XXX
  17. */
  18. int
  19. prom_startcpu(int cpunode, struct linux_prom_registers *ctable_reg, int ctx, char *pc)
  20. {
  21. int ret;
  22. unsigned long flags;
  23. spin_lock_irqsave(&prom_lock, flags);
  24. switch(prom_vers) {
  25. case PROM_V0:
  26. case PROM_V2:
  27. default:
  28. ret = -1;
  29. break;
  30. case PROM_V3:
  31. ret = (*(romvec->v3_cpustart))(cpunode, (int) ctable_reg, ctx, pc);
  32. break;
  33. };
  34. restore_current();
  35. spin_unlock_irqrestore(&prom_lock, flags);
  36. return ret;
  37. }
  38. /* Stop CPU with device prom-tree node 'cpunode'.
  39. * XXX Again, what does the return value really mean? XXX
  40. */
  41. int
  42. prom_stopcpu(int cpunode)
  43. {
  44. int ret;
  45. unsigned long flags;
  46. spin_lock_irqsave(&prom_lock, flags);
  47. switch(prom_vers) {
  48. case PROM_V0:
  49. case PROM_V2:
  50. default:
  51. ret = -1;
  52. break;
  53. case PROM_V3:
  54. ret = (*(romvec->v3_cpustop))(cpunode);
  55. break;
  56. };
  57. restore_current();
  58. spin_unlock_irqrestore(&prom_lock, flags);
  59. return ret;
  60. }
  61. /* Make CPU with device prom-tree node 'cpunode' idle.
  62. * XXX Return value, anyone? XXX
  63. */
  64. int
  65. prom_idlecpu(int cpunode)
  66. {
  67. int ret;
  68. unsigned long flags;
  69. spin_lock_irqsave(&prom_lock, flags);
  70. switch(prom_vers) {
  71. case PROM_V0:
  72. case PROM_V2:
  73. default:
  74. ret = -1;
  75. break;
  76. case PROM_V3:
  77. ret = (*(romvec->v3_cpuidle))(cpunode);
  78. break;
  79. };
  80. restore_current();
  81. spin_unlock_irqrestore(&prom_lock, flags);
  82. return ret;
  83. }
  84. /* Resume the execution of CPU with nodeid 'cpunode'.
  85. * XXX Come on, somebody has to know... XXX
  86. */
  87. int
  88. prom_restartcpu(int cpunode)
  89. {
  90. int ret;
  91. unsigned long flags;
  92. spin_lock_irqsave(&prom_lock, flags);
  93. switch(prom_vers) {
  94. case PROM_V0:
  95. case PROM_V2:
  96. default:
  97. ret = -1;
  98. break;
  99. case PROM_V3:
  100. ret = (*(romvec->v3_cpuresume))(cpunode);
  101. break;
  102. };
  103. restore_current();
  104. spin_unlock_irqrestore(&prom_lock, flags);
  105. return ret;
  106. }