Rev 1816 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1813 | decky | 1 | /* |
2 | * Copyright (C) 2006 Martin Decky |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
13 | * documentation and/or other materials provided with the distribution. |
||
14 | * - The name of the author may not be used to endorse or promote products |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
29 | #ifndef __xen32_HYPERCALL_H__ |
||
30 | #define __xen32_HYPERCALL_H__ |
||
31 | |||
32 | #include <arch/types.h> |
||
33 | |||
34 | #define hypercall0(id) \ |
||
35 | ({ \ |
||
36 | unative_t ret; \ |
||
37 | asm volatile ( \ |
||
38 | "call hypercall_page + (" STRING(id) " * 32)\n" \ |
||
39 | : "=a" (ret) \ |
||
40 | : \ |
||
41 | : "memory" \ |
||
42 | ); \ |
||
43 | ret; \ |
||
44 | }) |
||
45 | |||
46 | #define hypercall1(id, p1) \ |
||
47 | ({ \ |
||
48 | unative_t ret, __ign1; \ |
||
49 | asm volatile ( \ |
||
50 | "call hypercall_page + (" STRING(id) " * 32)\n" \ |
||
51 | : "=a" (ret), \ |
||
52 | "=b" (__ign1) \ |
||
53 | : "1" (p1) \ |
||
54 | : "memory" \ |
||
55 | ); \ |
||
56 | ret; \ |
||
57 | }) |
||
58 | |||
59 | #define hypercall2(id, p1, p2) \ |
||
60 | ({ \ |
||
61 | unative_t ret, __ign1, __ign2; \ |
||
62 | asm volatile ( \ |
||
63 | "call hypercall_page + (" STRING(id) " * 32)\n" \ |
||
64 | : "=a" (ret), \ |
||
65 | "=b" (__ign1), \ |
||
66 | "=c" (__ign2) \ |
||
67 | : "1" (p1), \ |
||
68 | "2" (p2) \ |
||
69 | : "memory" \ |
||
70 | ); \ |
||
71 | ret; \ |
||
72 | }) |
||
73 | |||
74 | #define hypercall3(id, p1, p2, p3) \ |
||
75 | ({ \ |
||
76 | unative_t ret, __ign1, __ign2, __ign3; \ |
||
77 | asm volatile ( \ |
||
78 | "call hypercall_page + (" STRING(id) " * 32)\n" \ |
||
79 | : "=a" (ret), \ |
||
80 | "=b" (__ign1), \ |
||
81 | "=c" (__ign2), \ |
||
82 | "=d" (__ign3) \ |
||
83 | : "1" (p1), \ |
||
84 | "2" (p2), \ |
||
85 | "3" (p3), \ |
||
86 | : "memory" \ |
||
87 | ); \ |
||
88 | ret; \ |
||
89 | }) |
||
90 | |||
91 | #define hypercall4(id, p1, p2, p3, p4) \ |
||
92 | ({ \ |
||
93 | unative_t ret, __ign1, __ign2, __ign3, __ign4; \ |
||
94 | asm volatile ( \ |
||
95 | "call hypercall_page + (" STRING(id) " * 32)\n" \ |
||
96 | : "=a" (ret), \ |
||
97 | "=b" (__ign1), \ |
||
98 | "=c" (__ign2), \ |
||
99 | "=d" (__ign3), \ |
||
100 | "=S" (__ign4) \ |
||
101 | : "1" (p1), \ |
||
102 | "2" (p2), \ |
||
103 | "3" (p3), \ |
||
104 | "4" (p4), \ |
||
105 | : "memory" \ |
||
106 | ); \ |
||
107 | ret; \ |
||
108 | }) |
||
109 | |||
110 | #define hypercall5(id, p1, p2, p3, p4, p5) \ |
||
111 | ({ \ |
||
112 | unative_t ret, __ign1, __ign2, __ign3, __ign4, __ing5; \ |
||
113 | asm volatile ( \ |
||
114 | "call hypercall_page + (" STRING(id) " * 32)\n" \ |
||
115 | : "=a" (ret), \ |
||
116 | "=b" (__ign1), \ |
||
117 | "=c" (__ign2), \ |
||
118 | "=d" (__ign3), \ |
||
119 | "=S" (__ign4), \ |
||
120 | "=D" (__ign5) \ |
||
121 | : "1" (p1), \ |
||
122 | "2" (p2), \ |
||
123 | "3" (p3), \ |
||
124 | "4" (p4), \ |
||
125 | "5" (p5), \ |
||
126 | : "memory" \ |
||
127 | ); \ |
||
128 | ret; \ |
||
129 | }) |
||
130 | |||
131 | |||
132 | static inline int xen_console_io(int cmd, int count, char *str) |
||
133 | { |
||
134 | return hypercall3(XEN_CONSOLE_IO, cmd, count, str); |
||
135 | } |
||
136 | |||
137 | #endif |