win-pvdrivers

view xenpci/xenpci_export.c @ 1004:a5d1d333e0e2

Start of major changes to xenpci interface. Now using xenpci as export driver. storport and xennet6 drivers working but not suspend/resume or dump mode
author James Harper <james.harper@bendigoit.com.au>
date Sun Jan 06 14:08:22 2013 +1100 (2013-01-06)
parents
children 4f7d5a8636bd
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
3 Copyright (C) 2012 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 #include "xenpci.h"
22 ULONG
23 XnGetVersion() {
24 return 1;
25 }
27 static VOID
28 XnBackendStateCallback(char *path, PVOID context) {
29 WDFDEVICE device = context;
30 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
31 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
32 PCHAR err;
33 PCHAR value;
34 ULONG backend_state;
36 FUNCTION_ENTER();
37 //RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
38 FUNCTION_MSG("Read path=%s\n", path);
39 err = XenBus_Read(xpdd, XBT_NIL, path, &value);
40 if (err) {
41 FUNCTION_MSG("Error %s\n", err);
42 XenPci_FreeMem(err);
43 /* this is pretty catastrophic... */
44 /* maybe call the callback with an unknown or something... or just ignore? */
45 FUNCTION_EXIT();
46 return;
47 }
48 FUNCTION_MSG("Read value=%s\n", value);
49 backend_state = atoi(value);
50 XenPci_FreeMem(value);
51 xppdd->backend_state_callback(xppdd->backend_state_callback_context, backend_state);
52 FUNCTION_EXIT();
53 }
56 char *
57 XenBus_AddWatchx(
58 PVOID Context,
59 xenbus_transaction_t xbt,
60 char *Path,
61 PXN_WATCH_CALLBACK ServiceRoutine,
62 PVOID ServiceContext);
64 XN_HANDLE
65 XnOpenDevice(PDEVICE_OBJECT pdo, PXN_BACKEND_STATE_CALLBACK callback, PVOID context) {
66 WDFDEVICE device;
67 PXENPCI_PDO_DEVICE_DATA xppdd;
68 PXENPCI_DEVICE_DATA xpdd;
69 PCHAR response;
70 CHAR path[128];
72 FUNCTION_ENTER();
73 device = WdfWdmDeviceGetWdfDeviceHandle(pdo);
74 if (!device) {
75 FUNCTION_MSG("Failed to get WDFDEVICE for %p\n", pdo);
76 return NULL;
77 }
78 xppdd = GetXppdd(device);
79 xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
80 xppdd->backend_state_callback = callback;
81 xppdd->backend_state_callback_context = context;
82 RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
83 response = XenBus_AddWatch(xpdd, XBT_NIL, path, XnBackendStateCallback, device);
84 if (response) {
85 FUNCTION_MSG("XnAddWatch - %s = %s\n", path, response);
86 XenPci_FreeMem(response);
87 xppdd->backend_state_callback = NULL;
88 xppdd->backend_state_callback_context = NULL;
89 FUNCTION_EXIT();
90 return NULL;
91 }
93 FUNCTION_EXIT();
94 return device;
95 }
97 VOID
98 XnCloseDevice(XN_HANDLE handle) {
99 UNREFERENCED_PARAMETER(handle);
100 }
102 #if 0
103 NTSTATUS
104 XnAddWatch(XN_HANDLE handle, char *path, PXN_WATCH_CALLBACK callback, PVOID context) {
105 WDFDEVICE device = handle;
106 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
107 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
108 PCHAR response;
109 NTSTATUS status;
111 response = XenBus_AddWatch(xpdd, XBT_NIL, path, callback, context);
112 if (response == NULL) {
113 FUNCTION_MSG("XnAddWatch - %s = NULL\n", path);
114 status = STATUS_SUCCESS;
115 } else {
116 FUNCTION_MSG("XnAddWatch - %s = %s\n", path, response);
117 XenPci_FreeMem(response);
118 status = STATUS_UNSUCCESSFUL;
119 }
120 return status;
121 }
123 NTSTATUS
124 XnRemoveWatch(XN_HANDLE handle, char *path, PXN_WATCH_CALLBACK callback, PVOID context) {
125 WDFDEVICE device = handle;
126 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
127 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
128 PCHAR response;
129 NTSTATUS status;
131 response = XenBus_RemWatch(xpdd, XBT_NIL, path, callback, context);
132 if (response == NULL) {
133 FUNCTION_MSG("XnRemoveWatch - %s = NULL\n", path);
134 status = STATUS_SUCCESS;
135 } else {
136 FUNCTION_MSG("XnRemoveWatch - %s = %s\n", path, response);
137 XenPci_FreeMem(response);
138 status = STATUS_UNSUCCESSFUL;
139 }
140 }
141 #endif
143 evtchn_port_t
144 XnAllocateEvent(XN_HANDLE handle) {
145 WDFDEVICE device = handle;
146 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
147 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
148 return EvtChn_AllocUnbound(xpdd, xppdd->backend_id);
149 }
151 VOID
152 XnFreeEvent(XN_HANDLE handle, evtchn_port_t port) {
153 WDFDEVICE device = handle;
154 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
155 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
156 EvtChn_Close(xpdd, port);
157 return;
158 }
160 NTSTATUS
161 XnBindEvent(XN_HANDLE handle, evtchn_port_t port, PXN_EVENT_CALLBACK callback, PVOID context) {
162 WDFDEVICE device = handle;
163 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
164 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
165 return EvtChn_Bind(xpdd, port, callback, context, EVT_ACTION_FLAGS_DEFAULT);
166 }
168 NTSTATUS
169 XnUnBindEvent(XN_HANDLE handle, evtchn_port_t port) {
170 WDFDEVICE device = handle;
171 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
172 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
173 return EvtChn_Unbind(xpdd, port);
174 }
176 grant_ref_t
177 XnGrantAccess(XN_HANDLE handle, uint32_t frame, int readonly, grant_ref_t ref, ULONG tag)
178 {
179 WDFDEVICE device = handle;
180 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
181 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
182 return GntTbl_GrantAccess(xpdd, xppdd->backend_id, frame, readonly, ref, tag);
183 }
185 BOOLEAN
186 XnEndAccess(XN_HANDLE handle, grant_ref_t ref, BOOLEAN keepref, ULONG tag)
187 {
188 WDFDEVICE device = handle;
189 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
190 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
191 return GntTbl_EndAccess(xpdd, ref, keepref, tag);
192 }
194 grant_ref_t
195 XnAllocateGrant(XN_HANDLE handle, ULONG tag) {
196 WDFDEVICE device = handle;
197 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
198 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
199 return GntTbl_GetRef(xpdd, tag);
200 }
202 VOID
203 XnFreeGrant(XN_HANDLE handle, grant_ref_t ref, ULONG tag) {
204 WDFDEVICE device = handle;
205 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
206 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
207 GntTbl_PutRef(xpdd, ref, tag);
208 }
210 /* result must be freed with XnFreeMem() */
211 NTSTATUS
212 XnReadString(XN_HANDLE handle, ULONG base, PCHAR path, PCHAR *value) {
213 WDFDEVICE device = handle;
214 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
215 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
216 PCHAR response;
217 CHAR full_path[1024];
219 switch(base) {
220 case XN_BASE_FRONTEND:
221 strncpy(full_path, xppdd->path, 1024);
222 break;
223 case XN_BASE_BACKEND:
224 strncpy(full_path, xppdd->backend_path, 1024);
225 break;
226 case XN_BASE_GLOBAL:
227 strncpy(full_path, "", 1024);
228 }
229 strncat(full_path, "/", 1024);
230 strncat(full_path, path, 1024);
232 response = XenBus_Read(xpdd, XBT_NIL, full_path, value);
233 if (response) {
234 FUNCTION_MSG("Error reading shutdown path - %s\n", response);
235 XenPci_FreeMem(response);
236 FUNCTION_EXIT();
237 return STATUS_UNSUCCESSFUL;
238 }
239 return STATUS_SUCCESS;
240 }
242 NTSTATUS
243 XnWriteString(XN_HANDLE handle, ULONG base, PCHAR path, PCHAR value) {
244 WDFDEVICE device = handle;
245 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
246 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
247 PCHAR response;
248 CHAR full_path[1024];
250 switch(base) {
251 case XN_BASE_FRONTEND:
252 strncpy(full_path, xppdd->path, 1024);
253 break;
254 case XN_BASE_BACKEND:
255 strncpy(full_path, xppdd->backend_path, 1024);
256 break;
257 case XN_BASE_GLOBAL:
258 strncpy(full_path, "", 1024);
259 }
260 strncat(full_path, "/", 1024);
261 strncat(full_path, path, 1024);
262 FUNCTION_MSG("XnWriteString(%s, %s)\n", full_path, value);
263 response = XenBus_Write(xpdd, XBT_NIL, full_path, value);
264 if (response) {
265 FUNCTION_MSG("XnWriteString - %s = %s\n", full_path, response);
266 XenPci_FreeMem(response);
267 FUNCTION_EXIT();
268 return STATUS_UNSUCCESSFUL;
269 }
270 return STATUS_SUCCESS;
271 }
273 NTSTATUS
274 XnReadInt32(XN_HANDLE handle, ULONG base, PCHAR path, ULONG *value) {
275 WDFDEVICE device = handle;
276 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
277 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
278 CHAR full_path[1024];
279 PCHAR response;
280 PCHAR string_value;
282 switch(base) {
283 case XN_BASE_FRONTEND:
284 strncpy(full_path, xppdd->path, 1024);
285 break;
286 case XN_BASE_BACKEND:
287 strncpy(full_path, xppdd->backend_path, 1024);
288 break;
289 case XN_BASE_GLOBAL:
290 strncpy(full_path, "", 1024);
291 }
292 strncat(full_path, "/", 1024);
293 strncat(full_path, path, 1024);
294 response = XenBus_Read(xpdd, XBT_NIL, full_path, &string_value);
295 if (response) {
296 FUNCTION_MSG("XnReadInt - %s = %s\n", full_path, response);
297 XenPci_FreeMem(response);
298 FUNCTION_EXIT();
299 return STATUS_UNSUCCESSFUL;
300 }
301 *value = atoi(string_value);
302 return STATUS_SUCCESS;
303 }
305 NTSTATUS
306 XnWriteInt32(XN_HANDLE handle, ULONG base, PCHAR path, ULONG value) {
307 WDFDEVICE device = handle;
308 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
309 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
310 CHAR full_path[1024];
311 PCHAR response;
313 switch(base) {
314 case XN_BASE_FRONTEND:
315 strncpy(full_path, xppdd->path, 1024);
316 break;
317 case XN_BASE_BACKEND:
318 strncpy(full_path, xppdd->backend_path, 1024);
319 break;
320 case XN_BASE_GLOBAL:
321 strncpy(full_path, "", 1024);
322 }
323 strncat(full_path, "/", 1024);
324 strncat(full_path, path, 1024);
326 FUNCTION_MSG("XnWriteInt32(%s, %d)\n", full_path, value);
327 response = XenBus_Printf(xpdd, XBT_NIL, full_path, "%d", value);
328 if (response) {
329 FUNCTION_MSG("XnWriteInt - %s = %s\n", full_path, response);
330 XenPci_FreeMem(response);
331 FUNCTION_EXIT();
332 return STATUS_UNSUCCESSFUL;
333 }
334 return STATUS_SUCCESS;
335 }
337 NTSTATUS
338 XnReadInt64(XN_HANDLE handle, ULONG base, PCHAR path, ULONGLONG *value) {
339 WDFDEVICE device = handle;
340 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
341 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
342 CHAR full_path[1024];
343 PCHAR response;
344 PCHAR string_value;
345 PCHAR ptr;
347 switch(base) {
348 case XN_BASE_FRONTEND:
349 strncpy(full_path, xppdd->path, 1024);
350 break;
351 case XN_BASE_BACKEND:
352 strncpy(full_path, xppdd->backend_path, 1024);
353 break;
354 case XN_BASE_GLOBAL:
355 strncpy(full_path, "", 1024);
356 break;
357 }
358 strncat(full_path, "/", 1024);
359 strncat(full_path, path, 1024);
360 response = XenBus_Read(xpdd, XBT_NIL, full_path, &string_value);
361 if (response) {
362 FUNCTION_MSG("XnReadInt - %s = %s\n", full_path, response);
363 XenPci_FreeMem(response);
364 FUNCTION_EXIT();
365 return STATUS_UNSUCCESSFUL;
366 }
367 *value = 0;
368 for (ptr = string_value; *ptr && *ptr >= '0' && *ptr <= '9'; ptr++) {
369 *value *= 10;
370 *value += (*ptr) - '0';
371 }
372 return STATUS_SUCCESS;
373 }
375 NTSTATUS
376 XnWriteInt64(XN_HANDLE handle, ULONG base, PCHAR path, ULONGLONG value) {
377 WDFDEVICE device = handle;
378 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
379 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
380 CHAR full_path[1024];
381 PCHAR response;
383 switch(base) {
384 case XN_BASE_FRONTEND:
385 strncpy(full_path, xppdd->path, 1024);
386 break;
387 case XN_BASE_BACKEND:
388 strncpy(full_path, xppdd->backend_path, 1024);
389 break;
390 case XN_BASE_GLOBAL:
391 strncpy(full_path, "", 1024);
392 }
393 strncat(full_path, "/", 1024);
394 strncat(full_path, path, 1024);
396 response = XenBus_Printf(xpdd, XBT_NIL, full_path, "%I64d", value);
397 if (response) {
398 FUNCTION_MSG("XnWriteInt - %s = %s\n", full_path, response);
399 XenPci_FreeMem(response);
400 FUNCTION_EXIT();
401 return STATUS_UNSUCCESSFUL;
402 }
403 return STATUS_SUCCESS;
404 }
406 NTSTATUS
407 XnNotify(XN_HANDLE handle, evtchn_port_t port) {
408 WDFDEVICE device = handle;
409 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
410 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
412 return EvtChn_Notify(xpdd, port);
413 }
415 /* called at PASSIVE_LEVEL */
416 VOID
417 XnGetValue(XN_HANDLE handle, ULONG value_type, PVOID value) {
418 WDFDEVICE device = handle;
419 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
420 //PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
421 DECLARE_UNICODE_STRING_SIZE(my_device_name, 128);
422 ULONG i;
424 switch (value_type) {
425 case XN_VALUE_TYPE_QEMU_HIDE_FLAGS:
426 *(PULONG)value = (ULONG)qemu_hide_flags_value;
427 break;
428 case XN_VALUE_TYPE_QEMU_FILTER:
429 *(PULONG)value = FALSE;
430 RtlUnicodeStringPrintf(&my_device_name, L"#%S#", xppdd->device);
431 for (i = 0; i < WdfCollectionGetCount(qemu_hide_devices); i++) {
432 WDFSTRING wdf_string = WdfCollectionGetItem(qemu_hide_devices, i);
433 UNICODE_STRING hide_device_name;
434 WdfStringGetUnicodeString(wdf_string, &hide_device_name);
435 if (RtlCompareUnicodeString(&hide_device_name, &my_device_name, TRUE) != 0) {
436 *(PULONG)value = TRUE;
437 break;
438 }
439 }
440 break;
441 default:
442 FUNCTION_MSG("GetValue unknown type %d\n", value_type);
443 break;
444 }
445 }
447 #if 0
448 static NTSTATUS
449 XenConfig_InitConfigPage(WDFDEVICE device)
450 {
451 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
452 //PXENCONFIG_DEVICE_DATA xcdd = (PXENCONFIG_DEVICE_DATA)device_object->DeviceExtension;
453 //PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
454 //PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
455 PUCHAR ptr;
456 PDEVICE_OBJECT curr, prev;
457 PDRIVER_OBJECT fdo_driver_object;
458 PUCHAR fdo_driver_extension;
460 FUNCTION_ENTER();
462 ptr = MmGetMdlVirtualAddress(xppdd->config_page_mdl);
463 curr = IoGetAttachedDeviceReference(WdfDeviceWdmGetDeviceObject(device));
464 //curr = WdfDeviceWdmGetAttachedDevice(device);
465 while (curr != NULL)
466 {
467 fdo_driver_object = curr->DriverObject;
468 KdPrint((__DRIVER_NAME " fdo_driver_object = %p\n", fdo_driver_object));
469 if (fdo_driver_object)
470 {
471 fdo_driver_extension = IoGetDriverObjectExtension(fdo_driver_object, UlongToPtr(XEN_INIT_DRIVER_EXTENSION_MAGIC));
472 KdPrint((__DRIVER_NAME " fdo_driver_extension = %p\n", fdo_driver_extension));
473 if (fdo_driver_extension)
474 {
475 memcpy(ptr, fdo_driver_extension, PAGE_SIZE);
476 ObDereferenceObject(curr);
477 break;
478 }
479 }
480 prev = curr;
481 curr = IoGetLowerDeviceObject(curr);
482 ObDereferenceObject(prev);
483 }
485 FUNCTION_EXIT();
487 return STATUS_SUCCESS;
488 }
490 static NTSTATUS
491 XenPci_EvtChn_Bind(PVOID context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
492 {
493 WDFDEVICE device = context;
494 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
495 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
497 return EvtChn_Bind(xpdd, Port, ServiceRoutine, ServiceContext, EVT_ACTION_FLAGS_DEFAULT);
498 }
500 static NTSTATUS
501 XenPci_EvtChn_BindDpc(PVOID context, evtchn_port_t Port, PXEN_EVTCHN_SERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
502 {
503 WDFDEVICE device = context;
504 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
505 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
507 return EvtChn_BindDpc(xpdd, Port, ServiceRoutine, ServiceContext, EVT_ACTION_FLAGS_DEFAULT);
508 }
510 static NTSTATUS
511 XenPci_EvtChn_Unbind(PVOID context, evtchn_port_t Port)
512 {
513 WDFDEVICE device = context;
514 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
515 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
517 return EvtChn_Unbind(xpdd, Port);
518 }
520 static NTSTATUS
521 XenPci_EvtChn_Mask(PVOID context, evtchn_port_t Port)
522 {
523 WDFDEVICE device = context;
524 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
525 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
527 return EvtChn_Mask(xpdd, Port);
528 }
530 static NTSTATUS
531 XenPci_EvtChn_Unmask(PVOID context, evtchn_port_t Port)
532 {
533 WDFDEVICE device = context;
534 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
535 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
537 return EvtChn_Unmask(xpdd, Port);
538 }
540 static BOOLEAN
541 XenPci_EvtChn_AckEvent(PVOID context, evtchn_port_t port, BOOLEAN *last_interrupt)
542 {
543 WDFDEVICE device = context;
544 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
545 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
547 return EvtChn_AckEvent(xpdd, port, last_interrupt);
548 }
550 typedef struct {
551 PXEN_EVTCHN_SYNC_ROUTINE sync_routine;
552 PVOID sync_context;
553 } sync_context_t;
555 static BOOLEAN
556 XenPci_EvtChn_Sync_Routine(WDFINTERRUPT interrupt, WDFCONTEXT context)
557 {
558 sync_context_t *wdf_sync_context = context;
559 UNREFERENCED_PARAMETER(interrupt);
560 return wdf_sync_context->sync_routine(wdf_sync_context->sync_context);
561 }
563 static BOOLEAN
564 XenPci_EvtChn_Sync(PVOID context, PXEN_EVTCHN_SYNC_ROUTINE sync_routine, PVOID sync_context)
565 {
566 WDFDEVICE device = context;
567 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
568 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
569 sync_context_t wdf_sync_context;
571 wdf_sync_context.sync_routine = sync_routine;
572 wdf_sync_context.sync_context = sync_context;
574 return WdfInterruptSynchronize(xpdd->interrupt, XenPci_EvtChn_Sync_Routine, &wdf_sync_context);
575 }
578 PCHAR
579 XenPci_XenBus_Read(PVOID context, xenbus_transaction_t xbt, char *path, char **value)
580 {
581 WDFDEVICE device = context;
582 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
583 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
584 return XenBus_Read(xpdd, xbt, path, value);
585 }
587 PCHAR
588 XenPci_XenBus_Write(PVOID context, xenbus_transaction_t xbt, char *path, char *value)
589 {
590 WDFDEVICE device = context;
591 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
592 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
593 return XenBus_Write(xpdd, xbt, path, value);
594 }
596 PCHAR
597 XenPci_XenBus_Printf(PVOID context, xenbus_transaction_t xbt, char *path, char *fmt, ...)
598 {
599 //PXENPCI_PDO_DEVICE_DATA xppdd = Context;
600 //PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
601 //return XenBus_Printf(xpdd, xbt, path, value);
602 UNREFERENCED_PARAMETER(context);
603 UNREFERENCED_PARAMETER(xbt);
604 UNREFERENCED_PARAMETER(path);
605 UNREFERENCED_PARAMETER(fmt);
606 return NULL;
607 }
609 PCHAR
610 XenPci_XenBus_StartTransaction(PVOID context, xenbus_transaction_t *xbt)
611 {
612 WDFDEVICE device = context;
613 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
614 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
615 return XenBus_StartTransaction(xpdd, xbt);
616 }
618 PCHAR
619 XenPci_XenBus_EndTransaction(PVOID context, xenbus_transaction_t xbt, int abort, int *retry)
620 {
621 WDFDEVICE device = context;
622 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
623 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
624 return XenBus_EndTransaction(xpdd, xbt, abort, retry);
625 }
627 PCHAR
628 XenPci_XenBus_List(PVOID context, xenbus_transaction_t xbt, char *prefix, char ***contents)
629 {
630 WDFDEVICE device = context;
631 PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
632 PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
633 return XenBus_List(xpdd, xbt, prefix, contents);
634 }
636 #endif