win-pvdrivers

changeset 9:b55f3c61e509

Updated inf files to put the devices in the right places.
Started adding CDROM code (doesn't work though)
author James Harper <james.harper@bendigoit.com.au>
date Fri Nov 23 10:24:38 2007 +1100 (2007-11-23)
parents d25a6f733a8e
children 7dd1e28542fe
files TODO.txt target/xenhide.inf target/xenpci.inf target/xenvbd.inf xenpci/xenbus.c xenvbd/xenvbd.c xenvbd/xenvbd.h
line diff
     1.1 --- a/TODO.txt	Mon Nov 19 17:42:06 2007 +1100
     1.2 +++ b/TODO.txt	Fri Nov 23 10:24:38 2007 +1100
     1.3 @@ -7,6 +7,9 @@ Known problems or things that need doing
     1.4  . No power management
     1.5  . Almost certainly won't support migration or suspend/resume.
     1.6  . Probably really poor performance - no optimisation done at all yet.
     1.7 +. Reports of problems on Intel systems
     1.8 +. No CDROM Support
     1.9 +. Lockups under SMP
    1.10  . Probably lots of other things too.
    1.11  
    1.12  TODO:
     2.1 --- a/target/xenhide.inf	Mon Nov 19 17:42:06 2007 +1100
     2.2 +++ b/target/xenhide.inf	Fri Nov 23 10:24:38 2007 +1100
     2.3 @@ -3,32 +3,15 @@ Signature="$WINDOWS NT$"
     2.4  Class=System
     2.5  ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}
     2.6  Provider=%JAMESHARPER%
     2.7 -DriverVer=11/11/2007,1.0.0.22
     2.8 +DriverVer=11/20/2007,0.3.0.1
     2.9  
    2.10  [ControlFlags]
    2.11  ExcludeFromSelect = *
    2.12  
    2.13  [DestinationDirs]
    2.14  DefaultDestDir = 12
    2.15 -;ClassInstall32_CopyFiles=11
    2.16  CoInstaller_CopyFiles = 11
    2.17  
    2.18 -; ================= Class section =====================
    2.19 -;
    2.20 -;[ClassInstall32]
    2.21 -;Addreg=ClassInstall32_AddReg
    2.22 -;CopyFiles=ClassInstall32_CopyFiles
    2.23 -;
    2.24 -;[ClassInstall32_AddReg]
    2.25 -;HKR,,,0,%ClassName%
    2.26 -;HKR,,Icon,,100
    2.27 -;HKR,,DeviceCharacteristics,0x10001,0x100     ;Use same security checks on relative opens
    2.28 -;HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)" ;Allow generic all access to system and built-in Admin. 
    2.29 -
    2.30 -;[ClassInstall32_CopyFiles]
    2.31 -
    2.32 -; ================= Device Install section =====================
    2.33 -
    2.34  [Manufacturer]
    2.35  %JAMESHARPER%=JAMESHARPER,NTx86
    2.36  
    2.37 @@ -96,7 +79,6 @@ KmdfLibraryVersion = 1.0
    2.38  
    2.39  [Strings]
    2.40  JAMESHARPER = "James Harper"
    2.41 -ClassName = "System devices"
    2.42  XenHide.SVCDESC = "Xen PCI Device Hider Driver"
    2.43  XenHide.DRVDESC = "Xen PCI Device Hider Driver"
    2.44  DISK_NAME = "Xen PCI Device Driver Hider Install Disk"
     3.1 --- a/target/xenpci.inf	Mon Nov 19 17:42:06 2007 +1100
     3.2 +++ b/target/xenpci.inf	Fri Nov 23 10:24:38 2007 +1100
     3.3 @@ -1,35 +1,18 @@
     3.4  [Version]
     3.5  Signature="$WINDOWS NT$"
     3.6 -Class=Xen
     3.7 -ClassGuid={C828ABE9-14CA-4445-BAA6-82C2376C6518}
     3.8 +Class=System
     3.9 +ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
    3.10  Provider=%JAMESHARPER%
    3.11 -DriverVer=11/19/2007,1.0.1.8
    3.12 +DriverVer=11/20/2007,0.3.0.2
    3.13  
    3.14  [DestinationDirs]
    3.15  DefaultDestDir = 12
    3.16  ClassInstall32_CopyFiles=11
    3.17  CoInstaller_CopyFiles = 11
    3.18  
    3.19 -; ================= Class section =====================
    3.20 -
    3.21 -[ClassInstall32]
    3.22 -Addreg=ClassInstall32_AddReg
    3.23 -CopyFiles=ClassInstall32_CopyFiles
    3.24 -
    3.25 -[ClassInstall32_AddReg]
    3.26 -HKR,,,0,%ClassName%
    3.27 -HKR,,Icon,,-5
    3.28 -HKR,,DeviceCharacteristics,0x10001,0x100     ;Use same security checks on relative opens
    3.29 -HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)" ;Allow generic all access to system and built-in Admin. 
    3.30 -
    3.31 -[ClassInstall32_CopyFiles]
    3.32 -
    3.33 -; ================= Device Install section =====================
    3.34 -
    3.35  [ControlFlags]
    3.36  ExcludeFromSelect=*
    3.37  
    3.38 -
    3.39  [Manufacturer]
    3.40  %JAMESHARPER%=JAMESHARPER,NTx86
    3.41  
    3.42 @@ -87,7 +70,6 @@ KmdfLibraryVersion = 1.0
    3.43  
    3.44  [Strings]
    3.45  JAMESHARPER = "James Harper"
    3.46 -ClassName = "System devices"
    3.47  XenPCI.SVCDESC = "Xen PCI Device Driver"
    3.48  XenPCI.DRVDESC = "Xen PCI Device Driver"
    3.49  DISK_NAME = "Xen PCI Device Driver Install Disk"
     4.1 --- a/target/xenvbd.inf	Mon Nov 19 17:42:06 2007 +1100
     4.2 +++ b/target/xenvbd.inf	Fri Nov 23 10:24:38 2007 +1100
     4.3 @@ -1,33 +1,18 @@
     4.4  [Version]
     4.5  Signature="$WINDOWS NT$"
     4.6  Class=SCSIAdapter
     4.7 -ClassGuid={B968331F-9539-47d0-855E-66CB6AA613E2}
     4.8 +ClassGuid={4D36E97B-E325-11CE-BFC1-08002BE10318}
     4.9  Provider=%JAMESHARPER%
    4.10 -DriverVer=11/19/2007,1.0.1.332
    4.11 +DriverVer=11/23/2007,0.3.0.32
    4.12  
    4.13  [DestinationDirs]
    4.14  DefaultDestDir = 12
    4.15  ClassInstall32_CopyFiles=11
    4.16  CoInstaller_CopyFiles = 11
    4.17  
    4.18 -; ================= Class section =====================
    4.19 -
    4.20 -[ClassInstall32]
    4.21 -Addreg=ClassInstall32_AddReg
    4.22 -CopyFiles=ClassInstall32_CopyFiles
    4.23 -
    4.24 -[ClassInstall32_AddReg]
    4.25 -HKR,,,0,%ClassName%
    4.26 -HKR,,Icon,,-5
    4.27 -HKR,,DeviceCharacteristics,0x10001,0x100
    4.28 -HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)"
    4.29 -
    4.30 -[ClassInstall32_CopyFiles]
    4.31 -
    4.32  [ControlFlags]
    4.33  ExcludeFromSelect=*
    4.34  
    4.35 -
    4.36  [Manufacturer]
    4.37  %JAMESHARPER%=JAMESHARPER,NTx86
    4.38  
    4.39 @@ -66,10 +51,8 @@ ServiceBinary  = %12%\xenvbd.sys
    4.40  AddReg = XenVbd_Service_AddReg
    4.41  
    4.42  [XenVbd_Service_AddReg]
    4.43 -; 5 = PciBus, 0 = Internal, 15 = PnpBus
    4.44  HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
    4.45  
    4.46 -
    4.47  [XenVbd_Inst.NT.CoInstallers]
    4.48  AddReg=CoInstaller_AddReg
    4.49  CopyFiles=CoInstaller_CopyFiles
    4.50 @@ -88,7 +71,6 @@ KmdfLibraryVersion = 1.0
    4.51  
    4.52  [Strings]
    4.53  JAMESHARPER = "James Harper"
    4.54 -ClassName = "SCSI Adapters"
    4.55  XenVbd.SVCDESC = "Xen Block Device Driver"
    4.56  XenVbd.DRVDESC = "Xen Block Device Driver"
    4.57  DISK_NAME = "Xen Block Device Driver Install Disk"
     5.1 --- a/xenpci/xenbus.c	Mon Nov 19 17:42:06 2007 +1100
     5.2 +++ b/xenpci/xenbus.c	Fri Nov 23 10:24:38 2007 +1100
     5.3 @@ -281,7 +281,7 @@ xenbus_msg_reply(int type, xenbus_transa
     5.4  
     5.5    KeWaitForSingleObject(&req_info[id].WaitEvent, Executive, KernelMode, FALSE, NULL);
     5.6  
     5.7 -  KdPrint((__DRIVER_NAME "     wait complete\n"));
     5.8 +  //KdPrint((__DRIVER_NAME "     wait complete\n"));
     5.9  
    5.10    rep = req_info[id].Reply;
    5.11  //  BUG_ON(rep->req_id != id);
     6.1 --- a/xenvbd/xenvbd.c	Mon Nov 19 17:42:06 2007 +1100
     6.2 +++ b/xenvbd/xenvbd.c	Fri Nov 23 10:24:38 2007 +1100
     6.3 @@ -45,10 +45,16 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
     6.4  //XenVbd_DeviceResourceRequirementsQuery(WDFDEVICE Device, WDFIORESREQLIST IoResourceRequirementsList);
     6.5  static NTSTATUS
     6.6  XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEVICE Device, PIRP Irp);
     6.7 +static NTSTATUS
     6.8 +XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp);
     6.9  static VOID 
    6.10 -XenVbd_Child_IoDefault(WDFQUEUE  Queue, WDFREQUEST  Request);
    6.11 +XenVbd_Child_IoDefault(WDFQUEUE Queue, WDFREQUEST Request);
    6.12 +static VOID 
    6.13 +XenVbd_Child_IoReadWrite(WDFQUEUE Queue, WDFREQUEST Request, size_t Length);
    6.14  static VOID 
    6.15  XenVbd_Child_IoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, size_t OutputBufferLength, size_t InputBufferLength, ULONG IoControlCode);
    6.16 +static VOID 
    6.17 +XenVbd_Child_IoInternalDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, size_t OutputBufferLength, size_t InputBufferLength, ULONG IoControlCode);
    6.18  
    6.19  static VOID
    6.20  XenVbd_HotPlugHandler(char *Path, PVOID Data);
    6.21 @@ -199,7 +205,6 @@ XenVbd_AddDevice(
    6.22  
    6.23    Pdo = WdfFdoInitWdmGetPhysicalDevice(DeviceInit);
    6.24  
    6.25 -  //*** just changed ***
    6.26    //WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_BUS_EXTENDER);
    6.27    WDF_CHILD_LIST_CONFIG_INIT(&ChildListConfig, sizeof(XENVBD_DEVICE_IDENTIFICATION_DESCRIPTION), XenVbd_ChildListCreateDevice);
    6.28    WdfFdoInitSetDefaultChildListConfig(DeviceInit, &ChildListConfig, WDF_NO_OBJECT_ATTRIBUTES);
    6.29 @@ -345,6 +350,7 @@ XenVbd_D0EntryPostInterruptsEnabled(WDFD
    6.30    EnumeratedDevices = 0;
    6.31    KeInitializeEvent(&WaitDevicesEvent, SynchronizationEvent, FALSE);  
    6.32  
    6.33 +  // TODO: Should probably do this in an EvtChildListScanForChildren
    6.34    if (AutoEnumerate)
    6.35    {
    6.36      msg = XenBusInterface.List(XBT_NIL, "device/vbd", &VbdDevices);
    6.37 @@ -562,12 +568,15 @@ XenVbd_DpcThreadProc(WDFDPC Dpc)
    6.38          GntTblInterface.EndAccess(ChildDeviceData->shadow[rep->id].req.seg[j].gref);
    6.39        }
    6.40        BlockCount = (Srb->Cdb[7] << 8) | Srb->Cdb[8];
    6.41 -      if (Srb->Cdb[0] == SCSIOP_READ && ChildDeviceData->shadow[rep->id].Buf != NULL)
    6.42 +      if (ChildDeviceData->shadow[rep->id].Buf != NULL)
    6.43        {
    6.44 -        DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
    6.45 -        if (DataBuffer == NULL)
    6.46 -          KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe Failed in DpcThreadProc\n"));
    6.47 -        memcpy(DataBuffer, ChildDeviceData->shadow[rep->id].Buf, BlockCount * ChildDeviceData->BytesPerSector);
    6.48 +        if (Srb->Cdb[0] == SCSIOP_READ)
    6.49 +        {
    6.50 +          DataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, HighPagePriority);
    6.51 +          if (DataBuffer == NULL)
    6.52 +            KdPrint((__DRIVER_NAME "     MmGetSystemAddressForMdlSafe Failed in DpcThreadProc\n"));
    6.53 +          memcpy(DataBuffer, ChildDeviceData->shadow[rep->id].Buf, BlockCount * ChildDeviceData->BytesPerSector);
    6.54 +        }
    6.55          FreePages(ChildDeviceData->shadow[rep->id].Mdl);
    6.56        }
    6.57        Srb->SrbStatus = SRB_STATUS_SUCCESS;
    6.58 @@ -706,13 +715,33 @@ XenVbd_BackEndStateHandler(char *Path, P
    6.59  
    6.60      Description.DeviceData = DeviceData;
    6.61  
    6.62 +    RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
    6.63 +    RtlStringCbCatA(TmpPath, 128, "/device-type");
    6.64 +    XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    6.65 +    if (strcmp(Value, "disk") == 0)
    6.66 +    {
    6.67 +      KdPrint((__DRIVER_NAME "     DeviceType = Disk\n"));    
    6.68 +      DeviceData->DeviceType = XENVBD_DEVICETYPE_DISK;
    6.69 +    }
    6.70 +    else if (strcmp(Value, "cdrom") == 0)
    6.71 +    {
    6.72 +      KdPrint((__DRIVER_NAME "     DeviceType = CDROM\n"));    
    6.73 +      DeviceData->DeviceType = XENVBD_DEVICETYPE_CDROM;
    6.74 +    }
    6.75 +    else
    6.76 +    {
    6.77 +      KdPrint((__DRIVER_NAME "     DeviceType = %s (This probably won't work!)\n", Value));
    6.78 +    }
    6.79 +
    6.80      RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
    6.81 -    RtlStringCbCatA(TmpPath, 128, "/type"); // should probably check that this is 'phy'
    6.82 +    RtlStringCbCatA(TmpPath, 128, "/type"); // should probably check that this is 'phy' or 'file' or at least not ''
    6.83      XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    6.84 +    KdPrint((__DRIVER_NAME "     Backend Type = %s\n", Value));
    6.85  
    6.86      RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
    6.87      RtlStringCbCatA(TmpPath, 128, "/mode"); // should store this...
    6.88      XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
    6.89 +    KdPrint((__DRIVER_NAME "     Backend Mode = %s\n", Value));
    6.90  
    6.91      RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
    6.92      RtlStringCbCatA(TmpPath, 128, "/sector-size");
    6.93 @@ -738,6 +767,8 @@ XenVbd_BackEndStateHandler(char *Path, P
    6.94      DeviceData->Geometry.Cylinders.QuadPart = DeviceData->TotalSectors / DeviceData->Geometry.SectorsPerTrack / DeviceData->Geometry.TracksPerCylinder;
    6.95      KdPrint((__DRIVER_NAME "     Geometry C/H/S = %d/%d/%d\n", DeviceData->Geometry.Cylinders.LowPart, DeviceData->Geometry.TracksPerCylinder, DeviceData->Geometry.SectorsPerTrack));
    6.96  
    6.97 +    // if we detected something wrong, we should not enumarate the device and should instead initiate a close
    6.98 +
    6.99      status = WdfChildListAddOrUpdateChildDescriptionAsPresent(WdfFdoGetDefaultChildList(GlobalDevice), &Description.Header, NULL);
   6.100      if (!NT_SUCCESS(status))
   6.101      {
   6.102 @@ -861,43 +892,70 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
   6.103    WDF_DPC_CONFIG DpcConfig;
   6.104    WDF_OBJECT_ATTRIBUTES DpcObjectAttributes;
   6.105    WDF_DEVICE_STATE DeviceState;
   6.106 +  UCHAR ScsiMinors[1] = { IRP_MN_SCSI_CLASS };
   6.107  
   6.108    UNREFERENCED_PARAMETER(ChildList);
   6.109  
   6.110 -  //KdPrint((__DRIVER_NAME " --> ChildListCreateDevice\n"));
   6.111 +  KdPrint((__DRIVER_NAME " --> ChildListCreateDevice\n"));
   6.112  
   6.113    XenVbdIdentificationDesc = CONTAINING_RECORD(IdentificationDescription, XENVBD_DEVICE_IDENTIFICATION_DESCRIPTION, Header);
   6.114  
   6.115    ChildDeviceData = XenVbdIdentificationDesc->DeviceData;
   6.116  
   6.117 -  WdfDeviceInitSetDeviceType(ChildInit, FILE_DEVICE_MASS_STORAGE);
   6.118 -
   6.119    // Capabilities = CM_DEVCAP_UNIQUEID
   6.120    // Devnode Flages = DN_NEED_RESTART??? DN_DISABLEABLE???
   6.121  
   6.122 -  status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk&Ven_James&Prod_James&Rev_1.00\0");
   6.123 -  status = WdfPdoInitAssignDeviceID(ChildInit, &buffer);
   6.124 -
   6.125 -  status = RtlUnicodeStringPrintf(&buffer, L"%02d", ChildDeviceData->DeviceIndex);
   6.126 -  status = WdfPdoInitAssignInstanceID(ChildInit, &buffer);
   6.127 +  switch (ChildDeviceData->DeviceType)
   6.128 +  {
   6.129 +  case XENVBD_DEVICETYPE_DISK:
   6.130 +    WdfDeviceInitSetDeviceType(ChildInit, FILE_DEVICE_DISK);
   6.131  
   6.132 -  //status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk\0");
   6.133 -  //status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
   6.134 -  //status = RtlUnicodeStringPrintf(&buffer, L"XEN\\RAW\0");
   6.135 -  //status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
   6.136 -  status = RtlUnicodeStringPrintf(&buffer, L"GenDisk\0");
   6.137 -  status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
   6.138 -  status = WdfPdoInitAddHardwareID(ChildInit, &buffer);
   6.139 +    status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk\0");
   6.140 +    //status = RtlUnicodeStringPrintf(&buffer, L"XEN\\Disk&Ven_James&Prod_James&Rev_1.00\0");
   6.141 +    status = WdfPdoInitAssignDeviceID(ChildInit, &buffer);
   6.142  
   6.143 -  status = RtlUnicodeStringPrintf(&buffer, L"Xen PV Disk (%d)", ChildDeviceData->DeviceIndex);
   6.144 -  status = WdfPdoInitAddDeviceText(ChildInit, &buffer, &DeviceLocation, 0x409);
   6.145 +    status = RtlUnicodeStringPrintf(&buffer, L"%02d\0", ChildDeviceData->DeviceIndex);
   6.146 +    status = WdfPdoInitAssignInstanceID(ChildInit, &buffer);
   6.147 +
   6.148 +    status = RtlUnicodeStringPrintf(&buffer, L"GenDisk\0");
   6.149 +    status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
   6.150 +    status = WdfPdoInitAddHardwareID(ChildInit, &buffer);
   6.151 +
   6.152 +    status = RtlUnicodeStringPrintf(&buffer, L"Xen PV Disk (%d)", ChildDeviceData->DeviceIndex);
   6.153 +    status = WdfPdoInitAddDeviceText(ChildInit, &buffer, &DeviceLocation, 0x409);
   6.154 +    break;
   6.155 +  case XENVBD_DEVICETYPE_CDROM:
   6.156 +    WdfDeviceInitSetDeviceType(ChildInit, FILE_DEVICE_MASS_STORAGE);
   6.157 +    WdfDeviceInitSetCharacteristics(ChildInit, FILE_READ_ONLY_DEVICE|FILE_REMOVABLE_MEDIA, TRUE);
   6.158 +
   6.159 +    status = RtlUnicodeStringPrintf(&buffer, L"XEN\\CDROM\0");
   6.160 +    status = WdfPdoInitAssignDeviceID(ChildInit, &buffer);
   6.161 +
   6.162 +    status = RtlUnicodeStringPrintf(&buffer, L"%02d\0", ChildDeviceData->DeviceIndex);
   6.163 +    status = WdfPdoInitAssignInstanceID(ChildInit, &buffer);
   6.164 +
   6.165 +    status = RtlUnicodeStringPrintf(&buffer, L"GenCdRom\0");
   6.166 +    status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
   6.167 +    status = WdfPdoInitAddHardwareID(ChildInit, &buffer);
   6.168 +
   6.169 +    status = RtlUnicodeStringPrintf(&buffer, L"Xen PV CDROM (%d)\0", ChildDeviceData->DeviceIndex);
   6.170 +    status = WdfPdoInitAddDeviceText(ChildInit, &buffer, &DeviceLocation, 0x409);
   6.171 +    break;
   6.172 +  default:
   6.173 +    // wtf?
   6.174 +    break;
   6.175 +  }
   6.176  
   6.177    WdfPdoInitSetDefaultLocale(ChildInit, 0x409);
   6.178    
   6.179    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&PdoAttributes, PXENVBD_CHILD_DEVICE_DATA);
   6.180  
   6.181 +  //WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, ScsiMinors, 1);
   6.182    WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSCSI, IRP_MJ_SCSI, NULL, 0);
   6.183  
   6.184 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_QUERY_VOLUME_INFORMATION, NULL, 0);
   6.185 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpSomethingSomething, IRP_MJ_DEVICE_CHANGE, NULL, 0);
   6.186 +
   6.187    WdfDeviceInitSetIoType(ChildInit, WdfDeviceIoDirect);
   6.188  
   6.189    //WdfDeviceInitSetPowerNotPageable(ChildInit);
   6.190 @@ -908,17 +966,19 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
   6.191      KdPrint((__DRIVER_NAME "     WdfDeviceCreate status = %08X\n", status));
   6.192    }
   6.193  
   6.194 -  WDF_DEVICE_STATE_INIT(&DeviceState);
   6.195 -  DeviceState.NotDisableable = WdfTrue;
   6.196 -  WdfDeviceSetDeviceState(ChildDevice, &DeviceState);
   6.197 -  WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFilePaging, TRUE);
   6.198 -  WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFileHibernation, TRUE);
   6.199 -  WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFileDump, TRUE);
   6.200 -
   6.201 -  WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&IoQueueConfig, WdfIoQueueDispatchSequential);
   6.202 -  IoQueueConfig.EvtIoDefault = XenVbd_Child_IoDefault;
   6.203 -  IoQueueConfig.EvtIoDeviceControl = XenVbd_Child_IoDeviceControl;
   6.204 -
   6.205 +  switch (ChildDeviceData->DeviceType)
   6.206 +  {
   6.207 +  case XENVBD_DEVICETYPE_DISK:
   6.208 +    WDF_DEVICE_STATE_INIT(&DeviceState);
   6.209 +    DeviceState.NotDisableable = WdfTrue;
   6.210 +    WdfDeviceSetDeviceState(ChildDevice, &DeviceState);
   6.211 +    WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFilePaging, TRUE);
   6.212 +    WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFileHibernation, TRUE);
   6.213 +    WdfDeviceSetSpecialFileSupport(ChildDevice, WdfSpecialFileDump, TRUE);
   6.214 +    break;
   6.215 +  case XENVBD_DEVICETYPE_CDROM:
   6.216 +    break;
   6.217 +  }
   6.218    *GetChildDeviceData(ChildDevice) = ChildDeviceData;
   6.219  
   6.220    ChildDeviceData->FastPathUsed = 0;
   6.221 @@ -932,6 +992,14 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
   6.222    ChildDeviceData->IrpRemovedFromRing = 0;
   6.223    ChildDeviceData->IrpCompleted = 0;
   6.224  
   6.225 +  WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&IoQueueConfig, WdfIoQueueDispatchSequential);
   6.226 +  IoQueueConfig.AllowZeroLengthRequests = TRUE;
   6.227 +  //IoQueueConfig.EvtIoDefault = XenVbd_Child_IoDefault;
   6.228 +  //IoQueueConfig.EvtIoRead = XenVbd_Child_IoReadWrite;
   6.229 +  //IoQueueConfig.EvtIoWrite = XenVbd_Child_IoReadWrite;
   6.230 +  IoQueueConfig.EvtIoDeviceControl = XenVbd_Child_IoDeviceControl;
   6.231 +  //IoQueueConfig.EvtIoInternalDeviceControl = XenVbd_Child_IoInternalDeviceControl;
   6.232 +
   6.233    status = WdfIoQueueCreate(ChildDevice, &IoQueueConfig, WDF_NO_OBJECT_ATTRIBUTES, &ChildDeviceData->IoDefaultQueue);
   6.234    if(!NT_SUCCESS(status))
   6.235    {
   6.236 @@ -958,7 +1026,7 @@ XenVbd_ChildListCreateDevice(WDFCHILDLIS
   6.237    DpcObjectAttributes.ParentObject = ChildDevice;
   6.238    WdfDpcCreate(&DpcConfig, &DpcObjectAttributes, &ChildDeviceData->Dpc);
   6.239  
   6.240 -  //KdPrint((__DRIVER_NAME " <-- ChildListCreateDevice\n"));
   6.241 +  KdPrint((__DRIVER_NAME " <-- ChildListCreateDevice (status = %08x)\n", status));
   6.242  
   6.243    return status;
   6.244  }
   6.245 @@ -980,9 +1048,10 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
   6.246    int BlockCount;
   6.247    int sect_offset;
   6.248  
   6.249 -  //KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
   6.250 +  ChildDeviceData = *GetChildDeviceData(Device);
   6.251  
   6.252 -  ChildDeviceData = *GetChildDeviceData(Device);
   6.253 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.254 +    KdPrint((__DRIVER_NAME " --> PutIrpOnRing\n"));
   6.255  
   6.256    if (RING_FULL(&ChildDeviceData->Ring))
   6.257    {
   6.258 @@ -1030,11 +1099,11 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
   6.259      ChildDeviceData->SlowPathUsed++;
   6.260    }
   6.261  
   6.262 -  if (((ChildDeviceData->FastPathUsed + ChildDeviceData->SlowPathUsed) & 0x2FF) == 0)
   6.263 -  {
   6.264 -    KdPrint((__DRIVER_NAME "     Fast Path = %d, Slow Path = %d\n", ChildDeviceData->FastPathUsed, ChildDeviceData->SlowPathUsed));
   6.265 -    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));
   6.266 -  }
   6.267 +//  if (((ChildDeviceData->FastPathUsed + ChildDeviceData->SlowPathUsed) & 0x2FF) == 0)
   6.268 +//  {
   6.269 +//    KdPrint((__DRIVER_NAME "     Fast Path = %d, Slow Path = %d\n", ChildDeviceData->FastPathUsed, ChildDeviceData->SlowPathUsed));
   6.270 +//    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));
   6.271 +//  }
   6.272  
   6.273    sect_offset = MmGetMdlByteOffset(ChildDeviceData->shadow[req->id].Mdl) >> 9;
   6.274    for (i = 0, req->nr_segments = 0; i < BlockCount; req->nr_segments++)
   6.275 @@ -1057,7 +1126,9 @@ XenVbd_PutIrpOnRing(WDFDEVICE Device, PI
   6.276    ChildDeviceData->Ring.req_prod_pvt++;
   6.277  
   6.278    ChildDeviceData->IrpAddedToRing++;
   6.279 -  //KdPrint((__DRIVER_NAME " <-- PutIrpOnRing\n"));
   6.280 +
   6.281 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.282 +    KdPrint((__DRIVER_NAME " <-- PutIrpOnRing\n"));
   6.283  }
   6.284  
   6.285  static ULONG
   6.286 @@ -1068,6 +1139,8 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
   6.287    switch (PageCode)
   6.288    {
   6.289    case MODE_PAGE_RIGID_GEOMETRY:
   6.290 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.291 +    {
   6.292      KdPrint((__DRIVER_NAME "     MODE_PAGE_RIGID_GEOMETRY\n"));
   6.293      if (*Offset + sizeof(MODE_RIGID_GEOMETRY_PAGE) > BufferLength)
   6.294        return 1;
   6.295 @@ -1084,6 +1157,7 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
   6.296      ModeRigidGeometry->RoataionRate[0] = 0x05;
   6.297      ModeRigidGeometry->RoataionRate[0] = 0x39;
   6.298      *Offset += sizeof(MODE_RIGID_GEOMETRY_PAGE);
   6.299 +    }
   6.300      break;
   6.301    case MODE_PAGE_FAULT_REPORTING:
   6.302      break;
   6.303 @@ -1094,6 +1168,20 @@ XenVBD_FillModePage(PXENVBD_CHILD_DEVICE
   6.304  }
   6.305  
   6.306  static NTSTATUS
   6.307 +XenVbd_Child_PreprocessWdmIrpSomethingSomething(WDFDEVICE Device, PIRP Irp)
   6.308 +{
   6.309 +  NTSTATUS Status;
   6.310 +
   6.311 +  KdPrint((__DRIVER_NAME " --> XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   6.312 +
   6.313 +  Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   6.314 +
   6.315 +  KdPrint((__DRIVER_NAME " <-- XenVbd_Child_PreprocessWdmIrpSomethingSomething\n"));
   6.316 +
   6.317 +  return Status;
   6.318 +}
   6.319 +
   6.320 +static NTSTATUS
   6.321  XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEVICE Device, PIRP Irp)
   6.322  {
   6.323    char *DataBuffer;
   6.324 @@ -1108,9 +1196,12 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.325    //PUCHAR Ptr;
   6.326    ULONG i;
   6.327  
   6.328 -  //KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessSCSI\n"));
   6.329 +  ChildDeviceData = *GetChildDeviceData(Device);
   6.330  
   6.331 -  ChildDeviceData = *GetChildDeviceData(Device);
   6.332 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.333 +    KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessSCSI\n"));
   6.334 +
   6.335 +  //KdPrint((__DRIVER_NAME "     SCSI Minor = %02X\n", irpSp->MinorFunction));
   6.336  
   6.337    Srb = irpSp->Parameters.Scsi.Srb;
   6.338  
   6.339 @@ -1118,10 +1209,13 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.340    {
   6.341    case SRB_FUNCTION_EXECUTE_SCSI:
   6.342      cdb = (PCDB)Srb->Cdb;
   6.343 -    //KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   6.344 -    switch(cdb->CDB6GENERIC.OperationCode) { //Srb->Cdb[0]) {
   6.345 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.346 +      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   6.347 +    switch(cdb->CDB6GENERIC.OperationCode) //Srb->Cdb[0])
   6.348 +    {
   6.349      case SCSIOP_TEST_UNIT_READY:
   6.350 -      //KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   6.351 +      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.352 +        KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
   6.353        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   6.354        Srb->ScsiStatus = 0;
   6.355        status = STATUS_SUCCESS;
   6.356 @@ -1155,15 +1249,17 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.357        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   6.358        break;
   6.359      case SCSIOP_READ_CAPACITY:
   6.360 +      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.361 +        KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
   6.362        DataBuffer = Srb->DataBuffer;
   6.363        DataBuffer[0] = (unsigned char)(ChildDeviceData->TotalSectors >> 24) & 0xff;
   6.364        DataBuffer[1] = (unsigned char)(ChildDeviceData->TotalSectors >> 16) & 0xff;
   6.365        DataBuffer[2] = (unsigned char)(ChildDeviceData->TotalSectors >> 8) & 0xff;
   6.366        DataBuffer[3] = (unsigned char)(ChildDeviceData->TotalSectors >> 0) & 0xff;
   6.367 -      DataBuffer[4] = 0x00;
   6.368 -      DataBuffer[5] = 0x00;
   6.369 -      DataBuffer[6] = 0x02;
   6.370 -      DataBuffer[7] = 0x00;
   6.371 +      DataBuffer[4] = (unsigned char)(ChildDeviceData->BytesPerSector >> 24) & 0xff;
   6.372 +      DataBuffer[5] = (unsigned char)(ChildDeviceData->BytesPerSector >> 16) & 0xff;
   6.373 +      DataBuffer[6] = (unsigned char)(ChildDeviceData->BytesPerSector >> 8) & 0xff;
   6.374 +      DataBuffer[7] = (unsigned char)(ChildDeviceData->BytesPerSector >> 0) & 0xff;
   6.375        Srb->ScsiStatus = 0;
   6.376        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   6.377        status = STATUS_SUCCESS;
   6.378 @@ -1201,6 +1297,9 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.379        break;
   6.380      case SCSIOP_READ:
   6.381      case SCSIOP_WRITE:
   6.382 +      if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.383 +        KdPrint((__DRIVER_NAME "     Command = READ/WRITE\n"));
   6.384 +
   6.385        IoMarkIrpPending(Irp);
   6.386  
   6.387        //KdPrint((__DRIVER_NAME "     Irp Acquiring Lock\n"));
   6.388 @@ -1232,17 +1331,18 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.389        status = STATUS_PENDING;
   6.390        break;
   6.391      default:
   6.392 +      KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   6.393        status = STATUS_NOT_IMPLEMENTED;
   6.394        Irp->IoStatus.Status = status;
   6.395        Irp->IoStatus.Information = 0;
   6.396        IoCompleteRequest(Irp, IO_NO_INCREMENT);
   6.397 -      KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   6.398        break;
   6.399      }
   6.400      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   6.401      break;
   6.402    case SRB_FUNCTION_CLAIM_DEVICE:
   6.403 -    //KdPrint((__DRIVER_NAME "     SRB_FUNCTION_CLAIM_DEVICE\n"));
   6.404 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.405 +      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_CLAIM_DEVICE\n"));
   6.406      ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
   6.407      Srb->DataBuffer = WdfDeviceWdmGetDeviceObject(Device);
   6.408      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   6.409 @@ -1252,7 +1352,8 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.410      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   6.411      break;
   6.412    case SRB_FUNCTION_IO_CONTROL:
   6.413 -    //KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
   6.414 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.415 +      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
   6.416      //status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   6.417      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   6.418      status = STATUS_NOT_IMPLEMENTED;
   6.419 @@ -1261,6 +1362,8 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.420      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   6.421      break;
   6.422    case SRB_FUNCTION_FLUSH:
   6.423 +    if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.424 +      KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
   6.425      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   6.426      status = STATUS_SUCCESS;
   6.427      Irp->IoStatus.Status = status;
   6.428 @@ -1273,7 +1376,8 @@ XenVbd_Child_PreprocessWdmIrpSCSI(WDFDEV
   6.429      break;
   6.430    }
   6.431  
   6.432 -  //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));
   6.433 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.434 +    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));
   6.435    //KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessSCSI\n"));
   6.436  
   6.437    return status;
   6.438 @@ -1292,6 +1396,18 @@ XenVbd_Child_IoDefault(WDFQUEUE  Queue, 
   6.439  }
   6.440  
   6.441  static VOID 
   6.442 +XenVbd_Child_IoReadWrite(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)
   6.443 +{
   6.444 +  UNREFERENCED_PARAMETER(Queue);
   6.445 +
   6.446 +  KdPrint((__DRIVER_NAME " --> IoReadWrite\n"));
   6.447 +
   6.448 +  WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
   6.449 +
   6.450 +  KdPrint((__DRIVER_NAME " <-- IoReadWrite\n"));
   6.451 +}
   6.452 +
   6.453 +static VOID 
   6.454  XenVbd_Child_IoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, size_t OutputBufferLength, size_t InputBufferLength, ULONG IoControlCode)
   6.455  {
   6.456    WDFDEVICE Device;
   6.457 @@ -1316,7 +1432,8 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   6.458  
   6.459    ChildDeviceData = *GetChildDeviceData(Device);
   6.460  
   6.461 -  //KdPrint((__DRIVER_NAME " --> IoDeviceControl\n"));
   6.462 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.463 +    KdPrint((__DRIVER_NAME " --> IoDeviceControl\n"));
   6.464    //KdPrint((__DRIVER_NAME "     InputBufferLength = %d\n", InputBufferLength));
   6.465    //KdPrint((__DRIVER_NAME "     OutputBufferLength = %d\n", OutputBufferLength));
   6.466  
   6.467 @@ -1325,7 +1442,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   6.468    switch (IoControlCode)
   6.469    {
   6.470    case IOCTL_STORAGE_QUERY_PROPERTY:
   6.471 -    //KdPrint((__DRIVER_NAME "     IOCTL_STORAGE_QUERY_PROPERTY\n"));    
   6.472 +    KdPrint((__DRIVER_NAME "     IOCTL_STORAGE_QUERY_PROPERTY\n"));    
   6.473      Spq = (PSTORAGE_PROPERTY_QUERY)Irp->AssociatedIrp.SystemBuffer;
   6.474      if (Spq->PropertyId == StorageAdapterProperty && Spq->QueryType == PropertyStandardQuery)
   6.475      {
   6.476 @@ -1370,9 +1487,22 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   6.477          if (OutputBufferLength >= Sdd->Size)
   6.478          {
   6.479            Information = Sdd->Size;
   6.480 -          Sdd->DeviceType = 0x00;
   6.481 -          Sdd->DeviceTypeModifier = 0x00;
   6.482 -          Sdd->RemovableMedia = FALSE;
   6.483 +          switch (ChildDeviceData->DeviceType)
   6.484 +          { 
   6.485 +          case XENVBD_DEVICETYPE_DISK:
   6.486 +            Sdd->DeviceType = DIRECT_ACCESS_DEVICE;
   6.487 +            Sdd->DeviceTypeModifier = 0x00;
   6.488 +            Sdd->RemovableMedia = FALSE;
   6.489 +            break;
   6.490 +          case XENVBD_DEVICETYPE_CDROM:
   6.491 +            Sdd->DeviceType = READ_ONLY_DIRECT_ACCESS_DEVICE;
   6.492 +            Sdd->DeviceTypeModifier = 0x00;
   6.493 +            Sdd->RemovableMedia = TRUE;
   6.494 +            break;
   6.495 +          default:
   6.496 +            // wtf
   6.497 +            break;
   6.498 +          }
   6.499            Sdd->CommandQueueing = FALSE;
   6.500            StructEndOffset = Sdd->RawDeviceProperties - (PUCHAR)Sdd;
   6.501            Sdd->VendorIdOffset = StructEndOffset + 0;
   6.502 @@ -1473,7 +1603,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   6.503      WdfRequestComplete(Request, STATUS_SUCCESS);
   6.504      break;
   6.505    case IOCTL_SCSI_GET_ADDRESS:
   6.506 -    //KdPrint((__DRIVER_NAME "     IOCTL_SCSI_GET_ADDRESS\n"));
   6.507 +    KdPrint((__DRIVER_NAME "     IOCTL_SCSI_GET_ADDRESS\n"));
   6.508      Sa = (PSCSI_ADDRESS)Irp->AssociatedIrp.SystemBuffer;
   6.509      Sa->Length = sizeof(SCSI_ADDRESS);
   6.510      Sa->PortNumber = 0;
   6.511 @@ -1483,6 +1613,7 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   6.512      WdfRequestComplete(Request, STATUS_SUCCESS);
   6.513      break;
   6.514    case FT_BALANCED_READ_MODE: // just pretend we know what this is...
   6.515 +    KdPrint((__DRIVER_NAME "     FT_BALANCED_READ_MODE\n"));
   6.516      WdfRequestComplete(Request, STATUS_SUCCESS);
   6.517      break;
   6.518    default:
   6.519 @@ -1491,5 +1622,13 @@ XenVbd_Child_IoDeviceControl(WDFQUEUE Qu
   6.520      break;
   6.521    }
   6.522  
   6.523 -  //KdPrint((__DRIVER_NAME " <-- IoDeviceControl\n"));
   6.524 +  if (ChildDeviceData->DeviceType == XENVBD_DEVICETYPE_CDROM)
   6.525 +    KdPrint((__DRIVER_NAME " <-- IoDeviceControl\n"));
   6.526  }
   6.527 +
   6.528 +static VOID 
   6.529 +XenVbd_Child_IoInternalDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, size_t OutputBufferLength, size_t InputBufferLength, ULONG IoControlCode)
   6.530 +{
   6.531 +  KdPrint((__DRIVER_NAME " --> IoInternalDeviceControl\n"));
   6.532 +  KdPrint((__DRIVER_NAME " <-- IoInternalDeviceControl\n"));
   6.533 +}
     7.1 --- a/xenvbd/xenvbd.h	Mon Nov 19 17:42:06 2007 +1100
     7.2 +++ b/xenvbd/xenvbd.h	Fri Nov 23 10:24:38 2007 +1100
     7.3 @@ -55,6 +55,12 @@ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENVB
     7.4  extern XEN_IFACE_EVTCHN EvtChnInterface;
     7.5  extern XEN_IFACE_XENBUS XenBusInterface;
     7.6  
     7.7 +typedef enum {
     7.8 +  XENVBD_DEVICETYPE_UNKNOWN,
     7.9 +  XENVBD_DEVICETYPE_DISK,
    7.10 +  XENVBD_DEVICETYPE_CDROM
    7.11 +} XENVBD_DEVICETYPE;
    7.12 +
    7.13  struct {
    7.14    LIST_ENTRY Entry;
    7.15    KSPIN_LOCK Lock;
    7.16 @@ -80,6 +86,7 @@ struct {
    7.17    ULONG BytesPerSector;
    7.18    ULONGLONG TotalSectors;
    7.19    DISK_GEOMETRY Geometry;
    7.20 +  XENVBD_DEVICETYPE DeviceType;
    7.21  
    7.22    int IrpAddedToList;
    7.23    int IrpRemovedFromList;