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 * ap_nqap(): Send message to adjunct processor queue.
122 * @qid: The AP queue number
123 * @psmid: The program supplied message identifier
124 * @msg: The message text
125 * @length: The message length
127 * Returns AP queue status structure.
128 * Condition code 1 on NQAP can't happen because the L bit is 1.
129 * Condition code 2 on NQAP also means the send is incomplete,
130 * because a segment boundary was reached. The NQAP is repeated.
132 static inline struct ap_queue_status ap_nqap(ap_qid_t qid,
133 unsigned long long psmid,
134 void *msg, size_t length)
136 register unsigned long reg0 asm ("0") = qid | 0x40000000UL;
137 register struct ap_queue_status reg1 asm ("1");
138 register unsigned long reg2 asm ("2") = (unsigned long) msg;
139 register unsigned long reg3 asm ("3") = (unsigned long) length;
140 register unsigned long reg4 asm ("4") = (unsigned int) (psmid >> 32);
141 register unsigned long reg5 asm ("5") = psmid & 0xffffffff;
144 "0: .long 0xb2ad0042\n" /* NQAP */
146 : "+d" (reg0), "=d" (reg1), "+d" (reg2), "+d" (reg3)
147 : "d" (reg4), "d" (reg5)
153 * ap_dqap(): Receive message from adjunct processor queue.
154 * @qid: The AP queue number
155 * @psmid: Pointer to program supplied message identifier
156 * @msg: The message text
157 * @length: The message length
159 * Returns AP queue status structure.
160 * Condition code 1 on DQAP means the receive has taken place
161 * but only partially. The response is incomplete, hence the
163 * Condition code 2 on DQAP also means the receive is incomplete,
164 * this time because a segment boundary was reached. Again, the
166 * Note that gpr2 is used by the DQAP instruction to keep track of
167 * any 'residual' length, in case the instruction gets interrupted.
168 * Hence it gets zeroed before the instruction.
170 static inline struct ap_queue_status ap_dqap(ap_qid_t qid,
171 unsigned long long *psmid,
172 void *msg, size_t length)
174 register unsigned long reg0 asm("0") = qid | 0x80000000UL;
175 register struct ap_queue_status reg1 asm ("1");
176 register unsigned long reg2 asm("2") = 0UL;
177 register unsigned long reg4 asm("4") = (unsigned long) msg;
178 register unsigned long reg5 asm("5") = (unsigned long) length;
179 register unsigned long reg6 asm("6") = 0UL;
180 register unsigned long reg7 asm("7") = 0UL;
184 "0: .long 0xb2ae0064\n" /* DQAP */
186 : "+d" (reg0), "=d" (reg1), "+d" (reg2),
187 "+d" (reg4), "+d" (reg5), "+d" (reg6), "+d" (reg7)
189 *psmid = (((unsigned long long) reg6) << 32) + reg7;
193 #endif /* _AP_ASM_H_ */