ap_asm.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Copyright IBM Corp. 2016
  3. * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  4. *
  5. * Adjunct processor bus inline assemblies.
  6. */
  7. #ifndef _AP_ASM_H_
  8. #define _AP_ASM_H_
  9. #include <asm/isc.h>
  10. /**
  11. * ap_intructions_available() - Test if AP instructions are available.
  12. *
  13. * Returns 0 if the AP instructions are installed.
  14. */
  15. static inline int ap_instructions_available(void)
  16. {
  17. register unsigned long reg0 asm ("0") = AP_MKQID(0, 0);
  18. register unsigned long reg1 asm ("1") = -ENODEV;
  19. register unsigned long reg2 asm ("2") = 0UL;
  20. asm volatile(
  21. " .long 0xb2af0000\n" /* PQAP(TAPQ) */
  22. "0: la %1,0\n"
  23. "1:\n"
  24. EX_TABLE(0b, 1b)
  25. : "+d" (reg0), "+d" (reg1), "+d" (reg2) : : "cc");
  26. return reg1;
  27. }
  28. /**
  29. * ap_tapq(): Test adjunct processor queue.
  30. * @qid: The AP queue number
  31. * @info: Pointer to queue descriptor
  32. *
  33. * Returns AP queue status structure.
  34. */
  35. static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info)
  36. {
  37. register unsigned long reg0 asm ("0") = qid;
  38. register struct ap_queue_status reg1 asm ("1");
  39. register unsigned long reg2 asm ("2") = 0UL;
  40. asm volatile(".long 0xb2af0000" /* PQAP(TAPQ) */
  41. : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
  42. if (info)
  43. *info = reg2;
  44. return reg1;
  45. }
  46. /**
  47. * ap_pqap_rapq(): Reset adjunct processor queue.
  48. * @qid: The AP queue number
  49. *
  50. * Returns AP queue status structure.
  51. */
  52. static inline struct ap_queue_status ap_rapq(ap_qid_t qid)
  53. {
  54. register unsigned long reg0 asm ("0") = qid | 0x01000000UL;
  55. register struct ap_queue_status reg1 asm ("1");
  56. register unsigned long reg2 asm ("2") = 0UL;
  57. asm volatile(
  58. ".long 0xb2af0000" /* PQAP(RAPQ) */
  59. : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
  60. return reg1;
  61. }
  62. /**
  63. * ap_aqic(): Control interruption for a specific AP.
  64. * @qid: The AP queue number
  65. * @qirqctrl: struct ap_qirq_ctrl (64 bit value)
  66. * @ind: The notification indicator byte
  67. *
  68. * Returns AP queue status.
  69. */
  70. static inline struct ap_queue_status ap_aqic(ap_qid_t qid,
  71. struct ap_qirq_ctrl qirqctrl,
  72. void *ind)
  73. {
  74. register unsigned long reg0 asm ("0") = qid | (3UL << 24);
  75. register struct ap_qirq_ctrl reg1_in asm ("1") = qirqctrl;
  76. register struct ap_queue_status reg1_out asm ("1");
  77. register void *reg2 asm ("2") = ind;
  78. asm volatile(
  79. ".long 0xb2af0000" /* PQAP(AQIC) */
  80. : "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out), "+d" (reg2)
  81. :
  82. : "cc");
  83. return reg1_out;
  84. }
  85. /**
  86. * ap_qci(): Get AP configuration data
  87. *
  88. * Returns 0 on success, or -EOPNOTSUPP.
  89. */
  90. static inline int ap_qci(void *config)
  91. {
  92. register unsigned long reg0 asm ("0") = 0x04000000UL;
  93. register unsigned long reg1 asm ("1") = -EINVAL;
  94. register void *reg2 asm ("2") = (void *) config;
  95. asm volatile(
  96. ".long 0xb2af0000\n" /* PQAP(QCI) */
  97. "0: la %1,0\n"
  98. "1:\n"
  99. EX_TABLE(0b, 1b)
  100. : "+d" (reg0), "+d" (reg1), "+d" (reg2)
  101. :
  102. : "cc", "memory");
  103. return reg1;
  104. }
  105. /**
  106. * ap_nqap(): Send message to adjunct processor queue.
  107. * @qid: The AP queue number
  108. * @psmid: The program supplied message identifier
  109. * @msg: The message text
  110. * @length: The message length
  111. *
  112. * Returns AP queue status structure.
  113. * Condition code 1 on NQAP can't happen because the L bit is 1.
  114. * Condition code 2 on NQAP also means the send is incomplete,
  115. * because a segment boundary was reached. The NQAP is repeated.
  116. */
  117. static inline struct ap_queue_status ap_nqap(ap_qid_t qid,
  118. unsigned long long psmid,
  119. void *msg, size_t length)
  120. {
  121. register unsigned long reg0 asm ("0") = qid | 0x40000000UL;
  122. register struct ap_queue_status reg1 asm ("1");
  123. register unsigned long reg2 asm ("2") = (unsigned long) msg;
  124. register unsigned long reg3 asm ("3") = (unsigned long) length;
  125. register unsigned long reg4 asm ("4") = (unsigned int) (psmid >> 32);
  126. register unsigned long reg5 asm ("5") = psmid & 0xffffffff;
  127. asm volatile (
  128. "0: .long 0xb2ad0042\n" /* NQAP */
  129. " brc 2,0b"
  130. : "+d" (reg0), "=d" (reg1), "+d" (reg2), "+d" (reg3)
  131. : "d" (reg4), "d" (reg5)
  132. : "cc", "memory");
  133. return reg1;
  134. }
  135. /**
  136. * ap_dqap(): Receive message from adjunct processor queue.
  137. * @qid: The AP queue number
  138. * @psmid: Pointer to program supplied message identifier
  139. * @msg: The message text
  140. * @length: The message length
  141. *
  142. * Returns AP queue status structure.
  143. * Condition code 1 on DQAP means the receive has taken place
  144. * but only partially. The response is incomplete, hence the
  145. * DQAP is repeated.
  146. * Condition code 2 on DQAP also means the receive is incomplete,
  147. * this time because a segment boundary was reached. Again, the
  148. * DQAP is repeated.
  149. * Note that gpr2 is used by the DQAP instruction to keep track of
  150. * any 'residual' length, in case the instruction gets interrupted.
  151. * Hence it gets zeroed before the instruction.
  152. */
  153. static inline struct ap_queue_status ap_dqap(ap_qid_t qid,
  154. unsigned long long *psmid,
  155. void *msg, size_t length)
  156. {
  157. register unsigned long reg0 asm("0") = qid | 0x80000000UL;
  158. register struct ap_queue_status reg1 asm ("1");
  159. register unsigned long reg2 asm("2") = 0UL;
  160. register unsigned long reg4 asm("4") = (unsigned long) msg;
  161. register unsigned long reg5 asm("5") = (unsigned long) length;
  162. register unsigned long reg6 asm("6") = 0UL;
  163. register unsigned long reg7 asm("7") = 0UL;
  164. asm volatile(
  165. "0: .long 0xb2ae0064\n" /* DQAP */
  166. " brc 6,0b\n"
  167. : "+d" (reg0), "=d" (reg1), "+d" (reg2),
  168. "+d" (reg4), "+d" (reg5), "+d" (reg6), "+d" (reg7)
  169. : : "cc", "memory");
  170. *psmid = (((unsigned long long) reg6) << 32) + reg7;
  171. return reg1;
  172. }
  173. #endif /* _AP_ASM_H_ */