win-pvdrivers

view common/include/xen_public.h @ 382:ecfd4ddaaf3d

remove dead code
author Andy Grover <andy.grover@oracle.com>
date Wed Jul 09 12:35:41 2008 -0700 (2008-07-09)
parents eabe51317e3a
children fdb7f8853695
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 #if !defined(_XEN_PUBLIC_H_)
21 #define _XEN_PUBLIC_H_
23 #include <grant_table.h>
24 #include <event_channel.h>
25 #include <xen_guids.h>
26 //{5C568AC5-9DDF-4FA5-A94A-39D67077819C}
27 DEFINE_GUID(GUID_XEN_IFACE, 0x5C568AC5, 0x9DDF, 0x4FA5, 0xA9, 0x4A, 0x39, 0xD6, 0x70, 0x77, 0x81, 0x9C);
29 typedef PHYSICAL_ADDRESS
30 (*PXEN_ALLOCMMIO)(PVOID Context, ULONG Length);
32 typedef void
33 (*PXEN_FREEMEM)(PVOID Ptr);
35 typedef NTSTATUS
36 (*PXEN_EVTCHN_BIND)(PVOID Context, evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
38 typedef NTSTATUS
39 (*PXEN_EVTCHN_UNBIND)(PVOID Context, evtchn_port_t Port);
41 typedef NTSTATUS
42 (*PXEN_EVTCHN_MASK)(PVOID Context, evtchn_port_t Port);
44 typedef NTSTATUS
45 (*PXEN_EVTCHN_UNMASK)(PVOID Context, evtchn_port_t Port);
47 typedef NTSTATUS
48 (*PXEN_EVTCHN_NOTIFY)(PVOID Context, evtchn_port_t Port);
50 typedef evtchn_port_t
51 (*PXEN_EVTCHN_ALLOCUNBOUND)(PVOID Context, domid_t Domain);
53 typedef grant_ref_t
54 (*PXEN_GNTTBL_GRANTACCESS)(PVOID Context, domid_t domid, uint32_t frame, int readonly, grant_ref_t ref);
56 typedef BOOLEAN
57 (*PXEN_GNTTBL_ENDACCESS)(PVOID Context, grant_ref_t ref, BOOLEAN keepref);
59 typedef VOID
60 (*PXEN_GNTTBL_PUTREF)(PVOID Context, grant_ref_t ref);
62 typedef grant_ref_t
63 (*PXEN_GNTTBL_GETREF)(PVOID Context);
66 typedef VOID
67 (*PXENBUS_WATCH_CALLBACK)(char *Path, PVOID ServiceContext);
69 typedef char *
70 (*PXEN_XENBUS_READ)(PVOID Context, xenbus_transaction_t xbt, const char *path, char **value);
72 typedef char *
73 (*PXEN_XENBUS_WRITE)(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *value);
75 typedef char *
76 (*PXEN_XENBUS_PRINTF)(PVOID Context, xenbus_transaction_t xbt, const char *path, const char *fmt, ...);
78 typedef char *
79 (*PXEN_XENBUS_STARTTRANSACTION)(PVOID Context, xenbus_transaction_t *xbt);
81 typedef char *
82 (*PXEN_XENBUS_ENDTRANSACTION)(PVOID Context, xenbus_transaction_t t, int abort, int *retry);
84 typedef char *
85 (*PXEN_XENBUS_LIST)(PVOID Context, xenbus_transaction_t xbt, const char *prefix, char ***contents);
87 typedef char *
88 (*PXEN_XENBUS_ADDWATCH)(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
90 typedef char *
91 (*PXEN_XENBUS_REMWATCH)(PVOID Context, xenbus_transaction_t xbt, const char *Path, PXENBUS_WATCH_CALLBACK ServiceRoutine, PVOID ServiceContext);
93 typedef NTSTATUS
94 (*PXEN_XENPCI_XEN_CONFIG_DEVICE)(PVOID Context);
96 typedef NTSTATUS
97 (*PXEN_XENPCI_XEN_SHUTDOWN_DEVICE)(PVOID Context);
99 #define XEN_DATA_MAGIC 0x12345678
101 typedef struct {
102 ULONG magic;
103 USHORT length;
105 PVOID context;
106 PXEN_EVTCHN_BIND EvtChn_Bind;
107 PXEN_EVTCHN_BIND EvtChn_BindDpc;
108 PXEN_EVTCHN_UNBIND EvtChn_Unbind;
109 PXEN_EVTCHN_MASK EvtChn_Mask;
110 PXEN_EVTCHN_UNMASK EvtChn_Unmask;
111 PXEN_EVTCHN_NOTIFY EvtChn_Notify;
112 PXEN_GNTTBL_GETREF GntTbl_GetRef;
113 PXEN_GNTTBL_PUTREF GntTbl_PutRef;
114 PXEN_GNTTBL_GRANTACCESS GntTbl_GrantAccess;
115 PXEN_GNTTBL_ENDACCESS GntTbl_EndAccess;
116 PXEN_XENPCI_XEN_CONFIG_DEVICE XenPci_XenConfigDevice;
117 PXEN_XENPCI_XEN_SHUTDOWN_DEVICE XenPci_XenShutdownDevice;
119 } XENPCI_VECTORS, *PXENPCI_VECTORS;
121 #define RESUME_STATE_RUNNING 0
122 #define RESUME_STATE_BACKEND_RESUME 1
123 #define RESUME_STATE_FRONTEND_RESUME 2
125 typedef struct {
126 ULONG magic;
127 USHORT length;
129 ULONG resume_state;
130 } XENPCI_DEVICE_STATE, *PXENPCI_DEVICE_STATE;
132 #define XEN_INIT_TYPE_END 0
133 #define XEN_INIT_TYPE_WRITE_STRING 1
134 #define XEN_INIT_TYPE_RING 2
135 #define XEN_INIT_TYPE_EVENT_CHANNEL 3
136 #define XEN_INIT_TYPE_EVENT_CHANNEL_IRQ 4
137 #define XEN_INIT_TYPE_READ_STRING_FRONT 5
138 #define XEN_INIT_TYPE_READ_STRING_BACK 6
139 #define XEN_INIT_TYPE_VECTORS 7
140 #define XEN_INIT_TYPE_GRANT_ENTRIES 8
141 //#define XEN_INIT_TYPE_COPY_PTR 9
142 #define XEN_INIT_TYPE_RUN 10
143 #define XEN_INIT_TYPE_STATE_PTR 11
145 static __inline VOID
146 __ADD_XEN_INIT_UCHAR(PUCHAR *ptr, UCHAR val)
147 {
148 // KdPrint((__DRIVER_NAME " ADD_XEN_INIT_UCHAR *ptr = %p, val = %d\n", *ptr, val));
149 *(PUCHAR)(*ptr) = val;
150 *ptr += sizeof(UCHAR);
151 }
153 static __inline VOID
154 __ADD_XEN_INIT_USHORT(PUCHAR *ptr, USHORT val)
155 {
156 // KdPrint((__DRIVER_NAME " ADD_XEN_INIT_USHORT *ptr = %p, val = %d\n", *ptr, val));
157 *(PUSHORT)(*ptr) = val;
158 *ptr += sizeof(USHORT);
159 }
161 static __inline VOID
162 __ADD_XEN_INIT_ULONG(PUCHAR *ptr, ULONG val)
163 {
164 // KdPrint((__DRIVER_NAME " ADD_XEN_INIT_ULONG *ptr = %p, val = %d\n", *ptr, val));
165 *(PULONG)(*ptr) = val;
166 *ptr += sizeof(ULONG);
167 }
169 static __inline VOID
170 __ADD_XEN_INIT_PTR(PUCHAR *ptr, PVOID val)
171 {
172 // KdPrint((__DRIVER_NAME " ADD_XEN_INIT_PTR *ptr = %p, val = %p\n", *ptr, val));
173 *(PVOID *)(*ptr) = val;
174 *ptr += sizeof(PVOID);
175 }
177 static __inline VOID
178 __ADD_XEN_INIT_STRING(PUCHAR *ptr, PCHAR val)
179 {
180 // KdPrint((__DRIVER_NAME " ADD_XEN_INIT_STRING *ptr = %p, val = %s\n", *ptr, val));
181 RtlStringCbCopyA((PCHAR)*ptr, PAGE_SIZE - (PtrToUlong(*ptr) & (PAGE_SIZE - 1)), val);
182 *ptr += strlen(val) + 1;
183 }
185 static __inline UCHAR
186 __GET_XEN_INIT_UCHAR(PUCHAR *ptr)
187 {
188 UCHAR retval;
189 retval = **ptr;
190 // KdPrint((__DRIVER_NAME " GET_XEN_INIT_UCHAR *ptr = %p, retval = %d\n", *ptr, retval));
191 *ptr += sizeof(UCHAR);
192 return retval;
193 }
195 static __inline USHORT
196 __GET_XEN_INIT_USHORT(PUCHAR *ptr)
197 {
198 USHORT retval;
199 retval = *(PUSHORT)*ptr;
200 // KdPrint((__DRIVER_NAME " GET_XEN_INIT_USHORT *ptr = %p, retval = %d\n", *ptr, retval));
201 *ptr += sizeof(USHORT);
202 return retval;
203 }
205 static __inline ULONG
206 __GET_XEN_INIT_ULONG(PUCHAR *ptr)
207 {
208 ULONG retval;
209 retval = *(PLONG)*ptr;
210 // KdPrint((__DRIVER_NAME " GET_XEN_INIT_ULONG *ptr = %p, retval = %d\n", *ptr, retval));
211 *ptr += sizeof(ULONG);
212 return retval;
213 }
215 static __inline PCHAR
216 __GET_XEN_INIT_STRING(PUCHAR *ptr)
217 {
218 PCHAR retval;
219 retval = (PCHAR)*ptr;
220 // KdPrint((__DRIVER_NAME " GET_XEN_INIT_STRING *ptr = %p, retval = %s\n", *ptr, retval));
221 *ptr += strlen((PCHAR)*ptr) + 1;
222 return retval;
223 }
225 static __inline PVOID
226 __GET_XEN_INIT_PTR(PUCHAR *ptr)
227 {
228 PVOID retval;
229 retval = *(PVOID *)(*ptr);
230 // KdPrint((__DRIVER_NAME " GET_XEN_INIT_PTR *ptr = %p, retval = %p\n", *ptr, retval));
231 *ptr += sizeof(PVOID);
232 return retval;
233 }
235 static __inline VOID
236 ADD_XEN_INIT_REQ(PUCHAR *ptr, UCHAR type, PVOID p1, PVOID p2)
237 {
238 __ADD_XEN_INIT_UCHAR(ptr, type);
239 switch (type)
240 {
241 case XEN_INIT_TYPE_END:
242 case XEN_INIT_TYPE_VECTORS:
243 case XEN_INIT_TYPE_RUN:
244 case XEN_INIT_TYPE_STATE_PTR:
245 break;
246 case XEN_INIT_TYPE_WRITE_STRING:
247 __ADD_XEN_INIT_STRING(ptr, p1);
248 __ADD_XEN_INIT_STRING(ptr, p2);
249 break;
250 case XEN_INIT_TYPE_RING:
251 case XEN_INIT_TYPE_EVENT_CHANNEL:
252 case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ:
253 case XEN_INIT_TYPE_READ_STRING_FRONT:
254 case XEN_INIT_TYPE_READ_STRING_BACK:
255 __ADD_XEN_INIT_STRING(ptr, p1);
256 break;
257 case XEN_INIT_TYPE_GRANT_ENTRIES:
258 __ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p2));
259 break;
260 // case XEN_INIT_TYPE_COPY_PTR:
261 // __ADD_XEN_INIT_STRING(ptr, p1);
262 // __ADD_XEN_INIT_PTR(ptr, p2);
263 }
264 }
266 static __inline UCHAR
267 GET_XEN_INIT_REQ(PUCHAR *ptr, PVOID *p1, PVOID *p2)
268 {
269 UCHAR retval;
271 retval = __GET_XEN_INIT_UCHAR(ptr);
272 switch (retval)
273 {
274 case XEN_INIT_TYPE_END:
275 case XEN_INIT_TYPE_VECTORS:
276 case XEN_INIT_TYPE_RUN:
277 case XEN_INIT_TYPE_STATE_PTR:
278 *p1 = NULL;
279 *p2 = NULL;
280 break;
281 case XEN_INIT_TYPE_WRITE_STRING:
282 *p1 = __GET_XEN_INIT_STRING(ptr);
283 *p2 = __GET_XEN_INIT_STRING(ptr);
284 break;
285 case XEN_INIT_TYPE_RING:
286 case XEN_INIT_TYPE_EVENT_CHANNEL:
287 case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ:
288 case XEN_INIT_TYPE_READ_STRING_FRONT:
289 case XEN_INIT_TYPE_READ_STRING_BACK:
290 *p1 = __GET_XEN_INIT_STRING(ptr);
291 *p2 = NULL;
292 break;
293 case XEN_INIT_TYPE_GRANT_ENTRIES:
294 *p2 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
295 break;
296 // case XEN_INIT_TYPE_COPY_PTR:
297 // *p1 = __GET_XEN_INIT_STRING(ptr);
298 // *p2 = __GET_XEN_INIT_PTR(ptr);
299 }
300 return retval;
301 }
303 static __inline VOID
304 ADD_XEN_INIT_RSP(PUCHAR *ptr, UCHAR type, PVOID p1, PVOID p2)
305 {
306 __ADD_XEN_INIT_UCHAR(ptr, type);
307 switch (type)
308 {
309 case XEN_INIT_TYPE_END:
310 case XEN_INIT_TYPE_WRITE_STRING: /* this shouldn't happen */
311 case XEN_INIT_TYPE_RUN:
312 break;
313 case XEN_INIT_TYPE_RING:
314 __ADD_XEN_INIT_STRING(ptr, p1);
315 __ADD_XEN_INIT_PTR(ptr, p2);
316 break;
317 case XEN_INIT_TYPE_EVENT_CHANNEL:
318 case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ:
319 __ADD_XEN_INIT_STRING(ptr, p1);
320 __ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p2));
321 break;
322 case XEN_INIT_TYPE_READ_STRING_FRONT:
323 case XEN_INIT_TYPE_READ_STRING_BACK:
324 __ADD_XEN_INIT_STRING(ptr, p1);
325 __ADD_XEN_INIT_STRING(ptr, p2);
326 break;
327 case XEN_INIT_TYPE_VECTORS:
328 //__ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p1));
329 memcpy(*ptr, p2, sizeof(XENPCI_VECTORS));
330 *ptr += sizeof(XENPCI_VECTORS);
331 break;
332 case XEN_INIT_TYPE_GRANT_ENTRIES:
333 __ADD_XEN_INIT_ULONG(ptr, PtrToUlong(p1));
334 memcpy(*ptr, p2, PtrToUlong(p1) * sizeof(grant_entry_t));
335 *ptr += PtrToUlong(p1) * sizeof(grant_entry_t);
336 break;
337 case XEN_INIT_TYPE_STATE_PTR:
338 __ADD_XEN_INIT_PTR(ptr, p2);
339 break;
340 // case XEN_INIT_TYPE_COPY_PTR:
341 // __ADD_XEN_INIT_STRING(ptr, p1);
342 // __ADD_XEN_INIT_PTR(ptr, p2);
343 // break;
344 }
345 }
347 static __inline UCHAR
348 GET_XEN_INIT_RSP(PUCHAR *ptr, PVOID *p1, PVOID *p2)
349 {
350 UCHAR retval;
352 retval = __GET_XEN_INIT_UCHAR(ptr);
353 switch (retval)
354 {
355 case XEN_INIT_TYPE_END:
356 case XEN_INIT_TYPE_RUN:
357 *p1 = NULL;
358 *p2 = NULL;
359 break;
360 case XEN_INIT_TYPE_WRITE_STRING:
361 // this shouldn't happen - no response here
362 break;
363 case XEN_INIT_TYPE_RING:
364 *p1 = __GET_XEN_INIT_STRING(ptr);
365 *p2 = __GET_XEN_INIT_PTR(ptr);
366 break;
367 case XEN_INIT_TYPE_EVENT_CHANNEL:
368 case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ:
369 *p1 = __GET_XEN_INIT_STRING(ptr);
370 *p2 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
371 break;
372 case XEN_INIT_TYPE_READ_STRING_FRONT:
373 *p1 = __GET_XEN_INIT_STRING(ptr);
374 *p2 = __GET_XEN_INIT_STRING(ptr);
375 break;
376 case XEN_INIT_TYPE_READ_STRING_BACK:
377 *p1 = __GET_XEN_INIT_STRING(ptr);
378 *p2 = __GET_XEN_INIT_STRING(ptr);
379 break;
380 case XEN_INIT_TYPE_VECTORS:
381 *p1 = NULL;
382 *p2 = *ptr;
383 *ptr += ((PXENPCI_VECTORS)*p2)->length;
384 break;
385 case XEN_INIT_TYPE_GRANT_ENTRIES:
386 *p1 = UlongToPtr(__GET_XEN_INIT_ULONG(ptr));
387 *p2 = *ptr;
388 *ptr += PtrToUlong(*p1) * sizeof(grant_ref_t);
389 break;
390 case XEN_INIT_TYPE_STATE_PTR:
391 *p2 = __GET_XEN_INIT_PTR(ptr);
392 break;
393 // case XEN_INIT_TYPE_COPY_PTR:
394 // *p1 = __GET_XEN_INIT_STRING(ptr);
395 // *p2 = __GET_XEN_INIT_PTR(ptr);
396 }
397 return retval;
398 }
400 #endif