This source file includes following definitions.
- epapr_paravirt_early_init
- ev_int_set_config
- ev_int_get_config
- ev_int_set_mask
- ev_int_get_mask
- ev_int_eoi
- ev_byte_channel_send
- ev_byte_channel_receive
- ev_byte_channel_poll
- ev_int_iack
- ev_doorbell_send
- ev_idle
- epapr_hypercall
- epapr_hypercall
- epapr_hypercall0_1
- epapr_hypercall0
- epapr_hypercall1
- epapr_hypercall2
- epapr_hypercall3
- epapr_hypercall4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #ifndef _EPAPR_HCALLS_H
51 #define _EPAPR_HCALLS_H
52
53 #include <uapi/asm/epapr_hcalls.h>
54
55 #ifndef __ASSEMBLY__
56 #include <linux/types.h>
57 #include <linux/errno.h>
58 #include <asm/byteorder.h>
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 #define EV_HCALL_CLOBBERS "r0", "r12", "xer", "ctr", "lr", "cc", "memory"
95
96 #define EV_HCALL_CLOBBERS8 EV_HCALL_CLOBBERS
97 #define EV_HCALL_CLOBBERS7 EV_HCALL_CLOBBERS8, "r10"
98 #define EV_HCALL_CLOBBERS6 EV_HCALL_CLOBBERS7, "r9"
99 #define EV_HCALL_CLOBBERS5 EV_HCALL_CLOBBERS6, "r8"
100 #define EV_HCALL_CLOBBERS4 EV_HCALL_CLOBBERS5, "r7"
101 #define EV_HCALL_CLOBBERS3 EV_HCALL_CLOBBERS4, "r6"
102 #define EV_HCALL_CLOBBERS2 EV_HCALL_CLOBBERS3, "r5"
103 #define EV_HCALL_CLOBBERS1 EV_HCALL_CLOBBERS2, "r4"
104
105 extern bool epapr_paravirt_enabled;
106 extern u32 epapr_hypercall_start[];
107
108 #ifdef CONFIG_EPAPR_PARAVIRT
109 int __init epapr_paravirt_early_init(void);
110 #else
111 static inline int epapr_paravirt_early_init(void) { return 0; }
112 #endif
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 static inline unsigned int ev_int_set_config(unsigned int interrupt,
137 uint32_t config, unsigned int priority, uint32_t destination)
138 {
139 register uintptr_t r11 __asm__("r11");
140 register uintptr_t r3 __asm__("r3");
141 register uintptr_t r4 __asm__("r4");
142 register uintptr_t r5 __asm__("r5");
143 register uintptr_t r6 __asm__("r6");
144
145 r11 = EV_HCALL_TOKEN(EV_INT_SET_CONFIG);
146 r3 = interrupt;
147 r4 = config;
148 r5 = priority;
149 r6 = destination;
150
151 asm volatile("bl epapr_hypercall_start"
152 : "+r" (r11), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6)
153 : : EV_HCALL_CLOBBERS4
154 );
155
156 return r3;
157 }
158
159
160
161
162
163
164
165
166
167
168 static inline unsigned int ev_int_get_config(unsigned int interrupt,
169 uint32_t *config, unsigned int *priority, uint32_t *destination)
170 {
171 register uintptr_t r11 __asm__("r11");
172 register uintptr_t r3 __asm__("r3");
173 register uintptr_t r4 __asm__("r4");
174 register uintptr_t r5 __asm__("r5");
175 register uintptr_t r6 __asm__("r6");
176
177 r11 = EV_HCALL_TOKEN(EV_INT_GET_CONFIG);
178 r3 = interrupt;
179
180 asm volatile("bl epapr_hypercall_start"
181 : "+r" (r11), "+r" (r3), "=r" (r4), "=r" (r5), "=r" (r6)
182 : : EV_HCALL_CLOBBERS4
183 );
184
185 *config = r4;
186 *priority = r5;
187 *destination = r6;
188
189 return r3;
190 }
191
192
193
194
195
196
197
198
199 static inline unsigned int ev_int_set_mask(unsigned int interrupt,
200 unsigned int mask)
201 {
202 register uintptr_t r11 __asm__("r11");
203 register uintptr_t r3 __asm__("r3");
204 register uintptr_t r4 __asm__("r4");
205
206 r11 = EV_HCALL_TOKEN(EV_INT_SET_MASK);
207 r3 = interrupt;
208 r4 = mask;
209
210 asm volatile("bl epapr_hypercall_start"
211 : "+r" (r11), "+r" (r3), "+r" (r4)
212 : : EV_HCALL_CLOBBERS2
213 );
214
215 return r3;
216 }
217
218
219
220
221
222
223
224
225 static inline unsigned int ev_int_get_mask(unsigned int interrupt,
226 unsigned int *mask)
227 {
228 register uintptr_t r11 __asm__("r11");
229 register uintptr_t r3 __asm__("r3");
230 register uintptr_t r4 __asm__("r4");
231
232 r11 = EV_HCALL_TOKEN(EV_INT_GET_MASK);
233 r3 = interrupt;
234
235 asm volatile("bl epapr_hypercall_start"
236 : "+r" (r11), "+r" (r3), "=r" (r4)
237 : : EV_HCALL_CLOBBERS2
238 );
239
240 *mask = r4;
241
242 return r3;
243 }
244
245
246
247
248
249
250
251
252
253
254
255 static inline unsigned int ev_int_eoi(unsigned int interrupt)
256 {
257 register uintptr_t r11 __asm__("r11");
258 register uintptr_t r3 __asm__("r3");
259
260 r11 = EV_HCALL_TOKEN(EV_INT_EOI);
261 r3 = interrupt;
262
263 asm volatile("bl epapr_hypercall_start"
264 : "+r" (r11), "+r" (r3)
265 : : EV_HCALL_CLOBBERS1
266 );
267
268 return r3;
269 }
270
271
272
273
274
275
276
277
278
279
280
281
282 static inline unsigned int ev_byte_channel_send(unsigned int handle,
283 unsigned int *count, const char buffer[EV_BYTE_CHANNEL_MAX_BYTES])
284 {
285 register uintptr_t r11 __asm__("r11");
286 register uintptr_t r3 __asm__("r3");
287 register uintptr_t r4 __asm__("r4");
288 register uintptr_t r5 __asm__("r5");
289 register uintptr_t r6 __asm__("r6");
290 register uintptr_t r7 __asm__("r7");
291 register uintptr_t r8 __asm__("r8");
292 const uint32_t *p = (const uint32_t *) buffer;
293
294 r11 = EV_HCALL_TOKEN(EV_BYTE_CHANNEL_SEND);
295 r3 = handle;
296 r4 = *count;
297 r5 = be32_to_cpu(p[0]);
298 r6 = be32_to_cpu(p[1]);
299 r7 = be32_to_cpu(p[2]);
300 r8 = be32_to_cpu(p[3]);
301
302 asm volatile("bl epapr_hypercall_start"
303 : "+r" (r11), "+r" (r3),
304 "+r" (r4), "+r" (r5), "+r" (r6), "+r" (r7), "+r" (r8)
305 : : EV_HCALL_CLOBBERS6
306 );
307
308 *count = r4;
309
310 return r3;
311 }
312
313
314
315
316
317
318
319
320
321
322
323
324
325 static inline unsigned int ev_byte_channel_receive(unsigned int handle,
326 unsigned int *count, char buffer[EV_BYTE_CHANNEL_MAX_BYTES])
327 {
328 register uintptr_t r11 __asm__("r11");
329 register uintptr_t r3 __asm__("r3");
330 register uintptr_t r4 __asm__("r4");
331 register uintptr_t r5 __asm__("r5");
332 register uintptr_t r6 __asm__("r6");
333 register uintptr_t r7 __asm__("r7");
334 register uintptr_t r8 __asm__("r8");
335 uint32_t *p = (uint32_t *) buffer;
336
337 r11 = EV_HCALL_TOKEN(EV_BYTE_CHANNEL_RECEIVE);
338 r3 = handle;
339 r4 = *count;
340
341 asm volatile("bl epapr_hypercall_start"
342 : "+r" (r11), "+r" (r3), "+r" (r4),
343 "=r" (r5), "=r" (r6), "=r" (r7), "=r" (r8)
344 : : EV_HCALL_CLOBBERS6
345 );
346
347 *count = r4;
348 p[0] = cpu_to_be32(r5);
349 p[1] = cpu_to_be32(r6);
350 p[2] = cpu_to_be32(r7);
351 p[3] = cpu_to_be32(r8);
352
353 return r3;
354 }
355
356
357
358
359
360
361
362
363
364
365
366
367
368 static inline unsigned int ev_byte_channel_poll(unsigned int handle,
369 unsigned int *rx_count, unsigned int *tx_count)
370 {
371 register uintptr_t r11 __asm__("r11");
372 register uintptr_t r3 __asm__("r3");
373 register uintptr_t r4 __asm__("r4");
374 register uintptr_t r5 __asm__("r5");
375
376 r11 = EV_HCALL_TOKEN(EV_BYTE_CHANNEL_POLL);
377 r3 = handle;
378
379 asm volatile("bl epapr_hypercall_start"
380 : "+r" (r11), "+r" (r3), "=r" (r4), "=r" (r5)
381 : : EV_HCALL_CLOBBERS3
382 );
383
384 *rx_count = r4;
385 *tx_count = r5;
386
387 return r3;
388 }
389
390
391
392
393
394
395
396
397
398
399
400
401
402 static inline unsigned int ev_int_iack(unsigned int handle,
403 unsigned int *vector)
404 {
405 register uintptr_t r11 __asm__("r11");
406 register uintptr_t r3 __asm__("r3");
407 register uintptr_t r4 __asm__("r4");
408
409 r11 = EV_HCALL_TOKEN(EV_INT_IACK);
410 r3 = handle;
411
412 asm volatile("bl epapr_hypercall_start"
413 : "+r" (r11), "+r" (r3), "=r" (r4)
414 : : EV_HCALL_CLOBBERS2
415 );
416
417 *vector = r4;
418
419 return r3;
420 }
421
422
423
424
425
426
427
428 static inline unsigned int ev_doorbell_send(unsigned int handle)
429 {
430 register uintptr_t r11 __asm__("r11");
431 register uintptr_t r3 __asm__("r3");
432
433 r11 = EV_HCALL_TOKEN(EV_DOORBELL_SEND);
434 r3 = handle;
435
436 asm volatile("bl epapr_hypercall_start"
437 : "+r" (r11), "+r" (r3)
438 : : EV_HCALL_CLOBBERS1
439 );
440
441 return r3;
442 }
443
444
445
446
447
448
449 static inline unsigned int ev_idle(void)
450 {
451 register uintptr_t r11 __asm__("r11");
452 register uintptr_t r3 __asm__("r3");
453
454 r11 = EV_HCALL_TOKEN(EV_IDLE);
455
456 asm volatile("bl epapr_hypercall_start"
457 : "+r" (r11), "=r" (r3)
458 : : EV_HCALL_CLOBBERS1
459 );
460
461 return r3;
462 }
463
464 #ifdef CONFIG_EPAPR_PARAVIRT
465 static inline unsigned long epapr_hypercall(unsigned long *in,
466 unsigned long *out,
467 unsigned long nr)
468 {
469 register unsigned long r0 asm("r0");
470 register unsigned long r3 asm("r3") = in[0];
471 register unsigned long r4 asm("r4") = in[1];
472 register unsigned long r5 asm("r5") = in[2];
473 register unsigned long r6 asm("r6") = in[3];
474 register unsigned long r7 asm("r7") = in[4];
475 register unsigned long r8 asm("r8") = in[5];
476 register unsigned long r9 asm("r9") = in[6];
477 register unsigned long r10 asm("r10") = in[7];
478 register unsigned long r11 asm("r11") = nr;
479 register unsigned long r12 asm("r12");
480
481 asm volatile("bl epapr_hypercall_start"
482 : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6),
483 "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11),
484 "=r"(r12)
485 : "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7), "r"(r8),
486 "r"(r9), "r"(r10), "r"(r11)
487 : "memory", "cc", "xer", "ctr", "lr");
488
489 out[0] = r4;
490 out[1] = r5;
491 out[2] = r6;
492 out[3] = r7;
493 out[4] = r8;
494 out[5] = r9;
495 out[6] = r10;
496 out[7] = r11;
497
498 return r3;
499 }
500 #else
501 static unsigned long epapr_hypercall(unsigned long *in,
502 unsigned long *out,
503 unsigned long nr)
504 {
505 return EV_UNIMPLEMENTED;
506 }
507 #endif
508
509 static inline long epapr_hypercall0_1(unsigned int nr, unsigned long *r2)
510 {
511 unsigned long in[8] = {0};
512 unsigned long out[8];
513 unsigned long r;
514
515 r = epapr_hypercall(in, out, nr);
516 *r2 = out[0];
517
518 return r;
519 }
520
521 static inline long epapr_hypercall0(unsigned int nr)
522 {
523 unsigned long in[8] = {0};
524 unsigned long out[8];
525
526 return epapr_hypercall(in, out, nr);
527 }
528
529 static inline long epapr_hypercall1(unsigned int nr, unsigned long p1)
530 {
531 unsigned long in[8] = {0};
532 unsigned long out[8];
533
534 in[0] = p1;
535 return epapr_hypercall(in, out, nr);
536 }
537
538 static inline long epapr_hypercall2(unsigned int nr, unsigned long p1,
539 unsigned long p2)
540 {
541 unsigned long in[8] = {0};
542 unsigned long out[8];
543
544 in[0] = p1;
545 in[1] = p2;
546 return epapr_hypercall(in, out, nr);
547 }
548
549 static inline long epapr_hypercall3(unsigned int nr, unsigned long p1,
550 unsigned long p2, unsigned long p3)
551 {
552 unsigned long in[8] = {0};
553 unsigned long out[8];
554
555 in[0] = p1;
556 in[1] = p2;
557 in[2] = p3;
558 return epapr_hypercall(in, out, nr);
559 }
560
561 static inline long epapr_hypercall4(unsigned int nr, unsigned long p1,
562 unsigned long p2, unsigned long p3,
563 unsigned long p4)
564 {
565 unsigned long in[8] = {0};
566 unsigned long out[8];
567
568 in[0] = p1;
569 in[1] = p2;
570 in[2] = p3;
571 in[3] = p4;
572 return epapr_hypercall(in, out, nr);
573 }
574 #endif
575 #endif