win-pvdrivers

changeset 56:b1f7c8a9eb17

manual merge fixes
author Andy Grover <andy.grover@oracle.com>
date Mon Dec 17 15:23:20 2007 -0800 (2007-12-17)
parents b80da01bb0bb
children 1acf9205fc43
files xenpci/xenbus.c xenpci/xenpci.c xenvbd/xenvbd.c
line diff
     1.1 --- a/xenpci/xenbus.c	Mon Dec 17 15:19:03 2007 -0800
     1.2 +++ b/xenpci/xenbus.c	Mon Dec 17 15:23:20 2007 -0800
     1.3 @@ -368,7 +368,7 @@ NTSTATUS
     1.4  XenBus_Close(WDFDEVICE Device)
     1.5  {
     1.6    PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
     1.7 -  KWAIT_BLOCK WaitBlockArray[2];
     1.8 +  //KWAIT_BLOCK WaitBlockArray[2];
     1.9    PVOID WaitArray[2];
    1.10  
    1.11    xpdd->XenBus_ShuttingDown = TRUE;
     2.1 --- a/xenpci/xenpci.c	Mon Dec 17 15:19:03 2007 -0800
     2.2 +++ b/xenpci/xenpci.c	Mon Dec 17 15:23:20 2007 -0800
     2.3 @@ -70,6 +70,8 @@ XenPCI_XenBusWatchHandler(char *Path, PV
     2.4  
     2.5  /* Global (driver-wide) variables */
     2.6  static BOOLEAN AutoEnumerate;
     2.7 +CM_PARTIAL_RESOURCE_DESCRIPTOR InterruptRaw;
     2.8 +CM_PARTIAL_RESOURCE_DESCRIPTOR InterruptTranslated;
     2.9  
    2.10  NTSTATUS
    2.11  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
     3.1 --- a/xenvbd/xenvbd.c	Mon Dec 17 15:19:03 2007 -0800
     3.2 +++ b/xenvbd/xenvbd.c	Mon Dec 17 15:23:20 2007 -0800
     3.3 @@ -106,7 +106,6 @@ AllocatePages(int Pages)
     3.4    if (Mdl == NULL)
     3.5    {
     3.6      KdPrint((__DRIVER_NAME "     AllocatePages Failed at IoAllocateMdl\n"));
     3.7 ->>>>>>> /tmp/xenvbd.c~other.LRcZCH
     3.8    }
     3.9    MmBuildMdlForNonPagedPool(Mdl);
    3.10    
    3.11 @@ -258,7 +257,9 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    3.12          Srb->SrbStatus = SRB_STATUS_ERROR;
    3.13        }
    3.14        for (j = 0; j < TargetData->shadow[rep->id].req.nr_segments; j++)
    3.15 -        DeviceData->XenDeviceData->GntTblInterface.EndAccess(TargetData->shadow[rep->id].req.seg[j].gref);
    3.16 +        DeviceData->XenDeviceData->GntTblInterface.EndAccess(
    3.17 +        DeviceData->XenDeviceData->GntTblInterface.InterfaceHeader.Context,
    3.18 +        TargetData->shadow[rep->id].req.seg[j].gref);
    3.19        if (Srb->Cdb[0] == SCSIOP_READ)
    3.20          memcpy(Srb->DataBuffer, TargetData->shadow[rep->id].Buf, BlockCount * TargetData->BytesPerSector);
    3.21  
    3.22 @@ -307,6 +308,8 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    3.23      }
    3.24    }
    3.25  //  KdPrint((__DRIVER_NAME " <-- HwScsiInterrupt\n"));
    3.26 +
    3.27 +  return TRUE;
    3.28  }
    3.29  
    3.30  static VOID
    3.31 @@ -332,7 +335,9 @@ XenVbd_BackEndStateHandler(char *Path, P
    3.32    TargetData = (PXENVBD_TARGET_DATA)Data;
    3.33    DeviceData = (PXENVBD_DEVICE_DATA)TargetData->DeviceData;
    3.34  
    3.35 -  DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, Path, &Value);
    3.36 +  DeviceData->XenDeviceData->XenBusInterface.Read(
    3.37 +    DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
    3.38 +    XBT_NIL, Path, &Value);
    3.39  
    3.40    NewState = atoi(Value);
    3.41    switch (NewState)
    3.42 @@ -348,14 +353,19 @@ XenVbd_BackEndStateHandler(char *Path, P
    3.43    case XenbusStateInitWait:
    3.44      KdPrint((__DRIVER_NAME "     Backend State Changed to InitWait\n"));  
    3.45  
    3.46 -    TargetData->EventChannel = DeviceData->XenDeviceData->EvtChnInterface.AllocUnbound(0);
    3.47 -    DeviceData->XenDeviceData->EvtChnInterface.Bind(TargetData->EventChannel, XenVbd_Interrupt, TargetData);
    3.48 +    TargetData->EventChannel = DeviceData->XenDeviceData->EvtChnInterface.AllocUnbound(
    3.49 +      DeviceData->XenDeviceData->EvtChnInterface.InterfaceHeader.Context, 0);
    3.50 +    DeviceData->XenDeviceData->EvtChnInterface.Bind(
    3.51 +      DeviceData->XenDeviceData->EvtChnInterface.InterfaceHeader.Context,
    3.52 +      TargetData->EventChannel, XenVbd_Interrupt, TargetData);
    3.53      Mdl = AllocatePage();
    3.54      PFN = *MmGetMdlPfnArray(Mdl);
    3.55      SharedRing = (blkif_sring_t *)MmGetMdlVirtualAddress(Mdl);
    3.56      SHARED_RING_INIT(SharedRing);
    3.57      FRONT_RING_INIT(&TargetData->Ring, SharedRing, PAGE_SIZE);
    3.58 -    ref = DeviceData->XenDeviceData->GntTblInterface.GrantAccess(0, PFN, FALSE);
    3.59 +    ref = DeviceData->XenDeviceData->GntTblInterface.GrantAccess(
    3.60 +      DeviceData->XenDeviceData->GntTblInterface.InterfaceHeader.Context,
    3.61 +      0, PFN, FALSE);
    3.62  
    3.63      TargetData->shadow = ExAllocatePoolWithTag(NonPagedPool, sizeof(blkif_shadow_t) * BLK_RING_SIZE, XENVBD_POOL_TAG);
    3.64  
    3.65 @@ -393,7 +403,9 @@ XenVbd_BackEndStateHandler(char *Path, P
    3.66  
    3.67      RtlStringCbCopyA(TmpPath, 128, TargetData->Path);
    3.68      RtlStringCbCatA(TmpPath, 128, "/device-type");
    3.69 -    DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    3.70 +    DeviceData->XenDeviceData->XenBusInterface.Read(
    3.71 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
    3.72 +      XBT_NIL, TmpPath, &Value);
    3.73      if (strcmp(Value, "disk") == 0)
    3.74      {
    3.75        KdPrint((__DRIVER_NAME "     DeviceType = Disk\n"));    
    3.76 @@ -412,19 +424,25 @@ XenVbd_BackEndStateHandler(char *Path, P
    3.77  
    3.78      RtlStringCbCopyA(TmpPath, 128, TargetData->BackendPath);
    3.79      RtlStringCbCatA(TmpPath, 128, "/type"); // should probably check that this is 'phy' or 'file' or at least not ''
    3.80 -    DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    3.81 +    DeviceData->XenDeviceData->XenBusInterface.Read(
    3.82 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
    3.83 +      XBT_NIL, TmpPath, &Value);
    3.84      KdPrint((__DRIVER_NAME "     Backend Type = %s\n", Value));
    3.85      ExFreePool(Value);
    3.86  
    3.87      RtlStringCbCopyA(TmpPath, 128, TargetData->BackendPath);
    3.88      RtlStringCbCatA(TmpPath, 128, "/mode"); // should store this...
    3.89 -    DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    3.90 +    DeviceData->XenDeviceData->XenBusInterface.Read(
    3.91 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
    3.92 +      XBT_NIL, TmpPath, &Value);
    3.93      KdPrint((__DRIVER_NAME "     Backend Mode = %s\n", Value));
    3.94      ExFreePool(Value);
    3.95  
    3.96      RtlStringCbCopyA(TmpPath, 128, TargetData->BackendPath);
    3.97      RtlStringCbCatA(TmpPath, 128, "/sector-size");
    3.98 -    DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    3.99 +    DeviceData->XenDeviceData->XenBusInterface.Read(
   3.100 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
   3.101 +      XBT_NIL, TmpPath, &Value);
   3.102      // should complain if Value == NULL
   3.103      TargetData->BytesPerSector = atoi(Value);
   3.104  
   3.105 @@ -432,7 +450,9 @@ XenVbd_BackEndStateHandler(char *Path, P
   3.106  
   3.107      RtlStringCbCopyA(TmpPath, 128, TargetData->BackendPath);
   3.108      RtlStringCbCatA(TmpPath, 128, "/sectors");
   3.109 -    DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
   3.110 +    DeviceData->XenDeviceData->XenBusInterface.Read(
   3.111 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
   3.112 +      XBT_NIL, TmpPath, &Value);
   3.113      // should complain if Value == NULL
   3.114      TargetData->TotalSectors = (ULONGLONG)atol(Value);
   3.115  
   3.116 @@ -496,65 +516,63 @@ XenVbd_WatchHandler(char *Path, PVOID De
   3.117    Bits = SplitString(Path, '/', 4, &Count);
   3.118    if (Count != 4)
   3.119    {
   3.120 -  case 0:
   3.121 -  case 1:
   3.122 -  case 2:
   3.123 -    break; // should never happen
   3.124 -  case 3:
   3.125 -    break;
   3.126 -  case 4:
   3.127 -    if (strcmp(Bits[3], "state") != 0) // we only care when the state appears
   3.128 -      break;
   3.129 -
   3.130 -    KeAcquireSpinLock(&DeviceData->Lock, &OldIrql);
   3.131 +    KdPrint((__FUNCTION__ ": Count = %d, not 4!\n", Count));
   3.132 +    goto cleanup;
   3.133 +  }
   3.134  
   3.135 -    for (VacantTarget = NULL,i = 0; i < SCSI_BUSES * SCSI_TARGETS_PER_BUS; i++)
   3.136 -    {
   3.137 -      CurrentBus = i / SCSI_TARGETS_PER_BUS;
   3.138 -      CurrentTarget = i % SCSI_TARGETS_PER_BUS;
   3.139 -      if (CurrentTarget == 7) // don't use 7 - it would be for the controller
   3.140 -        continue;
   3.141 -      TargetData = &DeviceData->BusData[CurrentBus].TargetData[CurrentTarget];
   3.142 -      if (TargetData->Present && strncmp(TargetData->Path, Path, strlen(TargetData->Path)) == 0 && Path[strlen(TargetData->Path)] == '/')
   3.143 -        break; // already exists
   3.144 -      else if (!TargetData->Present && VacantTarget == NULL)
   3.145 -        VacantTarget = TargetData;
   3.146 -    }
   3.147 -    if (i == SCSI_BUSES * SCSI_TARGETS_PER_BUS && VacantTarget != NULL)
   3.148 -    {
   3.149 -      VacantTarget->Present = 1;
   3.150 -      KeReleaseSpinLock(&DeviceData->Lock, OldIrql);
   3.151 +  if (strcmp(Bits[3], "state") != 0) // we only care when the state appears
   3.152 +    goto cleanup;
   3.153  
   3.154 -      RtlStringCbCopyA(VacantTarget->Path, 128, Bits[0]);
   3.155 -      RtlStringCbCatA(VacantTarget->Path, 128, "/");
   3.156 -      RtlStringCbCatA(VacantTarget->Path, 128, Bits[1]);
   3.157 -      RtlStringCbCatA(VacantTarget->Path, 128, "/");
   3.158 -      RtlStringCbCatA(VacantTarget->Path, 128, Bits[2]);
   3.159 -
   3.160 -      VacantTarget->DeviceIndex = atoi(Bits[2]);
   3.161 +  KeAcquireSpinLock(&DeviceData->Lock, &OldIrql);
   3.162  
   3.163 -      RtlStringCbCopyA(TmpPath, 128, VacantTarget->Path);
   3.164 -      RtlStringCbCatA(TmpPath, 128, "/backend");
   3.165 -      DeviceData->XenDeviceData->XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
   3.166 -      if (Value == NULL)
   3.167 -        KdPrint((__DRIVER_NAME "     Read Failed\n"));
   3.168 -      else
   3.169 -        RtlStringCbCopyA(VacantTarget->BackendPath, 128, Value);
   3.170 -      RtlStringCbCopyA(TmpPath, 128, VacantTarget->BackendPath);
   3.171 -      RtlStringCbCatA(TmpPath, 128, "/state");
   3.172 +  for (VacantTarget = NULL, i = 0; i < SCSI_BUSES * SCSI_TARGETS_PER_BUS; i++)
   3.173 +  {
   3.174 +    CurrentBus = i / SCSI_TARGETS_PER_BUS;
   3.175 +    CurrentTarget = i % SCSI_TARGETS_PER_BUS;
   3.176 +    if (CurrentTarget == 7) // don't use 7 - it would be for the controller
   3.177 +      continue;
   3.178 +    TargetData = &DeviceData->BusData[CurrentBus].TargetData[CurrentTarget];
   3.179 +    if (TargetData->Present && strncmp(TargetData->Path, Path, strlen(TargetData->Path)) == 0 && Path[strlen(TargetData->Path)] == '/')
   3.180 +      break; // already exists
   3.181 +    else if (!TargetData->Present && VacantTarget == NULL)
   3.182 +      VacantTarget = TargetData;
   3.183 +  }
   3.184  
   3.185 -      DeviceData->XenDeviceData->XenBusInterface.AddWatch(XBT_NIL, TmpPath, XenVbd_BackEndStateHandler, VacantTarget);
   3.186 -    }
   3.187 +  if (i == SCSI_BUSES * SCSI_TARGETS_PER_BUS && VacantTarget != NULL)
   3.188 +  {
   3.189 +    VacantTarget->Present = 1;
   3.190 +
   3.191 +    RtlStringCbCopyA(VacantTarget->Path, 128, Bits[0]);
   3.192 +    RtlStringCbCatA(VacantTarget->Path, 128, "/");
   3.193 +    RtlStringCbCatA(VacantTarget->Path, 128, Bits[1]);
   3.194 +    RtlStringCbCatA(VacantTarget->Path, 128, "/");
   3.195 +    RtlStringCbCatA(VacantTarget->Path, 128, Bits[2]);
   3.196 +
   3.197 +    VacantTarget->DeviceIndex = atoi(Bits[2]);
   3.198 +
   3.199 +    RtlStringCbPrintfA(TmpPath, ARRAY_SIZE(TmpPath), "%s/backend", VacantTarget->Path);
   3.200 +    DeviceData->XenDeviceData->XenBusInterface.Read(
   3.201 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
   3.202 +      XBT_NIL, TmpPath, &Value);
   3.203 +    if (!Value)
   3.204 +      KdPrint((__DRIVER_NAME "     Read Failed\n"));
   3.205      else
   3.206 -      KeReleaseSpinLock(&DeviceData->Lock, OldIrql);
   3.207 -    break;
   3.208 +      RtlStringCbCopyA(VacantTarget->BackendPath,
   3.209 +        ARRAY_SIZE(VacantTarget->BackendPath), Value);
   3.210 +
   3.211 +    RtlStringCbPrintfA(TmpPath, ARRAY_SIZE(TmpPath), "%s/state",
   3.212 +      VacantTarget->BackendPath);
   3.213 +    DeviceData->XenDeviceData->XenBusInterface.AddWatch(
   3.214 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
   3.215 +      XBT_NIL, TmpPath, XenVbd_BackEndStateHandler, VacantTarget);
   3.216    }
   3.217 -  
   3.218 +
   3.219 +  KeReleaseSpinLock(&DeviceData->Lock, OldIrql);
   3.220 +
   3.221 +cleanup:
   3.222    FreeSplitString(Bits, Count);
   3.223  
   3.224    KdPrint((__DRIVER_NAME " <-- WatchHandler\n"));  
   3.225 -
   3.226 -  return;
   3.227  }
   3.228  
   3.229  static VOID 
   3.230 @@ -601,7 +619,9 @@ XenVbd_HwScsiInitialize(PVOID DeviceExte
   3.231    DeviceData->EnumeratedDevices = 0;
   3.232    if (DeviceData->XenDeviceData->AutoEnumerate)
   3.233    {
   3.234 -    msg = DeviceData->XenDeviceData->XenBusInterface.List(XBT_NIL, "device/vbd", &VbdDevices);
   3.235 +    msg = DeviceData->XenDeviceData->XenBusInterface.List(
   3.236 +      DeviceData->XenDeviceData->XenBusInterface.InterfaceHeader.Context,
   3.237 +      XBT_NIL, "device/vbd", &VbdDevices);
   3.238      if (!msg) {
   3.239        for (i = 0; VbdDevices[i]; i++)
   3.240        {
   3.241 @@ -733,7 +753,9 @@ XenVbd_PutSrbOnRing(PXENVBD_TARGET_DATA 
   3.242  
   3.243    for (i = 0; i < req->nr_segments; i++)
   3.244    {
   3.245 -    req->seg[i].gref = DeviceData->XenDeviceData->GntTblInterface.GrantAccess(0, MmGetMdlPfnArray(TargetData->shadow[req->id].Mdl)[i], FALSE);
   3.246 +    req->seg[i].gref = DeviceData->XenDeviceData->GntTblInterface.GrantAccess(
   3.247 +      DeviceData->XenDeviceData->GntTblInterface.InterfaceHeader.Context,
   3.248 +      0, MmGetMdlPfnArray(TargetData->shadow[req->id].Mdl)[i], FALSE);
   3.249      req->seg[i].first_sect = 0;
   3.250      if (i == req->nr_segments - 1)
   3.251        req->seg[i].last_sect = (BlockCount - 1) % (PAGE_SIZE / TargetData->BytesPerSector);
   3.252 @@ -966,7 +988,9 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   3.253        XenVbd_PutSrbOnRing(TargetData, Srb);
   3.254        RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&TargetData->Ring, notify);
   3.255        if (notify)
   3.256 -        DeviceData->XenDeviceData->EvtChnInterface.Notify(TargetData->EventChannel);
   3.257 +        DeviceData->XenDeviceData->EvtChnInterface.Notify(
   3.258 +          DeviceData->XenDeviceData->EvtChnInterface.InterfaceHeader.Context,
   3.259 +          TargetData->EventChannel);
   3.260        //KeReleaseSpinLock(&DeviceData->Lock, KIrql);
   3.261  //      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.262  //      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);