win-pvdrivers

changeset 47:d87e19a1eeeb

trying something else
author James Harper <james.harper@bendigoit.com.au>
date Mon Dec 10 16:51:00 2007 +1100 (2007-12-10)
parents f5a275d63b7d
children a70cbf588756
files xenhide/sources xenpci/sources xenvbd/sources xenvbd/xenvbd.c
line diff
     1.1 --- a/xenhide/sources	Wed Dec 05 19:56:17 2007 +1100
     1.2 +++ b/xenhide/sources	Mon Dec 10 16:51:00 2007 +1100
     1.3 @@ -1,14 +1,13 @@
     1.4  TARGETNAME=XENHIDE
     1.5  TARGETTYPE=DRIVER
     1.6 -TARGETPATH=..\Target
     1.7 -
     1.8 +TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.9 +VERSION=0.4.0.0
    1.10 +KMDF_VERSION=1
    1.11  MSC_WARNING_LEVEL=/W4
    1.12 -
    1.13 +INF_NAME=xenhide
    1.14  INCLUDES = ..\common\include;..\common\include\public
    1.15 -
    1.16 -NO_BINPLACE=1
    1.17 -KMDF_VERSION=1
    1.18  TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib
    1.19 -
    1.20 +MISCFILES=$(TARGETPATH)\$(INF_NAME).inf
    1.21 +NTTARGETFILES=
    1.22  SOURCES=xenhide.c
    1.23  
     2.1 --- a/xenpci/sources	Wed Dec 05 19:56:17 2007 +1100
     2.2 +++ b/xenpci/sources	Mon Dec 10 16:51:00 2007 +1100
     2.3 @@ -1,14 +1,12 @@
     2.4  TARGETNAME=XENPCI
     2.5  TARGETTYPE=DRIVER
     2.6 -TARGETPATH=..\Target
     2.7 -
     2.8 +TARGETPATH=..\Target\$(DDK_TARGET_OS)
     2.9 +VERSION=0.4.0.0
    2.10 +KMDF_VERSION=1
    2.11  MSC_WARNING_LEVEL=/W4
    2.12 -
    2.13 +INF_NAME=xenpci
    2.14  INCLUDES = ..\common\include;..\common\include\public
    2.15 -
    2.16 -NO_BINPLACE=1
    2.17 -KMDF_VERSION=1
    2.18  TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib
    2.19 -
    2.20 +MISCFILES=$(TARGETPATH)\$(INF_NAME).inf
    2.21 +NTTARGETFILES=
    2.22  SOURCES=xenpci.c xenbus.c gnttbl.c evtchn.c
    2.23 -
     3.1 --- a/xenvbd/sources	Wed Dec 05 19:56:17 2007 +1100
     3.2 +++ b/xenvbd/sources	Mon Dec 10 16:51:00 2007 +1100
     3.3 @@ -1,13 +1,12 @@
     3.4  TARGETNAME=XENVBD
     3.5  TARGETTYPE=DRIVER
     3.6 -TARGETPATH=..\Target
     3.7 -
     3.8 +TARGETPATH=..\Target\$(DDK_TARGET_OS)
     3.9 +VERSION=0.4.0.20
    3.10 +KMDF_VERSION=1
    3.11  MSC_WARNING_LEVEL=/W4
    3.12 -
    3.13 +INF_NAME=xenvbd
    3.14  INCLUDES = ..\common\include;..\common\include\public
    3.15 -
    3.16 -NO_BINPLACE=1
    3.17 -KMDF_VERSION=1
    3.18 -TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib $(DDK_LIB_PATH)\scsiport.lib
    3.19 -
    3.20 +TARGETLIBS=$(TARGETLIBS) $(DDK_LIB_PATH)\ntstrsafe.lib $(DDK_LIB_PATH)\scsiport.lib
    3.21 +MISCFILES=..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf
    3.22 +NTTARGETFILES=
    3.23  SOURCES=xenvbd.c
     4.1 --- a/xenvbd/xenvbd.c	Wed Dec 05 19:56:17 2007 +1100
     4.2 +++ b/xenvbd/xenvbd.c	Mon Dec 10 16:51:00 2007 +1100
     4.3 @@ -426,11 +426,11 @@ XenVbd_IoDefault(
     4.4  {
     4.5    UNREFERENCED_PARAMETER(Queue);
     4.6  
     4.7 -  //KdPrint((__DRIVER_NAME " --> EvtDeviceIoDefault\n"));
     4.8 +  KdPrint((__DRIVER_NAME " --> EvtDeviceIoDefault\n"));
     4.9  
    4.10    WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
    4.11  
    4.12 -  //KdPrint((__DRIVER_NAME " <-- EvtDeviceIoDefault\n"));
    4.13 +  KdPrint((__DRIVER_NAME " <-- EvtDeviceIoDefault\n"));
    4.14  }
    4.15  
    4.16  static __inline uint64_t
    4.17 @@ -517,6 +517,8 @@ XenVbd_DpcThreadProc(WDFDPC Dpc)
    4.18    WDFDEVICE ChildDevice;
    4.19    XenVbd_ListEntry *ListEntry;
    4.20    int notify;
    4.21 +  PUCHAR ptr;
    4.22 +  int sum;
    4.23  
    4.24    //!!!IRQL_DISPATCH!!!
    4.25  
    4.26 @@ -567,6 +569,11 @@ XenVbd_DpcThreadProc(WDFDPC Dpc)
    4.27            if (DataBuffer == NULL)
    4.28              KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe Failed in DpcThreadProc\n"));
    4.29            memcpy(DataBuffer, ChildDeviceData->shadow[rep->id].Buf, BlockCount * ChildDeviceData->BytesPerSector);
    4.30 +          for (j = 0, sum = 0, ptr = ChildDeviceData->shadow[rep->id].Buf; j < BlockCount * ChildDeviceData->BytesPerSector; j++, ptr++)
    4.31 +          {
    4.32 +            sum += *ptr;
    4.33 +          }
    4.34 +          KdPrint((__DRIVER_NAME "     READ sum = %08X\n", sum));
    4.35          }
    4.36          FreePages(ChildDeviceData->shadow[rep->id].Mdl);
    4.37        }
    4.38 @@ -943,7 +950,7 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    4.39  
    4.40    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, NULL, 0);
    4.41    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL, IRP_MJ_DEVICE_CONTROL, NULL, 0);
    4.42 -/*
    4.43 +
    4.44    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLEANUP, NULL, 0);
    4.45    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLOSE, NULL, 0);
    4.46    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CREATE, NULL, 0);
    4.47 @@ -963,7 +970,7 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    4.48    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SHUTDOWN, NULL, 0);
    4.49    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SYSTEM_CONTROL, NULL, 0);
    4.50    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_WRITE, NULL, 0);
    4.51 -*/
    4.52 +
    4.53    WdfDeviceInitSetIoType(ChildInit, WdfDeviceIoDirect);
    4.54  
    4.55    //WdfDeviceInitSetPowerNotPageable(ChildInit);
    4.56 @@ -1040,11 +1047,13 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    4.57    int j;
    4.58    int BlockCount;
    4.59    int sect_offset;
    4.60 +  PUCHAR ptr;
    4.61 +  int sum;
    4.62  
    4.63    ChildDeviceData = *GetChildDeviceData(Device);
    4.64  
    4.65 -//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.66 -//    KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
    4.67 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.68 +    KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
    4.69  
    4.70    if (RING_FULL(&ChildDeviceData->Ring))
    4.71    {
    4.72 @@ -1073,7 +1082,9 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    4.73    req->operation = (Srb->Cdb[0] == SCSIOP_READ)?BLKIF_OP_READ:BLKIF_OP_WRITE;
    4.74    ChildDeviceData->shadow[req->id].Irp = Irp;
    4.75  
    4.76 -  if ((MmGetMdlByteOffset(Irp->MdlAddress) & 0x1ff) == 0) // 0x1ff shouldn't be hardcoded...
    4.77 +  KdPrint((__DRIVER_NAME "     %s: Sector = %d, Length = %d\n", (Srb->Cdb[0] == SCSIOP_READ)?"READ":"WRITE", (int)(req->sector_number), BlockCount * 512));
    4.78 +
    4.79 +  if (0) //(MmGetMdlByteOffset(Irp->MdlAddress) & 0x1ff) == 0) // 0x1ff shouldn't be hardcoded...
    4.80    {
    4.81      // fast path - zero copy
    4.82      ChildDeviceData->shadow[req->id].Mdl = Irp->MdlAddress;
    4.83 @@ -1084,21 +1095,41 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    4.84    {
    4.85      // slow path - copy to bounce buffer
    4.86      ChildDeviceData->shadow[req->id].Mdl = AllocatePages((BlockCount * ChildDeviceData->BytesPerSector + PAGE_SIZE - 1) / PAGE_SIZE);
    4.87 -    ChildDeviceData->shadow[req->id].Buf = MmGetMdlVirtualAddress(ChildDeviceData->shadow[req->id].Mdl);
    4.88 +    //ChildDeviceData->shadow[req->id].Buf = MmGetMdlVirtualAddress(ChildDeviceData->shadow[req->id].Mdl);
    4.89 +    ChildDeviceData->shadow[req->id].Buf = MmGetSystemAddressForMdlSafe(ChildDeviceData->shadow[req->id].Mdl, HighPagePriority);
    4.90      if (ChildDeviceData->shadow[req->id].Buf == NULL)
    4.91      {
    4.92 -      KdPrint((__DRIVER_NAME "     MmGetMdlVirtualAddress returned NULL in PutIrpOnRing\n"));
    4.93 +      KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe returned NULL in PutIrpOnRing\n"));
    4.94      }
    4.95      ChildDeviceData->SlowPathUsed++;
    4.96    }
    4.97  
    4.98 -//  if (((ChildDeviceData->FastPathUsed + ChildDeviceData->SlowPathUsed) & 0x2FF) == 0)
    4.99 -//  {
   4.100 -//    KdPrint((__DRIVER_NAME "     Fast Path = %d, Slow Path = %d\n", ChildDeviceData->FastPathUsed, ChildDeviceData->SlowPathUsed));
   4.101 +/*
   4.102 +  if (((ChildDeviceData->FastPathUsed + ChildDeviceData->SlowPathUsed) & 0x3F) == 0)
   4.103 +  {
   4.104 +    KdPrint((__DRIVER_NAME "     Fast Path = %d, Slow Path = %d\n", ChildDeviceData->FastPathUsed, ChildDeviceData->SlowPathUsed));
   4.105  //    KdPrint((__DRIVER_NAME "     AddedToList = %d, RemovedFromList = %d, AddedToRing = %d, AddedToRingAtLastNotify = %d, AddedToRingAtLastInterrupt = %d, AddedToRingAtLastDpc = %d, RemovedFromRing = %d, IrpCompleted = %d\n", ChildDeviceData->IrpAddedToList, ChildDeviceData->IrpRemovedFromList, ChildDeviceData->IrpAddedToRing, ChildDeviceData->IrpAddedToRingAtLastNotify, ChildDeviceData->IrpAddedToRingAtLastInterrupt, ChildDeviceData->IrpAddedToRingAtLastDpc, ChildDeviceData->IrpRemovedFromRing, ChildDeviceData->IrpCompleted));
   4.106 -//  }
   4.107 +  }
   4.108 +*/
   4.109 +
   4.110 +  if (Srb->Cdb[0] == SCSIOP_WRITE && ChildDeviceData->shadow[req->id].Buf != NULL)
   4.111 +  {
   4.112 +    DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.113 +    if (DataBuffer == NULL)
   4.114 +      KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe failed in PutIrpOnRing\n"));
   4.115 +    memcpy(ChildDeviceData->shadow[req->id].Buf, DataBuffer, BlockCount * ChildDeviceData->BytesPerSector);
   4.116 +    for (i = 0, sum = 0, ptr = ChildDeviceData->shadow[req->id].Buf; i < BlockCount * ChildDeviceData->BytesPerSector; i++, ptr++)
   4.117 +    {
   4.118 +      sum += *ptr;
   4.119 +    }
   4.120 +    KdPrint((__DRIVER_NAME "     WRITE sum = %08X\n", sum));
   4.121 +  }
   4.122 +
   4.123  
   4.124    sect_offset = MmGetMdlByteOffset(ChildDeviceData->shadow[req->id].Mdl) >> 9;
   4.125 +
   4.126 +  KdPrint((__DRIVER_NAME "     Pages = %d, Page[0] = %08X, Offset = %08X\n", ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(ChildDeviceData->shadow[req->id].Mdl), MmGetMdlByteCount(ChildDeviceData->shadow[req->id].Mdl)), *MmGetMdlPfnArray(ChildDeviceData->shadow[req->id].Mdl), MmGetMdlByteOffset(ChildDeviceData->shadow[req->id].Mdl)));
   4.127 +
   4.128    for (i = 0, req->nr_segments = 0; i < BlockCount; req->nr_segments++)
   4.129    {
   4.130      req->seg[req->nr_segments].gref = GntTblInterface.GrantAccess(0, MmGetMdlPfnArray(ChildDeviceData->shadow[req->id].Mdl)[req->nr_segments], FALSE);
   4.131 @@ -1107,13 +1138,8 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
   4.132        req->seg[req->nr_segments].last_sect = (uint8_t)j;
   4.133      sect_offset = 0;
   4.134    }
   4.135 -  if (Srb->Cdb[0] == SCSIOP_WRITE && ChildDeviceData->shadow[req->id].Buf != NULL)
   4.136 -  {
   4.137 -    DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.138 -    if (DataBuffer == NULL)
   4.139 -      KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe failed in PutIrpOnRing\n"));
   4.140 -    memcpy(ChildDeviceData->shadow[req->id].Buf, DataBuffer, BlockCount * ChildDeviceData->BytesPerSector);
   4.141 -  }
   4.142 +  KdPrint((__DRIVER_NAME "     Segments = %d\n", req->nr_segments));
   4.143 +
   4.144    ChildDeviceData->shadow[req->id].req = *req;
   4.145  
   4.146    ChildDeviceData->Ring.req_prod_pvt++;
   4.147 @@ -1129,14 +1155,17 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
   4.148  {
   4.149    PMODE_RIGID_GEOMETRY_PAGE ModeRigidGeometry;
   4.150  
   4.151 +//  KdPrint((__DRIVER_NAME " --> FillModePage (PageCode = %d)\n", PageCode));
   4.152 +
   4.153    switch (PageCode)
   4.154    {
   4.155    case MODE_PAGE_RIGID_GEOMETRY:
   4.156      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_DISK)
   4.157      {
   4.158      KdPrint((__DRIVER_NAME "     MODE_PAGE_RIGID_GEOMETRY\n"));
   4.159 -    if (*Offset + sizeof(MODE_RIGID_GEOMETRY_PAGE) > BufferLength)
   4.160 -      return 1;
   4.161 +    *Offset += sizeof(MODE_RIGID_GEOMETRY_PAGE);
   4.162 +    if (*Offset > BufferLength)
   4.163 +      break;
   4.164      ModeRigidGeometry = (PMODE_RIGID_GEOMETRY_PAGE)(DataBuffer + *Offset);
   4.165      memset(ModeRigidGeometry, 0, sizeof(MODE_RIGID_GEOMETRY_PAGE));
   4.166      ModeRigidGeometry->PageCode = PageCode;
   4.167 @@ -1149,7 +1178,6 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
   4.168      //ModeRigidGeometry->LandZoneCyclinder = 0;
   4.169      ModeRigidGeometry->RoataionRate[0] = 0x05;
   4.170      ModeRigidGeometry->RoataionRate[0] = 0x39;
   4.171 -    *Offset += sizeof(MODE_RIGID_GEOMETRY_PAGE);
   4.172      }
   4.173      break;
   4.174    case MODE_PAGE_FAULT_REPORTING:
   4.175 @@ -1157,6 +1185,9 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
   4.176    default:
   4.177      break;
   4.178    }
   4.179 +
   4.180 +//  KdPrint((__DRIVER_NAME " <-- FillModePage\n", PageCode));
   4.181 +
   4.182    return 0;
   4.183  }
   4.184  
   4.185 @@ -1324,6 +1355,7 @@ XenVbd_Child_PreprocessWdmIrpDEVICE_CONT
   4.186      }
   4.187      else
   4.188      {
   4.189 +      KdPrint((__DRIVER_NAME "     Not Implemented\n"));
   4.190        switch (Spq->PropertyId)
   4.191        {
   4.192        case StorageDeviceProperty:
   4.193 @@ -1367,13 +1399,16 @@ XenVbd_Child_PreprocessWdmIrpDEVICE_CONT
   4.194      break;
   4.195    // http://www.osronline.com/article.cfm?article=229
   4.196    // 0x00560030 device = 0x56, Function = 0x00c = 
   4.197 +/*
   4.198    case IOCTL_DISK_GET_DRIVE_GEOMETRY:
   4.199      KdPrint((__DRIVER_NAME "     IOCTL_DISK_GET_DRIVE_GEOMETRY\n"));
   4.200      memcpy(Irp->AssociatedIrp.SystemBuffer, &ChildDeviceData->Geometry, sizeof(DISK_GEOMETRY));
   4.201      Status = STATUS_SUCCESS;
   4.202      Irp->IoStatus.Status = Status;
   4.203 +    Irp->IoStatus.Information = sizeof(DISK_GEOMETRY);
   4.204      IoCompleteRequest(Irp, IO_NO_INCREMENT);      
   4.205      break;
   4.206 +*/
   4.207    case FT_BALANCED_READ_MODE: // just pretend we know what this is...
   4.208      KdPrint((__DRIVER_NAME "     FT_BALANCED_READ_MODE\n"));
   4.209      Status = STATUS_SUCCESS;
   4.210 @@ -1441,12 +1476,12 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.211    case SRB_FUNCTION_EXECUTE_SCSI:
   4.212      cdb = (PCDB)Srb->Cdb;
   4.213  //    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.214 -//      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   4.215 +    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   4.216      switch(cdb->CDB6GENERIC.OperationCode) //Srb->Cdb[0])
   4.217      {
   4.218      case SCSIOP_TEST_UNIT_READY:
   4.219  //      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.220 -//        KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   4.221 +      KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   4.222        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.223        Srb->ScsiStatus = 0;
   4.224        status = STATUS_SUCCESS;
   4.225 @@ -1483,13 +1518,16 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.226        break;
   4.227      case SCSIOP_READ_CAPACITY:
   4.228  //      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.229 -//        KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
   4.230 +      KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY, RelAdr = %d, LBA = %02x%02x%02x%02x, PMI=%d, Control=%d\n", Srb->Cdb[1] & 1, Srb->Cdb[2], Srb->Cdb[3], Srb->Cdb[4], Srb->Cdb[5], Srb->Cdb[8] & 1, Srb->Cdb[9]));
   4.231 +      KdPrint((__DRIVER_NAME "     Length = %d\n", Srb->DataTransferLength));
   4.232  //      DataBuffer = Srb->DataBuffer;
   4.233 +
   4.234        DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.235 -      DataBuffer[0] = (unsigned char)(ChildDeviceData->TotalSectors >> 24) & 0xff;
   4.236 -      DataBuffer[1] = (unsigned char)(ChildDeviceData->TotalSectors >> 16) & 0xff;
   4.237 -      DataBuffer[2] = (unsigned char)(ChildDeviceData->TotalSectors >> 8) & 0xff;
   4.238 -      DataBuffer[3] = (unsigned char)(ChildDeviceData->TotalSectors >> 0) & 0xff;
   4.239 +      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   4.240 +      DataBuffer[0] = (unsigned char)((ChildDeviceData->TotalSectors - 1) >> 24) & 0xff;
   4.241 +      DataBuffer[1] = (unsigned char)((ChildDeviceData->TotalSectors - 1) >> 16) & 0xff;
   4.242 +      DataBuffer[2] = (unsigned char)((ChildDeviceData->TotalSectors - 1) >> 8) & 0xff;
   4.243 +      DataBuffer[3] = (unsigned char)((ChildDeviceData->TotalSectors - 1) >> 0) & 0xff;
   4.244        DataBuffer[4] = (unsigned char)(ChildDeviceData->BytesPerSector >> 24) & 0xff;
   4.245        DataBuffer[5] = (unsigned char)(ChildDeviceData->BytesPerSector >> 16) & 0xff;
   4.246        DataBuffer[6] = (unsigned char)(ChildDeviceData->BytesPerSector >> 8) & 0xff;
   4.247 @@ -1498,11 +1536,12 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.248        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.249        status = STATUS_SUCCESS;
   4.250        Irp->IoStatus.Status = status;
   4.251 -      Irp->IoStatus.Information = 0;
   4.252 +      Irp->IoStatus.Information = Srb->DataTransferLength;
   4.253        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.254        break;
   4.255 +/*
   4.256      case SCSIOP_MODE_SENSE:
   4.257 -      KdPrint((__DRIVER_NAME "     Command = MODE_SENSE (DBD = %d, PC = %d, Page Code = %02x)\n", Srb->Cdb[1] & 0x10, Srb->Cdb[2] & 0xC0, Srb->Cdb[2] & 0x3F));
   4.258 +      KdPrint((__DRIVER_NAME "     Command = MODE_SENSE (DBD = %d, PC = %d, Page Code = %02x)\n", Srb->Cdb[1] & 0x10, Srb->Cdb[2] & 0xC0, cdb->MODE_SENSE.PageCode));
   4.259        KdPrint((__DRIVER_NAME "     Length = %d\n", Srb->DataTransferLength));
   4.260  
   4.261        status = STATUS_SUCCESS; 
   4.262 @@ -1516,22 +1555,22 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.263          //Ptr = (UCHAR *)Srb->DataBuffer;
   4.264          for (i = 0; i < MODE_SENSE_RETURN_ALL; i++)
   4.265          {
   4.266 -          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   4.267 -          {
   4.268 -            break;
   4.269 -          }
   4.270 +          XenVBD_FillModePage(ChildDeviceData, i, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   4.271          }
   4.272          break;
   4.273        default:
   4.274          XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   4.275          break;
   4.276        }
   4.277 -      Srb->DataTransferLength = Irp->IoStatus.Information;
   4.278 -//      Srb->ScsiStatus = 0;
   4.279 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.280 +      if (Irp->IoStatus.Information > Srb->DataTransferLength)
   4.281 +        Srb->SrbStatus = SRB_STATUS_DATA_OVERRUN;
   4.282 +      else
   4.283 +        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.284 +      status = STATUS_SUCCESS;
   4.285        Irp->IoStatus.Status = status;
   4.286        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.287        break;
   4.288 +*/
   4.289      case SCSIOP_READ:
   4.290      case SCSIOP_WRITE:
   4.291  //      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.292 @@ -1559,6 +1598,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.293        else
   4.294        {
   4.295          XenVbd_PutIrpOnRing(Device, Irp);
   4.296 +        //KeMemoryBarrier(); no need, the next function does it already
   4.297          RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&ChildDeviceData->Ring, notify);
   4.298          if (notify)
   4.299            EvtChnInterface.Notify(ChildDeviceData->EventChannel);
   4.300 @@ -1567,6 +1607,14 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.301        KeReleaseSpinLock(&ChildDeviceData->Lock, KIrql);
   4.302        status = STATUS_PENDING;
   4.303        break;
   4.304 +    case SCSIOP_VERIFY: // We just fake this for now...
   4.305 +      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.306 +      Srb->ScsiStatus = 0;
   4.307 +      status = STATUS_SUCCESS;
   4.308 +      Irp->IoStatus.Status = status;
   4.309 +      Irp->IoStatus.Information = Srb->DataTransferLength;
   4.310 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.311 +      break;
   4.312      case SCSIOP_READ_TOC:
   4.313        DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.314  /*
   4.315 @@ -1629,7 +1677,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.316      default:
   4.317        KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   4.318        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   4.319 -      Irp->IoStatus.Status = status;
   4.320 +      Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
   4.321        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.322        break;
   4.323      }
   4.324 @@ -1649,7 +1697,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.325      break;
   4.326    case SRB_FUNCTION_IO_CONTROL:
   4.327  //    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.328 -//      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
   4.329 +    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
   4.330      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.331      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   4.332      status = STATUS_NOT_IMPLEMENTED;
   4.333 @@ -1659,7 +1707,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.334      break;
   4.335    case SRB_FUNCTION_FLUSH:
   4.336  //    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.337 -//      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
   4.338 +    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
   4.339      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.340      status = STATUS_SUCCESS;
   4.341      Irp->IoStatus.Status = status;