1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2016
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 * Adjunct processor bus inline assemblies.
15 * ap_intructions_available() - Test if AP instructions are available.
17 * Returns 0 if the AP instructions are installed.
19 static inline int ap_instructions_available(void)
21 register unsigned long reg0 asm ("0") = AP_MKQID(0, 0);
22 register unsigned long reg1 asm ("1") = -ENODEV;
23 register unsigned long reg2 asm ("2") = 0UL;
26 " .long 0xb2af0000\n" /* PQAP(TAPQ) */
30 : "+d" (reg0), "+d" (reg1), "+d" (reg2) : : "cc");
35 * ap_tapq(): Test adjunct processor queue.
36 * @qid: The AP queue number
37 * @info: Pointer to queue descriptor
39 * Returns AP queue status structure.
41 static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info)
43 register unsigned long reg0 asm ("0") = qid;
44 register struct ap_queue_status reg1 asm ("1");
45 register unsigned long reg2 asm ("2") = 0UL;
47 asm volatile(".long 0xb2af0000" /* PQAP(TAPQ) */
48 : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
55 * ap_pqap_rapq(): Reset adjunct processor queue.
56 * @qid: The AP queue number
58 * Returns AP queue status structure.
60 static inline struct ap_queue_status ap_rapq(ap_qid_t qid)
62 register unsigned long reg0 asm ("0") = qid | 0x01000000UL;
63 register struct ap_queue_status reg1 asm ("1");
64 register unsigned long reg2 asm ("2") = 0UL;
67 ".long 0xb2af0000" /* PQAP(RAPQ) */
68 : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
73 * ap_aqic(): Control interruption for a specific AP.
74 * @qid: The AP queue number
75 * @qirqctrl: struct ap_qirq_ctrl (64 bit value)
76 * @ind: The notification indicator byte
78 * Returns AP queue status.
80 static inline struct ap_queue_status ap_aqic(ap_qid_t qid,
81 struct ap_qirq_ctrl qirqctrl,
84 register unsigned long reg0 asm ("0") = qid | (3UL << 24);
85 register struct ap_qirq_ctrl reg1_in asm ("1") = qirqctrl;
86 register struct ap_queue_status reg1_out asm ("1");
87 register void *reg2 asm ("2") = ind;
90 ".long 0xb2af0000" /* PQAP(AQIC) */
91 : "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out), "+d" (reg2)
98 * ap_qci(): Get AP configuration data
100 * Returns 0 on success, or -EOPNOTSUPP.
102 static inline int ap_qci(void *config)
104 register unsigned long reg0 asm ("0") = 0x04000000UL;
105 register unsigned long reg1 asm ("1") = -EINVAL;
106 register void *reg2 asm ("2") = (void *) config;
109 ".long 0xb2af0000\n" /* PQAP(QCI) */
113 : "+d" (reg0), "+d" (reg1), "+d" (reg2)
121 * union ap_qact_ap_info - used together with the
122 * ap_aqic() function to provide a convenient way
123 * to handle the ap info needed by the qact function.
125 union ap_qact_ap_info {
129 unsigned int mode : 3;
131 unsigned int cat : 8;
133 unsigned char ver[2];
138 * ap_qact(): Query AP combatibility type.
139 * @qid: The AP queue number
140 * @apinfo: On input the info about the AP queue. On output the
141 * alternate AP queue info provided by the qact function
142 * in GR2 is stored in.
144 * Returns AP queue status. Check response_code field for failures.
146 static inline struct ap_queue_status ap_qact(ap_qid_t qid, int ifbit,
147 union ap_qact_ap_info *apinfo)
149 register unsigned long reg0 asm ("0") = qid | (5UL << 24)
150 | ((ifbit & 0x01) << 22);
151 register unsigned long reg1_in asm ("1") = apinfo->val;
152 register struct ap_queue_status reg1_out asm ("1");
153 register unsigned long reg2 asm ("2") = 0;
156 ".long 0xb2af0000" /* PQAP(QACT) */
157 : "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out), "+d" (reg2)
164 * ap_nqap(): Send message to adjunct processor queue.
165 * @qid: The AP queue number
166 * @psmid: The program supplied message identifier
167 * @msg: The message text
168 * @length: The message length
170 * Returns AP queue status structure.
171 * Condition code 1 on NQAP can't happen because the L bit is 1.
172 * Condition code 2 on NQAP also means the send is incomplete,
173 * because a segment boundary was reached. The NQAP is repeated.
175 static inline struct ap_queue_status ap_nqap(ap_qid_t qid,
176 unsigned long long psmid,
177 void *msg, size_t length)
179 register unsigned long reg0 asm ("0") = qid | 0x40000000UL;
180 register struct ap_queue_status reg1 asm ("1");
181 register unsigned long reg2 asm ("2") = (unsigned long) msg;
182 register unsigned long reg3 asm ("3") = (unsigned long) length;
183 register unsigned long reg4 asm ("4") = (unsigned int) (psmid >> 32);
184 register unsigned long reg5 asm ("5") = psmid & 0xffffffff;
187 "0: .long 0xb2ad0042\n" /* NQAP */
189 : "+d" (reg0), "=d" (reg1), "+d" (reg2), "+d" (reg3)
190 : "d" (reg4), "d" (reg5)
196 * ap_dqap(): Receive message from adjunct processor queue.
197 * @qid: The AP queue number
198 * @psmid: Pointer to program supplied message identifier
199 * @msg: The message text
200 * @length: The message length
202 * Returns AP queue status structure.
203 * Condition code 1 on DQAP means the receive has taken place
204 * but only partially. The response is incomplete, hence the
206 * Condition code 2 on DQAP also means the receive is incomplete,
207 * this time because a segment boundary was reached. Again, the
209 * Note that gpr2 is used by the DQAP instruction to keep track of
210 * any 'residual' length, in case the instruction gets interrupted.
211 * Hence it gets zeroed before the instruction.
213 static inline struct ap_queue_status ap_dqap(ap_qid_t qid,
214 unsigned long long *psmid,
215 void *msg, size_t length)
217 register unsigned long reg0 asm("0") = qid | 0x80000000UL;
218 register struct ap_queue_status reg1 asm ("1");
219 register unsigned long reg2 asm("2") = 0UL;
220 register unsigned long reg4 asm("4") = (unsigned long) msg;
221 register unsigned long reg5 asm("5") = (unsigned long) length;
222 register unsigned long reg6 asm("6") = 0UL;
223 register unsigned long reg7 asm("7") = 0UL;
227 "0: .long 0xb2ae0064\n" /* DQAP */
229 : "+d" (reg0), "=d" (reg1), "+d" (reg2),
230 "+d" (reg4), "+d" (reg5), "+d" (reg6), "+d" (reg7)
232 *psmid = (((unsigned long long) reg6) << 32) + reg7;
236 #endif /* _AP_ASM_H_ */