2 * Copyright IBM Corp. 2016
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 * Adjunct processor bus inline assemblies.
14 * ap_intructions_available() - Test if AP instructions are available.
16 * Returns 0 if the AP instructions are installed.
18 static inline int ap_instructions_available(void)
20 register unsigned long reg0 asm ("0") = AP_MKQID(0, 0);
21 register unsigned long reg1 asm ("1") = -ENODEV;
22 register unsigned long reg2 asm ("2") = 0UL;
25 " .long 0xb2af0000\n" /* PQAP(TAPQ) */
29 : "+d" (reg0), "+d" (reg1), "+d" (reg2) : : "cc");
34 * ap_tapq(): Test adjunct processor queue.
35 * @qid: The AP queue number
36 * @info: Pointer to queue descriptor
38 * Returns AP queue status structure.
40 static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info)
42 register unsigned long reg0 asm ("0") = qid;
43 register struct ap_queue_status reg1 asm ("1");
44 register unsigned long reg2 asm ("2") = 0UL;
46 asm volatile(".long 0xb2af0000" /* PQAP(TAPQ) */
47 : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
54 * ap_pqap_rapq(): Reset adjunct processor queue.
55 * @qid: The AP queue number
57 * Returns AP queue status structure.
59 static inline struct ap_queue_status ap_rapq(ap_qid_t qid)
61 register unsigned long reg0 asm ("0") = qid | 0x01000000UL;
62 register struct ap_queue_status reg1 asm ("1");
63 register unsigned long reg2 asm ("2") = 0UL;
66 ".long 0xb2af0000" /* PQAP(RAPQ) */
67 : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
72 * ap_aqic(): Control interruption for a specific AP.
73 * @qid: The AP queue number
74 * @qirqctrl: struct ap_qirq_ctrl (64 bit value)
75 * @ind: The notification indicator byte
77 * Returns AP queue status.
79 static inline struct ap_queue_status ap_aqic(ap_qid_t qid,
80 struct ap_qirq_ctrl qirqctrl,
83 register unsigned long reg0 asm ("0") = qid | (3UL << 24);
84 register struct ap_qirq_ctrl reg1_in asm ("1") = qirqctrl;
85 register struct ap_queue_status reg1_out asm ("1");
86 register void *reg2 asm ("2") = ind;
89 ".long 0xb2af0000" /* PQAP(AQIC) */
90 : "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out), "+d" (reg2)
97 * ap_qci(): Get AP configuration data
99 * Returns 0 on success, or -EOPNOTSUPP.
101 static inline int ap_qci(void *config)
103 register unsigned long reg0 asm ("0") = 0x04000000UL;
104 register unsigned long reg1 asm ("1") = -EINVAL;
105 register void *reg2 asm ("2") = (void *) config;
108 ".long 0xb2af0000\n" /* PQAP(QCI) */
112 : "+d" (reg0), "+d" (reg1), "+d" (reg2)
120 * struct ap_qact_ap_info - used together with the
121 * ap_aqic() function to provide a convenient way
122 * to handle the ap info needed by the qact function.
124 struct ap_qact_ap_info {
125 unsigned int _res1 : 3;
126 unsigned int mode : 3;
127 unsigned int _res2 : 26;
128 unsigned int cat : 8;
129 unsigned int _res3 : 8;
130 unsigned char ver[2];
134 * ap_qact(): Query AP combatibility type.
135 * @qid: The AP queue number
136 * @apinfo: On input the info about the AP queue (content of GR1
137 * according to the AR). On output the alternate AP queue
138 * info provided by the qact function in GR2 is stored in.
140 * Returns AP queue status. Check response_code field for failures.
142 static inline struct ap_queue_status ap_qact(ap_qid_t qid, int ifbit,
143 struct ap_qact_ap_info *apinfo)
145 register unsigned long reg0 asm ("0") = qid | (5UL << 24)
146 | ((ifbit & 0x01) << 22);
147 register struct ap_qact_ap_info reg1_in asm ("1") = *apinfo;
148 register struct ap_queue_status reg1_out asm ("1");
149 register unsigned long reg2_in asm ("2") = 0;
150 register struct ap_qact_ap_info reg2_out asm ("2");
153 ".long 0xb2af0000" /* PQAP(QACT) */
154 : "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out),
155 "+d" (reg2_in), "=d" (reg2_out)
163 * ap_nqap(): Send message to adjunct processor queue.
164 * @qid: The AP queue number
165 * @psmid: The program supplied message identifier
166 * @msg: The message text
167 * @length: The message length
169 * Returns AP queue status structure.
170 * Condition code 1 on NQAP can't happen because the L bit is 1.
171 * Condition code 2 on NQAP also means the send is incomplete,
172 * because a segment boundary was reached. The NQAP is repeated.
174 static inline struct ap_queue_status ap_nqap(ap_qid_t qid,
175 unsigned long long psmid,
176 void *msg, size_t length)
178 register unsigned long reg0 asm ("0") = qid | 0x40000000UL;
179 register struct ap_queue_status reg1 asm ("1");
180 register unsigned long reg2 asm ("2") = (unsigned long) msg;
181 register unsigned long reg3 asm ("3") = (unsigned long) length;
182 register unsigned long reg4 asm ("4") = (unsigned int) (psmid >> 32);
183 register unsigned long reg5 asm ("5") = psmid & 0xffffffff;
186 "0: .long 0xb2ad0042\n" /* NQAP */
188 : "+d" (reg0), "=d" (reg1), "+d" (reg2), "+d" (reg3)
189 : "d" (reg4), "d" (reg5)
195 * ap_dqap(): Receive message from adjunct processor queue.
196 * @qid: The AP queue number
197 * @psmid: Pointer to program supplied message identifier
198 * @msg: The message text
199 * @length: The message length
201 * Returns AP queue status structure.
202 * Condition code 1 on DQAP means the receive has taken place
203 * but only partially. The response is incomplete, hence the
205 * Condition code 2 on DQAP also means the receive is incomplete,
206 * this time because a segment boundary was reached. Again, the
208 * Note that gpr2 is used by the DQAP instruction to keep track of
209 * any 'residual' length, in case the instruction gets interrupted.
210 * Hence it gets zeroed before the instruction.
212 static inline struct ap_queue_status ap_dqap(ap_qid_t qid,
213 unsigned long long *psmid,
214 void *msg, size_t length)
216 register unsigned long reg0 asm("0") = qid | 0x80000000UL;
217 register struct ap_queue_status reg1 asm ("1");
218 register unsigned long reg2 asm("2") = 0UL;
219 register unsigned long reg4 asm("4") = (unsigned long) msg;
220 register unsigned long reg5 asm("5") = (unsigned long) length;
221 register unsigned long reg6 asm("6") = 0UL;
222 register unsigned long reg7 asm("7") = 0UL;
226 "0: .long 0xb2ae0064\n" /* DQAP */
228 : "+d" (reg0), "=d" (reg1), "+d" (reg2),
229 "+d" (reg4), "+d" (reg5), "+d" (reg6), "+d" (reg7)
231 *psmid = (((unsigned long long) reg6) << 32) + reg7;
235 #endif /* _AP_ASM_H_ */