win-pvdrivers

changeset 28:28803c117324

trying to go back to scsi class driver
author James Harper <james.harper@bendigoit.com.au>
date Sat Dec 01 23:46:59 2007 +1100 (2007-12-01)
parents 37c64fba5fc7
children 7fc983eddda8
files .hgtags common/include/evtchn_public.h target/xenpci.inf target/xenvbdbus.inf target/xenvbddev.inf xenpci/evtchn.c xenpci/xenpci.c xenpci/xenpci.h xenvbdbus/makefile xenvbdbus/sources xenvbdbus/xenvbdbus.c xenvbdbus/xenvbdbus.h xenvbddev/makefile xenvbddev/sources xenvbddev/xenvbddev.c xenvbddev/xenvbddev.h
line diff
     1.1 --- a/.hgtags	Sat Dec 01 23:33:51 2007 +1100
     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 --- a/common/include/evtchn_public.h	Sat Dec 01 23:33:51 2007 +1100
     2.2 +++ b/common/include/evtchn_public.h	Sat Dec 01 23:46:59 2007 +1100
     2.3 @@ -42,7 +42,6 @@ typedef struct _XENBUS_IFACE_EVTCHN {
     2.4    INTERFACE InterfaceHeader;
     2.5  
     2.6    PXEN_EVTCHN_BIND Bind;
     2.7 -  PXEN_EVTCHN_BIND BindDpc;
     2.8    PXEN_EVTCHN_UNBIND Unbind;
     2.9    PXEN_EVTCHN_MASK Mask;
    2.10    PXEN_EVTCHN_UNMASK Unmask;
     3.1 --- a/target/xenpci.inf	Sat Dec 01 23:33:51 2007 +1100
     3.2 +++ b/target/xenpci.inf	Sat Dec 01 23:46:59 2007 +1100
     3.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     3.4  Class=System
     3.5  ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
     3.6  Provider=%JAMESHARPER%
     3.7 -DriverVer=12/01/2007,0.3.0.13
     3.8 +DriverVer=11/20/2007,0.3.0.2
     3.9  
    3.10  [DestinationDirs]
    3.11  DefaultDestDir = 12
     4.1 --- a/target/xenvbdbus.inf	Sat Dec 01 23:33:51 2007 +1100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,75 +0,0 @@
     4.4 -[Version]
     4.5 -Signature="$WINDOWS NT$"
     4.6 -Class=System
     4.7 -ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
     4.8 -Provider=%JAMESHARPER%
     4.9 -DriverVer=12/01/2007,0.3.0.116
    4.10 -
    4.11 -[DestinationDirs]
    4.12 -DefaultDestDir = 12
    4.13 -CoInstaller_CopyFiles = 11
    4.14 -
    4.15 -[ControlFlags]
    4.16 -ExcludeFromSelect=*
    4.17 -
    4.18 -[Manufacturer]
    4.19 -%JAMESHARPER%=JAMESHARPER,NTx86
    4.20 -
    4.21 -[JAMESHARPER]
    4.22 -%XenVbdBus.DRVDESC%=XenVbdBus_Inst, XEN\VBD
    4.23 -
    4.24 -[JAMESHARPER.NTx86]
    4.25 -%XenVbdBus.DRVDESC%=XenVbdBus_Inst, XEN\VBD
    4.26 -
    4.27 -[XenVbdBus_Inst.NT]
    4.28 -CopyFiles=XenVbdBus.CopyFiles
    4.29 -
    4.30 -[XenVbdBus.CopyFiles]
    4.31 -xenvbdbus.sys
    4.32 -
    4.33 -[SourceDisksFiles]
    4.34 -xenvbdbus.sys=1
    4.35 -WdfCoinstaller01005.dll=1,,
    4.36 -
    4.37 -[SourceDisksNames.x86]
    4.38 -1=%DISK_NAME%,,,\i386
    4.39 -
    4.40 -[XenVbdBus_Inst.Services]
    4.41 -AddService=XenVbdBus,2,XenVbdBus_Service 
    4.42 -
    4.43 -[XenVbdBus_Inst.NT.Services]
    4.44 -AddService=XenVbdBus,2,XenVbdBus_Service 
    4.45 -
    4.46 -[XenVbdBus_Service]
    4.47 -DisplayName    = %XenVbdBus.SVCDESC%                            
    4.48 -ServiceType    = 1
    4.49 -StartType      = 0
    4.50 -ErrorControl   = 1
    4.51 -LoadOrderGroup = WdfLoadGroup
    4.52 -ServiceBinary  = %12%\xenvbdbus.sys                            
    4.53 -AddReg = XenVbdBus_Service_AddReg
    4.54 -
    4.55 -[XenVbdBus_Service_AddReg]
    4.56 -HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
    4.57 -
    4.58 -[XenVbdBus_Inst.NT.CoInstallers]
    4.59 -AddReg=CoInstaller_AddReg
    4.60 -CopyFiles=CoInstaller_CopyFiles
    4.61 -
    4.62 -[CoInstaller_CopyFiles]
    4.63 -WdfCoinstaller01005.dll,,,2
    4.64 -
    4.65 -[CoInstaller_AddReg]
    4.66 -HKR,,CoInstallers32,0x00010000, "WdfCoinstaller01005.dll,WdfCoInstaller"
    4.67 -
    4.68 -[XenVbdBus_Inst.NT.Wdf]
    4.69 -KmdfService = xenvbdbus, xenvbdbus_wdfsect
    4.70 -
    4.71 -[xenvbdbus_wdfsect]
    4.72 -KmdfLibraryVersion = 1.0
    4.73 -
    4.74 -[Strings]
    4.75 -JAMESHARPER = "James Harper"
    4.76 -XenVbdBus.SVCDESC = "Xen Block Device Bus Driver"
    4.77 -XenVbdBus.DRVDESC = "Xen Block Device Bus Driver"
    4.78 -DISK_NAME = "Xen Block Device Bus Driver Install Disk"
     5.1 --- a/target/xenvbddev.inf	Sat Dec 01 23:33:51 2007 +1100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,76 +0,0 @@
     5.4 -[Version]
     5.5 -Signature="$WINDOWS NT$"
     5.6 -Class=SCSIAdapter
     5.7 -ClassGuid={4D36E97B-E325-11CE-BFC1-08002BE10318}
     5.8 -Provider=%JAMESHARPER%
     5.9 -DriverVer=12/01/2007,0.3.0.70
    5.10 -
    5.11 -[DestinationDirs]
    5.12 -DefaultDestDir = 12
    5.13 -CoInstaller_CopyFiles = 11
    5.14 -
    5.15 -[ControlFlags]
    5.16 -ExcludeFromSelect=*
    5.17 -
    5.18 -[Manufacturer]
    5.19 -%JAMESHARPER%=JAMESHARPER,NTx86
    5.20 -
    5.21 -[JAMESHARPER]
    5.22 -%XenVbdDev.DRVDESC%=XenVbdDev_Inst, XEN\VBDDEV
    5.23 -
    5.24 -[JAMESHARPER.NTx86]
    5.25 -%XenVbdDev.DRVDESC%=XenVbdDev_Inst, XEN\VBDDEV
    5.26 -
    5.27 -[XenVbdDev_Inst.NT]
    5.28 -CopyFiles=XenVbdDev.CopyFiles
    5.29 -
    5.30 -[XenVbdDev.CopyFiles]
    5.31 -XenVbdDev.sys
    5.32 -
    5.33 -[SourceDisksFiles]
    5.34 -XenVbdDev.sys=1
    5.35 -WdfCoinstaller01005.dll=1,,
    5.36 -
    5.37 -[SourceDisksNames.x86]
    5.38 -1 = %DISK_NAME%,,,\i386
    5.39 -
    5.40 -[XenVbdDev_Inst.Services]
    5.41 -AddService=XenVbdDev,2,XenVbdDev_Service 
    5.42 -
    5.43 -[XenVbdDev_Inst.NT.Services]
    5.44 -AddService=XenVbdDev,2,XenVbdDev_Service 
    5.45 -
    5.46 -[XenVbdDev_Service]
    5.47 -DisplayName    = %XenVbdDev.SVCDESC%                            
    5.48 -ServiceType    = 1
    5.49 -StartType      = 0
    5.50 -ErrorControl   = 1
    5.51 -LoadOrderGroup = WdfLoadGroup
    5.52 -ServiceBinary  = %12%\XenVbdDev.sys                            
    5.53 -AddReg = XenVbdDev_Service_AddReg
    5.54 -
    5.55 -[XenVbdDev_Service_AddReg]
    5.56 -;HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
    5.57 -HKR,"Parameters\PnpInterface", "0", 0x00010001, 0x00000001
    5.58 -
    5.59 -[XenVbdBus_Inst.NT.CoInstallers]
    5.60 -AddReg=CoInstaller_AddReg
    5.61 -CopyFiles=CoInstaller_CopyFiles
    5.62 -
    5.63 -[CoInstaller_CopyFiles]
    5.64 -WdfCoinstaller01005.dll,,,2
    5.65 -
    5.66 -[CoInstaller_AddReg]
    5.67 -HKR,,CoInstallers32,0x00010000, "WdfCoinstaller01005.dll,WdfCoInstaller"
    5.68 -
    5.69 -[XenVbdBus_Inst.NT.Wdf]
    5.70 -KmdfService = xenvbdbus, xenvbdbus_wdfsect
    5.71 -
    5.72 -[xenvbdbus_wdfsect]
    5.73 -KmdfLibraryVersion = 1.0
    5.74 -
    5.75 -[Strings]
    5.76 -JAMESHARPER = "James Harper"
    5.77 -XenVbdDev.SVCDESC = "Xen Block Device Driver"
    5.78 -XenVbdDev.DRVDESC = "Xen Block Device Driver"
    5.79 -DISK_NAME = "Xen Block Device Driver Install Disk"
     6.1 --- a/xenpci/evtchn.c	Sat Dec 01 23:33:51 2007 +1100
     6.2 +++ b/xenpci/evtchn.c	Sat Dec 01 23:46:59 2007 +1100
     6.3 @@ -25,8 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  typedef struct _ev_action_t {
     6.5    PKSERVICE_ROUTINE ServiceRoutine;
     6.6    PVOID ServiceContext;
     6.7 -  BOOLEAN DpcFlag;
     6.8 -  WDFDPC Dpc;
     6.9    ULONG Count;
    6.10  } ev_action_t;
    6.11  
    6.12 @@ -34,21 +32,6 @@ static ev_action_t ev_actions[NR_EVENTS]
    6.13  
    6.14  static unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
    6.15  
    6.16 -typedef struct {
    6.17 -  ev_action_t *Action;
    6.18 -} EVTCHN_DEVICE_DATA, *PEVTCHN_DEVICE_DATA;
    6.19 -
    6.20 -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(EVTCHN_DEVICE_DATA, GetEvtChnDeviceData);
    6.21 -
    6.22 -static VOID
    6.23 -EvtChn_DpcBounce(WDFDPC Dpc)
    6.24 -{
    6.25 -  ev_action_t *Action;
    6.26 -
    6.27 -  Action = GetEvtChnDeviceData(Dpc)->Action;
    6.28 -  Action->ServiceRoutine(NULL, Action->ServiceContext);
    6.29 -}
    6.30 -
    6.31  BOOLEAN
    6.32  EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID)
    6.33  {
    6.34 @@ -86,14 +69,7 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    6.35        else
    6.36        {
    6.37          //KdPrint((__DRIVER_NAME "     Calling Handler for port %d\n", port));
    6.38 -        if (ev_action->DpcFlag)
    6.39 -        {
    6.40 -          WdfDpcEnqueue(ev_action->Dpc);
    6.41 -        }
    6.42 -        else
    6.43 -        {
    6.44 -          ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    6.45 -        }
    6.46 +        ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    6.47        }
    6.48        _interlockedbittestandreset((volatile LONG *)&shared_info_area->evtchn_pending[0], port);
    6.49      }
    6.50 @@ -134,7 +110,6 @@ EvtChn_Bind(evtchn_port_t Port, PKSERVIC
    6.51    }
    6.52  
    6.53    ev_actions[Port].ServiceContext = ServiceContext;
    6.54 -  ev_actions[Port].DpcFlag = FALSE;
    6.55    KeMemoryBarrier();
    6.56    ev_actions[Port].ServiceRoutine = ServiceRoutine;
    6.57  
    6.58 @@ -146,46 +121,6 @@ EvtChn_Bind(evtchn_port_t Port, PKSERVIC
    6.59  }
    6.60  
    6.61  NTSTATUS
    6.62 -EvtChn_BindDpc(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    6.63 -{
    6.64 -  WDF_DPC_CONFIG DpcConfig;
    6.65 -  WDF_OBJECT_ATTRIBUTES DpcObjectAttributes;
    6.66 -
    6.67 -  KdPrint((__DRIVER_NAME " --> EvtChn_BindDpc\n"));
    6.68 -
    6.69 -  if(ev_actions[Port].ServiceRoutine != NULL)
    6.70 -  {
    6.71 -    KdPrint((__DRIVER_NAME " Handler for port %d already registered, replacing\n", Port));
    6.72 -    ev_actions[Port].ServiceRoutine = NULL;
    6.73 -    KeMemoryBarrier(); // make sure we don't call the old Service Routine with the new data...
    6.74 -  }
    6.75 -
    6.76 -  ev_actions[Port].ServiceContext = ServiceContext;
    6.77 -  ev_actions[Port].DpcFlag = TRUE;
    6.78 -
    6.79 -KdPrint((__DRIVER_NAME "     A\n"));
    6.80 -  WDF_DPC_CONFIG_INIT(&DpcConfig, EvtChn_DpcBounce);
    6.81 -KdPrint((__DRIVER_NAME "     B\n"));
    6.82 -  WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&DpcObjectAttributes, EVTCHN_DEVICE_DATA);
    6.83 -KdPrint((__DRIVER_NAME "     C\n"));
    6.84 -  DpcObjectAttributes.ParentObject = GlobalDevice;
    6.85 -KdPrint((__DRIVER_NAME "     D\n"));
    6.86 -  WdfDpcCreate(&DpcConfig, &DpcObjectAttributes, &ev_actions[Port].Dpc);
    6.87 -KdPrint((__DRIVER_NAME "     E\n"));
    6.88 -KdPrint((__DRIVER_NAME "     (%08x)\n", GetEvtChnDeviceData(ev_actions[Port].Dpc)));
    6.89 -  GetEvtChnDeviceData(ev_actions[Port].Dpc)->Action = &ev_actions[Port];
    6.90 -
    6.91 -  KeMemoryBarrier(); // make sure that the new service routine is only called once the context is set up
    6.92 -  ev_actions[Port].ServiceRoutine = ServiceRoutine;
    6.93 -
    6.94 -  EvtChn_Unmask(Port);
    6.95 -
    6.96 -  KdPrint((__DRIVER_NAME " <-- EvtChn_BindDpc\n"));
    6.97 -
    6.98 -  return STATUS_SUCCESS;
    6.99 -}
   6.100 -
   6.101 -NTSTATUS
   6.102  EvtChn_Unbind(evtchn_port_t Port)
   6.103  {
   6.104    //KdPrint((__DRIVER_NAME " --> EvtChn_UnBind\n"));
     7.1 --- a/xenpci/xenpci.c	Sat Dec 01 23:33:51 2007 +1100
     7.2 +++ b/xenpci/xenpci.c	Sat Dec 01 23:46:59 2007 +1100
     7.3 @@ -73,7 +73,7 @@ static ULONG irqNumber = 0;
     7.4  
     7.5  static BOOLEAN AutoEnumerate;
     7.6  
     7.7 -WDFDEVICE GlobalDevice;
     7.8 +static WDFDEVICE Device;
     7.9  
    7.10  NTSTATUS
    7.11  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    7.12 @@ -355,18 +355,18 @@ XenPCI_AddDevice(
    7.13    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, XENPCI_DEVICE_DATA);
    7.14  
    7.15    /*create a device instance.*/
    7.16 -  status = WdfDeviceCreate(&DeviceInit, &attributes, &GlobalDevice);  
    7.17 +  status = WdfDeviceCreate(&DeviceInit, &attributes, &Device);  
    7.18    if(!NT_SUCCESS(status))
    7.19    {
    7.20      KdPrint((__DRIVER_NAME "     WdfDeviceCreate failed with status 0x%08x\n", status));
    7.21      return status;
    7.22    }
    7.23  
    7.24 -  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFilePaging, TRUE);
    7.25 -  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFileHibernation, TRUE);
    7.26 -  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFileDump, TRUE);
    7.27 +  WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFilePaging, TRUE);
    7.28 +  WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFileHibernation, TRUE);
    7.29 +  WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFileDump, TRUE);
    7.30  
    7.31 -  status = WdfFdoQueryForInterface(GlobalDevice, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE) &BusInterface, sizeof(BUS_INTERFACE_STANDARD), 1, NULL);
    7.32 +  status = WdfFdoQueryForInterface(Device, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE) &BusInterface, sizeof(BUS_INTERFACE_STANDARD), 1, NULL);
    7.33    if(!NT_SUCCESS(status))
    7.34    {
    7.35      KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (BusInterface) failed with status 0x%08x\n", status));
    7.36 @@ -379,7 +379,7 @@ XenPCI_AddDevice(
    7.37    busInfo.LegacyBusType = PNPBus;
    7.38    busInfo.BusNumber = 0;
    7.39  
    7.40 -  WdfDeviceSetBusInformationForChildren(GlobalDevice, &busInfo);
    7.41 +  WdfDeviceSetBusInformationForChildren(Device, &busInfo);
    7.42  
    7.43    /*create the default IO queue. this one will 
    7.44    be used for all requests*/
    7.45 @@ -387,7 +387,7 @@ XenPCI_AddDevice(
    7.46    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
    7.47                                  WdfIoQueueDispatchSequential);
    7.48    ioQConfig.EvtIoDefault = XenPCI_IoDefault;
    7.49 -  status = WdfIoQueueCreate(GlobalDevice, &ioQConfig,
    7.50 +  status = WdfIoQueueCreate(Device, &ioQConfig,
    7.51                              WDF_NO_OBJECT_ATTRIBUTES,
    7.52                              &devData->IoDefaultQueue);
    7.53    if(!NT_SUCCESS(status))
    7.54 @@ -397,7 +397,7 @@ XenPCI_AddDevice(
    7.55    }
    7.56  */
    7.57  /*
    7.58 -  status = WdfDeviceCreateDeviceInterface(GlobalDevice, &GUID_INTERFACE_XENPCI, NULL);
    7.59 +  status = WdfDeviceCreateDeviceInterface(Device, &GUID_INTERFACE_XENPCI, NULL);
    7.60    if(!NT_SUCCESS(status))
    7.61    {
    7.62      KdPrint((__DRIVER_NAME "WdfDeviceCreateDeviceInterface failed with status 0x%08x\n", status));
    7.63 @@ -408,8 +408,7 @@ XenPCI_AddDevice(
    7.64    WDF_INTERRUPT_CONFIG_INIT(&interruptConfig, EvtChn_Interrupt, NULL); //EvtChn_InterruptDpc);
    7.65    interruptConfig.EvtInterruptEnable = XenPCI_InterruptEnable;
    7.66    interruptConfig.EvtInterruptDisable = XenPCI_InterruptDisable;
    7.67 -  interruptConfig.ShareVector = WdfTrue;
    7.68 -  status = WdfInterruptCreate(GlobalDevice, &interruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &XenInterrupt);
    7.69 +  status = WdfInterruptCreate(Device, &interruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &XenInterrupt);
    7.70    if (!NT_SUCCESS (status))
    7.71    {
    7.72      KdPrint((__DRIVER_NAME "WdfInterruptCreate failed 0x%08x\n", status));
    7.73 @@ -721,7 +720,6 @@ XenPCI_ChildListCreateDevice(WDFCHILDLIS
    7.74    EvtChnInterface.InterfaceHeader.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
    7.75    EvtChnInterface.InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
    7.76    EvtChnInterface.Bind = EvtChn_Bind;
    7.77 -  EvtChnInterface.BindDpc = EvtChn_BindDpc;
    7.78    EvtChnInterface.Unbind = EvtChn_Unbind;
    7.79    EvtChnInterface.Mask = EvtChn_Mask;
    7.80    EvtChnInterface.Unmask = EvtChn_Unmask;
    7.81 @@ -807,7 +805,7 @@ XenPCI_XenBusWatchHandler(char *Path, PV
    7.82  
    7.83    //KdPrint((__DRIVER_NAME "     %s\n", Path));
    7.84  
    7.85 -  ChildList = WdfFdoGetDefaultChildList(GlobalDevice);
    7.86 +  ChildList = WdfFdoGetDefaultChildList(Device);
    7.87  
    7.88    Bits = SplitString(Path, '/', 3, &Count);
    7.89    switch (Count)
     8.1 --- a/xenpci/xenpci.h	Sat Dec 01 23:33:51 2007 +1100
     8.2 +++ b/xenpci/xenpci.h	Sat Dec 01 23:46:59 2007 +1100
     8.3 @@ -119,7 +119,6 @@ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPC
     8.4  VOID
     8.5  GntTbl_Init();
     8.6  
     8.7 -extern WDFDEVICE GlobalDevice;
     8.8  
     8.9  
    8.10  typedef unsigned long xenbus_transaction_t;
    8.11 @@ -193,8 +192,6 @@ EvtChn_Unmask(evtchn_port_t Port);
    8.12  NTSTATUS
    8.13  EvtChn_Bind(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    8.14  NTSTATUS
    8.15 -EvtChn_BindDpc(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    8.16 -NTSTATUS
    8.17  EvtChn_Unbind(evtchn_port_t Port);
    8.18  NTSTATUS
    8.19  EvtChn_Notify(evtchn_port_t Port);
     9.1 --- a/xenvbdbus/makefile	Sat Dec 01 23:33:51 2007 +1100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,1 +0,0 @@
     9.4 -!INCLUDE $(NTMAKEENV)\makefile.def
     9.5 \ No newline at end of file
    10.1 --- a/xenvbdbus/sources	Sat Dec 01 23:33:51 2007 +1100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,13 +0,0 @@
    10.4 -TARGETNAME=XENVBDBUS
    10.5 -TARGETTYPE=DRIVER
    10.6 -TARGETPATH=..\Target
    10.7 -
    10.8 -MSC_WARNING_LEVEL=/W4
    10.9 -
   10.10 -INCLUDES = ..\common\include;..\common\include\public
   10.11 -
   10.12 -NO_BINPLACE=1
   10.13 -KMDF_VERSION=1
   10.14 -TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib
   10.15 -
   10.16 -SOURCES=xenvbdbus.c
    11.1 --- a/xenvbdbus/xenvbdbus.c	Sat Dec 01 23:33:51 2007 +1100
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,944 +0,0 @@
    11.4 -#include "xenvbdbus.h"
    11.5 -#include <io/blkif.h>
    11.6 -#include <srb.h>
    11.7 -#include <scsi.h>
    11.8 -#include <ntddscsi.h>
    11.9 -#include <ntdddisk.h>
   11.10 -#include <stdlib.h>
   11.11 -#include <xen_public.h>
   11.12 -#include <io/xenbus.h>
   11.13 -#include <ntddft.h>
   11.14 -
   11.15 -#define wmb() KeMemoryBarrier()
   11.16 -#define mb() KeMemoryBarrier()
   11.17 -
   11.18 -DRIVER_INITIALIZE DriverEntry;
   11.19 -
   11.20 -/*static NTSTATUS
   11.21 -XenPCI_FilterAddResourceRequirements(WDFDEVICE Device, WDFIORESREQLIST RequirementsList);
   11.22 -static NTSTATUS
   11.23 -XenPCI_RemoveAddedResources(WDFDEVICE Device, WDFCMRESLIST ResourcesRaw, WDFCMRESLIST ResourcesTranslated);
   11.24 -*/
   11.25 -static NTSTATUS
   11.26 -XenVbdBus_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit);
   11.27 -static NTSTATUS
   11.28 -XenVbdBus_PrepareHardware(WDFDEVICE hDevice, WDFCMRESLIST Resources, WDFCMRESLIST ResourcesTranslated);
   11.29 -static NTSTATUS
   11.30 -XenVbdBus_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated);
   11.31 -static NTSTATUS
   11.32 -XenVbdBus_D0Entry(WDFDEVICE Device, WDF_POWER_DEVICE_STATE PreviousState);
   11.33 -static NTSTATUS
   11.34 -XenVbdBus_D0EntryPostInterruptsEnabled(WDFDEVICE Device, WDF_POWER_DEVICE_STATE PreviousState);
   11.35 -static NTSTATUS
   11.36 -XenVbdBus_D0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetState);
   11.37 -static NTSTATUS
   11.38 -XenVbdBus_DeviceUsageNotification(WDFDEVICE Device, WDF_SPECIAL_FILE_TYPE NotificationType, BOOLEAN IsInNotificationPath);
   11.39 -
   11.40 -static NTSTATUS
   11.41 -XenVbdBus_ChildListCreateDevice(WDFCHILDLIST ChildList, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription, PWDFDEVICE_INIT ChildInit);
   11.42 -static NTSTATUS
   11.43 -XenVbdBus_DeviceResourceRequirementsQuery(WDFDEVICE Device, WDFIORESREQLIST IoResourceRequirementsList);
   11.44 -
   11.45 -static VOID
   11.46 -XenVbdBus_HotPlugHandler(char *Path, PVOID Data);
   11.47 -
   11.48 -static NTSTATUS
   11.49 -XenVbd_Child_PreprocessWdmIrpPnp(WDFDEVICE Device, PIRP Irp);
   11.50 -
   11.51 -#ifdef ALLOC_PRAGMA
   11.52 -#pragma alloc_text (INIT, DriverEntry)
   11.53 -#pragma alloc_text (PAGE, XenVbdBus_AddDevice)
   11.54 -#endif
   11.55 -
   11.56 -LIST_ENTRY DeviceListHead;
   11.57 -XEN_IFACE_EVTCHN EvtChnInterface;
   11.58 -XEN_IFACE_XENBUS XenBusInterface;
   11.59 -XEN_IFACE_XEN XenInterface;
   11.60 -XEN_IFACE_GNTTBL GntTblInterface;
   11.61 -
   11.62 -static BOOLEAN AutoEnumerate;
   11.63 -
   11.64 -NTSTATUS
   11.65 -DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   11.66 -{
   11.67 -  WDF_DRIVER_CONFIG config;
   11.68 -  ULONG status;
   11.69 -  UNICODE_STRING RegKeyName;
   11.70 -  UNICODE_STRING RegValueName;
   11.71 -  HANDLE RegHandle;
   11.72 -  OBJECT_ATTRIBUTES RegObjectAttributes;
   11.73 -  char Buf[200];
   11.74 -  ULONG BufLen = 200;
   11.75 -  PKEY_VALUE_PARTIAL_INFORMATION KeyPartialValue;
   11.76 -  int State = 0;
   11.77 -  int StartPos = 0;
   11.78 -  WCHAR *SystemStartOptions;
   11.79 -  size_t SystemStartOptionsLen;
   11.80 -  size_t i;
   11.81 -
   11.82 -  KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
   11.83 -
   11.84 -  WDF_DRIVER_CONFIG_INIT(&config, XenVbdBus_AddDevice);
   11.85 -  status = WdfDriverCreate(
   11.86 -                      DriverObject,
   11.87 -                      RegistryPath,
   11.88 -                      WDF_NO_OBJECT_ATTRIBUTES,
   11.89 -                      &config,
   11.90 -                      WDF_NO_HANDLE);
   11.91 -  if(!NT_SUCCESS(status))
   11.92 -  {
   11.93 -    KdPrint((__DRIVER_NAME " WdfDriverCreate failed with status 0x%08x\n", status));
   11.94 -  }
   11.95 -
   11.96 -  RtlInitUnicodeString(&RegKeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
   11.97 -  InitializeObjectAttributes(&RegObjectAttributes, &RegKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL);
   11.98 -  status = ZwOpenKey(&RegHandle, KEY_READ, &RegObjectAttributes);
   11.99 -  if(!NT_SUCCESS(status))
  11.100 -  {
  11.101 -    KdPrint((__DRIVER_NAME "     ZwOpenKey returned %08x\n", status));
  11.102 -  }
  11.103 -
  11.104 -  RtlInitUnicodeString(&RegValueName, L"SystemStartOptions");
  11.105 -  status = ZwQueryValueKey(RegHandle, &RegValueName, KeyValuePartialInformation, Buf, BufLen, &BufLen);
  11.106 -  if(!NT_SUCCESS(status))
  11.107 -  {
  11.108 -    KdPrint((__DRIVER_NAME "     ZwQueryKeyValue returned %08x\n", status));
  11.109 -  }
  11.110 -  //KdPrint((__DRIVER_NAME "     BufLen = %d\n", BufLen));
  11.111 -  KeyPartialValue = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
  11.112 -  KdPrint((__DRIVER_NAME "     Buf = %ws\n", KeyPartialValue->Data));
  11.113 -  SystemStartOptions = (WCHAR *)KeyPartialValue->Data;
  11.114 -
  11.115 -  AutoEnumerate = FALSE;
  11.116 -
  11.117 -  RtlStringCbLengthW(SystemStartOptions, KeyPartialValue->DataLength, &SystemStartOptionsLen);
  11.118 -
  11.119 -  for (i = 0; i <= SystemStartOptionsLen/2; i++)
  11.120 -  {
  11.121 -    //KdPrint((__DRIVER_NAME "     pos = %d, state = %d, char = '%wc' (%d)\n", i, State, SystemStartOptions[i], SystemStartOptions[i]));
  11.122 -    
  11.123 -    switch (State)
  11.124 -    {
  11.125 -    case 0:
  11.126 -      if (SystemStartOptions[i] == L'G')
  11.127 -      {
  11.128 -        StartPos = i;
  11.129 -        State = 2;
  11.130 -      } else if (SystemStartOptions[i] != L' ')
  11.131 -      {
  11.132 -        State = 1;
  11.133 -      }
  11.134 -      break;
  11.135 -    case 1:
  11.136 -      if (SystemStartOptions[i] == L' ')
  11.137 -        State = 0;
  11.138 -      break;
  11.139 -    case 2:
  11.140 -      if (SystemStartOptions[i] == L'P')
  11.141 -        State = 3;
  11.142 -      else
  11.143 -        State = 0;
  11.144 -      break;
  11.145 -    case 3:
  11.146 -      if (SystemStartOptions[i] == L'L')
  11.147 -        State = 4;
  11.148 -      else
  11.149 -        State = 0;
  11.150 -      break;
  11.151 -    case 4:
  11.152 -      if (SystemStartOptions[i] == L'P')
  11.153 -        State = 5;
  11.154 -      else
  11.155 -        State = 0;
  11.156 -      break;
  11.157 -    case 5:
  11.158 -      if (SystemStartOptions[i] == L'V')
  11.159 -        State = 6;
  11.160 -      else
  11.161 -        State = 0;
  11.162 -      break;
  11.163 -    case 6:
  11.164 -      if (SystemStartOptions[i] == L' ' || SystemStartOptions[i] == 0)
  11.165 -        AutoEnumerate = TRUE;
  11.166 -      State = 0;
  11.167 -      break;
  11.168 -    }
  11.169 -  }
  11.170 -
  11.171 -  KdPrint((__DRIVER_NAME "     AutoEnumerate = %d\n", AutoEnumerate));
  11.172 -
  11.173 -  KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
  11.174 -
  11.175 -  return status;
  11.176 -}
  11.177 -
  11.178 -DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
  11.179 -
  11.180 -static WDFDEVICE GlobalDevice;
  11.181 -static PDEVICE_OBJECT Pdo;
  11.182 -
  11.183 -static NTSTATUS
  11.184 -XenVbdBus_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)
  11.185 -{
  11.186 -  WDF_CHILD_LIST_CONFIG ChildListConfig;
  11.187 -  NTSTATUS status;
  11.188 -  WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
  11.189 -  PNP_BUS_INFORMATION BusInfo;
  11.190 -  
  11.191 -//  PWDF_FDO_EVENT_CALLBACKS FdoCallbacks;
  11.192 -
  11.193 -  UNREFERENCED_PARAMETER(Driver);
  11.194 -
  11.195 -  KdPrint((__DRIVER_NAME " --> DeviceAdd\n"));
  11.196 -
  11.197 -  Pdo = WdfFdoInitWdmGetPhysicalDevice(DeviceInit);
  11.198 -
  11.199 -  //WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_BUS_EXTENDER);
  11.200 -  WDF_CHILD_LIST_CONFIG_INIT(&ChildListConfig, sizeof(XENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION), XenVbdBus_ChildListCreateDevice);
  11.201 -  WdfFdoInitSetDefaultChildListConfig(DeviceInit, &ChildListConfig, WDF_NO_OBJECT_ATTRIBUTES);
  11.202 -
  11.203 -  WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_CONTROLLER);
  11.204 -  //WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);
  11.205 -  WdfDeviceInitSetExclusive(DeviceInit, FALSE);
  11.206 -
  11.207 -//  WDF_FDO_EVENT_CALLBACKS_INIT(&FdoCallbacks);
  11.208 -//  //FdoCallbacks.EvtDeviceFilterRemoveResourceRequirements = XenVbdBus_FilterRemoveResourceRequirements;
  11.209 -//  FdoCallbacks.EvtDeviceFilterAddResourceRequirements = XenVbdBus_FilterAddResourceRequirements;
  11.210 -//  FdoCallbacks.EvtDeviceRemoveAddedResources = XenVbdBus_RemoveAddedResources;
  11.211 -//  WdfFdoInitSetEventCallbacks(DeviceInit, &FdoCallbacks);
  11.212 -
  11.213 -  WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
  11.214 -  pnpPowerCallbacks.EvtDevicePrepareHardware = XenVbdBus_PrepareHardware;
  11.215 -  pnpPowerCallbacks.EvtDeviceReleaseHardware = XenVbdBus_ReleaseHardware;
  11.216 -  pnpPowerCallbacks.EvtDeviceD0Entry = XenVbdBus_D0Entry;
  11.217 -  pnpPowerCallbacks.EvtDeviceD0EntryPostInterruptsEnabled = XenVbdBus_D0EntryPostInterruptsEnabled;
  11.218 -  pnpPowerCallbacks.EvtDeviceD0Exit = XenVbdBus_D0Exit;
  11.219 -  pnpPowerCallbacks.EvtDeviceUsageNotification = XenVbdBus_DeviceUsageNotification;
  11.220 -  WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);
  11.221 -
  11.222 -  /*initialize storage for the device context*/
  11.223 -  //WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, XENVBDBUS_DEVICE_DATA);
  11.224 -
  11.225 -  //WdfDeviceInitSetPowerNotPageable(DeviceInit);
  11.226 -
  11.227 -  /*create a device instance.*/
  11.228 -  status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &GlobalDevice);  
  11.229 -  if(!NT_SUCCESS(status))
  11.230 -  {
  11.231 -    KdPrint((__DRIVER_NAME "WdfDeviceCreate failed with status 0x%08x\n", status));
  11.232 -    return status;
  11.233 -  }
  11.234 -
  11.235 -  BusInfo.BusTypeGuid = GUID_XENPCI_DEVCLASS;
  11.236 -  BusInfo.LegacyBusType = Internal; //PNPBus;
  11.237 -  BusInfo.BusNumber = 0;
  11.238 -
  11.239 -  WdfDeviceSetBusInformationForChildren(GlobalDevice, &BusInfo);
  11.240 -
  11.241 -  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFilePaging, TRUE);
  11.242 -  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFileHibernation, TRUE);
  11.243 -  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFileDump, TRUE);
  11.244 -  
  11.245 -  status = STATUS_SUCCESS;
  11.246 -
  11.247 -  KdPrint((__DRIVER_NAME " <-- DeviceAdd\n"));
  11.248 -  return status;
  11.249 -}
  11.250 -
  11.251 -static NTSTATUS
  11.252 -XenVbdBus_PrepareHardware(
  11.253 -  IN WDFDEVICE    Device,
  11.254 -  IN WDFCMRESLIST ResourceList,
  11.255 -  IN WDFCMRESLIST ResourceListTranslated)
  11.256 -{
  11.257 -  NTSTATUS status = STATUS_SUCCESS;
  11.258 -
  11.259 -  UNREFERENCED_PARAMETER(ResourceList);
  11.260 -  UNREFERENCED_PARAMETER(ResourceListTranslated);
  11.261 -
  11.262 -  //KdPrint((__DRIVER_NAME " --> EvtDevicePrepareHardware\n"));
  11.263 -
  11.264 -  status = WdfFdoQueryForInterface(Device, &GUID_XEN_IFACE_EVTCHN, (PINTERFACE) &EvtChnInterface, sizeof(XEN_IFACE_EVTCHN), 1, NULL);
  11.265 -  if(!NT_SUCCESS(status))
  11.266 -  {
  11.267 -    KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (EvtChn) failed with status 0x%08x\n", status));
  11.268 -  }
  11.269 -
  11.270 -  status = WdfFdoQueryForInterface(Device, &GUID_XEN_IFACE_XENBUS, (PINTERFACE)&XenBusInterface, sizeof(XEN_IFACE_XENBUS), 1, NULL);
  11.271 -  if(!NT_SUCCESS(status))
  11.272 -  {
  11.273 -    KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (XenBus) failed with status 0x%08x\n", status));
  11.274 -  }
  11.275 -
  11.276 -  status = WdfFdoQueryForInterface(Device, &GUID_XEN_IFACE_XEN, (PINTERFACE)&XenInterface, sizeof(XEN_IFACE_XEN), 1, NULL);
  11.277 -  if(!NT_SUCCESS(status))
  11.278 -  {
  11.279 -    KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (Xen) failed with status 0x%08x\n", status));
  11.280 -  }
  11.281 -
  11.282 -  status = WdfFdoQueryForInterface(Device, &GUID_XEN_IFACE_GNTTBL, (PINTERFACE)&GntTblInterface, sizeof(XEN_IFACE_GNTTBL), 1, NULL);
  11.283 -  if(!NT_SUCCESS(status))
  11.284 -  {
  11.285 -    KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (GntTbl) failed with status 0x%08x\n", status));
  11.286 -  }
  11.287 -  
  11.288 -  //KdPrint((__DRIVER_NAME " <-- EvtDevicePrepareHardware\n"));
  11.289 -
  11.290 -  InitializeListHead(&DeviceListHead);
  11.291 -
  11.292 -  return status;
  11.293 -}
  11.294 -
  11.295 -static NTSTATUS
  11.296 -XenVbdBus_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated)
  11.297 -{
  11.298 -  UNREFERENCED_PARAMETER(Device);
  11.299 -  UNREFERENCED_PARAMETER(ResourcesTranslated);
  11.300 -
  11.301 -  // release interfaces here...
  11.302 -
  11.303 -  //XenVbdBus_Close();
  11.304 -
  11.305 -  return STATUS_SUCCESS;
  11.306 -}
  11.307 -
  11.308 -static NTSTATUS
  11.309 -XenVbdBus_D0Entry(
  11.310 -    IN WDFDEVICE  Device,
  11.311 -    IN WDF_POWER_DEVICE_STATE PreviousState
  11.312 -    )
  11.313 -{
  11.314 -  NTSTATUS status = STATUS_SUCCESS;
  11.315 -
  11.316 -  UNREFERENCED_PARAMETER(Device);
  11.317 -  UNREFERENCED_PARAMETER(PreviousState);
  11.318 -
  11.319 -  //KdPrint((__DRIVER_NAME " --> EvtDeviceD0Entry\n"));
  11.320 -
  11.321 -  //KdPrint((__DRIVER_NAME " <-- EvtDeviceD0Entry\n"));
  11.322 -
  11.323 -  return status;
  11.324 -}
  11.325 -
  11.326 -static int EnumeratedDevices;
  11.327 -static KEVENT WaitDevicesEvent;
  11.328 -
  11.329 -static NTSTATUS
  11.330 -XenVbdBus_D0EntryPostInterruptsEnabled(WDFDEVICE Device, WDF_POWER_DEVICE_STATE PreviousState)
  11.331 -{
  11.332 -  //OBJECT_ATTRIBUTES oa;
  11.333 -  NTSTATUS status = STATUS_SUCCESS;
  11.334 -  //HANDLE nothing;
  11.335 -  //char *response;
  11.336 -  PXENPCI_XEN_DEVICE_DATA PdoDeviceData;
  11.337 -  char **VbdDevices;
  11.338 -  char *msg;
  11.339 -  char buffer[128];
  11.340 -  int i;
  11.341 -  LARGE_INTEGER WaitTimeout;
  11.342 -
  11.343 -  UNREFERENCED_PARAMETER(Device);
  11.344 -  UNREFERENCED_PARAMETER(PreviousState);
  11.345 -
  11.346 -  //KdPrint((__DRIVER_NAME " --> EvtDeviceD0EntryPostInterruptsEnabled\n"));
  11.347 -
  11.348 -  PdoDeviceData = (PXENPCI_XEN_DEVICE_DATA)Pdo->DeviceExtension; //GetXenDeviceData(Device);
  11.349 -
  11.350 -  //KdPrint((__DRIVER_NAME "     BasePath = %s\n", PdoDeviceData->BasePath));
  11.351 -  PdoDeviceData->WatchHandler = XenVbdBus_HotPlugHandler;
  11.352 -
  11.353 -  EnumeratedDevices = 0;
  11.354 -  KeInitializeEvent(&WaitDevicesEvent, SynchronizationEvent, FALSE);  
  11.355 -
  11.356 -  // TODO: Should probably do this in an EvtChildListScanForChildren
  11.357 -  if (AutoEnumerate)
  11.358 -  {
  11.359 -    msg = XenBusInterface.List(XBT_NIL, "device/vbd", &VbdDevices);
  11.360 -    if (!msg) {
  11.361 -      for (i = 0; VbdDevices[i]; i++)
  11.362 -      {
  11.363 -        KdPrint((__DRIVER_NAME "     found existing vbd device %s\n", VbdDevices[i]));
  11.364 -        RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "device/vbd/%s/state", VbdDevices[i]);
  11.365 -        XenVbdBus_HotPlugHandler(buffer, NULL);
  11.366 -        //ExFreePoolWithTag(bdDevices[i], XENPCI_POOL_TAG);
  11.367 -      }
  11.368 -      KdPrint((__DRIVER_NAME "     Waiting for devices to be enumerated\n"));
  11.369 -      while (EnumeratedDevices != i)
  11.370 -      {
  11.371 -        WaitTimeout.QuadPart = -600000000;
  11.372 -        if (KeWaitForSingleObject(&WaitDevicesEvent, Executive, KernelMode, FALSE, &WaitTimeout) == STATUS_TIMEOUT)
  11.373 -        {
  11.374 -          KdPrint((__DRIVER_NAME "     Wait timed out\n"));
  11.375 -          break;
  11.376 -        }
  11.377 -        KdPrint((__DRIVER_NAME "     %d out of %d devices enumerated\n", EnumeratedDevices, i));
  11.378 -      }  
  11.379 -    }
  11.380 -  }
  11.381 -
  11.382 -  //KdPrint((__DRIVER_NAME " <-- EvtDeviceD0EntryPostInterruptsEnabled\n"));
  11.383 -
  11.384 -  return status;
  11.385 -}
  11.386 -
  11.387 -static NTSTATUS
  11.388 -XenVbdBus_D0Exit(
  11.389 -    IN WDFDEVICE Device,
  11.390 -    IN WDF_POWER_DEVICE_STATE  TargetState
  11.391 -    )
  11.392 -{
  11.393 -  NTSTATUS status = STATUS_SUCCESS;
  11.394 -  //char *response;
  11.395 -
  11.396 -  UNREFERENCED_PARAMETER(Device);
  11.397 -  UNREFERENCED_PARAMETER(TargetState);
  11.398 -
  11.399 -  //KdPrint((__DRIVER_NAME " --> EvtDeviceD0Exit\n"));
  11.400 -
  11.401 -  //response = XenBusInterface.RemWatch(XBT_NIL, XenBusInterface.InterfaceHeader.Context, XenVbdBus_HotPlugHandler, NULL);
  11.402 -
  11.403 -  //KdPrint((__DRIVER_NAME " <-- EvtDeviceD0Exit\n"));
  11.404 -
  11.405 -  return status;
  11.406 -}
  11.407 -
  11.408 -static NTSTATUS
  11.409 -XenVbdBus_DeviceUsageNotification(WDFDEVICE Device, WDF_SPECIAL_FILE_TYPE NotificationType, BOOLEAN IsInNotificationPath)
  11.410 -{
  11.411 -  KdPrint((__DRIVER_NAME " --> DeviceUsageNotification\n"));
  11.412 -
  11.413 -  switch (NotificationType)
  11.414 -  {
  11.415 -  case WdfSpecialFilePaging:
  11.416 -    KdPrint((__DRIVER_NAME "     NotificationType = WdfSpecialFilePaging, Using = %d\n", IsInNotificationPath));
  11.417 -    break;
  11.418 -  case WdfSpecialFileHibernation:
  11.419 -    KdPrint((__DRIVER_NAME "     NotificationType = WdfSpecialFileHibernation, Using = %d\n", IsInNotificationPath));
  11.420 -    break;
  11.421 -  case WdfSpecialFileDump:
  11.422 -    KdPrint((__DRIVER_NAME "     NotificationType = WdfSpecialFileDump, Using = %d\n", IsInNotificationPath));
  11.423 -    break;
  11.424 -  default:
  11.425 -    KdPrint((__DRIVER_NAME "     NotificationType = %d, Using = %d\n", NotificationType, IsInNotificationPath));
  11.426 -    break;
  11.427 -  }
  11.428 -  KdPrint((__DRIVER_NAME " <-- DeviceUsageNotification\n"));
  11.429 -
  11.430 -  return TRUE;
  11.431 -}
  11.432 -
  11.433 -static VOID 
  11.434 -XenVbdBus_IoDefault(
  11.435 -    IN WDFQUEUE  Queue,
  11.436 -    IN WDFREQUEST  Request
  11.437 -    )
  11.438 -{
  11.439 -  UNREFERENCED_PARAMETER(Queue);
  11.440 -
  11.441 -  //KdPrint((__DRIVER_NAME " --> EvtDeviceIoDefault\n"));
  11.442 -
  11.443 -  WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
  11.444 -
  11.445 -  //KdPrint((__DRIVER_NAME " <-- EvtDeviceIoDefault\n"));
  11.446 -}
  11.447 -
  11.448 -
  11.449 -static PMDL
  11.450 -AllocatePages(int Pages)
  11.451 -{
  11.452 -  PMDL Mdl;
  11.453 -  PVOID Buf;
  11.454 -
  11.455 -  Buf = ExAllocatePoolWithTag(NonPagedPool, Pages * PAGE_SIZE, XENVBDBUS_POOL_TAG);
  11.456 -  if (Buf == NULL)
  11.457 -  {
  11.458 -    KdPrint((__DRIVER_NAME "     AllocatePages Failed at ExAllocatePoolWithTag\n"));
  11.459 -  }
  11.460 -  Mdl = IoAllocateMdl(Buf, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
  11.461 -  if (Mdl == NULL)
  11.462 -  {
  11.463 -    KdPrint((__DRIVER_NAME "     AllocatePages Failed at IoAllocateMdl\n"));
  11.464 -  }
  11.465 -  MmBuildMdlForNonPagedPool(Mdl);
  11.466 -  
  11.467 -  return Mdl;
  11.468 -}
  11.469 -
  11.470 -static PMDL
  11.471 -AllocatePage()
  11.472 -{
  11.473 -  return AllocatePages(1);
  11.474 -}
  11.475 -
  11.476 -static VOID
  11.477 -FreePages(PMDL Mdl)
  11.478 -{
  11.479 -  PVOID Buf = MmGetMdlVirtualAddress(Mdl);
  11.480 -  //KdPrint((__DRIVER_NAME "     FreePages Failed at IoAllocateMdl\n"));
  11.481 -  //KdPrint((__DRIVER_NAME "     FreePages Buf = %08x\n", Buf));
  11.482 -  IoFreeMdl(Mdl);
  11.483 -  ExFreePoolWithTag(Buf, XENVBDBUS_POOL_TAG);
  11.484 -}
  11.485 -
  11.486 -static VOID
  11.487 -XenVbdBus_Notify(PVOID Data)
  11.488 -{
  11.489 -  PXENVBDBUS_CHILD_DEVICE_DATA ChildDeviceData;
  11.490 -
  11.491 -  KdPrint((__DRIVER_NAME " --> XenVbdBus_Notify\n"));
  11.492 -
  11.493 -  ChildDeviceData = (PXENVBDBUS_CHILD_DEVICE_DATA)Data;
  11.494 -
  11.495 -  EvtChnInterface.Notify(ChildDeviceData->EventChannel);
  11.496 -
  11.497 -  KdPrint((__DRIVER_NAME " <-- XenVbdBus_Notify\n"));
  11.498 -}
  11.499 -
  11.500 -static BOOLEAN
  11.501 -XenVbdBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext)
  11.502 -{
  11.503 -  PXENVBDBUS_CHILD_DEVICE_DATA ChildDeviceData;
  11.504 -
  11.505 -  UNREFERENCED_PARAMETER(Interrupt);
  11.506 -  // !!!RUNS AT DIRQL!!!
  11.507 -
  11.508 -  KdPrint((__DRIVER_NAME " --> XenVbdBus_Interrupt\n"));
  11.509 -
  11.510 -  ChildDeviceData = (PXENVBDBUS_CHILD_DEVICE_DATA)ServiceContext;
  11.511 -  if (ChildDeviceData->ScsiDeviceData->IsrRoutine != NULL)
  11.512 -    ChildDeviceData->ScsiDeviceData->IsrRoutine(ChildDeviceData->ScsiDeviceData->IsrContext);
  11.513 -  else
  11.514 -    KdPrint((__DRIVER_NAME "     Isr Not Set\n"));  
  11.515 -
  11.516 -  KdPrint((__DRIVER_NAME " <-- XenVbdBus_Interrupt\n"));
  11.517 -
  11.518 -  return STATUS_SUCCESS;
  11.519 -}
  11.520 -
  11.521 -static VOID
  11.522 -XenVbdBus_BackEndStateHandler(char *Path, PVOID Data)
  11.523 -{
  11.524 -  PXENVBDBUS_CHILD_DEVICE_DATA DeviceData;
  11.525 -  char TmpPath[128];
  11.526 -  char *Value;
  11.527 -  int NewState;
  11.528 -  grant_ref_t ref;
  11.529 -  blkif_sring_t *SharedRing;
  11.530 -  //ULONG PFN;
  11.531 -  XENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION Description;
  11.532 -  NTSTATUS status;
  11.533 -
  11.534 -  DeviceData = (PXENVBDBUS_CHILD_DEVICE_DATA)Data;
  11.535 -
  11.536 -  XenBusInterface.Read(XBT_NIL, Path, &Value);
  11.537 -
  11.538 -  NewState = atoi(Value);
  11.539 -  switch (NewState)
  11.540 -  {
  11.541 -  case XenbusStateUnknown:
  11.542 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Unknown\n"));  
  11.543 -    break;
  11.544 -
  11.545 -  case XenbusStateInitialising:
  11.546 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Initialising\n"));  
  11.547 -    break;
  11.548 -
  11.549 -  case XenbusStateInitWait:
  11.550 -    KdPrint((__DRIVER_NAME "     Backend State Changed to InitWait\n"));  
  11.551 -
  11.552 -    // We create the Windows device node here
  11.553 -    WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(&Description.Header, sizeof(Description));
  11.554 -    Description.DeviceData = DeviceData;
  11.555 -    DeviceData->EventChannel = EvtChnInterface.AllocUnbound(0);
  11.556 -    EvtChnInterface.BindDpc(DeviceData->EventChannel, XenVbdBus_Interrupt, DeviceData);
  11.557 -    
  11.558 -    DeviceData->SharedRingMDL = AllocatePage();
  11.559 -    SharedRing = (blkif_sring_t *)MmGetMdlVirtualAddress(DeviceData->SharedRingMDL);
  11.560 -    SHARED_RING_INIT(SharedRing);
  11.561 -
  11.562 -    DeviceData->ScsiDeviceDataMdl = AllocatePage();
  11.563 -    DeviceData->ScsiDeviceData = MmGetMdlVirtualAddress(DeviceData->ScsiDeviceDataMdl);
  11.564 -
  11.565 -    DeviceData->ScsiDeviceData->Magic = SCSI_DATA_MAGIC;
  11.566 -    FRONT_RING_INIT(&DeviceData->ScsiDeviceData->Ring, SharedRing, PAGE_SIZE);
  11.567 -    ref = GntTblInterface.GrantAccess(0, *MmGetMdlPfnArray(DeviceData->SharedRingMDL), FALSE);
  11.568 -    DeviceData->ScsiDeviceData->NotifyContext = DeviceData;
  11.569 -    DeviceData->ScsiDeviceData->NotifyRoutine = XenVbdBus_Notify;
  11.570 -    DeviceData->ScsiDeviceData->GntTblInterface = GntTblInterface;
  11.571 -
  11.572 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
  11.573 -    RtlStringCbCatA(TmpPath, 128, "/ring-ref");
  11.574 -    XenBusInterface.Printf(XBT_NIL, TmpPath, "%d", ref);
  11.575 -
  11.576 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
  11.577 -    RtlStringCbCatA(TmpPath, 128, "/event-channel");
  11.578 -    XenBusInterface.Printf(XBT_NIL, TmpPath, "%d", DeviceData->EventChannel);
  11.579 -  
  11.580 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
  11.581 -    RtlStringCbCatA(TmpPath, 128, "/state");
  11.582 -    XenBusInterface.Printf(XBT_NIL, TmpPath, "%d", XenbusStateInitialised);
  11.583 -
  11.584 -    KdPrint((__DRIVER_NAME "     Set Frontend state to Initialised\n"));
  11.585 -    break;
  11.586 -
  11.587 -  case XenbusStateInitialised:
  11.588 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Initialised\n"));
  11.589 -    // create the device
  11.590 -    break;
  11.591 -
  11.592 -  case XenbusStateConnected:
  11.593 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Connected\n"));  
  11.594 -
  11.595 -    WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(&Description.Header, sizeof(Description));
  11.596 -
  11.597 -    Description.DeviceData = DeviceData;
  11.598 -
  11.599 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
  11.600 -    RtlStringCbCatA(TmpPath, 128, "/device-type");
  11.601 -    XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
  11.602 -    if (strcmp(Value, "disk") == 0)
  11.603 -    {
  11.604 -      KdPrint((__DRIVER_NAME "     DeviceType = Disk\n"));    
  11.605 -      DeviceData->ScsiDeviceData->DeviceType = XENVBD_DEVICETYPE_DISK;
  11.606 -    }
  11.607 -    else if (strcmp(Value, "cdrom") == 0)
  11.608 -    {
  11.609 -      KdPrint((__DRIVER_NAME "     DeviceType = CDROM\n"));    
  11.610 -      DeviceData->ScsiDeviceData->DeviceType = XENVBD_DEVICETYPE_CDROM;
  11.611 -    }
  11.612 -    else
  11.613 -    {
  11.614 -      KdPrint((__DRIVER_NAME "     DeviceType = %s (This probably won't work!)\n", Value));
  11.615 -    }
  11.616 -
  11.617 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
  11.618 -    RtlStringCbCatA(TmpPath, 128, "/type"); // should probably check that this is 'phy' or 'file' or at least not ''
  11.619 -    XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
  11.620 -    KdPrint((__DRIVER_NAME "     Backend Type = %s\n", Value));
  11.621 -
  11.622 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
  11.623 -    RtlStringCbCatA(TmpPath, 128, "/mode"); // should store this...
  11.624 -    XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
  11.625 -    KdPrint((__DRIVER_NAME "     Backend Mode = %s\n", Value));
  11.626 -
  11.627 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
  11.628 -    RtlStringCbCatA(TmpPath, 128, "/sector-size");
  11.629 -    XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
  11.630 -    // should complain if Value == NULL
  11.631 -    DeviceData->ScsiDeviceData->BytesPerSector = atoi(Value);
  11.632 -
  11.633 -    KdPrint((__DRIVER_NAME "     BytesPerSector = %d\n", DeviceData->ScsiDeviceData->BytesPerSector));    
  11.634 -
  11.635 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
  11.636 -    RtlStringCbCatA(TmpPath, 128, "/sectors");
  11.637 -    XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
  11.638 -    // should complain if Value == NULL
  11.639 -    DeviceData->ScsiDeviceData->TotalSectors = (ULONGLONG)atol(Value);
  11.640 -
  11.641 -    KdPrint((__DRIVER_NAME "     TotalSectors = %d\n", DeviceData->ScsiDeviceData->TotalSectors));    
  11.642 -
  11.643 -/*
  11.644 -    // should probably use the partition table (if one exists) here for the sectorspertrack and trackspercylinder values
  11.645 -    DeviceData->Geometry.MediaType = FixedMedia;
  11.646 -    DeviceData->Geometry.BytesPerSector = DeviceData->BytesPerSector;
  11.647 -    DeviceData->Geometry.SectorsPerTrack = 63;
  11.648 -    DeviceData->Geometry.TracksPerCylinder = 255;
  11.649 -    DeviceData->Geometry.Cylinders.QuadPart = DeviceData->TotalSectors / DeviceData->Geometry.SectorsPerTrack / DeviceData->Geometry.TracksPerCylinder;
  11.650 -    KdPrint((__DRIVER_NAME "     Geometry C/H/S = %d/%d/%d\n", DeviceData->Geometry.Cylinders.LowPart, DeviceData->Geometry.TracksPerCylinder, DeviceData->Geometry.SectorsPerTrack));
  11.651 -*/
  11.652 -    // if we detected something wrong, we should not enumerate the device and should instead initiate a close
  11.653 -
  11.654 -    status = WdfChildListAddOrUpdateChildDescriptionAsPresent(WdfFdoGetDefaultChildList(GlobalDevice), &Description.Header, NULL);
  11.655 -    if (!NT_SUCCESS(status))
  11.656 -    {
  11.657 -      KdPrint((__DRIVER_NAME "     WdfChildListAddOrUpdateChildDescriptionAsPresent failed %08x\n", status));
  11.658 -    } 
  11.659 -
  11.660 -    RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
  11.661 -    RtlStringCbCatA(TmpPath, 128, "/state");
  11.662 -    XenBusInterface.Printf(XBT_NIL, TmpPath, "%d", XenbusStateConnected);
  11.663 -
  11.664 -    KdPrint((__DRIVER_NAME "     Set Frontend state to Connected\n"));
  11.665 -    InterlockedIncrement(&EnumeratedDevices);
  11.666 -    KdPrint((__DRIVER_NAME "     Added a controller, notifying\n"));
  11.667 -    KeSetEvent(&WaitDevicesEvent, 1, FALSE);
  11.668 -    break;
  11.669 -
  11.670 -  case XenbusStateClosing:
  11.671 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Closing\n"));  
  11.672 -    break;
  11.673 -
  11.674 -  case XenbusStateClosed:
  11.675 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Closed\n"));  
  11.676 -    break;
  11.677 -
  11.678 -  default:
  11.679 -    KdPrint((__DRIVER_NAME "     Backend State Changed to Undefined = %d\n", NewState));
  11.680 -    break;
  11.681 -  }
  11.682 -}
  11.683 -
  11.684 -static VOID
  11.685 -XenVbdBus_HotPlugHandler(char *Path, PVOID Data)
  11.686 -{
  11.687 -  PXENVBDBUS_CHILD_DEVICE_DATA DeviceData;
  11.688 -  char **Bits;
  11.689 -  int Count;
  11.690 -  char TmpPath[128];
  11.691 -  char *Value;
  11.692 -
  11.693 -  UNREFERENCED_PARAMETER(Data);  
  11.694 -
  11.695 -  //KdPrint((__DRIVER_NAME " --> HotPlugHandler\n"));
  11.696 -
  11.697 -  KdPrint((__DRIVER_NAME "     Path = %s\n", Path));
  11.698 -
  11.699 -  Bits = SplitString(Path, '/', 4, &Count);
  11.700 -  switch (Count)
  11.701 -  {
  11.702 -  case 0:
  11.703 -  case 1:
  11.704 -  case 2:
  11.705 -    break; // should never happen
  11.706 -  case 3:
  11.707 -    break;
  11.708 -  case 4:
  11.709 -    if (strcmp(Bits[3], "state") != 0) // we only care when the state appears
  11.710 -      break;
  11.711 -    KdPrint((__DRIVER_NAME "     Bits[0] = %s\n", Bits[0]));
  11.712 -    KdPrint((__DRIVER_NAME "     Bits[1] = %s\n", Bits[1]));
  11.713 -    KdPrint((__DRIVER_NAME "     Bits[2] = %s\n", Bits[2]));
  11.714 -    for (DeviceData = (PXENVBDBUS_CHILD_DEVICE_DATA)DeviceListHead.Flink; DeviceData != (PXENVBDBUS_CHILD_DEVICE_DATA)&DeviceListHead; DeviceData = (PXENVBDBUS_CHILD_DEVICE_DATA)DeviceData->Entry.Flink)
  11.715 -    {
  11.716 -
  11.717 -      KdPrint((__DRIVER_NAME "     Comparing '%s' and '%s'\n", DeviceData->Path, Path));
  11.718 -      if (strncmp(DeviceData->Path, Path, strlen(DeviceData->Path)) == 0 && Path[strlen(DeviceData->Path)] == '/')
  11.719 -      {
  11.720 -        KdPrint((__DRIVER_NAME "     Matched\n"));
  11.721 -        break;
  11.722 -      }
  11.723 -    }
  11.724 -    if (DeviceData == (PXENVBDBUS_CHILD_DEVICE_DATA)&DeviceListHead)
  11.725 -    {
  11.726 -      DeviceData = ExAllocatePoolWithTag(NonPagedPool, sizeof(XENVBDBUS_CHILD_DEVICE_DATA), XENVBDBUS_POOL_TAG);
  11.727 -      memset(DeviceData, 0, sizeof(XENVBDBUS_CHILD_DEVICE_DATA));
  11.728 -
  11.729 -      KdPrint((__DRIVER_NAME "     Allocated ChildDeviceData = %08x\n", DeviceData));
  11.730 -      
  11.731 -      RtlStringCbCopyA(DeviceData->Path, 128, Bits[0]);
  11.732 -      RtlStringCbCatA(DeviceData->Path, 128, "/");
  11.733 -      RtlStringCbCatA(DeviceData->Path, 128, Bits[1]);
  11.734 -      RtlStringCbCatA(DeviceData->Path, 128, "/");
  11.735 -      RtlStringCbCatA(DeviceData->Path, 128, Bits[2]);
  11.736 -      InsertTailList(&DeviceListHead, &DeviceData->Entry);
  11.737 -
  11.738 -      DeviceData->DeviceIndex = atoi(Bits[2]);
  11.739 -
  11.740 -      RtlStringCbCopyA(TmpPath, 128, DeviceData->Path);
  11.741 -      RtlStringCbCatA(TmpPath, 128, "/backend");
  11.742 -      XenBusInterface.Read(XBT_NIL, TmpPath, &Value);
  11.743 -      if (Value == NULL)
  11.744 -      {
  11.745 -        KdPrint((__DRIVER_NAME "     Read Failed\n"));
  11.746 -      }
  11.747 -      else
  11.748 -      {
  11.749 -        RtlStringCbCopyA(DeviceData->BackendPath, 128, Value);
  11.750 -      }
  11.751 -      RtlStringCbCopyA(TmpPath, 128, DeviceData->BackendPath);
  11.752 -      RtlStringCbCatA(TmpPath, 128, "/state");
  11.753 -      XenBusInterface.AddWatch(XBT_NIL, TmpPath, XenVbdBus_BackEndStateHandler, DeviceData);
  11.754 -    }
  11.755 -    break;
  11.756 -  }
  11.757 -  
  11.758 -  FreeSplitString(Bits, Count);
  11.759 -
  11.760 -  //KdPrint((__DRIVER_NAME " <-- HotPlugHandler\n"));  
  11.761 -
  11.762 -  return;
  11.763 -}
  11.764 -
  11.765 -static NTSTATUS
  11.766 -XenVbdBus_ChildListCreateDevice(WDFCHILDLIST ChildList, PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER IdentificationDescription, PWDFDEVICE_INIT ChildInit)
  11.767 -{
  11.768 -  NTSTATUS status;
  11.769 -  WDFDEVICE ChildDevice;
  11.770 -  PXENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION XenVbdBusIdentificationDesc;
  11.771 -  DECLARE_UNICODE_STRING_SIZE(buffer, 50);
  11.772 -  WDF_OBJECT_ATTRIBUTES PdoAttributes;
  11.773 -  DECLARE_CONST_UNICODE_STRING(DeviceLocation, L"Xen Bus");
  11.774 -  PXENVBDBUS_CHILD_DEVICE_DATA ChildDeviceData;
  11.775 -  WDF_PDO_EVENT_CALLBACKS PdoCallbacks;
  11.776 -  UCHAR PnpMinors[2] = { IRP_MN_START_DEVICE, IRP_MN_STOP_DEVICE };
  11.777 -
  11.778 -  UNREFERENCED_PARAMETER(ChildList);
  11.779 -
  11.780 -  KdPrint((__DRIVER_NAME " --> ChildListCreateDevice\n"));
  11.781 -
  11.782 -  XenVbdBusIdentificationDesc = CONTAINING_RECORD(IdentificationDescription, XENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION, Header);
  11.783 -
  11.784 -  ChildDeviceData = XenVbdBusIdentificationDesc->DeviceData;
  11.785 -
  11.786 -  WdfDeviceInitSetDeviceType(ChildInit, FILE_DEVICE_CONTROLLER);
  11.787 -
  11.788 -  status = RtlUnicodeStringPrintf(&buffer, L"XEN\\VBDDev\0");
  11.789 -  status = WdfPdoInitAssignDeviceID(ChildInit, &buffer);
  11.790 -
  11.791 -  status = RtlUnicodeStringPrintf(&buffer, L"%02d\0", ChildDeviceData->DeviceIndex);
  11.792 -  status = WdfPdoInitAssignInstanceID(ChildInit, &buffer);
  11.793 -
  11.794 -  status = RtlUnicodeStringPrintf(&buffer, L"XEN\\VBDDev\0");
  11.795 -  status = WdfPdoInitAddCompatibleID(ChildInit, &buffer);
  11.796 -  status = WdfPdoInitAddHardwareID(ChildInit, &buffer);
  11.797 -
  11.798 -  //status = RtlUnicodeStringPrintf(&buffer, L"Xen PV Disk (%d)", ChildDeviceData->DeviceIndex);
  11.799 -  //status = WdfPdoInitAddDeviceText(ChildInit, &buffer, &DeviceLocation, 0x409);
  11.800 -  //WdfPdoInitSetDefaultLocale(ChildInit, 0x409);
  11.801 -
  11.802 -  WDF_PDO_EVENT_CALLBACKS_INIT(&PdoCallbacks);
  11.803 -  PdoCallbacks.EvtDeviceResourceRequirementsQuery = XenVbdBus_DeviceResourceRequirementsQuery;
  11.804 -  WdfPdoInitSetEventCallbacks(ChildInit, &PdoCallbacks);
  11.805 -
  11.806 -  WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&PdoAttributes, PXENVBDBUS_CHILD_DEVICE_DATA);
  11.807 -
  11.808 -//  status = WdfDeviceInitAssignWdmIrpPreprocessCallback(ChildInit, XenVbd_Child_PreprocessWdmIrpPnp, IRP_MJ_PNP, PnpMinors, 2);
  11.809 -//  if (!NT_SUCCESS(status))
  11.810 -//    KdPrint((__DRIVER_NAME "     WdfDeviceInitAssignWdmIrpPreprocessCallback(IRP_MJ_PNP) status = %08X\n", status));
  11.811 -
  11.812 -  status = WdfDeviceCreate(&ChildInit, &PdoAttributes, &ChildDevice);
  11.813 -  if (!NT_SUCCESS(status))
  11.814 -  {
  11.815 -    KdPrint((__DRIVER_NAME "     WdfDeviceCreate status = %08X\n", status));
  11.816 -  }
  11.817 -
  11.818 -  *GetChildDeviceData(ChildDevice) = ChildDeviceData;
  11.819 -
  11.820 -  KdPrint((__DRIVER_NAME " <-- ChildListCreateDevice (status = %08x)\n", status));
  11.821 -
  11.822 -  return status;
  11.823 -}
  11.824 -
  11.825 -static NTSTATUS
  11.826 -XenVbd_Child_PreprocessWdmIrpPnp(WDFDEVICE Device, PIRP Irp)
  11.827 -{
  11.828 -  NTSTATUS Status;
  11.829 -  PIO_STACK_LOCATION IrpStackLocation;
  11.830 -  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
  11.831 -  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
  11.832 -  int i;  
  11.833 -
  11.834 -  KdPrint((__DRIVER_NAME " --> PreprocessWdmIrpPnp\n"));
  11.835 -
  11.836 -  IrpStackLocation = IoGetCurrentIrpStackLocation(Irp);
  11.837 -
  11.838 -  switch (IrpStackLocation->MinorFunction)
  11.839 -  {
  11.840 -  case IRP_MN_START_DEVICE:
  11.841 -    KdPrint((__DRIVER_NAME "     START_DEVICE\n"));
  11.842 -    PartialResourceList = &IrpStackLocation->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList;
  11.843 -    for (i = 0; i < PartialResourceList->Count; i++)
  11.844 -    {
  11.845 -      PartialDescriptor = &PartialResourceList->PartialDescriptors[i];
  11.846 -      switch (PartialDescriptor->Type)
  11.847 -      {
  11.848 -      case CmResourceTypeInterrupt:
  11.849 -        KdPrint((__DRIVER_NAME "     CmResourceTypeInterrupt\n"));
  11.850 -        KdPrint((__DRIVER_NAME "     Level = %d, Vector = %08x\n", PartialDescriptor->u.Interrupt.Level, PartialDescriptor->u.Interrupt.Vector));
  11.851 -        break;
  11.852 -      default:
  11.853 -        KdPrint((__DRIVER_NAME "     Other Resource %02X\n", PartialDescriptor->Type));
  11.854 -        break;
  11.855 -      }
  11.856 -    }
  11.857 -    PartialResourceList = &IrpStackLocation->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList;
  11.858 -    for (i = 0; i < PartialResourceList->Count; i++)
  11.859 -    {
  11.860 -      PartialDescriptor = &PartialResourceList->PartialDescriptors[i];
  11.861 -      switch (PartialDescriptor->Type)
  11.862 -      {
  11.863 -      case CmResourceTypeInterrupt:
  11.864 -        KdPrint((__DRIVER_NAME "     CmResourceTypeInterrupt\n"));
  11.865 -        KdPrint((__DRIVER_NAME "     Level = %d, Vector = %08x\n", PartialDescriptor->u.Interrupt.Level, PartialDescriptor->u.Interrupt.Vector));
  11.866 -        break;
  11.867 -      default:
  11.868 -        KdPrint((__DRIVER_NAME "     Other Resource %02X\n", PartialDescriptor->Type));
  11.869 -        break;
  11.870 -      }
  11.871 -    }
  11.872 -    break;
  11.873 -  case IRP_MN_STOP_DEVICE:
  11.874 -    KdPrint((__DRIVER_NAME "     STOP_DEVICE\n"));
  11.875 -    // Unbind the PIRQ here
  11.876 -    break;
  11.877 -  default:
  11.878 -    break;
  11.879 -  }
  11.880 -
  11.881 -  IoSkipCurrentIrpStackLocation(Irp);
  11.882 -
  11.883 -  Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
  11.884 -
  11.885 -  KdPrint((__DRIVER_NAME " <-- PreprocessWdmIrpPnp\n"));
  11.886 -
  11.887 -  return Status;
  11.888 -}
  11.889 -
  11.890 -static NTSTATUS
  11.891 -XenVbdBus_DeviceResourceRequirementsQuery(WDFDEVICE ChildDevice, WDFIORESREQLIST IoResourceRequirementsList)
  11.892 -{
  11.893 -  NTSTATUS  status = STATUS_SUCCESS;
  11.894 -  WDFIORESLIST resourceList;
  11.895 -  IO_RESOURCE_DESCRIPTOR descriptor;
  11.896 -  PXENVBDBUS_CHILD_DEVICE_DATA ChildDeviceData;
  11.897 -
  11.898 -  ChildDeviceData = *GetChildDeviceData(ChildDevice);
  11.899 -
  11.900 -  KdPrint((__DRIVER_NAME " --> DeviceResourceRequirementsQuery\n"));
  11.901 -
  11.902 -  status = WdfIoResourceListCreate(IoResourceRequirementsList, WDF_NO_OBJECT_ATTRIBUTES, &resourceList);
  11.903 -  if (!NT_SUCCESS(status))
  11.904 -    return status;
  11.905 -
  11.906 -  RtlZeroMemory(&descriptor, sizeof(descriptor));
  11.907 -
  11.908 -  descriptor.Type = CmResourceTypeMemory;
  11.909 -  descriptor.ShareDisposition = CmResourceShareDeviceExclusive;
  11.910 -  descriptor.Flags = CM_RESOURCE_MEMORY_READ_WRITE;
  11.911 -  descriptor.u.Memory.Length = 0; //PAGE_SIZE;
  11.912 -  descriptor.u.Memory.Alignment = PAGE_SIZE;
  11.913 -  //descriptor.u.Memory.MinimumAddress.QuadPart = *MmGetMdlPfnArray(ChildDeviceData->ScsiDeviceDataMdl) << PAGE_SHIFT;
  11.914 -  descriptor.u.Memory.MinimumAddress.QuadPart = MmGetSystemAddressForMdlSafe(ChildDeviceData->ScsiDeviceDataMdl, NormalPagePriority);
  11.915 -  descriptor.u.Memory.MaximumAddress.QuadPart = descriptor.u.Memory.MinimumAddress.QuadPart;
  11.916 -
  11.917 -  KdPrint((__DRIVER_NAME "     MinimumAddress = %08x, MaximumAddress = %08x\n", descriptor.u.Memory.MinimumAddress.LowPart, descriptor.u.Memory.MaximumAddress.LowPart));
  11.918 -
  11.919 -  status = WdfIoResourceListAppendDescriptor(resourceList, &descriptor);
  11.920 -  if (!NT_SUCCESS(status))
  11.921 -    return status;
  11.922 -/*
  11.923 -  RtlZeroMemory(&descriptor, sizeof(descriptor));
  11.924 -
  11.925 -  descriptor.Type = CmResourceTypeInterrupt;
  11.926 -  descriptor.ShareDisposition = CmResourceShareDeviceExclusive;
  11.927 -  descriptor.Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
  11.928 -  descriptor.u.Interrupt.MinimumVector = 16;
  11.929 -  descriptor.u.Interrupt.MaximumVector = 255;
  11.930 -
  11.931 -  KdPrint((__DRIVER_NAME "     MinimumVector = %d, MaximumVector = %d\n", descriptor.u.Interrupt.MinimumVector, descriptor.u.Interrupt.MaximumVector));
  11.932 -
  11.933 -  status = WdfIoResourceListAppendDescriptor(resourceList, &descriptor);
  11.934 -  if (!NT_SUCCESS(status))
  11.935 -    return status;
  11.936 -*/
  11.937 -
  11.938 -  status = WdfIoResourceRequirementsListAppendIoResList(IoResourceRequirementsList, resourceList);
  11.939 -  if (!NT_SUCCESS(status))
  11.940 -  {
  11.941 -    return status;
  11.942 -  }
  11.943 -
  11.944 -  KdPrint((__DRIVER_NAME " <-- DeviceResourceRequirementsQuery\n"));
  11.945 -
  11.946 -  return status;
  11.947 -}
    12.1 --- a/xenvbdbus/xenvbdbus.h	Sat Dec 01 23:33:51 2007 +1100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,96 +0,0 @@
    12.4 -#if !defined(_XENVBDBUS_H_)
    12.5 -#define _XENVBDBUS_H_
    12.6 -
    12.7 -#include <ntddk.h>
    12.8 -#include <wdm.h>
    12.9 -#include <wdf.h>
   12.10 -#include <initguid.h>
   12.11 -#include <ntdddisk.h>
   12.12 -
   12.13 -#define NTSTRSAFE_LIB
   12.14 -#include <ntstrsafe.h>
   12.15 -
   12.16 -#include <xen_windows.h>
   12.17 -#include <memory.h>
   12.18 -#include <grant_table.h>
   12.19 -#include <event_channel.h>
   12.20 -#include <hvm/params.h>
   12.21 -#include <hvm/hvm_op.h>
   12.22 -#include <evtchn_public.h>
   12.23 -#include <gnttbl_public.h>
   12.24 -#include <xenbus_public.h>
   12.25 -#include <io/ring.h>
   12.26 -#include <io/blkif.h>
   12.27 -#define __DRIVER_NAME "XenVbdBus"
   12.28 -#define XENVBDBUS_POOL_TAG (ULONG) 'XVBD'
   12.29 -
   12.30 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
   12.31 -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
   12.32 -
   12.33 -extern XEN_IFACE_EVTCHN EvtChnInterface;
   12.34 -extern XEN_IFACE_XENBUS XenBusInterface;
   12.35 -
   12.36 -#include "..\xenvbddev\scsidata.h"
   12.37 -
   12.38 -struct
   12.39 -{
   12.40 -  LIST_ENTRY Entry;
   12.41 -  char Path[128];
   12.42 -  char BackendPath[128];
   12.43 -  ULONG DeviceIndex;
   12.44 -  evtchn_port_t EventChannel;
   12.45 -  PMDL SharedRingMDL;
   12.46 -//  ULONG BytesPerSector;
   12.47 -//  ULONGLONG TotalSectors;
   12.48 -  PMDL ScsiDeviceDataMdl;
   12.49 -  PXENVBDDEV_SCSI_DATA ScsiDeviceData;
   12.50 -/*
   12.51 -  KSPIN_LOCK Lock;
   12.52 -  WDFQUEUE IoDefaultQueue;
   12.53 -  WDFDEVICE Device;
   12.54 -*/
   12.55 -
   12.56 -//  int TmpCount;
   12.57 -/*
   12.58 -  int BackendState;
   12.59 -  int FrontendState;
   12.60 -*/
   12.61 -  
   12.62 -/*
   12.63 -  blkif_shadow_t *shadow;
   12.64 -  uint64_t shadow_free;
   12.65 -
   12.66 -  LIST_ENTRY IrpListHead;
   12.67 -  KSPIN_LOCK IrpListLock;
   12.68 -
   12.69 -  WDFDPC Dpc;
   12.70 -*/
   12.71 -/*
   12.72 -  DISK_GEOMETRY Geometry;
   12.73 -*/
   12.74 -/*
   12.75 -  int IrpAddedToList;
   12.76 -  int IrpRemovedFromList;
   12.77 -  int IrpAddedToRing;
   12.78 -  int IrpAddedToRingAtLastNotify;
   12.79 -  int IrpAddedToRingAtLastInterrupt;
   12.80 -  int IrpAddedToRingAtLastDpc;
   12.81 -  int IrpRemovedFromRing;
   12.82 -  int IrpCompleted;
   12.83 -
   12.84 -  int FastPathUsed;
   12.85 -  int SlowPathUsed;
   12.86 -*/
   12.87 -} typedef XENVBDBUS_CHILD_DEVICE_DATA, *PXENVBDBUS_CHILD_DEVICE_DATA, **PPXENVBDBUS_CHILD_DEVICE_DATA;
   12.88 -
   12.89 -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(PXENVBDBUS_CHILD_DEVICE_DATA, GetChildDeviceData);
   12.90 -
   12.91 -typedef struct _XENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION
   12.92 -{
   12.93 -  WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
   12.94 -  PXENVBDBUS_CHILD_DEVICE_DATA DeviceData;
   12.95 -  //ULONG DeviceIndex;
   12.96 -  //char Path[128];
   12.97 -} XENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION, *PXENVBDBUS_DEVICE_IDENTIFICATION_DESCRIPTION;
   12.98 -
   12.99 -#endif
    13.1 --- a/xenvbddev/makefile	Sat Dec 01 23:33:51 2007 +1100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,1 +0,0 @@
    13.4 -!INCLUDE $(NTMAKEENV)\makefile.def
    13.5 \ No newline at end of file
    14.1 --- a/xenvbddev/sources	Sat Dec 01 23:33:51 2007 +1100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,13 +0,0 @@
    14.4 -TARGETNAME=XENVBDDEV
    14.5 -TARGETTYPE=DRIVER
    14.6 -TARGETPATH=..\Target
    14.7 -
    14.8 -MSC_WARNING_LEVEL=/W4
    14.9 -
   14.10 -INCLUDES = ..\common\include;..\common\include\public
   14.11 -
   14.12 -NO_BINPLACE=1
   14.13 -KMDF_VERSION=1
   14.14 -TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib $(DDK_LIB_PATH)\scsiport.lib
   14.15 -
   14.16 -SOURCES=xenvbddev.c
    15.1 --- a/xenvbddev/xenvbddev.c	Sat Dec 01 23:33:51 2007 +1100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,831 +0,0 @@
    15.4 -#include "xenvbddev.h"
    15.5 -#include <io/blkif.h>
    15.6 -#include <scsi.h>
    15.7 -#include <ntddscsi.h>
    15.8 -#include <ntdddisk.h>
    15.9 -#include <stdlib.h>
   15.10 -#include <xen_public.h>
   15.11 -#include <io/xenbus.h>
   15.12 -//#include <ntddft.h>
   15.13 -//#include <ntifs.h>
   15.14 -
   15.15 -#define wmb() KeMemoryBarrier()
   15.16 -#define mb() KeMemoryBarrier()
   15.17 -
   15.18 -DRIVER_INITIALIZE DriverEntry;
   15.19 -
   15.20 -static ULONG
   15.21 -XenVbdDev_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again);
   15.22 -static BOOLEAN
   15.23 -XenVbdDev_HwScsiInitialize(PVOID DeviceExtension);
   15.24 -static BOOLEAN
   15.25 -XenVbdDev_HwScsiStartIo(PVOID DeviceExtension, PSCSI_REQUEST_BLOCK Srb);
   15.26 -//static BOOLEAN
   15.27 -//XenVbdDev_HwScsiInterrupt(PVOID DeviceExtension);
   15.28 -static BOOLEAN
   15.29 -XenVbdDev_HwScsiResetBus(PVOID DeviceExtension, ULONG PathId);
   15.30 -static BOOLEAN
   15.31 -XenVbdDev_HwScsiAdapterState(PVOID DeviceExtension, PVOID Context, BOOLEAN SaveState);
   15.32 -static SCSI_ADAPTER_CONTROL_STATUS
   15.33 -XenVbdDev_HwScsiAdapterControl(PVOID DeviceExtension, SCSI_ADAPTER_CONTROL_TYPE ControlType, PVOID Parameters);
   15.34 -
   15.35 -#ifdef ALLOC_PRAGMA
   15.36 -#pragma alloc_text (INIT, DriverEntry)
   15.37 -#endif
   15.38 -
   15.39 -LIST_ENTRY DeviceListHead;
   15.40 -//XEN_IFACE_EVTCHN EvtChnInterface;
   15.41 -//XEN_IFACE_XENBUS XenBusInterface;
   15.42 -//XEN_IFACE_XEN XenInterface;
   15.43 -XEN_IFACE_GNTTBL GntTblInterface;
   15.44 -
   15.45 -static BOOLEAN AutoEnumerate;
   15.46 -
   15.47 -NTSTATUS
   15.48 -DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   15.49 -{
   15.50 -  ULONG Status;
   15.51 -  HW_INITIALIZATION_DATA HwInitializationData;
   15.52 -
   15.53 -  KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
   15.54 -
   15.55 -  RtlZeroMemory(&HwInitializationData, sizeof(HW_INITIALIZATION_DATA));
   15.56 -
   15.57 -  HwInitializationData.HwInitializationDataSize = sizeof(HW_INITIALIZATION_DATA);
   15.58 -  HwInitializationData.AdapterInterfaceType = Internal; //PNPBus;
   15.59 -  HwInitializationData.HwInitialize = XenVbdDev_HwScsiInitialize;
   15.60 -  HwInitializationData.HwStartIo = XenVbdDev_HwScsiStartIo;
   15.61 -  //HwInitializationData.HwInterrupt = XenVbdDev_HwScsiInterrupt;
   15.62 -  HwInitializationData.HwFindAdapter = XenVbdDev_HwScsiFindAdapter;
   15.63 -  HwInitializationData.HwResetBus = XenVbdDev_HwScsiResetBus;
   15.64 -  HwInitializationData.HwDmaStarted = NULL;
   15.65 -  HwInitializationData.HwAdapterState = NULL;
   15.66 -  HwInitializationData.DeviceExtensionSize = sizeof(XENVBDDEV_DEVICE_DATA);
   15.67 -  HwInitializationData.SpecificLuExtensionSize = 0;
   15.68 -  HwInitializationData.SrbExtensionSize = 0;
   15.69 -  HwInitializationData.NumberOfAccessRanges = 1;
   15.70 -  HwInitializationData.MapBuffers = TRUE; //FALSE;
   15.71 -  HwInitializationData.NeedPhysicalAddresses = FALSE; //TRUE;
   15.72 -  //HwInitializationData.TaggedQueueing = FALSE;
   15.73 -  HwInitializationData.AutoRequestSense = FALSE;
   15.74 -  HwInitializationData.MultipleRequestPerLu = FALSE;
   15.75 -  HwInitializationData.ReceiveEvent = FALSE; // check this
   15.76 -  HwInitializationData.VendorIdLength = 0;
   15.77 -  HwInitializationData.VendorId = NULL;
   15.78 -  HwInitializationData.DeviceIdLength = 0;
   15.79 -  HwInitializationData.DeviceId = NULL;
   15.80 -  HwInitializationData.HwAdapterControl = XenVbdDev_HwScsiAdapterControl;
   15.81 -
   15.82 -  Status = ScsiPortInitialize(DriverObject, RegistryPath, &HwInitializationData, NULL);
   15.83 -
   15.84 -  if(!NT_SUCCESS(Status))
   15.85 -  {
   15.86 -    KdPrint((__DRIVER_NAME " ScsiPortInitialize failed with status 0x%08x\n", Status));
   15.87 -  }
   15.88 -
   15.89 -  KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
   15.90 -
   15.91 -  return Status;
   15.92 -}
   15.93 -
   15.94 -static PMDL
   15.95 -AllocatePages(int Pages)
   15.96 -{
   15.97 -  PMDL Mdl;
   15.98 -  PVOID Buf;
   15.99 -
  15.100 -  Buf = ExAllocatePoolWithTag(NonPagedPool, Pages * PAGE_SIZE, XENVBDDEV_POOL_TAG);
  15.101 -  if (Buf == NULL)
  15.102 -  {
  15.103 -    KdPrint((__DRIVER_NAME "     AllocatePages Failed at ExAllocatePoolWithTag\n"));
  15.104 -  }
  15.105 -  Mdl = IoAllocateMdl(Buf, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
  15.106 -  if (Mdl == NULL)
  15.107 -  {
  15.108 -    KdPrint((__DRIVER_NAME "     AllocatePages Failed at IoAllocateMdl\n"));
  15.109 -  }
  15.110 -  MmBuildMdlForNonPagedPool(Mdl);
  15.111 -  
  15.112 -  return Mdl;
  15.113 -}
  15.114 -
  15.115 -static PMDL
  15.116 -AllocatePage()
  15.117 -{
  15.118 -  return AllocatePages(1);
  15.119 -}
  15.120 -
  15.121 -static VOID
  15.122 -FreePages(PMDL Mdl)
  15.123 -{
  15.124 -  PVOID Buf = MmGetMdlVirtualAddress(Mdl);
  15.125 -  //KdPrint((__DRIVER_NAME "     FreePages Failed at IoAllocateMdl\n"));
  15.126 -  //KdPrint((__DRIVER_NAME "     FreePages Buf = %08x\n", Buf));
  15.127 -  IoFreeMdl(Mdl);
  15.128 -  ExFreePoolWithTag(Buf, XENVBDDEV_POOL_TAG);
  15.129 -}
  15.130 -
  15.131 -static ULONG
  15.132 -XenVbdDev_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
  15.133 -{
  15.134 -  ULONG Status = SP_RETURN_FOUND;
  15.135 -  ULONG i;
  15.136 -  PACCESS_RANGE AccessRange;
  15.137 -  PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
  15.138 -
  15.139 -  KdPrint((__DRIVER_NAME " --> HwScsiFindAdapter\n"));
  15.140 -
  15.141 -  KdPrint((__DRIVER_NAME "     BusInterruptVector = %d\n", ConfigInfo->BusInterruptVector));
  15.142 -
  15.143 -  KdPrint((__DRIVER_NAME "     AccessRanges = %d\n", ConfigInfo->NumberOfAccessRanges));
  15.144 -
  15.145 -  for (i = 0; i < ConfigInfo->NumberOfAccessRanges; i++)
  15.146 -  {
  15.147 -    AccessRange = &(*(ConfigInfo->AccessRanges))[i];
  15.148 -    KdPrint((__DRIVER_NAME "     AccessRange %2d: RangeStart = %08x, RangeLength = %08x, RangeInMemory = %d\n", i, AccessRange->RangeStart.LowPart, AccessRange->RangeLength, AccessRange->RangeInMemory));
  15.149 -    switch (i)
  15.150 -    {
  15.151 -    case 0:
  15.152 -      //DeviceData->ScsiData = ScsiPortGetDeviceBase(DeviceExtension, ConfigInfo->AdapterInterfaceType, ConfigInfo->SystemIoBusNumber, AccessRange->RangeStart, PAGE_SIZE, FALSE);
  15.153 -      //DeviceData->ScsiData = MmMapIoSpace(AccessRange->RangeStart, PAGE_SIZE, MmCached);
  15.154 -      DeviceData->ScsiData = (PXENVBDDEV_SCSI_DATA)AccessRange->RangeStart.LowPart;
  15.155 -      KdPrint((__DRIVER_NAME "     Mapped to virtual address %08x\n", DeviceData->ScsiData));
  15.156 -      if (DeviceData->ScsiData->Magic == SCSI_DATA_MAGIC)
  15.157 -      {
  15.158 -      }
  15.159 -      KdPrint((__DRIVER_NAME "     Magic = %08x\n", DeviceData->ScsiData->Magic));
  15.160 -      break;
  15.161 -    default:
  15.162 -      break;
  15.163 -    }
  15.164 -  }
  15.165 -
  15.166 -  ConfigInfo->NumberOfBuses = 1;
  15.167 -  ConfigInfo->MaximumTransferLength = 45056;
  15.168 -  ConfigInfo->NumberOfPhysicalBreaks = 11 - 1;
  15.169 -  ConfigInfo->ScatterGather = FALSE;
  15.170 -  ConfigInfo->Master = TRUE;
  15.171 -  ConfigInfo->AlignmentMask =  0;
  15.172 -  ConfigInfo->MaximumNumberOfLogicalUnits = 1;
  15.173 -  ConfigInfo->MaximumNumberOfTargets = 2;
  15.174 -
  15.175 -  *Again = FALSE;
  15.176 -
  15.177 -  KdPrint((__DRIVER_NAME " <-- HwScsiFindAdapter\n"));  
  15.178 -
  15.179 -  return Status;
  15.180 -}
  15.181 -
  15.182 -static __inline uint64_t
  15.183 -GET_ID_FROM_FREELIST(PXENVBDDEV_DEVICE_DATA DeviceData)
  15.184 -{
  15.185 -  uint64_t free;
  15.186 -  free = DeviceData->shadow_free;
  15.187 -  DeviceData->shadow_free = DeviceData->shadow[free].req.id;
  15.188 -  DeviceData->shadow[free].req.id = 0x0fffffee; /* debug */
  15.189 -  return free;
  15.190 -}
  15.191 -
  15.192 -static __inline VOID
  15.193 -ADD_ID_TO_FREELIST(PXENVBDDEV_DEVICE_DATA DeviceData, uint64_t Id)
  15.194 -{
  15.195 -  DeviceData->shadow[Id].req.id  = DeviceData->shadow_free;
  15.196 -  DeviceData->shadow[Id].Srb = NULL;
  15.197 -  DeviceData->shadow_free = Id;
  15.198 -}
  15.199 -
  15.200 -//static HANDLE XenVbdDev_ScsiPortThreadHandle;
  15.201 -//static KEVENT XenVbdDev_ScsiPortThreadEvent;
  15.202 -
  15.203 -static VOID
  15.204 -XenVbdDev_Interrupt(PVOID DeviceExtension)
  15.205 -{
  15.206 -  PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
  15.207 -  PSCSI_REQUEST_BLOCK Srb;
  15.208 -  RING_IDX i, rp;
  15.209 -  int j;
  15.210 -  blkif_response_t *rep;
  15.211 -  char *DataBuffer;
  15.212 -  int more_to_do;
  15.213 -  int BlockCount;
  15.214 -  KIRQL KIrql;
  15.215 -  int notify;
  15.216 -  KAPC_STATE ApcState;
  15.217 -  PIRP Irp;
  15.218 -  SCSI_REQUEST_BLOCK TmpSrb;
  15.219 -
  15.220 -  //!!!IRQL_DISPATCH!!!
  15.221 -
  15.222 -  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
  15.223 -
  15.224 -  more_to_do = TRUE;
  15.225 -//  KeAcquireSpinLock(&DeviceData->Lock, &KIrql);
  15.226 -
  15.227 -  while (more_to_do)
  15.228 -  {
  15.229 -    rp = DeviceData->ScsiData->Ring.sring->rsp_prod;
  15.230 -    KeMemoryBarrier();
  15.231 -    for (i = DeviceData->ScsiData->Ring.rsp_cons; i != rp; i++)
  15.232 -    {
  15.233 -      rep = RING_GET_RESPONSE(&DeviceData->ScsiData->Ring, i);
  15.234 -      Srb = DeviceData->shadow[rep->id].Srb;
  15.235 -
  15.236 -      KdPrint((__DRIVER_NAME "     Response Id = %d\n", rep->id));
  15.237 -
  15.238 -      if (rep->status != BLKIF_RSP_OKAY)
  15.239 -      {
  15.240 -        KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
  15.241 -      }
  15.242 -      for (j = 0; j < DeviceData->shadow[rep->id].req.nr_segments; j++)
  15.243 -      {
  15.244 -        GntTblInterface.EndAccess(DeviceData->shadow[rep->id].req.seg[j].gref);
  15.245 -      }
  15.246 -      BlockCount = (Srb->Cdb[7] << 8) | Srb->Cdb[8];
  15.247 -      if (Srb->Cdb[0] == SCSIOP_READ)
  15.248 -      {
  15.249 -        memcpy(Srb->DataBuffer, DeviceData->shadow[rep->id].Buf, BlockCount * DeviceData->ScsiData->BytesPerSector);
  15.250 -        KdPrint((__DRIVER_NAME "     Read Sector = %08X, Sectors = %d\n", (int)DeviceData->shadow[rep->id].req.sector_number, BlockCount));
  15.251 -        KdPrint((__DRIVER_NAME "     (504-511 = %02X%02X%02X%02X%02X%02X%02X%02X)\n", ((PUCHAR)Srb->DataBuffer)[504], ((PUCHAR)Srb->DataBuffer)[505], ((PUCHAR)Srb->DataBuffer)[506], ((PUCHAR)Srb->DataBuffer)[507], ((PUCHAR)Srb->DataBuffer)[508], ((PUCHAR)Srb->DataBuffer)[509], ((PUCHAR)Srb->DataBuffer)[510], ((PUCHAR)Srb->DataBuffer)[511])); 
  15.252 -      }
  15.253 -      else
  15.254 -      {
  15.255 -        KdPrint((__DRIVER_NAME "     Write Sector = %08X, Sectors = %d\n", (int)DeviceData->shadow[rep->id].req.sector_number, BlockCount));
  15.256 -      }
  15.257 -
  15.258 -      FreePages(DeviceData->shadow[rep->id].Mdl);
  15.259 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.260 -      //KdPrint((__DRIVER_NAME "     Attaching to Process %08x\n", DeviceData->Process));
  15.261 -      //KeStackAttachProcess(DeviceData->Process, &ApcState);
  15.262 -      //KdPrint((__DRIVER_NAME "     Attached\n"));
  15.263 -      //ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.264 -      //KdPrint((__DRIVER_NAME "     Detaching\n"));
  15.265 -      //KeUnstackDetachProcess(&ApcState);
  15.266 -      //KdPrint((__DRIVER_NAME "     Detached\n"));
  15.267 -
  15.268 -/*
  15.269 -      RtlZeroMemory(&TmpSrb, sizeof(SCSI_REQUEST_BLOCK));
  15.270 -      TmpSrb.Length = SCSI_REQUEST_BLOCK_SIZE;
  15.271 -      TmpSrb.PathId = LunInfo->PathId;
  15.272 -      TmpSrb.TargetId = LunInfo->TargetId;
  15.273 -      TmpSrb.Lun = LunInfo->Lun;
  15.274 -      TmpSrb.Function = SRB_FUNCTION_CLAIM_DEVICE;
  15.275 -
  15.276 -      Irp = IoBuildDeviceIoControlRequest(IOCTL_SCSI_EXECUTE_NONE, PortDeviceObject, NULL, 0, NULL, 0, TRUE, &Event, &IoStatusBlock);
  15.277 -
  15.278 -      IoCallDriver(DeviceData->DeviceObject, Irp);
  15.279 -*/
  15.280 -
  15.281 -      ADD_ID_TO_FREELIST(DeviceData, rep->id);
  15.282 -    }
  15.283 -
  15.284 -    DeviceData->ScsiData->Ring.rsp_cons = i;
  15.285 -    if (i != DeviceData->ScsiData->Ring.req_prod_pvt)
  15.286 -    {
  15.287 -      RING_FINAL_CHECK_FOR_RESPONSES(&DeviceData->ScsiData->Ring, more_to_do);
  15.288 -    }
  15.289 -    else
  15.290 -    {
  15.291 -      DeviceData->ScsiData->Ring.sring->rsp_event = i + 1;
  15.292 -      more_to_do = FALSE;
  15.293 -    }
  15.294 -  }
  15.295 -
  15.296 -//  ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.297 -
  15.298 -//  KeReleaseSpinLock(&DeviceData->Lock, KIrql);
  15.299 -
  15.300 -  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
  15.301 -
  15.302 -  return;
  15.303 -}
  15.304 -
  15.305 -/*
  15.306 -static VOID
  15.307 -XenVbdDev_ScsiPortThreadProc(PVOID DeviceExtension)
  15.308 -{
  15.309 -  PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
  15.310 -  PSCSI_REQUEST_BLOCK Srb;
  15.311 -  RING_IDX i, rp;
  15.312 -  int j;
  15.313 -  blkif_response_t *rep;
  15.314 -  char *DataBuffer;
  15.315 -  int more_to_do;
  15.316 -  int BlockCount;
  15.317 -  KIRQL KIrql;
  15.318 -  int notify;
  15.319 -
  15.320 -  //!!!IRQL_DISPATCH!!!
  15.321 -
  15.322 -  KdPrint((__DRIVER_NAME " --> ScsiPortThreadProc\n"));
  15.323 -
  15.324 -  for(;;)
  15.325 -  {
  15.326 -    KeWaitForSingleObject(&XenVbdDev_ScsiPortThreadEvent, Executive, KernelMode, FALSE, NULL);
  15.327 -    KdPrint((__DRIVER_NAME " --- Thread woke up\n"));
  15.328 -    more_to_do = TRUE;
  15.329 -//  KeAcquireSpinLock(&DeviceData->Lock, &KIrql);
  15.330 -
  15.331 -    while (more_to_do)
  15.332 -    {
  15.333 -      rp = DeviceData->ScsiData->Ring.sring->rsp_prod;
  15.334 -      KeMemoryBarrier();
  15.335 -      for (i = DeviceData->ScsiData->Ring.rsp_cons; i != rp; i++)
  15.336 -      {
  15.337 -        rep = RING_GET_RESPONSE(&DeviceData->ScsiData->Ring, i);
  15.338 -        Srb = DeviceData->shadow[rep->id].Srb;
  15.339 -  
  15.340 -        KdPrint((__DRIVER_NAME "     Response Id = %d\n", rep->id));
  15.341 -  
  15.342 -        if (rep->status != BLKIF_RSP_OKAY)
  15.343 -        {
  15.344 -          KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
  15.345 -        }
  15.346 -        for (j = 0; j < DeviceData->shadow[rep->id].req.nr_segments; j++)
  15.347 -        {
  15.348 -          GntTblInterface.EndAccess(DeviceData->shadow[rep->id].req.seg[j].gref);
  15.349 -        }
  15.350 -        BlockCount = (Srb->Cdb[7] << 8) | Srb->Cdb[8];
  15.351 -        if (Srb->Cdb[0] == SCSIOP_READ)
  15.352 -        {
  15.353 -          memcpy(Srb->DataBuffer, DeviceData->shadow[rep->id].Buf, BlockCount * DeviceData->ScsiData->BytesPerSector);
  15.354 -          KdPrint((__DRIVER_NAME "     Read Sector = %08X, Sectors = %d\n", (int)DeviceData->shadow[rep->id].req.sector_number, BlockCount));
  15.355 -          KdPrint((__DRIVER_NAME "     (504-511 = %02X%02X%02X%02X%02X%02X%02X%02X)\n", ((PUCHAR)Srb->DataBuffer)[504], ((PUCHAR)Srb->DataBuffer)[505], ((PUCHAR)Srb->DataBuffer)[506], ((PUCHAR)Srb->DataBuffer)[507], ((PUCHAR)Srb->DataBuffer)[508], ((PUCHAR)Srb->DataBuffer)[509], ((PUCHAR)Srb->DataBuffer)[510], ((PUCHAR)Srb->DataBuffer)[511])); 
  15.356 -        }
  15.357 -        else
  15.358 -        {
  15.359 -          KdPrint((__DRIVER_NAME "     Write Sector = %08X, Sectors = %d\n", (int)DeviceData->shadow[rep->id].req.sector_number, BlockCount));
  15.360 -        }
  15.361 -  
  15.362 -        FreePages(DeviceData->shadow[rep->id].Mdl);
  15.363 -        Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.364 -        ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.365 -  
  15.366 -        ADD_ID_TO_FREELIST(DeviceData, rep->id);
  15.367 -      }
  15.368 -  
  15.369 -      DeviceData->ScsiData->Ring.rsp_cons = i;
  15.370 -      if (i != DeviceData->ScsiData->Ring.req_prod_pvt)
  15.371 -      {
  15.372 -        RING_FINAL_CHECK_FOR_RESPONSES(&DeviceData->ScsiData->Ring, more_to_do);
  15.373 -      }
  15.374 -      else
  15.375 -      {
  15.376 -        DeviceData->ScsiData->Ring.sring->rsp_event = i + 1;
  15.377 -        more_to_do = FALSE;
  15.378 -      }
  15.379 -    }
  15.380 -  }
  15.381 -}
  15.382 -
  15.383 -static VOID
  15.384 -XenVbdDev_StartThread(PVOID DeviceExtension)
  15.385 -{
  15.386 -  NTSTATUS Status;
  15.387 -  OBJECT_ATTRIBUTES oa;
  15.388 -
  15.389 -  KdPrint((__DRIVER_NAME " --> StartThread\n"));
  15.390 -
  15.391 -  InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
  15.392 -  Status = PsCreateSystemThread(&XenVbdDev_ScsiPortThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenVbdDev_ScsiPortThreadProc, DeviceExtension);
  15.393 -
  15.394 -  KdPrint((__DRIVER_NAME " <-- StartThread\n"));
  15.395 -}
  15.396 -*/
  15.397 -
  15.398 -static BOOLEAN
  15.399 -XenVbdDev_HwScsiInitialize(PVOID DeviceExtension)
  15.400 -{
  15.401 -  PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
  15.402 -  unsigned int i;
  15.403 -  NTSTATUS Status;
  15.404 -
  15.405 -  KdPrint((__DRIVER_NAME " --> HwScsiInitialize\n"));
  15.406 -
  15.407 -  GntTblInterface = DeviceData->ScsiData->GntTblInterface;
  15.408 -
  15.409 -  KdPrint((__DRIVER_NAME "     A\n"));
  15.410 -
  15.411 -  DeviceData->ScsiData->IsrContext = DeviceExtension;
  15.412 -// might we need a barrier here???
  15.413 -  DeviceData->ScsiData->IsrRoutine = XenVbdDev_Interrupt;
  15.414 -
  15.415 -  KdPrint((__DRIVER_NAME "     B\n"));
  15.416 -
  15.417 -  DeviceData->shadow = ExAllocatePoolWithTag(NonPagedPool, sizeof(blkif_shadow_t) * BLK_RING_SIZE, XENVBDDEV_POOL_TAG);
  15.418 -
  15.419 -  KdPrint((__DRIVER_NAME "     C - %08x\n", DeviceData->shadow));
  15.420 -
  15.421 -  memset(DeviceData->shadow, 0, sizeof(blkif_shadow_t) * BLK_RING_SIZE);
  15.422 -  for (i = 0; i < BLK_RING_SIZE; i++)
  15.423 -    DeviceData->shadow[i].req.id = i + 1;
  15.424 -  DeviceData->shadow_free = 0;
  15.425 -  DeviceData->shadow[BLK_RING_SIZE - 1].req.id = 0x0fffffff;
  15.426 -
  15.427 -  KdPrint((__DRIVER_NAME "     D\n"));
  15.428 -
  15.429 -  KeInitializeSpinLock(&DeviceData->Lock);
  15.430 -
  15.431 -  KdPrint((__DRIVER_NAME "     E\n"));
  15.432 -
  15.433 -//  KeInitializeEvent(&XenVbdDev_ScsiPortThreadEvent, SynchronizationEvent, FALSE);
  15.434 -
  15.435 -  KdPrint((__DRIVER_NAME "     F\n"));
  15.436 -
  15.437 -//  Status = PsCreateSystemThread(&XenVbdDev_ScsiPortThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenVbdDev_ScsiPortThreadProc, DeviceExtension);
  15.438 -
  15.439 -//  ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbdDev_StartThread, 1);
  15.440 -
  15.441 -  DeviceData->Process = IoGetCurrentProcess();
  15.442 -  KdPrint((__DRIVER_NAME "     Process = %08x\n", DeviceData->Process));
  15.443 -
  15.444 -  KdPrint((__DRIVER_NAME " <-- HwScsiInitialize\n"));
  15.445 -
  15.446 -
  15.447 -  return TRUE;
  15.448 -}
  15.449 -
  15.450 -static ULONG
  15.451 -XenVbdDev_FillModePage(PXENVBDDEV_DEVICE_DATA DeviceData, UCHAR PageCode, PUCHAR DataBuffer, ULONG BufferLength, PULONG Offset)
  15.452 -{
  15.453 -  PMODE_RIGID_GEOMETRY_PAGE ModeRigidGeometry;
  15.454 -
  15.455 -  switch (PageCode)
  15.456 -  {
  15.457 -/*
  15.458 -  case MODE_PAGE_RIGID_GEOMETRY:
  15.459 -    if (DeviceData->ScsiData->DeviceType == XENVBD_DEVICETYPE_CDROM)
  15.460 -    {
  15.461 -    KdPrint((__DRIVER_NAME "     MODE_PAGE_RIGID_GEOMETRY\n"));
  15.462 -    if (*Offset + sizeof(MODE_RIGID_GEOMETRY_PAGE) > BufferLength)
  15.463 -      return 1;
  15.464 -    ModeRigidGeometry = (PMODE_RIGID_GEOMETRY_PAGE)(DataBuffer + *Offset);
  15.465 -    memset(ModeRigidGeometry, 0, sizeof(MODE_RIGID_GEOMETRY_PAGE));
  15.466 -    ModeRigidGeometry->PageCode = PageCode;
  15.467 -    ModeRigidGeometry->PageSavable = 0;
  15.468 -    ModeRigidGeometry->PageLength = sizeof(MODE_RIGID_GEOMETRY_PAGE);
  15.469 -    ModeRigidGeometry->NumberOfCylinders[0] = (DeviceData->Geometry.Cylinders.LowPart >> 16) & 0xFF;
  15.470 -    ModeRigidGeometry->NumberOfCylinders[1] = (DeviceData->Geometry.Cylinders.LowPart >> 8) & 0xFF;
  15.471 -    ModeRigidGeometry->NumberOfCylinders[2] = (DeviceData->Geometry.Cylinders.LowPart >> 0) & 0xFF;
  15.472 -    ModeRigidGeometry->NumberOfHeads = DeviceData->Geometry.TracksPerCylinder;
  15.473 -    //ModeRigidGeometry->LandZoneCyclinder = 0;
  15.474 -    ModeRigidGeometry->RoataionRate[0] = 0x05;
  15.475 -    ModeRigidGeometry->RoataionRate[0] = 0x39;
  15.476 -    *Offset += sizeof(MODE_RIGID_GEOMETRY_PAGE);
  15.477 -    }
  15.478 -    break;
  15.479 -*/
  15.480 -  case MODE_PAGE_FAULT_REPORTING:
  15.481 -    break;
  15.482 -  default:
  15.483 -    break;
  15.484 -  }
  15.485 -  return 0;
  15.486 -}
  15.487 -
  15.488 -// Call with device lock held
  15.489 -static VOID
  15.490 -XenVbdDev_PutSrbOnRing(PXENVBDDEV_DEVICE_DATA DeviceData, PSCSI_REQUEST_BLOCK Srb)
  15.491 -{
  15.492 -  //PUCHAR DataBuffer;
  15.493 -  blkif_request_t *req;
  15.494 -  int i;
  15.495 -  int j;
  15.496 -  int BlockCount;
  15.497 -  int sect_offset;
  15.498 -
  15.499 -// can use SRB_STATUS_BUSY to push the SRB back to windows...
  15.500 -
  15.501 -  KdPrint((__DRIVER_NAME " --> PutSrbOnRing\n"));
  15.502 -
  15.503 -  if (RING_FULL(&DeviceData->ScsiData->Ring))
  15.504 -  {
  15.505 -    KdPrint((__DRIVER_NAME "     RING IS FULL - EXPECT BADNESS\n"));
  15.506 -    // TODO: Fail badly here
  15.507 -  }
  15.508 -
  15.509 -  req = RING_GET_REQUEST(&DeviceData->ScsiData->Ring, DeviceData->ScsiData->Ring.req_prod_pvt);
  15.510 -
  15.511 -  //KdPrint((__DRIVER_NAME "     req = %08x\n", req));
  15.512 -
  15.513 -  req->sector_number = (Srb->Cdb[2] << 24) | (Srb->Cdb[3] << 16) | (Srb->Cdb[4] << 8) | Srb->Cdb[5];
  15.514 -  BlockCount = (Srb->Cdb[7] << 8) | Srb->Cdb[8];
  15.515 -
  15.516 -  req->id = GET_ID_FROM_FREELIST(DeviceData);
  15.517 -
  15.518 -  KdPrint((__DRIVER_NAME "     Request Id = %d\n", req->id));
  15.519 -
  15.520 -  if (req->id == 0x0fffffff)
  15.521 -  {
  15.522 -    KdPrint((__DRIVER_NAME "     Something is horribly wrong in PutSrbOnRing\n"));
  15.523 -  }
  15.524 -
  15.525 -  req->handle = 0;
  15.526 -  req->operation = (Srb->Cdb[0] == SCSIOP_READ)?BLKIF_OP_READ:BLKIF_OP_WRITE;
  15.527 -  DeviceData->shadow[req->id].Srb = Srb;
  15.528 -
  15.529 -  DeviceData->shadow[req->id].Mdl = AllocatePages((BlockCount * DeviceData->ScsiData->BytesPerSector + PAGE_SIZE - 1) / PAGE_SIZE);
  15.530 -  DeviceData->shadow[req->id].Buf = MmGetMdlVirtualAddress(DeviceData->shadow[req->id].Mdl);
  15.531 -  if (DeviceData->shadow[req->id].Buf == NULL)
  15.532 -  {
  15.533 -    KdPrint((__DRIVER_NAME "     MmGetMdlVirtualAddress returned NULL in PutSrbOnRing\n"));
  15.534 -  }
  15.535 -  sect_offset = MmGetMdlByteOffset(DeviceData->shadow[req->id].Mdl) >> 9;
  15.536 -  for (i = 0, req->nr_segments = 0; i < BlockCount; req->nr_segments++)
  15.537 -  {
  15.538 -    req->seg[req->nr_segments].gref = GntTblInterface.GrantAccess(0, MmGetMdlPfnArray(DeviceData->shadow[req->id].Mdl)[req->nr_segments], FALSE);
  15.539 -    req->seg[req->nr_segments].first_sect = sect_offset;
  15.540 -    for (j = sect_offset; i < BlockCount && j < PAGE_SIZE / DeviceData->ScsiData->BytesPerSector; j++, i++)
  15.541 -      req->seg[req->nr_segments].last_sect = (uint8_t)j;
  15.542 -    sect_offset = 0;
  15.543 -  }
  15.544 -  if (Srb->Cdb[0] == SCSIOP_READ) // && DeviceData->shadow[req->id].Buf != NULL)
  15.545 -  {
  15.546 -    KdPrint((__DRIVER_NAME "     Read Sector = %08X, Sectors = %d\n", (int)req->sector_number, BlockCount));
  15.547 -  }
  15.548 -  else
  15.549 -  {
  15.550 -    KdPrint((__DRIVER_NAME "     Write Sector = %08X, Sectors = %d\n", (int)req->sector_number, BlockCount));
  15.551 -    memcpy(DeviceData->shadow[req->id].Buf, Srb->DataBuffer, BlockCount * DeviceData->ScsiData->BytesPerSector);
  15.552 -  }
  15.553 -  DeviceData->shadow[req->id].req = *req;
  15.554 -
  15.555 -  DeviceData->ScsiData->Ring.req_prod_pvt++;
  15.556 -
  15.557 -  KdPrint((__DRIVER_NAME " <-- PutSrbOnRing\n"));
  15.558 -}
  15.559 -
  15.560 -static BOOLEAN
  15.561 -XenVbdDev_HwScsiStartIo(PVOID DeviceExtension, PSCSI_REQUEST_BLOCK Srb)
  15.562 -{
  15.563 -  PUCHAR DataBuffer;
  15.564 -  PCDB cdb;
  15.565 -  PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
  15.566 -  unsigned int i;
  15.567 -  KIRQL KIrql;
  15.568 -  int notify;
  15.569 -  SCSI_PHYSICAL_ADDRESS ScsiPhysicalAddress;
  15.570 -  ULONG Length;
  15.571 -
  15.572 -  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
  15.573 -
  15.574 -  KdPrint((__DRIVER_NAME "     Process = %08x\n", IoGetCurrentProcess()));
  15.575 -
  15.576 -  if (Srb->TargetId != 0 || Srb->Lun != 0)
  15.577 -  {
  15.578 -    Srb->SrbStatus = SRB_STATUS_NO_DEVICE;
  15.579 -    ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.580 -    ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.581 -    KdPrint((__DRIVER_NAME " <-- HwScsiStartIo (No Device)\n"));
  15.582 -    return TRUE;
  15.583 -  }
  15.584 -
  15.585 -  switch (Srb->Function)
  15.586 -  {
  15.587 -  case SRB_FUNCTION_EXECUTE_SCSI:
  15.588 -    cdb = (PCDB)Srb->Cdb;
  15.589 -    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
  15.590 -    switch(cdb->CDB6GENERIC.OperationCode)
  15.591 -    {
  15.592 -    case SCSIOP_TEST_UNIT_READY:
  15.593 -      KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
  15.594 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.595 -      Srb->ScsiStatus = 0;
  15.596 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.597 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.598 -      break;
  15.599 -    case SCSIOP_INQUIRY:
  15.600 -      KdPrint((__DRIVER_NAME "     Command = INQUIRY\n"));
  15.601 -      KdPrint((__DRIVER_NAME "     (LUN = %d, EVPD = %d, Page Code = %02X)\n", Srb->Cdb[1] >> 5, Srb->Cdb[1] & 1, Srb->Cdb[2]));
  15.602 -      KdPrint((__DRIVER_NAME "     (Length = %d)\n", Srb->DataTransferLength));
  15.603 -      KdPrint((__DRIVER_NAME "     (Databuffer = %08x)\n", Srb->DataBuffer));
  15.604 -      DataBuffer = Srb->DataBuffer;
  15.605 -      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
  15.606 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.607 -      if ((Srb->Cdb[1] & 1) == 0)
  15.608 -      {
  15.609 -        DataBuffer[0] = DIRECT_ACCESS_DEVICE;
  15.610 -        DataBuffer[1] = 0x00; // not removable
  15.611 -        DataBuffer[3] = 32;
  15.612 -        memcpy(DataBuffer + 8, "James   ", 8); // vendor id
  15.613 -        memcpy(DataBuffer + 16, "XenVBD          ", 16); // product id
  15.614 -        memcpy(DataBuffer + 32, "0000", 4); // product revision level
  15.615 -      }
  15.616 -      else
  15.617 -      {
  15.618 -        switch (Srb->Cdb[2])
  15.619 -        {
  15.620 -        case 0x00:
  15.621 -          DataBuffer[0] = DIRECT_ACCESS_DEVICE;
  15.622 -          DataBuffer[1] = 0x00;
  15.623 -          DataBuffer[2] = 0x00;
  15.624 -          DataBuffer[3] = 2;
  15.625 -          DataBuffer[4] = 0x00;
  15.626 -          DataBuffer[5] = 0x80;
  15.627 -          break;
  15.628 -        case 0x80:
  15.629 -          DataBuffer[0] = DIRECT_ACCESS_DEVICE;
  15.630 -          DataBuffer[1] = 0x80;
  15.631 -          DataBuffer[2] = 0x00;
  15.632 -          DataBuffer[3] = 8;
  15.633 -          DataBuffer[4] = 0x31;
  15.634 -          DataBuffer[5] = 0x32;
  15.635 -          DataBuffer[6] = 0x33;
  15.636 -          DataBuffer[7] = 0x34;
  15.637 -          DataBuffer[8] = 0x35;
  15.638 -          DataBuffer[9] = 0x36;
  15.639 -          DataBuffer[10] = 0x37;
  15.640 -          DataBuffer[11] = 0x38;
  15.641 -          break;
  15.642 -        default:
  15.643 -          KdPrint((__DRIVER_NAME "     Unknown Page %02x requested\n", Srb->Cdb[2]));
  15.644 -          Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
  15.645 -          break;
  15.646 -        }
  15.647 -//        KdPrint((__DRIVER_NAME "     Command = INQUIRY (LUN = %d, EVPD = %d, Page Code = %02X)\n", Srb->Cdb[1] >> 5, Srb->Cdb[1] & 1, Srb->Cdb[2]));
  15.648 -      }
  15.649 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.650 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.651 -      break;
  15.652 -    case SCSIOP_READ_CAPACITY:
  15.653 -      KdPrint((__DRIVER_NAME "     Command = READ_CAPACITY\n"));
  15.654 -      DataBuffer = Srb->DataBuffer;
  15.655 -      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
  15.656 -      DataBuffer[0] = (unsigned char)(DeviceData->ScsiData->TotalSectors >> 24) & 0xff;
  15.657 -      DataBuffer[1] = (unsigned char)(DeviceData->ScsiData->TotalSectors >> 16) & 0xff;
  15.658 -      DataBuffer[2] = (unsigned char)(DeviceData->ScsiData->TotalSectors >> 8) & 0xff;
  15.659 -      DataBuffer[3] = (unsigned char)(DeviceData->ScsiData->TotalSectors >> 0) & 0xff;
  15.660 -      DataBuffer[4] = (unsigned char)(DeviceData->ScsiData->BytesPerSector >> 24) & 0xff;
  15.661 -      DataBuffer[5] = (unsigned char)(DeviceData->ScsiData->BytesPerSector >> 16) & 0xff;
  15.662 -      DataBuffer[6] = (unsigned char)(DeviceData->ScsiData->BytesPerSector >> 8) & 0xff;
  15.663 -      DataBuffer[7] = (unsigned char)(DeviceData->ScsiData->BytesPerSector >> 0) & 0xff;
  15.664 -      Srb->ScsiStatus = 0;
  15.665 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.666 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.667 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.668 -      break;
  15.669 -    case SCSIOP_MODE_SENSE:
  15.670 -      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));
  15.671 -      KdPrint((__DRIVER_NAME "     Length = %d\n", Srb->DataTransferLength));
  15.672 -
  15.673 -      Srb->ScsiStatus = 0;
  15.674 -      Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.675 -      Srb->DataTransferLength = 0;
  15.676 -      ScsiPhysicalAddress = ScsiPortGetPhysicalAddress(DeviceData, Srb, Srb->DataBuffer, &Srb->DataTransferLength);
  15.677 -      DataBuffer = ScsiPortGetVirtualAddress(DeviceData, ScsiPhysicalAddress);
  15.678 -      RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
  15.679 -      switch(cdb->MODE_SENSE.PageCode)
  15.680 -      {
  15.681 -      case MODE_SENSE_RETURN_ALL:
  15.682 -        //Ptr = (UCHAR *)Srb->DataBuffer;
  15.683 -        for (i = 0; i < MODE_SENSE_RETURN_ALL; i++)
  15.684 -        {
  15.685 -          if (XenVbdDev_FillModePage(DeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Srb->DataTransferLength))
  15.686 -          {
  15.687 -            break;
  15.688 -          }
  15.689 -        }
  15.690 -        break;
  15.691 -      default:
  15.692 -        XenVbdDev_FillModePage(DeviceData, cdb->MODE_SENSE.PageCode, DataBuffer, cdb->MODE_SENSE.AllocationLength, &Srb->DataTransferLength);
  15.693 -        break;
  15.694 -      }
  15.695 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.696 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.697 -      break;
  15.698 -    case SCSIOP_READ:
  15.699 -    case SCSIOP_WRITE:
  15.700 -      KdPrint((__DRIVER_NAME "     Command = READ/WRITE\n"));
  15.701 -
  15.702 -      for (i = 0; i < 10; i++)
  15.703 -      {
  15.704 -        KdPrint((__DRIVER_NAME "     %02x: %02x\n", i, Srb->Cdb[i]));
  15.705 -      }
  15.706 -      //KeAcquireSpinLock(&DeviceData->Lock, &KIrql);
  15.707 -
  15.708 -      XenVbdDev_PutSrbOnRing(DeviceData, Srb);
  15.709 -      RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&DeviceData->ScsiData->Ring, notify);
  15.710 -      if (notify)
  15.711 -        DeviceData->ScsiData->NotifyRoutine(DeviceData->ScsiData->NotifyContext);
  15.712 -      //KeReleaseSpinLock(&DeviceData->Lock, KIrql);
  15.713 -//      Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.714 -//      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.715 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.716 -
  15.717 -      break;
  15.718 -    case SCSIOP_REPORT_LUNS:
  15.719 -      KdPrint((__DRIVER_NAME "     Command = REPORT_LUNS\n"));
  15.720 -      Srb->SrbStatus = SRB_STATUS_SUCCESS; //SRB_STATUS_INVALID_REQUEST;
  15.721 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.722 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.723 -      break;
  15.724 -    default:
  15.725 -      KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
  15.726 -      Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
  15.727 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.728 -      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.729 -      break;
  15.730 -    }
  15.731 -    break;
  15.732 -  case SRB_FUNCTION_CLAIM_DEVICE:
  15.733 -    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_CLAIM_DEVICE\n"));
  15.734 -//    ObReferenceObject(WdfDeviceWdmGetDeviceObject(Device));
  15.735 -//    Srb->DataBuffer = WdfDeviceWdmGetDeviceObject(Device);
  15.736 -    Srb->SrbStatus = SRB_STATUS_SUCCESS;
  15.737 -    ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.738 -    ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.739 -    break;
  15.740 -  case SRB_FUNCTION_IO_CONTROL:
  15.741 -    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_IO_CONTROL\n"));
  15.742 -    Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
  15.743 -    ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.744 -    ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.745 -    break;
  15.746 -  case SRB_FUNCTION_FLUSH:
  15.747 -    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_FLUSH\n"));
  15.748 -    Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
  15.749 -    ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.750 -    ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.751 -    break;
  15.752 -  default:
  15.753 -    KdPrint((__DRIVER_NAME "     Unhandled Srb->Function = %08X\n", Srb->Function));
  15.754 -    Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
  15.755 -    ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
  15.756 -    ScsiPortNotification(NextRequest, DeviceExtension, NULL);
  15.757 -    break;
  15.758 -  }
  15.759 -
  15.760 -  KdPrint((__DRIVER_NAME " <-- HwScsiStartIo\n"));
  15.761 -
  15.762 -  return TRUE;
  15.763 -}
  15.764 -
  15.765 -/*
  15.766 -static BOOLEAN
  15.767 -XenVbdDev_HwScsiInterrupt(PVOID DeviceExtension)
  15.768 -{
  15.769 -  KdPrint((__DRIVER_NAME " --> HwScsiInterrupt\n"));
  15.770 -
  15.771 -  KdPrint((__DRIVER_NAME " <-- HwScsiInterrupt\n"));
  15.772 -
  15.773 -  return TRUE;
  15.774 -}
  15.775 -*/
  15.776 -
  15.777 -static BOOLEAN
  15.778 -XenVbdDev_HwScsiResetBus(PVOID DeviceExtension, ULONG PathId)
  15.779 -{
  15.780 -  KdPrint((__DRIVER_NAME " --> HwScsiResetBus\n"));
  15.781 -
  15.782 -  KdPrint((__DRIVER_NAME " <-- HwScsiResetBus\n"));
  15.783 -
  15.784 -  return TRUE;
  15.785 -}
  15.786 -
  15.787 -
  15.788 -static BOOLEAN
  15.789 -XenVbdDev_HwScsiAdapterState(PVOID DeviceExtension, PVOID Context, BOOLEAN SaveState)
  15.790 -{
  15.791 -  KdPrint((__DRIVER_NAME " --> HwScsiAdapterState\n"));
  15.792 -
  15.793 -  KdPrint((__DRIVER_NAME " <-- HwScsiAdapterState\n"));
  15.794 -
  15.795 -  return TRUE;
  15.796 -}
  15.797 -
  15.798 -static SCSI_ADAPTER_CONTROL_STATUS
  15.799 -XenVbdDev_HwScsiAdapterControl(PVOID DeviceExtension, SCSI_ADAPTER_CONTROL_TYPE ControlType, PVOID Parameters)
  15.800 -{
  15.801 -  SCSI_ADAPTER_CONTROL_STATUS Status = ScsiAdapterControlSuccess;
  15.802 -  PSCSI_SUPPORTED_CONTROL_TYPE_LIST SupportedControlTypeList;
  15.803 -
  15.804 -  KdPrint((__DRIVER_NAME " --> HwScsiAdapterControl\n"));
  15.805 -
  15.806 -  switch (ControlType)
  15.807 -  {
  15.808 -  case ScsiQuerySupportedControlTypes:
  15.809 -    SupportedControlTypeList = (PSCSI_SUPPORTED_CONTROL_TYPE_LIST)Parameters;
  15.810 -    KdPrint((__DRIVER_NAME "     ScsiQuerySupportedControlTypes (Max = %d)\n", SupportedControlTypeList->MaxControlType));
  15.811 -    SupportedControlTypeList->SupportedTypeList[ScsiQuerySupportedControlTypes] = TRUE;
  15.812 -    SupportedControlTypeList->SupportedTypeList[ScsiStopAdapter] = TRUE;
  15.813 -    break;
  15.814 -  case ScsiStopAdapter:
  15.815 -    KdPrint((__DRIVER_NAME "     ScsiStopAdapter\n"));
  15.816 -    break;
  15.817 -  case ScsiRestartAdapter:
  15.818 -    KdPrint((__DRIVER_NAME "     ScsiRestartAdapter\n"));
  15.819 -    break;
  15.820 -  case ScsiSetBootConfig:
  15.821 -    KdPrint((__DRIVER_NAME "     ScsiSetBootConfig\n"));
  15.822 -    break;
  15.823 -  case ScsiSetRunningConfig:
  15.824 -    KdPrint((__DRIVER_NAME "     ScsiSetRunningConfig\n"));
  15.825 -    break;
  15.826 -  default:
  15.827 -    KdPrint((__DRIVER_NAME "     UNKNOWN\n"));
  15.828 -    break;
  15.829 -  }
  15.830 -
  15.831 -  KdPrint((__DRIVER_NAME " <-- HwScsiAdapterControl\n"));
  15.832 -
  15.833 -  return Status;
  15.834 -}
    16.1 --- a/xenvbddev/xenvbddev.h	Sat Dec 01 23:33:51 2007 +1100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,107 +0,0 @@
    16.4 -#if !defined(_XENVBDDEV_H_)
    16.5 -#define _XENVBDDEV_H_
    16.6 -
    16.7 -#include <ntifs.h>
    16.8 -#include <ntddk.h>
    16.9 -#include <wdm.h>
   16.10 -#include <wdf.h>
   16.11 -#include <initguid.h>
   16.12 -#include <ntdddisk.h>
   16.13 -#include <srb.h>
   16.14 -
   16.15 -#define NTSTRSAFE_LIB
   16.16 -#include <ntstrsafe.h>
   16.17 -
   16.18 -#include <xen_windows.h>
   16.19 -#include <memory.h>
   16.20 -#include <grant_table.h>
   16.21 -#include <event_channel.h>
   16.22 -#include <hvm/params.h>
   16.23 -#include <hvm/hvm_op.h>
   16.24 -#include <evtchn_public.h>
   16.25 -#include <xenbus_public.h>
   16.26 -#include <gnttbl_public.h>
   16.27 -#include <io/ring.h>
   16.28 -#include <io/blkif.h>
   16.29 -#define __DRIVER_NAME "XenVbdDev"
   16.30 -#define XENVBDDEV_POOL_TAG (ULONG) 'XVBD'
   16.31 -
   16.32 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
   16.33 -#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
   16.34 -
   16.35 -typedef struct {
   16.36 -  blkif_request_t req;
   16.37 -  PSCSI_REQUEST_BLOCK Srb;
   16.38 -  PMDL Mdl;
   16.39 -  VOID *Buf;
   16.40 -} blkif_shadow_t;
   16.41 -
   16.42 -#include "scsidata.h"
   16.43 -
   16.44 -struct
   16.45 -{
   16.46 -  PXENVBDDEV_SCSI_DATA ScsiData;
   16.47 -
   16.48 -  PEPROCESS Process;
   16.49 -
   16.50 -  KSPIN_LOCK Lock;
   16.51 -
   16.52 -  blkif_shadow_t *shadow;
   16.53 -  uint64_t shadow_free;
   16.54 -
   16.55 -  int FastPathUsed;
   16.56 -  int SlowPathUsed;
   16.57 -} typedef XENVBDDEV_DEVICE_DATA, *PXENVBDDEV_DEVICE_DATA;
   16.58 -
   16.59 -/*
   16.60 -struct {
   16.61 -  LIST_ENTRY Entry;
   16.62 -//  KSPIN_LOCK Lock;
   16.63 -//  WDFQUEUE IoDefaultQueue;
   16.64 -  WDFDEVICE Device;
   16.65 -  char Path[128];
   16.66 -  char BackendPath[128];
   16.67 -  ULONG DeviceIndex;
   16.68 -  evtchn_port_t EventChannel;
   16.69 -  //blkif_sring_t *SharedRing;
   16.70 -  ULONG RingBufPFN;
   16.71 -  int BackendState;
   16.72 -  int FrontendState;
   16.73 -  blkif_front_ring_t Ring;
   16.74 -  blkif_shadow_t *shadow;
   16.75 -  uint64_t shadow_free;
   16.76 -
   16.77 -  LIST_ENTRY IrpListHead;
   16.78 -  KSPIN_LOCK IrpListLock;
   16.79 -
   16.80 -  WDFDPC Dpc;
   16.81 -
   16.82 -//  ULONG BytesPerSector;
   16.83 -//  ULONGLONG TotalSectors;
   16.84 -  DISK_GEOMETRY Geometry;
   16.85 -  XENVBD_DEVICETYPE DeviceType;
   16.86 -
   16.87 -  int IrpAddedToList;
   16.88 -  int IrpRemovedFromList;
   16.89 -  int IrpAddedToRing;
   16.90 -  int IrpAddedToRingAtLastNotify;
   16.91 -  int IrpAddedToRingAtLastInterrupt;
   16.92 -  int IrpAddedToRingAtLastDpc;
   16.93 -  int IrpRemovedFromRing;
   16.94 -  int IrpCompleted;
   16.95 -
   16.96 -  int FastPathUsed;
   16.97 -  int SlowPathUsed;
   16.98 -
   16.99 -} typedef XENVBD_CHILD_DEVICE_DATA, *PXENVBD_CHILD_DEVICE_DATA, **PPXENVBD_CHILD_DEVICE_DATA;
  16.100 -
  16.101 -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(PXENVBD_CHILD_DEVICE_DATA, GetChildDeviceData);
  16.102 -
  16.103 -typedef struct _XENVBD_DEVICE_IDENTIFICATION_DESCRIPTION
  16.104 -{
  16.105 -  WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
  16.106 -  PXENVBD_CHILD_DEVICE_DATA DeviceData;
  16.107 -} XENVBD_DEVICE_IDENTIFICATION_DESCRIPTION, *PXENVBD_DEVICE_IDENTIFICATION_DESCRIPTION;
  16.108 -*/
  16.109 -
  16.110 -#endif