Subversion Repositories HelenOS

Rev

Rev 1813 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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