Subversion Repositories HelenOS

Rev

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

Rev 1829 Rev 1830
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>
33
#include <macros.h>
34
 
34
 
35
 
35
 
36
typedef uint16_t domid_t;
36
typedef uint16_t domid_t;
37
 
37
 
38
 
38
 
39
typedef struct {
39
typedef struct {
40
    uint8_t vector;     /**< Exception vector */
40
    uint8_t vector;     /**< Exception vector */
41
    uint8_t flags;      /**< 0-3: privilege level; 4: clear event enable */
41
    uint8_t flags;      /**< 0-3: privilege level; 4: clear event enable */
42
    uint16_t cs;        /**< Code selector */
42
    uint16_t cs;        /**< Code selector */
43
    uintptr_t address;  /**< Code offset */
43
    uintptr_t address;  /**< Code offset */
44
} trap_info_t;
44
} trap_info_t;
45
 
45
 
46
 
46
 
47
#define XEN_SET_TRAP_TABLE      0
47
#define XEN_SET_TRAP_TABLE      0
48
#define XEN_MMU_UPDATE          1
48
#define XEN_MMU_UPDATE          1
49
#define XEN_SET_CALLBACKS       4
49
#define XEN_SET_CALLBACKS       4
50
#define XEN_UPDATE_VA_MAPPING   14
50
#define XEN_UPDATE_VA_MAPPING   14
-
 
51
#define XEN_VERSION             17
51
#define XEN_CONSOLE_IO          18
52
#define XEN_CONSOLE_IO          18
52
#define XEN_VM_ASSIST           21
53
#define XEN_VM_ASSIST           21
53
#define XEN_MMUEXT_OP           26
54
#define XEN_MMUEXT_OP           26
54
 
55
 
55
 
56
 
56
/*
57
/*
57
 * Commands for XEN_CONSOLE_IO
58
 * Commands for XEN_CONSOLE_IO
58
 */
59
 */
59
#define CONSOLE_IO_WRITE    0
60
#define CONSOLE_IO_WRITE    0
60
#define CONSOLE_IO_READ     1
61
#define CONSOLE_IO_READ     1
61
 
62
 
62
 
63
 
63
#define MMUEXT_PIN_L1_TABLE      0
64
#define MMUEXT_PIN_L1_TABLE      0
64
#define MMUEXT_PIN_L2_TABLE      1
65
#define MMUEXT_PIN_L2_TABLE      1
65
#define MMUEXT_PIN_L3_TABLE      2
66
#define MMUEXT_PIN_L3_TABLE      2
66
#define MMUEXT_PIN_L4_TABLE      3
67
#define MMUEXT_PIN_L4_TABLE      3
67
#define MMUEXT_UNPIN_TABLE       4
68
#define MMUEXT_UNPIN_TABLE       4
68
#define MMUEXT_NEW_BASEPTR       5
69
#define MMUEXT_NEW_BASEPTR       5
69
#define MMUEXT_TLB_FLUSH_LOCAL   6
70
#define MMUEXT_TLB_FLUSH_LOCAL   6
70
#define MMUEXT_INVLPG_LOCAL      7
71
#define MMUEXT_INVLPG_LOCAL      7
71
#define MMUEXT_TLB_FLUSH_MULTI   8
72
#define MMUEXT_TLB_FLUSH_MULTI   8
72
#define MMUEXT_INVLPG_MULTI      9
73
#define MMUEXT_INVLPG_MULTI      9
73
#define MMUEXT_TLB_FLUSH_ALL    10
74
#define MMUEXT_TLB_FLUSH_ALL    10
74
#define MMUEXT_INVLPG_ALL       11
75
#define MMUEXT_INVLPG_ALL       11
75
#define MMUEXT_FLUSH_CACHE      12
76
#define MMUEXT_FLUSH_CACHE      12
76
#define MMUEXT_SET_LDT          13
77
#define MMUEXT_SET_LDT          13
77
#define MMUEXT_NEW_USER_BASEPTR 15
78
#define MMUEXT_NEW_USER_BASEPTR 15
78
 
79
 
79
 
80
 
80
#define UVMF_NONE               0        /**< No flushing at all */
81
#define UVMF_NONE               0        /**< No flushing at all */
81
#define UVMF_TLB_FLUSH          1        /**< Flush entire TLB(s) */
82
#define UVMF_TLB_FLUSH          1        /**< Flush entire TLB(s) */
82
#define UVMF_INVLPG             2        /**< Flush only one entry */
83
#define UVMF_INVLPG             2        /**< Flush only one entry */
83
#define UVMF_FLUSHTYPE_MASK     3
84
#define UVMF_FLUSHTYPE_MASK     3
84
#define UVMF_MULTI              0        /**< Flush subset of TLBs */
85
#define UVMF_MULTI              0        /**< Flush subset of TLBs */
85
#define UVMF_LOCAL              0        /**< Flush local TLB */
86
#define UVMF_LOCAL              0        /**< Flush local TLB */
86
#define UVMF_ALL                (1 << 2) /**< Flush all TLBs */
87
#define UVMF_ALL                (1 << 2) /**< Flush all TLBs */
87
 
88
 
88
 
89
 
89
/*
90
/*
90
 * Commands to XEN_VM_ASSIST
91
 * Commands to XEN_VM_ASSIST
91
 */
92
 */
92
#define VMASST_CMD_ENABLE               0
93
#define VMASST_CMD_ENABLE               0
93
#define VMASST_CMD_DISABLE              1
94
#define VMASST_CMD_DISABLE              1
94
#define VMASST_TYPE_4GB_SEGMENTS        0
95
#define VMASST_TYPE_4GB_SEGMENTS        0
95
#define VMASST_TYPE_4GB_SEGMENTS_NOTIFY 1
96
#define VMASST_TYPE_4GB_SEGMENTS_NOTIFY 1
96
#define VMASST_TYPE_WRITABLE_PAGETABLES 2
97
#define VMASST_TYPE_WRITABLE_PAGETABLES 2
97
 
98
 
98
 
99
 
99
#define DOMID_SELF (0x7FF0U)
100
#define DOMID_SELF (0x7FF0U)
100
#define DOMID_IO   (0x7FF1U)
101
#define DOMID_IO   (0x7FF1U)
101
 
102
 
102
 
103
 
-
 
104
#define force_evtchn_callback() ((void) xen_version(0, 0))
-
 
105
 
103
#define hypercall0(id)  \
106
#define hypercall0(id)  \
104
    ({  \
107
    ({  \
105
        unative_t ret;  \
108
        unative_t ret;  \
106
        asm volatile (  \
109
        asm volatile (  \
107
            "call hypercall_page + (" STRING(id) " * 32)\n" \
110
            "call hypercall_page + (" STRING(id) " * 32)\n" \
108
            : "=a" (ret)    \
111
            : "=a" (ret)    \
109
            :   \
112
            :   \
110
            : "memory"  \
113
            : "memory"  \
111
        );  \
114
        );  \
112
        ret;    \
115
        ret;    \
113
    })
116
    })
114
 
117
 
115
#define hypercall1(id, p1)  \
118
#define hypercall1(id, p1)  \
116
    ({  \
119
    ({  \
117
        unative_t ret, __ign1;  \
120
        unative_t ret, __ign1;  \
118
        asm volatile (  \
121
        asm volatile (  \
119
            "call hypercall_page + (" STRING(id) " * 32)\n" \
122
            "call hypercall_page + (" STRING(id) " * 32)\n" \
120
            : "=a" (ret), \
123
            : "=a" (ret), \
121
              "=b" (__ign1) \
124
              "=b" (__ign1) \
122
            : "1" (p1)  \
125
            : "1" (p1)  \
123
            : "memory"  \
126
            : "memory"  \
124
        );  \
127
        );  \
125
        ret;    \
128
        ret;    \
126
    })
129
    })
127
 
130
 
128
#define hypercall2(id, p1, p2)  \
131
#define hypercall2(id, p1, p2)  \
129
    ({  \
132
    ({  \
130
        unative_t ret, __ign1, __ign2;  \
133
        unative_t ret, __ign1, __ign2;  \
131
        asm volatile (  \
134
        asm volatile (  \
132
            "call hypercall_page + (" STRING(id) " * 32)\n" \
135
            "call hypercall_page + (" STRING(id) " * 32)\n" \
133
            : "=a" (ret), \
136
            : "=a" (ret), \
134
              "=b" (__ign1),    \
137
              "=b" (__ign1),    \
135
              "=c" (__ign2) \
138
              "=c" (__ign2) \
136
            : "1" (p1), \
139
            : "1" (p1), \
137
              "2" (p2)  \
140
              "2" (p2)  \
138
            : "memory"  \
141
            : "memory"  \
139
        );  \
142
        );  \
140
        ret;    \
143
        ret;    \
141
    })
144
    })
142
 
145
 
143
#define hypercall3(id, p1, p2, p3)  \
146
#define hypercall3(id, p1, p2, p3)  \
144
    ({  \
147
    ({  \
145
        unative_t ret, __ign1, __ign2, __ign3;  \
148
        unative_t ret, __ign1, __ign2, __ign3;  \
146
        asm volatile (  \
149
        asm volatile (  \
147
            "call hypercall_page + (" STRING(id) " * 32)\n" \
150
            "call hypercall_page + (" STRING(id) " * 32)\n" \
148
            : "=a" (ret), \
151
            : "=a" (ret), \
149
              "=b" (__ign1),    \
152
              "=b" (__ign1),    \
150
              "=c" (__ign2),    \
153
              "=c" (__ign2),    \
151
              "=d" (__ign3) \
154
              "=d" (__ign3) \
152
            : "1" (p1), \
155
            : "1" (p1), \
153
              "2" (p2), \
156
              "2" (p2), \
154
              "3" (p3)  \
157
              "3" (p3)  \
155
            : "memory"  \
158
            : "memory"  \
156
        );  \
159
        );  \
157
        ret;    \
160
        ret;    \
158
    })
161
    })
159
 
162
 
160
#define hypercall4(id, p1, p2, p3, p4)  \
163
#define hypercall4(id, p1, p2, p3, p4)  \
161
    ({  \
164
    ({  \
162
        unative_t ret, __ign1, __ign2, __ign3, __ign4;  \
165
        unative_t ret, __ign1, __ign2, __ign3, __ign4;  \
163
        asm volatile (  \
166
        asm volatile (  \
164
            "call hypercall_page + (" STRING(id) " * 32)\n" \
167
            "call hypercall_page + (" STRING(id) " * 32)\n" \
165
            : "=a" (ret), \
168
            : "=a" (ret), \
166
              "=b" (__ign1),    \
169
              "=b" (__ign1),    \
167
              "=c" (__ign2),    \
170
              "=c" (__ign2),    \
168
              "=d" (__ign3),    \
171
              "=d" (__ign3),    \
169
              "=S" (__ign4) \
172
              "=S" (__ign4) \
170
            : "1" (p1), \
173
            : "1" (p1), \
171
              "2" (p2), \
174
              "2" (p2), \
172
              "3" (p3), \
175
              "3" (p3), \
173
              "4" (p4)  \
176
              "4" (p4)  \
174
            : "memory"  \
177
            : "memory"  \
175
        );  \
178
        );  \
176
        ret;    \
179
        ret;    \
177
    })
180
    })
178
 
181
 
179
#define hypercall5(id, p1, p2, p3, p4, p5)  \
182
#define hypercall5(id, p1, p2, p3, p4, p5)  \
180
    ({  \
183
    ({  \
181
        unative_t ret, __ign1, __ign2, __ign3, __ign4, __ign5;  \
184
        unative_t ret, __ign1, __ign2, __ign3, __ign4, __ign5;  \
182
        asm volatile (  \
185
        asm volatile (  \
183
            "call hypercall_page + (" STRING(id) " * 32)\n" \
186
            "call hypercall_page + (" STRING(id) " * 32)\n" \
184
            : "=a" (ret), \
187
            : "=a" (ret), \
185
              "=b" (__ign1),    \
188
              "=b" (__ign1),    \
186
              "=c" (__ign2),    \
189
              "=c" (__ign2),    \
187
              "=d" (__ign3),    \
190
              "=d" (__ign3),    \
188
              "=S" (__ign4),    \
191
              "=S" (__ign4),    \
189
              "=D" (__ign5) \
192
              "=D" (__ign5) \
190
            : "1" (p1), \
193
            : "1" (p1), \
191
              "2" (p2), \
194
              "2" (p2), \
192
              "3" (p3), \
195
              "3" (p3), \
193
              "4" (p4), \
196
              "4" (p4), \
194
              "5" (p5)  \
197
              "5" (p5)  \
195
            : "memory"  \
198
            : "memory"  \
196
        );  \
199
        );  \
197
        ret;    \
200
        ret;    \
198
    })
201
    })
199
 
202
 
200
 
203
 
201
static inline int xen_console_io(const unsigned int cmd, const unsigned int count, const char *str)
204
static inline int xen_console_io(const unsigned int cmd, const unsigned int count, const char *str)
202
{
205
{
203
    return hypercall3(XEN_CONSOLE_IO, cmd, count, str);
206
    return hypercall3(XEN_CONSOLE_IO, cmd, count, str);
204
}
207
}
205
 
208
 
206
static inline int xen_vm_assist(const unsigned int cmd, const unsigned int type)
209
static inline int xen_vm_assist(const unsigned int cmd, const unsigned int type)
207
{
210
{
208
    return hypercall2(XEN_VM_ASSIST, cmd, type);
211
    return hypercall2(XEN_VM_ASSIST, cmd, type);
209
}
212
}
210
 
213
 
211
static inline int xen_set_callbacks(const unsigned int event_selector, const void *event_address, const unsigned int failsafe_selector, void *failsafe_address)
214
static inline int xen_set_callbacks(const unsigned int event_selector, const void *event_address, const unsigned int failsafe_selector, void *failsafe_address)
212
{
215
{
213
    return hypercall4(XEN_SET_CALLBACKS, event_selector, event_address, failsafe_selector, failsafe_address);
216
    return hypercall4(XEN_SET_CALLBACKS, event_selector, event_address, failsafe_selector, failsafe_address);
214
}
217
}
215
 
218
 
216
static inline int xen_set_trap_table(const trap_info_t *table)
219
static inline int xen_set_trap_table(const trap_info_t *table)
217
{
220
{
218
    return hypercall1(XEN_SET_TRAP_TABLE, table);
221
    return hypercall1(XEN_SET_TRAP_TABLE, table);
219
}
222
}
-
 
223
 
-
 
224
static inline int xen_version(const unsigned int cmd, const void *arg)
-
 
225
{
-
 
226
    return hypercall2(XEN_VERSION, cmd, arg);
-
 
227
}
220
 
228
 
221
#endif
229
#endif
222
 
230