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 | #include <macros.h>
|
---|
34 |
|
---|
35 |
|
---|
36 | #define XEN_CONSOLE_IO 18
|
---|
37 |
|
---|
38 |
|
---|
39 | /*
|
---|
40 | * Commands for XEN_CONSOLE_IO
|
---|
41 | */
|
---|
42 | #define CONSOLE_IO_WRITE 0
|
---|
43 | #define CONSOLE_IO_READ 1
|
---|
44 |
|
---|
45 |
|
---|
46 | #define hypercall0(id) \
|
---|
47 | ({ \
|
---|
48 | unative_t ret; \
|
---|
49 | asm volatile ( \
|
---|
50 | "call hypercall_page + (" STRING(id) " * 32)\n" \
|
---|
51 | : "=a" (ret) \
|
---|
52 | : \
|
---|
53 | : "memory" \
|
---|
54 | ); \
|
---|
55 | ret; \
|
---|
56 | })
|
---|
57 |
|
---|
58 | #define hypercall1(id, p1) \
|
---|
59 | ({ \
|
---|
60 | unative_t ret, __ign1; \
|
---|
61 | asm volatile ( \
|
---|
62 | "call hypercall_page + (" STRING(id) " * 32)\n" \
|
---|
63 | : "=a" (ret), \
|
---|
64 | "=b" (__ign1) \
|
---|
65 | : "1" (p1) \
|
---|
66 | : "memory" \
|
---|
67 | ); \
|
---|
68 | ret; \
|
---|
69 | })
|
---|
70 |
|
---|
71 | #define hypercall2(id, p1, p2) \
|
---|
72 | ({ \
|
---|
73 | unative_t ret, __ign1, __ign2; \
|
---|
74 | asm volatile ( \
|
---|
75 | "call hypercall_page + (" STRING(id) " * 32)\n" \
|
---|
76 | : "=a" (ret), \
|
---|
77 | "=b" (__ign1), \
|
---|
78 | "=c" (__ign2) \
|
---|
79 | : "1" (p1), \
|
---|
80 | "2" (p2) \
|
---|
81 | : "memory" \
|
---|
82 | ); \
|
---|
83 | ret; \
|
---|
84 | })
|
---|
85 |
|
---|
86 | #define hypercall3(id, p1, p2, p3) \
|
---|
87 | ({ \
|
---|
88 | unative_t ret, __ign1, __ign2, __ign3; \
|
---|
89 | asm volatile ( \
|
---|
90 | "call hypercall_page + (" STRING(id) " * 32)\n" \
|
---|
91 | : "=a" (ret), \
|
---|
92 | "=b" (__ign1), \
|
---|
93 | "=c" (__ign2), \
|
---|
94 | "=d" (__ign3) \
|
---|
95 | : "1" (p1), \
|
---|
96 | "2" (p2), \
|
---|
97 | "3" (p3) \
|
---|
98 | : "memory" \
|
---|
99 | ); \
|
---|
100 | ret; \
|
---|
101 | })
|
---|
102 |
|
---|
103 | #define hypercall4(id, p1, p2, p3, p4) \
|
---|
104 | ({ \
|
---|
105 | unative_t ret, __ign1, __ign2, __ign3, __ign4; \
|
---|
106 | asm volatile ( \
|
---|
107 | "call hypercall_page + (" STRING(id) " * 32)\n" \
|
---|
108 | : "=a" (ret), \
|
---|
109 | "=b" (__ign1), \
|
---|
110 | "=c" (__ign2), \
|
---|
111 | "=d" (__ign3), \
|
---|
112 | "=S" (__ign4) \
|
---|
113 | : "1" (p1), \
|
---|
114 | "2" (p2), \
|
---|
115 | "3" (p3), \
|
---|
116 | "4" (p4) \
|
---|
117 | : "memory" \
|
---|
118 | ); \
|
---|
119 | ret; \
|
---|
120 | })
|
---|
121 |
|
---|
122 | #define hypercall5(id, p1, p2, p3, p4, p5) \
|
---|
123 | ({ \
|
---|
124 | unative_t ret, __ign1, __ign2, __ign3, __ign4, __ign5; \
|
---|
125 | asm volatile ( \
|
---|
126 | "call hypercall_page + (" STRING(id) " * 32)\n" \
|
---|
127 | : "=a" (ret), \
|
---|
128 | "=b" (__ign1), \
|
---|
129 | "=c" (__ign2), \
|
---|
130 | "=d" (__ign3), \
|
---|
131 | "=S" (__ign4), \
|
---|
132 | "=D" (__ign5) \
|
---|
133 | : "1" (p1), \
|
---|
134 | "2" (p2), \
|
---|
135 | "3" (p3), \
|
---|
136 | "4" (p4), \
|
---|
137 | "5" (p5) \
|
---|
138 | : "memory" \
|
---|
139 | ); \
|
---|
140 | ret; \
|
---|
141 | })
|
---|
142 |
|
---|
143 |
|
---|
144 | static inline int xen_console_io(const int cmd, const int count, const char *str)
|
---|
145 | {
|
---|
146 | return hypercall3(XEN_CONSOLE_IO, cmd, count, str);
|
---|
147 | }
|
---|
148 |
|
---|
149 | #endif
|
---|