win-pvdrivers

changeset 29:7fc983eddda8

Finally got CDROM access working. Lots of cleaning up to do though...
author James Harper <james.harper@bendigoit.com.au>
date Sun Dec 02 23:13:20 2007 +1100 (2007-12-02)
parents 28803c117324
children f56c47274c37 2e1d570b69e9
files dirs target/xenvbd.inf xenvbd/xenvbd.c
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dirs	Sun Dec 02 23:13:20 2007 +1100
     1.3 @@ -0,0 +1,1 @@
     1.4 +DIRS=xenpci xenhide xenvbd
     1.5 \ No newline at end of file
     2.1 --- a/target/xenvbd.inf	Sat Dec 01 23:46:59 2007 +1100
     2.2 +++ b/target/xenvbd.inf	Sun Dec 02 23:13:20 2007 +1100
     2.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     2.4  Class=SCSIAdapter
     2.5  ClassGuid={4D36E97B-E325-11CE-BFC1-08002BE10318}
     2.6  Provider=%JAMESHARPER%
     2.7 -DriverVer=11/23/2007,0.3.0.32
     2.8 +DriverVer=12/02/2007,0.3.0.52
     2.9  
    2.10  [DestinationDirs]
    2.11  DefaultDestDir = 12
     3.1 --- a/xenvbd/xenvbd.c	Sat Dec 01 23:46:59 2007 +1100
     3.2 +++ b/xenvbd/xenvbd.c	Sun Dec 02 23:13:20 2007 +1100
     3.3 @@ -46,6 +46,8 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
     3.4  static NTSTATUS
     3.5  XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEVICE Device, PIRP Irp);
     3.6  static NTSTATUS
     3.7 +XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL(WDFDEVICE Device, PIRP Irp);
     3.8 +static NTSTATUS
     3.9  XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp);
    3.10  static VOID 
    3.11  XenVbd_Child_IoDefault(WDFQUEUE Queue, WDFREQUEST Request);
    3.12 @@ -190,10 +192,7 @@ static WDFDEVICE GlobalDevice;
    3.13  static PDEVICE_OBJECT Pdo;
    3.14  
    3.15  static NTSTATUS
    3.16 -XenVbd_AddDevice(
    3.17 -    IN WDFDRIVER Driver,
    3.18 -    IN PWDFDEVICE_INIT DeviceInit
    3.19 -    )
    3.20 +XenVbd_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)
    3.21  {
    3.22    WDF_CHILD_LIST_CONFIG ChildListConfig;
    3.23    NTSTATUS status;
    3.24 @@ -952,9 +951,28 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    3.25  
    3.26    //WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, ScsiMinors, 1);
    3.27    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, NULL, 0);
    3.28 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL, IRP_MJ_DEVICE_CONTROL, NULL, 0);
    3.29  
    3.30 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLEANUP, NULL, 0);
    3.31 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLOSE, NULL, 0);
    3.32 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CREATE, NULL, 0);
    3.33 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DIRECTORY_CONTROL, NULL, 0);
    3.34 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_FILE_SYSTEM_CONTROL, NULL, 0);
    3.35 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_FLUSH_BUFFERS, NULL, 0);
    3.36 +///  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_INTERNAL_DEVICE_CONTROL, NULL, 0);
    3.37 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_LOCK_CONTROL, NULL, 0);
    3.38 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_POWER, NULL, 0);
    3.39 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_EA, NULL, 0);
    3.40 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_INFORMATION, NULL, 0);
    3.41 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_SECURITY, NULL, 0);
    3.42    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_VOLUME_INFORMATION, NULL, 0);
    3.43 -  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DEVICE_CHANGE, NULL, 0);
    3.44 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_READ, NULL, 0);
    3.45 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_INFORMATION, NULL, 0);
    3.46 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_SECURITY, NULL, 0);
    3.47 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_VOLUME_INFORMATION, NULL, 0);
    3.48 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SHUTDOWN, NULL, 0);
    3.49 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SYSTEM_CONTROL, NULL, 0);
    3.50 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_WRITE, NULL, 0);
    3.51  
    3.52    WdfDeviceInitSetIoType(ChildInit, WdfDeviceIoDirect);
    3.53  
    3.54 @@ -998,7 +1016,7 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    3.55    //IoQueueConfig.EvtIoRead = XenVbd_Child_IoReadWrite;
    3.56    //IoQueueConfig.EvtIoWrite = XenVbd_Child_IoReadWrite;
    3.57    IoQueueConfig.EvtIoDeviceControl = XenVbd_Child_IoDeviceControl;
    3.58 -  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl;
    3.59 +  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl; // is IRP_MJ_SCSI
    3.60  
    3.61    status = WdfIoQueueCreate(ChildDevice, &IoQueueConfig, WDF_NO_OBJECT_ATTRIBUTES, &ChildDeviceData->IoDefaultQueue);
    3.62    if(!NT_SUCCESS(status))
    3.63 @@ -1050,7 +1068,7 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    3.64  
    3.65    ChildDeviceData = *GetChildDeviceData(Device);
    3.66  
    3.67 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    3.68 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    3.69      KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
    3.70  
    3.71    if (RING_FULL(&ChildDeviceData->Ring))
    3.72 @@ -1127,7 +1145,7 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    3.73  
    3.74    ChildDeviceData->IrpAddedToRing++;
    3.75  
    3.76 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    3.77 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    3.78      KdPrint((__DRIVER_NAME " <-- PutIrpOnRing\n"));
    3.79  }
    3.80  
    3.81 @@ -1139,7 +1157,7 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
    3.82    switch (PageCode)
    3.83    {
    3.84    case MODE_PAGE_RIGID_GEOMETRY:
    3.85 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    3.86 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_DISK)
    3.87      {
    3.88      KdPrint((__DRIVER_NAME "     MODE_PAGE_RIGID_GEOMETRY\n"));
    3.89      if (*Offset + sizeof(MODE_RIGID_GEOMETRY_PAGE) > BufferLength)
    3.90 @@ -1168,12 +1186,62 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
    3.91  }
    3.92  
    3.93  static NTSTATUS
    3.94 +XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL(WDFDEVICE Device, PIRP Irp)
    3.95 +{
    3.96 +  NTSTATUS Status;
    3.97 +  PIO_STACK_LOCATION IrpStack;
    3.98 +  PSCSI_ADDRESS ScsiAddress;
    3.99 +
   3.100 +  KdPrint((__DRIVER_NAME " --> PreprocessWdmIrpDEVICE_CONTROL\n"));
   3.101 +
   3.102 +  IrpStack = IoGetCurrentIrpStackLocation(Irp);
   3.103 +
   3.104 +  switch (IrpStack->Parameters.DeviceIoControl.IoControlCode)
   3.105 +  {
   3.106 +  case IOCTL_SCSI_GET_ADDRESS:
   3.107 +    KdPrint((__DRIVER_NAME "     IOCTL_SCSI_GET_ADDRESS\n"));
   3.108 +    Irp->IoStatus.Information = sizeof(SCSI_ADDRESS);
   3.109 +    if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(SCSI_ADDRESS))
   3.110 +    {
   3.111 +      ScsiAddress = (PSCSI_ADDRESS)Irp->AssociatedIrp.SystemBuffer;
   3.112 +      ScsiAddress->Length = sizeof(SCSI_ADDRESS);
   3.113 +      ScsiAddress->PortNumber = 0;
   3.114 +      ScsiAddress->PathId = 0;
   3.115 +      ScsiAddress->TargetId = 0;
   3.116 +      ScsiAddress->Lun = 0;
   3.117 +      Status = STATUS_SUCCESS;
   3.118 +      Irp->IoStatus.Status = Status;
   3.119 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);      
   3.120 +    }
   3.121 +    else
   3.122 +    {
   3.123 +      KdPrint((__DRIVER_NAME "     (Buffer size too small @ %d\n", IrpStack->Parameters.DeviceIoControl.OutputBufferLength));    
   3.124 +    }
   3.125 +    break;  
   3.126 +  default:
   3.127 +    KdPrint((__DRIVER_NAME "     Control Code = %08x\n", IrpStack->Parameters.DeviceIoControl.IoControlCode));
   3.128 +    IoSkipCurrentIrpStackLocation(Irp);
   3.129 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   3.130 +  }
   3.131 +
   3.132 +  KdPrint((__DRIVER_NAME " <-- PreprocessWdmIrpDEVICE_CONTROL\n"));
   3.133 +
   3.134 +  return Status;
   3.135 +}
   3.136 +
   3.137 +static NTSTATUS
   3.138  XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp)
   3.139  {
   3.140    NTSTATUS Status;
   3.141 +  PIO_STACK_LOCATION IrpStack;
   3.142  
   3.143    KdPrint((__DRIVER_NAME " --> XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   3.144  
   3.145 +  IrpStack = IoGetCurrentIrpStackLocation(Irp);
   3.146 +  KdPrint((__DRIVER_NAME "     Major = %02X, Minor = %02X\n", IrpStack->MajorFunction, IrpStack->MinorFunction));
   3.147 +
   3.148 +  IoSkipCurrentIrpStackLocation(Irp);
   3.149 +
   3.150    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   3.151  
   3.152    KdPrint((__DRIVER_NAME " <-- XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   3.153 @@ -1198,7 +1266,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.154  
   3.155    ChildDeviceData = *GetChildDeviceData(Device);
   3.156  
   3.157 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.158 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.159      KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessSCSI\n"));
   3.160  
   3.161    //KdPrint((__DRIVER_NAME "     SCSI Minor = %02X\n", irpSp->MinorFunction));
   3.162 @@ -1209,12 +1277,12 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.163    {
   3.164    case SRB_FUNCTION_EXECUTE_SCSI:
   3.165      cdb = (PCDB)Srb->Cdb;
   3.166 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.167 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.168        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   3.169      switch(cdb->CDB6GENERIC.OperationCode) //Srb->Cdb[0])
   3.170      {
   3.171      case SCSIOP_TEST_UNIT_READY:
   3.172 -      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.173 +//      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.174          KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   3.175        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.176        Srb->ScsiStatus = 0;
   3.177 @@ -1228,8 +1296,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.178        KdPrint((__DRIVER_NAME "     (LUN = %d, EVPD = %d, Page Code = %02X)\n", Srb->Cdb[1] >> 5, Srb->Cdb[1] & 1, Srb->Cdb[2]));
   3.179        if ((Srb->Cdb[1] & 1) == 0)
   3.180        {
   3.181 -        memset(Srb->DataBuffer, 0, Srb->DataTransferLength);
   3.182 -        DataBuffer = Srb->DataBuffer;
   3.183 +//        DataBuffer = Srb->DataBuffer;
   3.184 +        DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   3.185 +        RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   3.186 +
   3.187          DataBuffer[0] = 0x00; // disk
   3.188          DataBuffer[1] = 0x00; // not removable
   3.189          memcpy(DataBuffer + 8, "James   ", 8); // vendor id
   3.190 @@ -1249,9 +1319,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.191        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.192        break;
   3.193      case SCSIOP_READ_CAPACITY:
   3.194 -      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.195 +//      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.196          KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
   3.197 -      DataBuffer = Srb->DataBuffer;
   3.198 +//      DataBuffer = Srb->DataBuffer;
   3.199 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   3.200        DataBuffer[0] = (unsigned char)(ChildDeviceData->TotalSectors >> 24) & 0xff;
   3.201        DataBuffer[1] = (unsigned char)(ChildDeviceData->TotalSectors >> 16) & 0xff;
   3.202        DataBuffer[2] = (unsigned char)(ChildDeviceData->TotalSectors >> 8) & 0xff;
   3.203 @@ -1271,9 +1342,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.204        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));
   3.205        KdPrint((__DRIVER_NAME "     Length = %d\n", Srb->DataTransferLength));
   3.206  
   3.207 -      Srb->ScsiStatus = 0;
   3.208 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.209        status = STATUS_SUCCESS; 
   3.210 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   3.211 +//      DataBuffer = Srb->DataBuffer;
   3.212 +      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   3.213        switch(cdb->MODE_SENSE.PageCode) //Srb->Cdb[2] & 0x3F)
   3.214        {
   3.215        case MODE_SENSE_RETURN_ALL:
   3.216 @@ -1281,17 +1353,19 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.217          //Ptr = (UCHAR *)Srb->DataBuffer;
   3.218          for (i = 0; i < MODE_SENSE_RETURN_ALL; i++)
   3.219          {
   3.220 -          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, Srb->DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   3.221 +          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   3.222            {
   3.223              break;
   3.224            }
   3.225          }
   3.226          break;
   3.227        default:
   3.228 -        XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, Srb->DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   3.229 +        XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   3.230          break;
   3.231        }
   3.232        Srb->DataTransferLength = Irp->IoStatus.Information;
   3.233 +//      Srb->ScsiStatus = 0;
   3.234 +      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.235        Irp->IoStatus.Status = status;
   3.236        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.237        break;
   3.238 @@ -1330,21 +1404,80 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.239        KeReleaseSpinLock(&ChildDeviceData->Lock, KIrql);
   3.240        status = STATUS_PENDING;
   3.241        break;
   3.242 +    case SCSIOP_READ_TOC:
   3.243 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   3.244 +/*
   3.245 +#define READ_TOC_FORMAT_TOC         0x00
   3.246 +#define READ_TOC_FORMAT_SESSION     0x01
   3.247 +#define READ_TOC_FORMAT_FULL_TOC    0x02
   3.248 +#define READ_TOC_FORMAT_PMA         0x03
   3.249 +#define READ_TOC_FORMAT_ATIP        0x04
   3.250 +*/
   3.251 +      KdPrint((__DRIVER_NAME "     Command = READ_TOC\n"));
   3.252 +      KdPrint((__DRIVER_NAME "     Msf = %d\n", cdb->READ_TOC.Msf));
   3.253 +      KdPrint((__DRIVER_NAME "     LogicalUnitNumber = %d\n", cdb->READ_TOC.LogicalUnitNumber));
   3.254 +      KdPrint((__DRIVER_NAME "     Format2 = %d\n", cdb->READ_TOC.Format2));
   3.255 +      KdPrint((__DRIVER_NAME "     StartingTrack = %d\n", cdb->READ_TOC.StartingTrack));
   3.256 +      KdPrint((__DRIVER_NAME "     AllocationLength = %d\n", (cdb->READ_TOC.AllocationLength[0] << 8) | cdb->READ_TOC.AllocationLength[1]));
   3.257 +      KdPrint((__DRIVER_NAME "     Control = %d\n", cdb->READ_TOC.Control));
   3.258 +      KdPrint((__DRIVER_NAME "     Format = %d\n", cdb->READ_TOC.Format));
   3.259 +      switch (cdb->READ_TOC.Format2)
   3.260 +      {
   3.261 +      case READ_TOC_FORMAT_TOC:
   3.262 +        DataBuffer[0] = 0; // length MSB
   3.263 +        DataBuffer[1] = 10; // length LSB
   3.264 +        DataBuffer[2] = 1; // First Track
   3.265 +        DataBuffer[3] = 1; // Last Track
   3.266 +        DataBuffer[4] = 0; // Reserved
   3.267 +        DataBuffer[5] = 0x14; // current position data + uninterrupted data
   3.268 +        DataBuffer[6] = 1; // last complete track
   3.269 +        DataBuffer[7] = 0; // reserved
   3.270 +        DataBuffer[8] = 0; // MSB Block
   3.271 +        DataBuffer[9] = 0;
   3.272 +        DataBuffer[10] = 0;
   3.273 +        DataBuffer[11] = 0; // LSB Block
   3.274 +        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.275 +        break;
   3.276 +      case READ_TOC_FORMAT_SESSION:
   3.277 +      case READ_TOC_FORMAT_FULL_TOC:
   3.278 +      case READ_TOC_FORMAT_PMA:
   3.279 +      case READ_TOC_FORMAT_ATIP:
   3.280 +        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   3.281 +        break;
   3.282 +      }
   3.283 +      Irp->IoStatus.Status = status;
   3.284 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.285 +      break;
   3.286 +/*
   3.287 +    case SCSIOP_GET_CONFIGURATION:
   3.288 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ALL     0x0
   3.289 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_CURRENT 0x1
   3.290 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ONE     0x2
   3.291 +
   3.292 +        UCHAR OperationCode;       // 0x46 - SCSIOP_GET_CONFIGURATION
   3.293 +        UCHAR RequestType : 2;     // SCSI_GET_CONFIGURATION_REQUEST_TYPE_*
   3.294 +        UCHAR Reserved1   : 6;     // includes obsolete LUN field
   3.295 +        UCHAR StartingFeature[2];
   3.296 +        UCHAR Reserved2[3];
   3.297 +        UCHAR AllocationLength[2];
   3.298 +        UCHAR Control;
   3.299 +      break;
   3.300 +*/     
   3.301      default:
   3.302        KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   3.303 -      status = STATUS_NOT_IMPLEMENTED;
   3.304 +      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   3.305        Irp->IoStatus.Status = status;
   3.306 -      Irp->IoStatus.Information = 0;
   3.307        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.308        break;
   3.309      }
   3.310      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   3.311      break;
   3.312    case SRB_FUNCTION_CLAIM_DEVICE:
   3.313 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.314 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.315        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_CLAIM_DEVICE\n"));
   3.316 -    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   3.317 +//    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   3.318      Srb->DataBuffer = WdfDeviceWdmGetDeviceObject(Device);
   3.319 +//    Srb->DataBuffer = WdfDeviceWdmGetAttachedDevice(Device);
   3.320      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.321      status = STATUS_SUCCESS;
   3.322      Irp->IoStatus.Status = status;
   3.323 @@ -1352,7 +1485,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.324      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.325      break;
   3.326    case SRB_FUNCTION_IO_CONTROL:
   3.327 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.328 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.329        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
   3.330      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   3.331      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   3.332 @@ -1362,7 +1495,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.333      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.334      break;
   3.335    case SRB_FUNCTION_FLUSH:
   3.336 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.337 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.338        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
   3.339      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   3.340      status = STATUS_SUCCESS;
   3.341 @@ -1376,7 +1509,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   3.342      break;
   3.343    }
   3.344  
   3.345 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.346 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.347      KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessSCSI (AddedToList = %d, RemovedFromList = %d, AddedToRing = %d, AddedToRingAtLastNotify = %d, AddedToRingAtLastInterrupt = %d, RemovedFromRing = %d)\n", ChildDeviceData->IrpAddedToList, ChildDeviceData->IrpRemovedFromList, ChildDeviceData->IrpAddedToRing, ChildDeviceData->IrpAddedToRingAtLastNotify, ChildDeviceData->IrpAddedToRingAtLastInterrupt, ChildDeviceData->IrpCompleted));
   3.348    //KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessSCSI\n"));
   3.349  
   3.350 @@ -1432,7 +1565,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   3.351  
   3.352    ChildDeviceData = *GetChildDeviceData(Device);
   3.353  
   3.354 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.355 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.356      KdPrint((__DRIVER_NAME " --> IoDeviceControl\n"));
   3.357    //KdPrint((__DRIVER_NAME "     InputBufferLength = %d\n", InputBufferLength));
   3.358    //KdPrint((__DRIVER_NAME "     OutputBufferLength = %d\n", OutputBufferLength));
   3.359 @@ -1622,7 +1755,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   3.360      break;
   3.361    }
   3.362  
   3.363 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.364 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   3.365      KdPrint((__DRIVER_NAME " <-- IoDeviceControl\n"));
   3.366  }
   3.367