win-pvdrivers

changeset 972:ef1f25e2c281

Make xenpci account for driver domain. Patch from Marek Marczykowski
author James Harper <james.harper@bendigoit.com.au>
date Sun Apr 15 14:27:22 2012 +1000 (2012-04-15)
parents 6c6def3fb1ca
children b6d85bc1ce2d
files xenpci/xenpci.h xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/xenpci.h	Sun Apr 08 10:41:09 2012 +1000
     1.2 +++ b/xenpci/xenpci.h	Sun Apr 15 14:27:22 2012 +1000
     1.3 @@ -254,7 +254,7 @@ typedef struct {
     1.4    ULONG irq_vector;
     1.5    KIRQL irq_level;
     1.6    char backend_path[128];
     1.7 -  //PVOID xenbus_request;
     1.8 +  domid_t backend_id;
     1.9    KEVENT backend_state_event;
    1.10    ULONG backend_state;
    1.11    FAST_MUTEX backend_state_mutex;
     2.1 --- a/xenpci/xenpci_pdo.c	Sun Apr 08 10:41:09 2012 +1000
     2.2 +++ b/xenpci/xenpci_pdo.c	Sun Apr 15 14:27:22 2012 +1000
     2.3 @@ -194,6 +194,18 @@ XenPci_GetBackendAndAddWatch(WDFDEVICE d
     2.4    RtlStringCbCopyA(xppdd->backend_path, ARRAY_SIZE(xppdd->backend_path), value);
     2.5    XenPci_FreeMem(value);
     2.6  
     2.7 +  /* Get backend id */
     2.8 +  RtlStringCbPrintfA(path, ARRAY_SIZE(path),
     2.9 +    "%s/backend-id", xppdd->path);
    2.10 +  res = XenBus_Read(xpdd, XBT_NIL, path, &value);
    2.11 +  if (res) {
    2.12 +    KdPrint((__DRIVER_NAME "    Failed to read backend id\n"));
    2.13 +    XenPci_FreeMem(res);
    2.14 +    return STATUS_UNSUCCESSFUL;
    2.15 +  }
    2.16 +  xppdd->backend_id = atoi(value);
    2.17 +  XenPci_FreeMem(value);
    2.18 +
    2.19    /* Add watch on backend state */
    2.20    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    2.21    XenBus_AddWatch(xpdd, XBT_NIL, path, XenPci_BackendStateHandler, device);
    2.22 @@ -687,7 +699,7 @@ XenPci_XenConfigDeviceSpecifyBuffers(WDF
    2.23          KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_RING - %s = %p\n", setting, address));
    2.24          SHARED_RING_INIT((struct dummy_sring *)address);
    2.25          if ((gref = GntTbl_GrantAccess(
    2.26 -          xpdd, 0, (ULONG)*MmGetMdlPfnArray(ring), FALSE, INVALID_GRANT_REF, (ULONG)'XPDO')) != INVALID_GRANT_REF)
    2.27 +          xpdd, xppdd->backend_id, (ULONG)*MmGetMdlPfnArray(ring), FALSE, INVALID_GRANT_REF, (ULONG)'XPDO')) != INVALID_GRANT_REF)
    2.28          {
    2.29            RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/%s", xppdd->path, setting);
    2.30            KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_RING - %s = %d\n", setting, gref));
    2.31 @@ -716,7 +728,7 @@ XenPci_XenConfigDeviceSpecifyBuffers(WDF
    2.32      case XEN_INIT_TYPE_EVENT_CHANNEL: /* frontend event channel */
    2.33      case XEN_INIT_TYPE_EVENT_CHANNEL_DPC: /* frontend event channel bound to dpc */
    2.34      case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ: /* frontend event channel bound to irq */
    2.35 -      if ((event_channel = EvtChn_AllocUnbound(xpdd, 0)) != 0)
    2.36 +      if ((event_channel = EvtChn_AllocUnbound(xpdd, xppdd->backend_id)) != 0)
    2.37        {
    2.38          KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_EVENT_CHANNEL - %s = %d\n", setting, event_channel));
    2.39          RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/%s", xppdd->path, setting);
    2.40 @@ -1434,6 +1446,7 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
    2.41    xppdd->backend_state = XenbusStateUnknown;
    2.42    xppdd->frontend_state = XenbusStateUnknown;
    2.43    xppdd->backend_path[0] = '\0';
    2.44 +  xppdd->backend_id = 0;
    2.45      
    2.46    FUNCTION_EXIT();
    2.47