win-pvdrivers

changeset 31:f56c47274c37

Automated merge with ssh://win-pvdrivers@xenbits.xensource.com/win-pvdrivers.hg
author Andy Grover <andy.grover@oracle.com>
date Mon Dec 03 23:05:02 2007 -0800 (2007-12-03)
parents bc0ea67acebb 7fc983eddda8
children d5df0038627d
files .hgtags common/include/evtchn_public.h xenpci/evtchn.c xenpci/xenpci.c xenpci/xenpci.h xenvbd/xenvbd.c
line diff
     1.1 --- a/.hgtags	Mon Dec 03 23:04:07 2007 -0800
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1 +0,0 @@
     1.4 -b55f3c61e50949edb419f4e93ecf854ffa4e5007 0.3.0
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/dirs	Mon Dec 03 23:05:02 2007 -0800
     2.3 @@ -0,0 +1,1 @@
     2.4 +DIRS=xenpci xenhide xenvbd
     2.5 \ No newline at end of file
     3.1 --- a/target/xenvbd.inf	Mon Dec 03 23:04:07 2007 -0800
     3.2 +++ b/target/xenvbd.inf	Mon Dec 03 23:05:02 2007 -0800
     3.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     3.4  Class=SCSIAdapter
     3.5  ClassGuid={4D36E97B-E325-11CE-BFC1-08002BE10318}
     3.6  Provider=%JAMESHARPER%
     3.7 -DriverVer=11/23/2007,0.3.0.32
     3.8 +DriverVer=12/02/2007,0.3.0.52
     3.9  
    3.10  [DestinationDirs]
    3.11  DefaultDestDir = 12
     4.1 --- a/xenvbd/xenvbd.c	Mon Dec 03 23:04:07 2007 -0800
     4.2 +++ b/xenvbd/xenvbd.c	Mon Dec 03 23:05:02 2007 -0800
     4.3 @@ -46,6 +46,8 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
     4.4  static NTSTATUS
     4.5  XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEVICE Device, PIRP Irp);
     4.6  static NTSTATUS
     4.7 +XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL(WDFDEVICE Device, PIRP Irp);
     4.8 +static NTSTATUS
     4.9  XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp);
    4.10  static VOID 
    4.11  XenVbd_Child_IoDefault(WDFQUEUE Queue, WDFREQUEST Request);
    4.12 @@ -192,10 +194,7 @@ static WDFDEVICE GlobalDevice;
    4.13  static PDEVICE_OBJECT Pdo;
    4.14  
    4.15  static NTSTATUS
    4.16 -XenVbd_AddDevice(
    4.17 -    IN WDFDRIVER Driver,
    4.18 -    IN PWDFDEVICE_INIT DeviceInit
    4.19 -    )
    4.20 +XenVbd_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)
    4.21  {
    4.22    WDF_CHILD_LIST_CONFIG ChildListConfig;
    4.23    NTSTATUS status;
    4.24 @@ -978,9 +977,28 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    4.25  
    4.26    //WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, ScsiMinors, 1);
    4.27    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, NULL, 0);
    4.28 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL, IRP_MJ_DEVICE_CONTROL, NULL, 0);
    4.29  
    4.30 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLEANUP, NULL, 0);
    4.31 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLOSE, NULL, 0);
    4.32 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CREATE, NULL, 0);
    4.33 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DIRECTORY_CONTROL, NULL, 0);
    4.34 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_FILE_SYSTEM_CONTROL, NULL, 0);
    4.35 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_FLUSH_BUFFERS, NULL, 0);
    4.36 +///  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_INTERNAL_DEVICE_CONTROL, NULL, 0);
    4.37 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_LOCK_CONTROL, NULL, 0);
    4.38 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_POWER, NULL, 0);
    4.39 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_EA, NULL, 0);
    4.40 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_INFORMATION, NULL, 0);
    4.41 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_SECURITY, NULL, 0);
    4.42    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_VOLUME_INFORMATION, NULL, 0);
    4.43 -  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DEVICE_CHANGE, NULL, 0);
    4.44 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_READ, NULL, 0);
    4.45 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_INFORMATION, NULL, 0);
    4.46 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_SECURITY, NULL, 0);
    4.47 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_VOLUME_INFORMATION, NULL, 0);
    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    WdfDeviceInitSetIoType(ChildInit, WdfDeviceIoDirect);
    4.53  
    4.54 @@ -1024,7 +1042,7 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    4.55    //IoQueueConfig.EvtIoRead = XenVbd_Child_IoReadWrite;
    4.56    //IoQueueConfig.EvtIoWrite = XenVbd_Child_IoReadWrite;
    4.57    IoQueueConfig.EvtIoDeviceControl = XenVbd_Child_IoDeviceControl;
    4.58 -  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl;
    4.59 +  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl; // is IRP_MJ_SCSI
    4.60  
    4.61    status = WdfIoQueueCreate(ChildDevice, &IoQueueConfig, WDF_NO_OBJECT_ATTRIBUTES, &ChildDeviceData->IoDefaultQueue);
    4.62    if(!NT_SUCCESS(status))
    4.63 @@ -1076,7 +1094,7 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    4.64  
    4.65    ChildDeviceData = *GetChildDeviceData(Device);
    4.66  
    4.67 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.68 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.69      KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
    4.70  
    4.71    if (RING_FULL(&ChildDeviceData->Ring))
    4.72 @@ -1157,7 +1175,7 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    4.73  
    4.74    ChildDeviceData->IrpAddedToRing++;
    4.75  
    4.76 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.77 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.78      KdPrint((__DRIVER_NAME " <-- PutIrpOnRing\n"));
    4.79  }
    4.80  
    4.81 @@ -1169,7 +1187,7 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
    4.82    switch (PageCode)
    4.83    {
    4.84    case MODE_PAGE_RIGID_GEOMETRY:
    4.85 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    4.86 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_DISK)
    4.87      {
    4.88      KdPrint((__DRIVER_NAME "     MODE_PAGE_RIGID_GEOMETRY\n"));
    4.89      if (*Offset + sizeof(MODE_RIGID_GEOMETRY_PAGE) > BufferLength)
    4.90 @@ -1198,12 +1216,62 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
    4.91  }
    4.92  
    4.93  static NTSTATUS
    4.94 +XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL(WDFDEVICE Device, PIRP Irp)
    4.95 +{
    4.96 +  NTSTATUS Status;
    4.97 +  PIO_STACK_LOCATION IrpStack;
    4.98 +  PSCSI_ADDRESS ScsiAddress;
    4.99 +
   4.100 +  KdPrint((__DRIVER_NAME " --> PreprocessWdmIrpDEVICE_CONTROL\n"));
   4.101 +
   4.102 +  IrpStack = IoGetCurrentIrpStackLocation(Irp);
   4.103 +
   4.104 +  switch (IrpStack->Parameters.DeviceIoControl.IoControlCode)
   4.105 +  {
   4.106 +  case IOCTL_SCSI_GET_ADDRESS:
   4.107 +    KdPrint((__DRIVER_NAME "     IOCTL_SCSI_GET_ADDRESS\n"));
   4.108 +    Irp->IoStatus.Information = sizeof(SCSI_ADDRESS);
   4.109 +    if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(SCSI_ADDRESS))
   4.110 +    {
   4.111 +      ScsiAddress = (PSCSI_ADDRESS)Irp->AssociatedIrp.SystemBuffer;
   4.112 +      ScsiAddress->Length = sizeof(SCSI_ADDRESS);
   4.113 +      ScsiAddress->PortNumber = 0;
   4.114 +      ScsiAddress->PathId = 0;
   4.115 +      ScsiAddress->TargetId = 0;
   4.116 +      ScsiAddress->Lun = 0;
   4.117 +      Status = STATUS_SUCCESS;
   4.118 +      Irp->IoStatus.Status = Status;
   4.119 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);      
   4.120 +    }
   4.121 +    else
   4.122 +    {
   4.123 +      KdPrint((__DRIVER_NAME "     (Buffer size too small @ %d\n", IrpStack->Parameters.DeviceIoControl.OutputBufferLength));    
   4.124 +    }
   4.125 +    break;  
   4.126 +  default:
   4.127 +    KdPrint((__DRIVER_NAME "     Control Code = %08x\n", IrpStack->Parameters.DeviceIoControl.IoControlCode));
   4.128 +    IoSkipCurrentIrpStackLocation(Irp);
   4.129 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.130 +  }
   4.131 +
   4.132 +  KdPrint((__DRIVER_NAME " <-- PreprocessWdmIrpDEVICE_CONTROL\n"));
   4.133 +
   4.134 +  return Status;
   4.135 +}
   4.136 +
   4.137 +static NTSTATUS
   4.138  XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp)
   4.139  {
   4.140    NTSTATUS Status;
   4.141 +  PIO_STACK_LOCATION IrpStack;
   4.142  
   4.143    KdPrint((__DRIVER_NAME " --> XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   4.144  
   4.145 +  IrpStack = IoGetCurrentIrpStackLocation(Irp);
   4.146 +  KdPrint((__DRIVER_NAME "     Major = %02X, Minor = %02X\n", IrpStack->MajorFunction, IrpStack->MinorFunction));
   4.147 +
   4.148 +  IoSkipCurrentIrpStackLocation(Irp);
   4.149 +
   4.150    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.151  
   4.152    KdPrint((__DRIVER_NAME " <-- XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   4.153 @@ -1228,7 +1296,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.154  
   4.155    ChildDeviceData = *GetChildDeviceData(Device);
   4.156  
   4.157 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.158 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.159      KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessSCSI\n"));
   4.160  
   4.161    //KdPrint((__DRIVER_NAME "     SCSI Minor = %02X\n", irpSp->MinorFunction));
   4.162 @@ -1239,12 +1307,12 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.163    {
   4.164    case SRB_FUNCTION_EXECUTE_SCSI:
   4.165      cdb = (PCDB)Srb->Cdb;
   4.166 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.167 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.168        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   4.169      switch(cdb->CDB6GENERIC.OperationCode) //Srb->Cdb[0])
   4.170      {
   4.171      case SCSIOP_TEST_UNIT_READY:
   4.172 -      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.173 +//      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.174          KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   4.175        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.176        Srb->ScsiStatus = 0;
   4.177 @@ -1258,8 +1326,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.178        KdPrint((__DRIVER_NAME "     (LUN = %d, EVPD = %d, Page Code = %02X)\n", Srb->Cdb[1] >> 5, Srb->Cdb[1] & 1, Srb->Cdb[2]));
   4.179        if ((Srb->Cdb[1] & 1) == 0)
   4.180        {
   4.181 -        memset(Srb->DataBuffer, 0, Srb->DataTransferLength);
   4.182 -        DataBuffer = Srb->DataBuffer;
   4.183 +//        DataBuffer = Srb->DataBuffer;
   4.184 +        DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.185 +        RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   4.186 +
   4.187          DataBuffer[0] = 0x00; // disk
   4.188          DataBuffer[1] = 0x00; // not removable
   4.189          memcpy(DataBuffer + 8, "James   ", 8); // vendor id
   4.190 @@ -1279,9 +1349,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.191        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.192        break;
   4.193      case SCSIOP_READ_CAPACITY:
   4.194 -      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.195 +//      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.196          KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
   4.197 -      DataBuffer = Srb->DataBuffer;
   4.198 +//      DataBuffer = Srb->DataBuffer;
   4.199 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.200        DataBuffer[0] = (unsigned char)(ChildDeviceData->TotalSectors >> 24) & 0xff;
   4.201        DataBuffer[1] = (unsigned char)(ChildDeviceData->TotalSectors >> 16) & 0xff;
   4.202        DataBuffer[2] = (unsigned char)(ChildDeviceData->TotalSectors >> 8) & 0xff;
   4.203 @@ -1301,9 +1372,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.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));
   4.205        KdPrint((__DRIVER_NAME "     Length = %d\n", Srb->DataTransferLength));
   4.206  
   4.207 -      Srb->ScsiStatus = 0;
   4.208 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.209        status = STATUS_SUCCESS; 
   4.210 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.211 +//      DataBuffer = Srb->DataBuffer;
   4.212 +      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   4.213        switch(cdb->MODE_SENSE.PageCode) //Srb->Cdb[2] & 0x3F)
   4.214        {
   4.215        case MODE_SENSE_RETURN_ALL:
   4.216 @@ -1311,17 +1383,19 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.217          //Ptr = (UCHAR *)Srb->DataBuffer;
   4.218          for (i = 0; i < MODE_SENSE_RETURN_ALL; i++)
   4.219          {
   4.220 -          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, Srb->DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   4.221 +          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   4.222            {
   4.223              break;
   4.224            }
   4.225          }
   4.226          break;
   4.227        default:
   4.228 -        XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, Srb->DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   4.229 +        XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   4.230          break;
   4.231        }
   4.232        Srb->DataTransferLength = Irp->IoStatus.Information;
   4.233 +//      Srb->ScsiStatus = 0;
   4.234 +      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.235        Irp->IoStatus.Status = status;
   4.236        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.237        break;
   4.238 @@ -1361,21 +1435,80 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.239        KeReleaseSpinLock(&ChildDeviceData->Lock, KIrql);
   4.240        status = STATUS_PENDING;
   4.241        break;
   4.242 +    case SCSIOP_READ_TOC:
   4.243 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   4.244 +/*
   4.245 +#define READ_TOC_FORMAT_TOC         0x00
   4.246 +#define READ_TOC_FORMAT_SESSION     0x01
   4.247 +#define READ_TOC_FORMAT_FULL_TOC    0x02
   4.248 +#define READ_TOC_FORMAT_PMA         0x03
   4.249 +#define READ_TOC_FORMAT_ATIP        0x04
   4.250 +*/
   4.251 +      KdPrint((__DRIVER_NAME "     Command = READ_TOC\n"));
   4.252 +      KdPrint((__DRIVER_NAME "     Msf = %d\n", cdb->READ_TOC.Msf));
   4.253 +      KdPrint((__DRIVER_NAME "     LogicalUnitNumber = %d\n", cdb->READ_TOC.LogicalUnitNumber));
   4.254 +      KdPrint((__DRIVER_NAME "     Format2 = %d\n", cdb->READ_TOC.Format2));
   4.255 +      KdPrint((__DRIVER_NAME "     StartingTrack = %d\n", cdb->READ_TOC.StartingTrack));
   4.256 +      KdPrint((__DRIVER_NAME "     AllocationLength = %d\n", (cdb->READ_TOC.AllocationLength[0] << 8) | cdb->READ_TOC.AllocationLength[1]));
   4.257 +      KdPrint((__DRIVER_NAME "     Control = %d\n", cdb->READ_TOC.Control));
   4.258 +      KdPrint((__DRIVER_NAME "     Format = %d\n", cdb->READ_TOC.Format));
   4.259 +      switch (cdb->READ_TOC.Format2)
   4.260 +      {
   4.261 +      case READ_TOC_FORMAT_TOC:
   4.262 +        DataBuffer[0] = 0; // length MSB
   4.263 +        DataBuffer[1] = 10; // length LSB
   4.264 +        DataBuffer[2] = 1; // First Track
   4.265 +        DataBuffer[3] = 1; // Last Track
   4.266 +        DataBuffer[4] = 0; // Reserved
   4.267 +        DataBuffer[5] = 0x14; // current position data + uninterrupted data
   4.268 +        DataBuffer[6] = 1; // last complete track
   4.269 +        DataBuffer[7] = 0; // reserved
   4.270 +        DataBuffer[8] = 0; // MSB Block
   4.271 +        DataBuffer[9] = 0;
   4.272 +        DataBuffer[10] = 0;
   4.273 +        DataBuffer[11] = 0; // LSB Block
   4.274 +        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.275 +        break;
   4.276 +      case READ_TOC_FORMAT_SESSION:
   4.277 +      case READ_TOC_FORMAT_FULL_TOC:
   4.278 +      case READ_TOC_FORMAT_PMA:
   4.279 +      case READ_TOC_FORMAT_ATIP:
   4.280 +        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   4.281 +        break;
   4.282 +      }
   4.283 +      Irp->IoStatus.Status = status;
   4.284 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.285 +      break;
   4.286 +/*
   4.287 +    case SCSIOP_GET_CONFIGURATION:
   4.288 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ALL     0x0
   4.289 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_CURRENT 0x1
   4.290 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ONE     0x2
   4.291 +
   4.292 +        UCHAR OperationCode;       // 0x46 - SCSIOP_GET_CONFIGURATION
   4.293 +        UCHAR RequestType : 2;     // SCSI_GET_CONFIGURATION_REQUEST_TYPE_*
   4.294 +        UCHAR Reserved1   : 6;     // includes obsolete LUN field
   4.295 +        UCHAR StartingFeature[2];
   4.296 +        UCHAR Reserved2[3];
   4.297 +        UCHAR AllocationLength[2];
   4.298 +        UCHAR Control;
   4.299 +      break;
   4.300 +*/     
   4.301      default:
   4.302        KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   4.303 -      status = STATUS_NOT_IMPLEMENTED;
   4.304 +      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   4.305        Irp->IoStatus.Status = status;
   4.306 -      Irp->IoStatus.Information = 0;
   4.307        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.308        break;
   4.309      }
   4.310      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.311      break;
   4.312    case SRB_FUNCTION_CLAIM_DEVICE:
   4.313 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.314 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.315        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_CLAIM_DEVICE\n"));
   4.316 -    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   4.317 +//    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   4.318      Srb->DataBuffer = WdfDeviceWdmGetDeviceObject(Device);
   4.319 +//    Srb->DataBuffer = WdfDeviceWdmGetAttachedDevice(Device);
   4.320      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.321      status = STATUS_SUCCESS;
   4.322      Irp->IoStatus.Status = status;
   4.323 @@ -1383,7 +1516,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.324      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.325      break;
   4.326    case SRB_FUNCTION_IO_CONTROL:
   4.327 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.328 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   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 @@ -1393,7 +1526,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.333      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   4.334      break;
   4.335    case SRB_FUNCTION_FLUSH:
   4.336 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.337 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.338        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
   4.339      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   4.340      status = STATUS_SUCCESS;
   4.341 @@ -1407,7 +1540,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   4.342      break;
   4.343    }
   4.344  
   4.345 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.346 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.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));
   4.348    //KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessSCSI\n"));
   4.349  
   4.350 @@ -1464,7 +1597,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   4.351  
   4.352    ChildDeviceData = *GetChildDeviceData(Device);
   4.353  
   4.354 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.355 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.356      KdPrint((__DRIVER_NAME " --> IoDeviceControl\n"));
   4.357    //KdPrint((__DRIVER_NAME "     InputBufferLength = %d\n", InputBufferLength));
   4.358    //KdPrint((__DRIVER_NAME "     OutputBufferLength = %d\n", OutputBufferLength));
   4.359 @@ -1654,7 +1787,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   4.360      break;
   4.361    }
   4.362  
   4.363 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.364 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   4.365      KdPrint((__DRIVER_NAME " <-- IoDeviceControl\n"));
   4.366  }
   4.367