sigp.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Routines and structures for signalling other processors.
  3. *
  4. * Copyright IBM Corp. 1999,2010
  5. * Author(s): Denis Joseph Barrow,
  6. * Martin Schwidefsky <schwidefsky@de.ibm.com>,
  7. * Heiko Carstens <heiko.carstens@de.ibm.com>,
  8. */
  9. #ifndef __ASM_SIGP_H
  10. #define __ASM_SIGP_H
  11. #include <asm/system.h>
  12. /* Get real cpu address from logical cpu number. */
  13. extern unsigned short __cpu_logical_map[];
  14. static inline int cpu_logical_map(int cpu)
  15. {
  16. #ifdef CONFIG_SMP
  17. return __cpu_logical_map[cpu];
  18. #else
  19. return stap();
  20. #endif
  21. }
  22. enum {
  23. sigp_sense = 1,
  24. sigp_external_call = 2,
  25. sigp_emergency_signal = 3,
  26. sigp_start = 4,
  27. sigp_stop = 5,
  28. sigp_restart = 6,
  29. sigp_stop_and_store_status = 9,
  30. sigp_initial_cpu_reset = 11,
  31. sigp_cpu_reset = 12,
  32. sigp_set_prefix = 13,
  33. sigp_store_status_at_address = 14,
  34. sigp_store_extended_status_at_address = 15,
  35. sigp_set_architecture = 18,
  36. sigp_conditional_emergency_signal = 19,
  37. sigp_sense_running = 21,
  38. };
  39. enum {
  40. sigp_order_code_accepted = 0,
  41. sigp_status_stored = 1,
  42. sigp_busy = 2,
  43. sigp_not_operational = 3,
  44. };
  45. /*
  46. * Definitions for external call.
  47. */
  48. enum {
  49. ec_schedule = 0,
  50. ec_call_function,
  51. ec_call_function_single,
  52. ec_stop_cpu,
  53. };
  54. /*
  55. * Signal processor.
  56. */
  57. static inline int raw_sigp(u16 cpu, int order)
  58. {
  59. register unsigned long reg1 asm ("1") = 0;
  60. int ccode;
  61. asm volatile(
  62. " sigp %1,%2,0(%3)\n"
  63. " ipm %0\n"
  64. " srl %0,28\n"
  65. : "=d" (ccode)
  66. : "d" (reg1), "d" (cpu),
  67. "a" (order) : "cc" , "memory");
  68. return ccode;
  69. }
  70. /*
  71. * Signal processor with parameter.
  72. */
  73. static inline int raw_sigp_p(u32 parameter, u16 cpu, int order)
  74. {
  75. register unsigned int reg1 asm ("1") = parameter;
  76. int ccode;
  77. asm volatile(
  78. " sigp %1,%2,0(%3)\n"
  79. " ipm %0\n"
  80. " srl %0,28\n"
  81. : "=d" (ccode)
  82. : "d" (reg1), "d" (cpu),
  83. "a" (order) : "cc" , "memory");
  84. return ccode;
  85. }
  86. /*
  87. * Signal processor with parameter and return status.
  88. */
  89. static inline int raw_sigp_ps(u32 *status, u32 parm, u16 cpu, int order)
  90. {
  91. register unsigned int reg1 asm ("1") = parm;
  92. int ccode;
  93. asm volatile(
  94. " sigp %1,%2,0(%3)\n"
  95. " ipm %0\n"
  96. " srl %0,28\n"
  97. : "=d" (ccode), "+d" (reg1)
  98. : "d" (cpu), "a" (order)
  99. : "cc" , "memory");
  100. *status = reg1;
  101. return ccode;
  102. }
  103. static inline int sigp(int cpu, int order)
  104. {
  105. return raw_sigp(cpu_logical_map(cpu), order);
  106. }
  107. static inline int sigp_p(u32 parameter, int cpu, int order)
  108. {
  109. return raw_sigp_p(parameter, cpu_logical_map(cpu), order);
  110. }
  111. static inline int sigp_ps(u32 *status, u32 parm, int cpu, int order)
  112. {
  113. return raw_sigp_ps(status, parm, cpu_logical_map(cpu), order);
  114. }
  115. #endif /* __ASM_SIGP_H */