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
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/dirs	Mon Dec 03 23:05:02 2007 -0800
     3.3 @@ -0,0 +1,1 @@
     3.4 +DIRS=xenpci xenhide xenvbd
     3.5 \ No newline at end of file
     5.1 --- a/target/xenvbd.inf	Mon Dec 03 23:04:07 2007 -0800
     5.2 +++ b/target/xenvbd.inf	Mon Dec 03 23:05:02 2007 -0800
     5.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     5.4  Class=SCSIAdapter
     5.5  ClassGuid={4D36E97B-E325-11CE-BFC1-08002BE10318}
     5.6  Provider=%JAMESHARPER%
     5.7 -DriverVer=11/23/2007,0.3.0.32
     5.8 +DriverVer=12/02/2007,0.3.0.52
     5.9  
    5.10  [DestinationDirs]
    5.11  DefaultDestDir = 12
     9.1 --- a/xenvbd/xenvbd.c	Mon Dec 03 23:04:07 2007 -0800
     9.2 +++ b/xenvbd/xenvbd.c	Mon Dec 03 23:05:02 2007 -0800
     9.3 @@ -46,6 +46,8 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
     9.4  static NTSTATUS
     9.5  XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEVICE Device, PIRP Irp);
     9.6  static NTSTATUS
     9.7 +XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL(WDFDEVICE Device, PIRP Irp);
     9.8 +static NTSTATUS
     9.9  XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp);
    9.10  static VOID 
    9.11  XenVbd_Child_IoDefault(WDFQUEUE Queue, WDFREQUEST Request);
    9.12 @@ -192,10 +194,7 @@ static WDFDEVICE GlobalDevice;
    9.13  static PDEVICE_OBJECT Pdo;
    9.14  
    9.15  static NTSTATUS
    9.16 -XenVbd_AddDevice(
    9.17 -    IN WDFDRIVER Driver,
    9.18 -    IN PWDFDEVICE_INIT DeviceInit
    9.19 -    )
    9.20 +XenVbd_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)
    9.21  {
    9.22    WDF_CHILD_LIST_CONFIG ChildListConfig;
    9.23    NTSTATUS status;
    9.24 @@ -978,9 +977,28 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    9.25  
    9.26    //WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, ScsiMinors, 1);
    9.27    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, NULL, 0);
    9.28 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL, IRP_MJ_DEVICE_CONTROL, NULL, 0);
    9.29  
    9.30 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLEANUP, NULL, 0);
    9.31 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CLOSE, NULL, 0);
    9.32 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_CREATE, NULL, 0);
    9.33 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DIRECTORY_CONTROL, NULL, 0);
    9.34 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_FILE_SYSTEM_CONTROL, NULL, 0);
    9.35 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_FLUSH_BUFFERS, NULL, 0);
    9.36 +///  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_INTERNAL_DEVICE_CONTROL, NULL, 0);
    9.37 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_LOCK_CONTROL, NULL, 0);
    9.38 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_POWER, NULL, 0);
    9.39 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_EA, NULL, 0);
    9.40 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_INFORMATION, NULL, 0);
    9.41 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_SECURITY, NULL, 0);
    9.42    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_VOLUME_INFORMATION, NULL, 0);
    9.43 -  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DEVICE_CHANGE, NULL, 0);
    9.44 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_READ, NULL, 0);
    9.45 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_INFORMATION, NULL, 0);
    9.46 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_SECURITY, NULL, 0);
    9.47 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SET_VOLUME_INFORMATION, NULL, 0);
    9.48 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SHUTDOWN, NULL, 0);
    9.49 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_SYSTEM_CONTROL, NULL, 0);
    9.50 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_WRITE, NULL, 0);
    9.51  
    9.52    WdfDeviceInitSetIoType(ChildInit, WdfDeviceIoDirect);
    9.53  
    9.54 @@ -1024,7 +1042,7 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
    9.55    //IoQueueConfig.EvtIoRead = XenVbd_Child_IoReadWrite;
    9.56    //IoQueueConfig.EvtIoWrite = XenVbd_Child_IoReadWrite;
    9.57    IoQueueConfig.EvtIoDeviceControl = XenVbd_Child_IoDeviceControl;
    9.58 -  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl;
    9.59 +  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl; // is IRP_MJ_SCSI
    9.60  
    9.61    status = WdfIoQueueCreate(ChildDevice, &IoQueueConfig, WDF_NO_OBJECT_ATTRIBUTES, &ChildDeviceData->IoDefaultQueue);
    9.62    if(!NT_SUCCESS(status))
    9.63 @@ -1076,7 +1094,7 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    9.64  
    9.65    ChildDeviceData = *GetChildDeviceData(Device);
    9.66  
    9.67 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    9.68 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    9.69      KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
    9.70  
    9.71    if (RING_FULL(&ChildDeviceData->Ring))
    9.72 @@ -1157,7 +1175,7 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
    9.73  
    9.74    ChildDeviceData->IrpAddedToRing++;
    9.75  
    9.76 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    9.77 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    9.78      KdPrint((__DRIVER_NAME " <-- PutIrpOnRing\n"));
    9.79  }
    9.80  
    9.81 @@ -1169,7 +1187,7 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
    9.82    switch (PageCode)
    9.83    {
    9.84    case MODE_PAGE_RIGID_GEOMETRY:
    9.85 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
    9.86 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_DISK)
    9.87      {
    9.88      KdPrint((__DRIVER_NAME "     MODE_PAGE_RIGID_GEOMETRY\n"));
    9.89      if (*Offset + sizeof(MODE_RIGID_GEOMETRY_PAGE) > BufferLength)
    9.90 @@ -1198,12 +1216,62 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
    9.91  }
    9.92  
    9.93  static NTSTATUS
    9.94 +XenVbd_Child_PreprocessWdmIrpDEVICE_CONTROL(WDFDEVICE Device, PIRP Irp)
    9.95 +{
    9.96 +  NTSTATUS Status;
    9.97 +  PIO_STACK_LOCATION IrpStack;
    9.98 +  PSCSI_ADDRESS ScsiAddress;
    9.99 +
   9.100 +  KdPrint((__DRIVER_NAME " --> PreprocessWdmIrpDEVICE_CONTROL\n"));
   9.101 +
   9.102 +  IrpStack = IoGetCurrentIrpStackLocation(Irp);
   9.103 +
   9.104 +  switch (IrpStack->Parameters.DeviceIoControl.IoControlCode)
   9.105 +  {
   9.106 +  case IOCTL_SCSI_GET_ADDRESS:
   9.107 +    KdPrint((__DRIVER_NAME "     IOCTL_SCSI_GET_ADDRESS\n"));
   9.108 +    Irp->IoStatus.Information = sizeof(SCSI_ADDRESS);
   9.109 +    if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(SCSI_ADDRESS))
   9.110 +    {
   9.111 +      ScsiAddress = (PSCSI_ADDRESS)Irp->AssociatedIrp.SystemBuffer;
   9.112 +      ScsiAddress->Length = sizeof(SCSI_ADDRESS);
   9.113 +      ScsiAddress->PortNumber = 0;
   9.114 +      ScsiAddress->PathId = 0;
   9.115 +      ScsiAddress->TargetId = 0;
   9.116 +      ScsiAddress->Lun = 0;
   9.117 +      Status = STATUS_SUCCESS;
   9.118 +      Irp->IoStatus.Status = Status;
   9.119 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);      
   9.120 +    }
   9.121 +    else
   9.122 +    {
   9.123 +      KdPrint((__DRIVER_NAME "     (Buffer size too small @ %d\n", IrpStack->Parameters.DeviceIoControl.OutputBufferLength));    
   9.124 +    }
   9.125 +    break;  
   9.126 +  default:
   9.127 +    KdPrint((__DRIVER_NAME "     Control Code = %08x\n", IrpStack->Parameters.DeviceIoControl.IoControlCode));
   9.128 +    IoSkipCurrentIrpStackLocation(Irp);
   9.129 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   9.130 +  }
   9.131 +
   9.132 +  KdPrint((__DRIVER_NAME " <-- PreprocessWdmIrpDEVICE_CONTROL\n"));
   9.133 +
   9.134 +  return Status;
   9.135 +}
   9.136 +
   9.137 +static NTSTATUS
   9.138  XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp)
   9.139  {
   9.140    NTSTATUS Status;
   9.141 +  PIO_STACK_LOCATION IrpStack;
   9.142  
   9.143    KdPrint((__DRIVER_NAME " --> XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   9.144  
   9.145 +  IrpStack = IoGetCurrentIrpStackLocation(Irp);
   9.146 +  KdPrint((__DRIVER_NAME "     Major = %02X, Minor = %02X\n", IrpStack->MajorFunction, IrpStack->MinorFunction));
   9.147 +
   9.148 +  IoSkipCurrentIrpStackLocation(Irp);
   9.149 +
   9.150    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   9.151  
   9.152    KdPrint((__DRIVER_NAME " <-- XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   9.153 @@ -1228,7 +1296,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.154  
   9.155    ChildDeviceData = *GetChildDeviceData(Device);
   9.156  
   9.157 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.158 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.159      KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessSCSI\n"));
   9.160  
   9.161    //KdPrint((__DRIVER_NAME "     SCSI Minor = %02X\n", irpSp->MinorFunction));
   9.162 @@ -1239,12 +1307,12 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.163    {
   9.164    case SRB_FUNCTION_EXECUTE_SCSI:
   9.165      cdb = (PCDB)Srb->Cdb;
   9.166 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.167 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.168        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   9.169      switch(cdb->CDB6GENERIC.OperationCode) //Srb->Cdb[0])
   9.170      {
   9.171      case SCSIOP_TEST_UNIT_READY:
   9.172 -      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.173 +//      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.174          KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   9.175        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.176        Srb->ScsiStatus = 0;
   9.177 @@ -1258,8 +1326,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.178        KdPrint((__DRIVER_NAME "     (LUN = %d, EVPD = %d, Page Code = %02X)\n", Srb->Cdb[1] >> 5, Srb->Cdb[1] & 1, Srb->Cdb[2]));
   9.179        if ((Srb->Cdb[1] & 1) == 0)
   9.180        {
   9.181 -        memset(Srb->DataBuffer, 0, Srb->DataTransferLength);
   9.182 -        DataBuffer = Srb->DataBuffer;
   9.183 +//        DataBuffer = Srb->DataBuffer;
   9.184 +        DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   9.185 +        RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   9.186 +
   9.187          DataBuffer[0] = 0x00; // disk
   9.188          DataBuffer[1] = 0x00; // not removable
   9.189          memcpy(DataBuffer + 8, "James   ", 8); // vendor id
   9.190 @@ -1279,9 +1349,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.191        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   9.192        break;
   9.193      case SCSIOP_READ_CAPACITY:
   9.194 -      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.195 +//      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.196          KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
   9.197 -      DataBuffer = Srb->DataBuffer;
   9.198 +//      DataBuffer = Srb->DataBuffer;
   9.199 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   9.200        DataBuffer[0] = (unsigned char)(ChildDeviceData->TotalSectors >> 24) & 0xff;
   9.201        DataBuffer[1] = (unsigned char)(ChildDeviceData->TotalSectors >> 16) & 0xff;
   9.202        DataBuffer[2] = (unsigned char)(ChildDeviceData->TotalSectors >> 8) & 0xff;
   9.203 @@ -1301,9 +1372,10 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.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));
   9.205        KdPrint((__DRIVER_NAME "     Length = %d\n", Srb->DataTransferLength));
   9.206  
   9.207 -      Srb->ScsiStatus = 0;
   9.208 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.209        status = STATUS_SUCCESS; 
   9.210 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   9.211 +//      DataBuffer = Srb->DataBuffer;
   9.212 +      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   9.213        switch(cdb->MODE_SENSE.PageCode) //Srb->Cdb[2] & 0x3F)
   9.214        {
   9.215        case MODE_SENSE_RETURN_ALL:
   9.216 @@ -1311,17 +1383,19 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.217          //Ptr = (UCHAR *)Srb->DataBuffer;
   9.218          for (i = 0; i < MODE_SENSE_RETURN_ALL; i++)
   9.219          {
   9.220 -          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, Srb->DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   9.221 +          if (XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information))
   9.222            {
   9.223              break;
   9.224            }
   9.225          }
   9.226          break;
   9.227        default:
   9.228 -        XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, Srb->DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   9.229 +        XenVBD_FillModePage(ChildDeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Irp->IoStatus.Information);
   9.230          break;
   9.231        }
   9.232        Srb->DataTransferLength = Irp->IoStatus.Information;
   9.233 +//      Srb->ScsiStatus = 0;
   9.234 +      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.235        Irp->IoStatus.Status = status;
   9.236        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   9.237        break;
   9.238 @@ -1361,21 +1435,80 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.239        KeReleaseSpinLock(&ChildDeviceData->Lock, KIrql);
   9.240        status = STATUS_PENDING;
   9.241        break;
   9.242 +    case SCSIOP_READ_TOC:
   9.243 +      DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
   9.244 +/*
   9.245 +#define READ_TOC_FORMAT_TOC         0x00
   9.246 +#define READ_TOC_FORMAT_SESSION     0x01
   9.247 +#define READ_TOC_FORMAT_FULL_TOC    0x02
   9.248 +#define READ_TOC_FORMAT_PMA         0x03
   9.249 +#define READ_TOC_FORMAT_ATIP        0x04
   9.250 +*/
   9.251 +      KdPrint((__DRIVER_NAME "     Command = READ_TOC\n"));
   9.252 +      KdPrint((__DRIVER_NAME "     Msf = %d\n", cdb->READ_TOC.Msf));
   9.253 +      KdPrint((__DRIVER_NAME "     LogicalUnitNumber = %d\n", cdb->READ_TOC.LogicalUnitNumber));
   9.254 +      KdPrint((__DRIVER_NAME "     Format2 = %d\n", cdb->READ_TOC.Format2));
   9.255 +      KdPrint((__DRIVER_NAME "     StartingTrack = %d\n", cdb->READ_TOC.StartingTrack));
   9.256 +      KdPrint((__DRIVER_NAME "     AllocationLength = %d\n", (cdb->READ_TOC.AllocationLength[0] << 8) | cdb->READ_TOC.AllocationLength[1]));
   9.257 +      KdPrint((__DRIVER_NAME "     Control = %d\n", cdb->READ_TOC.Control));
   9.258 +      KdPrint((__DRIVER_NAME "     Format = %d\n", cdb->READ_TOC.Format));
   9.259 +      switch (cdb->READ_TOC.Format2)
   9.260 +      {
   9.261 +      case READ_TOC_FORMAT_TOC:
   9.262 +        DataBuffer[0] = 0; // length MSB
   9.263 +        DataBuffer[1] = 10; // length LSB
   9.264 +        DataBuffer[2] = 1; // First Track
   9.265 +        DataBuffer[3] = 1; // Last Track
   9.266 +        DataBuffer[4] = 0; // Reserved
   9.267 +        DataBuffer[5] = 0x14; // current position data + uninterrupted data
   9.268 +        DataBuffer[6] = 1; // last complete track
   9.269 +        DataBuffer[7] = 0; // reserved
   9.270 +        DataBuffer[8] = 0; // MSB Block
   9.271 +        DataBuffer[9] = 0;
   9.272 +        DataBuffer[10] = 0;
   9.273 +        DataBuffer[11] = 0; // LSB Block
   9.274 +        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.275 +        break;
   9.276 +      case READ_TOC_FORMAT_SESSION:
   9.277 +      case READ_TOC_FORMAT_FULL_TOC:
   9.278 +      case READ_TOC_FORMAT_PMA:
   9.279 +      case READ_TOC_FORMAT_ATIP:
   9.280 +        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   9.281 +        break;
   9.282 +      }
   9.283 +      Irp->IoStatus.Status = status;
   9.284 +      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   9.285 +      break;
   9.286 +/*
   9.287 +    case SCSIOP_GET_CONFIGURATION:
   9.288 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ALL     0x0
   9.289 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_CURRENT 0x1
   9.290 +#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ONE     0x2
   9.291 +
   9.292 +        UCHAR OperationCode;       // 0x46 - SCSIOP_GET_CONFIGURATION
   9.293 +        UCHAR RequestType : 2;     // SCSI_GET_CONFIGURATION_REQUEST_TYPE_*
   9.294 +        UCHAR Reserved1   : 6;     // includes obsolete LUN field
   9.295 +        UCHAR StartingFeature[2];
   9.296 +        UCHAR Reserved2[3];
   9.297 +        UCHAR AllocationLength[2];
   9.298 +        UCHAR Control;
   9.299 +      break;
   9.300 +*/     
   9.301      default:
   9.302        KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   9.303 -      status = STATUS_NOT_IMPLEMENTED;
   9.304 +      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   9.305        Irp->IoStatus.Status = status;
   9.306 -      Irp->IoStatus.Information = 0;
   9.307        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   9.308        break;
   9.309      }
   9.310      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   9.311      break;
   9.312    case SRB_FUNCTION_CLAIM_DEVICE:
   9.313 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.314 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.315        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_CLAIM_DEVICE\n"));
   9.316 -    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   9.317 +//    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   9.318      Srb->DataBuffer = WdfDeviceWdmGetDeviceObject(Device);
   9.319 +//    Srb->DataBuffer = WdfDeviceWdmGetAttachedDevice(Device);
   9.320      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.321      status = STATUS_SUCCESS;
   9.322      Irp->IoStatus.Status = status;
   9.323 @@ -1383,7 +1516,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.324      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   9.325      break;
   9.326    case SRB_FUNCTION_IO_CONTROL:
   9.327 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.328 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.329        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
   9.330      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   9.331      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   9.332 @@ -1393,7 +1526,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.333      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   9.334      break;
   9.335    case SRB_FUNCTION_FLUSH:
   9.336 -    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.337 +//    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.338        KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
   9.339      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.340      status = STATUS_SUCCESS;
   9.341 @@ -1407,7 +1540,7 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   9.342      break;
   9.343    }
   9.344  
   9.345 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.346 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.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));
   9.348    //KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessSCSI\n"));
   9.349  
   9.350 @@ -1464,7 +1597,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   9.351  
   9.352    ChildDeviceData = *GetChildDeviceData(Device);
   9.353  
   9.354 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.355 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.356      KdPrint((__DRIVER_NAME " --> IoDeviceControl\n"));
   9.357    //KdPrint((__DRIVER_NAME "     InputBufferLength = %d\n", InputBufferLength));
   9.358    //KdPrint((__DRIVER_NAME "     OutputBufferLength = %d\n", OutputBufferLength));
   9.359 @@ -1654,7 +1787,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   9.360      break;
   9.361    }
   9.362  
   9.363 -  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.364 +//  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   9.365      KdPrint((__DRIVER_NAME " <-- IoDeviceControl\n"));
   9.366  }
   9.367