win-pvdrivers

view xenpci/hypercall_x86.h @ 198:c5f21187ef46

Working on suspend/resume. Suspend works (well... you get a checkpoint file), but resume fails.
author James Harper <james.harper@bendigoit.com.au>
date Thu Feb 28 09:06:35 2008 +1100 (2008-02-28)
parents edbeec8025e8
children 9b16ad37af17
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
3 Copyright (C) 2007 James Harper
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
20 static __inline int
21 HYPERVISOR_memory_op(WDFDEVICE Device, int cmd, void *arg)
22 {
23 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
24 long __res;
25 __asm {
26 mov ebx, cmd
27 mov ecx, arg
28 mov eax, hypercall_stubs
29 add eax, (__HYPERVISOR_memory_op * 32)
30 call eax
31 mov [__res], eax
32 }
33 return __res;
34 }
36 static __inline int
37 HYPERVISOR_sched_op(WDFDEVICE Device, int cmd, void *arg)
38 {
39 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
40 long __res;
41 __asm {
42 mov ebx, cmd
43 mov ecx, arg
44 mov eax, hypercall_stubs
45 add eax, (__HYPERVISOR_sched_op * 32)
46 call eax
47 mov [__res], eax
48 }
49 return __res;
50 }
52 static __inline int
53 HYPERVISOR_xen_version(WDFDEVICE Device, int cmd, void *arg)
54 {
55 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
56 long __res;
57 __asm {
58 mov ebx, cmd
59 mov ecx, arg
60 mov eax, hypercall_stubs
61 add eax, (__HYPERVISOR_xen_version * 32)
62 call eax
63 mov [__res], eax
64 }
65 return __res;
66 }
68 static __inline int
69 HYPERVISOR_grant_table_op(WDFDEVICE Device, int cmd, void *uop, unsigned int count)
70 {
71 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
72 long __res;
73 __asm {
74 mov ebx, cmd
75 mov ecx, uop
76 mov edx, count
77 mov eax, hypercall_stubs
78 add eax, (__HYPERVISOR_grant_table_op * 32)
79 call eax
80 mov [__res], eax
81 }
82 return __res;
83 }
85 static __inline int
86 HYPERVISOR_mmu_update(WDFDEVICE Device, mmu_update_t *req, int count, int *success_count, domid_t domid)
87 {
88 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
89 long __res;
90 long _domid = (long)domid;
91 __asm {
92 mov ebx, req
93 mov ecx, count
94 mov edx, success_count
95 mov edi, _domid
96 mov eax, hypercall_stubs
97 add eax, (__HYPERVISOR_mmu_update * 32)
98 call eax
99 mov [__res], eax
100 }
101 return __res;
102 }
104 static __inline int
105 HYPERVISOR_console_io(WDFDEVICE Device, int cmd, int count, char *string)
106 {
107 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
108 long __res;
109 __asm {
110 mov ebx, cmd
111 mov ecx, count
112 mov edx, string
113 mov eax, hypercall_stubs
114 add eax, (__HYPERVISOR_console_io * 32)
115 call eax
116 mov [__res], eax
117 }
118 return __res;
119 }
121 static __inline int
122 HYPERVISOR_hvm_op(WDFDEVICE Device, int op, struct xen_hvm_param *arg)
123 {
124 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
125 long __res;
126 __asm {
127 mov ebx, op
128 mov ecx, arg
129 mov eax, hypercall_stubs
130 add eax, (__HYPERVISOR_hvm_op * 32)
131 call eax
132 mov [__res], eax
133 }
134 return __res;
135 }
137 static __inline int
138 HYPERVISOR_event_channel_op(WDFDEVICE Device, int cmd, void *op)
139 {
140 char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
141 long __res;
142 __asm {
143 mov ebx, cmd
144 mov ecx, op
145 mov eax, hypercall_stubs
146 add eax, (__HYPERVISOR_event_channel_op * 32)
147 call eax
148 mov [__res], eax
149 }
150 return __res;
151 }
153 static __inline ULONGLONG
154 hvm_get_parameter(WDFDEVICE Device, int hvm_param)
155 {
156 struct xen_hvm_param a;
157 int retval;
159 KdPrint((__DRIVER_NAME " --> hvm_get_parameter\n"));
160 a.domid = DOMID_SELF;
161 a.index = hvm_param;
162 //a.value = via;
163 retval = HYPERVISOR_hvm_op(Device, HVMOP_get_param, &a);
164 KdPrint((__DRIVER_NAME " hvm_get_parameter retval = %d\n", retval));
165 KdPrint((__DRIVER_NAME " <-- hvm_get_parameter\n"));
166 return a.value;
167 }
169 static __inline int
170 HYPERVISOR_shutdown(WDFDEVICE Device, unsigned int reason)
171 {
172 struct sched_shutdown ss;
173 int retval;
175 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
177 ss.reason = reason;
179 KdPrint((__DRIVER_NAME " A\n"));
181 retval = HYPERVISOR_sched_op(Device, SCHEDOP_shutdown, &ss);
183 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
185 return retval;
186 }