win-pvdrivers

changeset 27:37c64fba5fc7 scsiport

Giving up on scsiport...
author James Harper <james.harper@bendigoit.com.au>
date Sat Dec 01 23:33:51 2007 +1100 (2007-12-01)
parents d026b7958f07
children 28803c117324
files common/include/evtchn_public.h target/xenpci.inf target/xenvbdbus.inf target/xenvbddev.inf xenpci/evtchn.c xenpci/xenpci.c xenpci/xenpci.h xenvbdbus/xenvbdbus.c xenvbddev/xenvbddev.c xenvbddev/xenvbddev.h
line diff
     1.1 --- a/common/include/evtchn_public.h	Fri Nov 30 21:33:49 2007 +1100
     1.2 +++ b/common/include/evtchn_public.h	Sat Dec 01 23:33:51 2007 +1100
     1.3 @@ -42,6 +42,7 @@ typedef struct _XENBUS_IFACE_EVTCHN {
     1.4    INTERFACE InterfaceHeader;
     1.5  
     1.6    PXEN_EVTCHN_BIND Bind;
     1.7 +  PXEN_EVTCHN_BIND BindDpc;
     1.8    PXEN_EVTCHN_UNBIND Unbind;
     1.9    PXEN_EVTCHN_MASK Mask;
    1.10    PXEN_EVTCHN_UNMASK Unmask;
     2.1 --- a/target/xenpci.inf	Fri Nov 30 21:33:49 2007 +1100
     2.2 +++ b/target/xenpci.inf	Sat Dec 01 23:33:51 2007 +1100
     2.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     2.4  Class=System
     2.5  ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
     2.6  Provider=%JAMESHARPER%
     2.7 -DriverVer=11/30/2007,0.3.0.5
     2.8 +DriverVer=12/01/2007,0.3.0.13
     2.9  
    2.10  [DestinationDirs]
    2.11  DefaultDestDir = 12
     3.1 --- a/target/xenvbdbus.inf	Fri Nov 30 21:33:49 2007 +1100
     3.2 +++ b/target/xenvbdbus.inf	Sat Dec 01 23:33:51 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=11/30/2007,0.3.0.114
     3.8 +DriverVer=12/01/2007,0.3.0.116
     3.9  
    3.10  [DestinationDirs]
    3.11  DefaultDestDir = 12
     4.1 --- a/target/xenvbddev.inf	Fri Nov 30 21:33:49 2007 +1100
     4.2 +++ b/target/xenvbddev.inf	Sat Dec 01 23:33:51 2007 +1100
     4.3 @@ -3,7 +3,7 @@ Signature="$WINDOWS NT$"
     4.4  Class=SCSIAdapter
     4.5  ClassGuid={4D36E97B-E325-11CE-BFC1-08002BE10318}
     4.6  Provider=%JAMESHARPER%
     4.7 -DriverVer=11/30/2007,0.3.0.59
     4.8 +DriverVer=12/01/2007,0.3.0.70
     4.9  
    4.10  [DestinationDirs]
    4.11  DefaultDestDir = 12
     5.1 --- a/xenpci/evtchn.c	Fri Nov 30 21:33:49 2007 +1100
     5.2 +++ b/xenpci/evtchn.c	Sat Dec 01 23:33:51 2007 +1100
     5.3 @@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     5.4  typedef struct _ev_action_t {
     5.5    PKSERVICE_ROUTINE ServiceRoutine;
     5.6    PVOID ServiceContext;
     5.7 +  BOOLEAN DpcFlag;
     5.8 +  WDFDPC Dpc;
     5.9    ULONG Count;
    5.10  } ev_action_t;
    5.11  
    5.12 @@ -32,6 +34,21 @@ static ev_action_t ev_actions[NR_EVENTS]
    5.13  
    5.14  static unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
    5.15  
    5.16 +typedef struct {
    5.17 +  ev_action_t *Action;
    5.18 +} EVTCHN_DEVICE_DATA, *PEVTCHN_DEVICE_DATA;
    5.19 +
    5.20 +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(EVTCHN_DEVICE_DATA, GetEvtChnDeviceData);
    5.21 +
    5.22 +static VOID
    5.23 +EvtChn_DpcBounce(WDFDPC Dpc)
    5.24 +{
    5.25 +  ev_action_t *Action;
    5.26 +
    5.27 +  Action = GetEvtChnDeviceData(Dpc)->Action;
    5.28 +  Action->ServiceRoutine(NULL, Action->ServiceContext);
    5.29 +}
    5.30 +
    5.31  BOOLEAN
    5.32  EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID)
    5.33  {
    5.34 @@ -69,7 +86,14 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    5.35        else
    5.36        {
    5.37          //KdPrint((__DRIVER_NAME "     Calling Handler for port %d\n", port));
    5.38 -        ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    5.39 +        if (ev_action->DpcFlag)
    5.40 +        {
    5.41 +          WdfDpcEnqueue(ev_action->Dpc);
    5.42 +        }
    5.43 +        else
    5.44 +        {
    5.45 +          ev_action->ServiceRoutine(NULL, ev_action->ServiceContext);
    5.46 +        }
    5.47        }
    5.48        _interlockedbittestandreset((volatile LONG *)&shared_info_area->evtchn_pending[0], port);
    5.49      }
    5.50 @@ -110,6 +134,7 @@ EvtChn_Bind(evtchn_port_t Port, PKSERVIC
    5.51    }
    5.52  
    5.53    ev_actions[Port].ServiceContext = ServiceContext;
    5.54 +  ev_actions[Port].DpcFlag = FALSE;
    5.55    KeMemoryBarrier();
    5.56    ev_actions[Port].ServiceRoutine = ServiceRoutine;
    5.57  
    5.58 @@ -121,6 +146,46 @@ EvtChn_Bind(evtchn_port_t Port, PKSERVIC
    5.59  }
    5.60  
    5.61  NTSTATUS
    5.62 +EvtChn_BindDpc(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext)
    5.63 +{
    5.64 +  WDF_DPC_CONFIG DpcConfig;
    5.65 +  WDF_OBJECT_ATTRIBUTES DpcObjectAttributes;
    5.66 +
    5.67 +  KdPrint((__DRIVER_NAME " --> EvtChn_BindDpc\n"));
    5.68 +
    5.69 +  if(ev_actions[Port].ServiceRoutine != NULL)
    5.70 +  {
    5.71 +    KdPrint((__DRIVER_NAME " Handler for port %d already registered, replacing\n", Port));
    5.72 +    ev_actions[Port].ServiceRoutine = NULL;
    5.73 +    KeMemoryBarrier(); // make sure we don't call the old Service Routine with the new data...
    5.74 +  }
    5.75 +
    5.76 +  ev_actions[Port].ServiceContext = ServiceContext;
    5.77 +  ev_actions[Port].DpcFlag = TRUE;
    5.78 +
    5.79 +KdPrint((__DRIVER_NAME "     A\n"));
    5.80 +  WDF_DPC_CONFIG_INIT(&DpcConfig, EvtChn_DpcBounce);
    5.81 +KdPrint((__DRIVER_NAME "     B\n"));
    5.82 +  WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&DpcObjectAttributes, EVTCHN_DEVICE_DATA);
    5.83 +KdPrint((__DRIVER_NAME "     C\n"));
    5.84 +  DpcObjectAttributes.ParentObject = GlobalDevice;
    5.85 +KdPrint((__DRIVER_NAME "     D\n"));
    5.86 +  WdfDpcCreate(&DpcConfig, &DpcObjectAttributes, &ev_actions[Port].Dpc);
    5.87 +KdPrint((__DRIVER_NAME "     E\n"));
    5.88 +KdPrint((__DRIVER_NAME "     (%08x)\n", GetEvtChnDeviceData(ev_actions[Port].Dpc)));
    5.89 +  GetEvtChnDeviceData(ev_actions[Port].Dpc)->Action = &ev_actions[Port];
    5.90 +
    5.91 +  KeMemoryBarrier(); // make sure that the new service routine is only called once the context is set up
    5.92 +  ev_actions[Port].ServiceRoutine = ServiceRoutine;
    5.93 +
    5.94 +  EvtChn_Unmask(Port);
    5.95 +
    5.96 +  KdPrint((__DRIVER_NAME " <-- EvtChn_BindDpc\n"));
    5.97 +
    5.98 +  return STATUS_SUCCESS;
    5.99 +}
   5.100 +
   5.101 +NTSTATUS
   5.102  EvtChn_Unbind(evtchn_port_t Port)
   5.103  {
   5.104    //KdPrint((__DRIVER_NAME " --> EvtChn_UnBind\n"));
     6.1 --- a/xenpci/xenpci.c	Fri Nov 30 21:33:49 2007 +1100
     6.2 +++ b/xenpci/xenpci.c	Sat Dec 01 23:33:51 2007 +1100
     6.3 @@ -73,7 +73,7 @@ static ULONG irqNumber = 0;
     6.4  
     6.5  static BOOLEAN AutoEnumerate;
     6.6  
     6.7 -static WDFDEVICE Device;
     6.8 +WDFDEVICE GlobalDevice;
     6.9  
    6.10  NTSTATUS
    6.11  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    6.12 @@ -355,18 +355,18 @@ XenPCI_AddDevice(
    6.13    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, XENPCI_DEVICE_DATA);
    6.14  
    6.15    /*create a device instance.*/
    6.16 -  status = WdfDeviceCreate(&DeviceInit, &attributes, &Device);  
    6.17 +  status = WdfDeviceCreate(&DeviceInit, &attributes, &GlobalDevice);  
    6.18    if(!NT_SUCCESS(status))
    6.19    {
    6.20      KdPrint((__DRIVER_NAME "     WdfDeviceCreate failed with status 0x%08x\n", status));
    6.21      return status;
    6.22    }
    6.23  
    6.24 -  WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFilePaging, TRUE);
    6.25 -  WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFileHibernation, TRUE);
    6.26 -  WdfDeviceSetSpecialFileSupport(Device, WdfSpecialFileDump, TRUE);
    6.27 +  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFilePaging, TRUE);
    6.28 +  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFileHibernation, TRUE);
    6.29 +  WdfDeviceSetSpecialFileSupport(GlobalDevice, WdfSpecialFileDump, TRUE);
    6.30  
    6.31 -  status = WdfFdoQueryForInterface(Device, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE) &BusInterface, sizeof(BUS_INTERFACE_STANDARD), 1, NULL);
    6.32 +  status = WdfFdoQueryForInterface(GlobalDevice, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE) &BusInterface, sizeof(BUS_INTERFACE_STANDARD), 1, NULL);
    6.33    if(!NT_SUCCESS(status))
    6.34    {
    6.35      KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface (BusInterface) failed with status 0x%08x\n", status));
    6.36 @@ -379,7 +379,7 @@ XenPCI_AddDevice(
    6.37    busInfo.LegacyBusType = PNPBus;
    6.38    busInfo.BusNumber = 0;
    6.39  
    6.40 -  WdfDeviceSetBusInformationForChildren(Device, &busInfo);
    6.41 +  WdfDeviceSetBusInformationForChildren(GlobalDevice, &busInfo);
    6.42  
    6.43    /*create the default IO queue. this one will 
    6.44    be used for all requests*/
    6.45 @@ -387,7 +387,7 @@ XenPCI_AddDevice(
    6.46    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
    6.47                                  WdfIoQueueDispatchSequential);
    6.48    ioQConfig.EvtIoDefault = XenPCI_IoDefault;
    6.49 -  status = WdfIoQueueCreate(Device, &ioQConfig,
    6.50 +  status = WdfIoQueueCreate(GlobalDevice, &ioQConfig,
    6.51                              WDF_NO_OBJECT_ATTRIBUTES,
    6.52                              &devData->IoDefaultQueue);
    6.53    if(!NT_SUCCESS(status))
    6.54 @@ -397,7 +397,7 @@ XenPCI_AddDevice(
    6.55    }
    6.56  */
    6.57  /*
    6.58 -  status = WdfDeviceCreateDeviceInterface(Device, &GUID_INTERFACE_XENPCI, NULL);
    6.59 +  status = WdfDeviceCreateDeviceInterface(GlobalDevice, &GUID_INTERFACE_XENPCI, NULL);
    6.60    if(!NT_SUCCESS(status))
    6.61    {
    6.62      KdPrint((__DRIVER_NAME "WdfDeviceCreateDeviceInterface failed with status 0x%08x\n", status));
    6.63 @@ -409,7 +409,7 @@ XenPCI_AddDevice(
    6.64    interruptConfig.EvtInterruptEnable = XenPCI_InterruptEnable;
    6.65    interruptConfig.EvtInterruptDisable = XenPCI_InterruptDisable;
    6.66    interruptConfig.ShareVector = WdfTrue;
    6.67 -  status = WdfInterruptCreate(Device, &interruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &XenInterrupt);
    6.68 +  status = WdfInterruptCreate(GlobalDevice, &interruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &XenInterrupt);
    6.69    if (!NT_SUCCESS (status))
    6.70    {
    6.71      KdPrint((__DRIVER_NAME "WdfInterruptCreate failed 0x%08x\n", status));
    6.72 @@ -721,6 +721,7 @@ XenPCI_ChildListCreateDevice(WDFCHILDLIS
    6.73    EvtChnInterface.InterfaceHeader.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
    6.74    EvtChnInterface.InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
    6.75    EvtChnInterface.Bind = EvtChn_Bind;
    6.76 +  EvtChnInterface.BindDpc = EvtChn_BindDpc;
    6.77    EvtChnInterface.Unbind = EvtChn_Unbind;
    6.78    EvtChnInterface.Mask = EvtChn_Mask;
    6.79    EvtChnInterface.Unmask = EvtChn_Unmask;
    6.80 @@ -806,7 +807,7 @@ XenPCI_XenBusWatchHandler(char *Path, PV
    6.81  
    6.82    //KdPrint((__DRIVER_NAME "     %s\n", Path));
    6.83  
    6.84 -  ChildList = WdfFdoGetDefaultChildList(Device);
    6.85 +  ChildList = WdfFdoGetDefaultChildList(GlobalDevice);
    6.86  
    6.87    Bits = SplitString(Path, '/', 3, &Count);
    6.88    switch (Count)
     7.1 --- a/xenpci/xenpci.h	Fri Nov 30 21:33:49 2007 +1100
     7.2 +++ b/xenpci/xenpci.h	Sat Dec 01 23:33:51 2007 +1100
     7.3 @@ -119,6 +119,7 @@ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPC
     7.4  VOID
     7.5  GntTbl_Init();
     7.6  
     7.7 +extern WDFDEVICE GlobalDevice;
     7.8  
     7.9  
    7.10  typedef unsigned long xenbus_transaction_t;
    7.11 @@ -192,6 +193,8 @@ EvtChn_Unmask(evtchn_port_t Port);
    7.12  NTSTATUS
    7.13  EvtChn_Bind(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    7.14  NTSTATUS
    7.15 +EvtChn_BindDpc(evtchn_port_t Port, PKSERVICE_ROUTINE ServiceRoutine, PVOID ServiceContext);
    7.16 +NTSTATUS
    7.17  EvtChn_Unbind(evtchn_port_t Port);
    7.18  NTSTATUS
    7.19  EvtChn_Notify(evtchn_port_t Port);
     8.1 --- a/xenvbdbus/xenvbdbus.c	Fri Nov 30 21:33:49 2007 +1100
     8.2 +++ b/xenvbdbus/xenvbdbus.c	Sat Dec 01 23:33:51 2007 +1100
     8.3 @@ -502,7 +502,7 @@ XenVbdBus_Interrupt(PKINTERRUPT Interrup
     8.4    UNREFERENCED_PARAMETER(Interrupt);
     8.5    // !!!RUNS AT DIRQL!!!
     8.6  
     8.7 -  KdPrint((__DRIVER_NAME " --> XenVbd_Interrupt\n"));
     8.8 +  KdPrint((__DRIVER_NAME " --> XenVbdBus_Interrupt\n"));
     8.9  
    8.10    ChildDeviceData = (PXENVBDBUS_CHILD_DEVICE_DATA)ServiceContext;
    8.11    if (ChildDeviceData->ScsiDeviceData->IsrRoutine != NULL)
    8.12 @@ -510,6 +510,8 @@ XenVbdBus_Interrupt(PKINTERRUPT Interrup
    8.13    else
    8.14      KdPrint((__DRIVER_NAME "     Isr Not Set\n"));  
    8.15  
    8.16 +  KdPrint((__DRIVER_NAME " <-- XenVbdBus_Interrupt\n"));
    8.17 +
    8.18    return STATUS_SUCCESS;
    8.19  }
    8.20  
    8.21 @@ -548,7 +550,7 @@ XenVbdBus_BackEndStateHandler(char *Path
    8.22      WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(&Description.Header, sizeof(Description));
    8.23      Description.DeviceData = DeviceData;
    8.24      DeviceData->EventChannel = EvtChnInterface.AllocUnbound(0);
    8.25 -    EvtChnInterface.Bind(DeviceData->EventChannel, XenVbdBus_Interrupt, DeviceData);
    8.26 +    EvtChnInterface.BindDpc(DeviceData->EventChannel, XenVbdBus_Interrupt, DeviceData);
    8.27      
    8.28      DeviceData->SharedRingMDL = AllocatePage();
    8.29      SharedRing = (blkif_sring_t *)MmGetMdlVirtualAddress(DeviceData->SharedRingMDL);
     9.1 --- a/xenvbddev/xenvbddev.c	Fri Nov 30 21:33:49 2007 +1100
     9.2 +++ b/xenvbddev/xenvbddev.c	Sat Dec 01 23:33:51 2007 +1100
     9.3 @@ -6,7 +6,8 @@
     9.4  #include <stdlib.h>
     9.5  #include <xen_public.h>
     9.6  #include <io/xenbus.h>
     9.7 -#include <ntddft.h>
     9.8 +//#include <ntddft.h>
     9.9 +//#include <ntifs.h>
    9.10  
    9.11  #define wmb() KeMemoryBarrier()
    9.12  #define mb() KeMemoryBarrier()
    9.13 @@ -127,7 +128,7 @@ FreePages(PMDL Mdl)
    9.14  static ULONG
    9.15  XenVbdDev_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
    9.16  {
    9.17 -  NTSTATUS Status = SP_RETURN_FOUND;
    9.18 +  ULONG Status = SP_RETURN_FOUND;
    9.19    ULONG i;
    9.20    PACCESS_RANGE AccessRange;
    9.21    PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
    9.22 @@ -165,7 +166,7 @@ XenVbdDev_HwScsiFindAdapter(PVOID Device
    9.23    ConfigInfo->ScatterGather = FALSE;
    9.24    ConfigInfo->Master = TRUE;
    9.25    ConfigInfo->AlignmentMask =  0;
    9.26 -  ConfigInfo->MaximumNumberOfLogicalUnits = 1; 
    9.27 +  ConfigInfo->MaximumNumberOfLogicalUnits = 1;
    9.28    ConfigInfo->MaximumNumberOfTargets = 2;
    9.29  
    9.30    *Again = FALSE;
    9.31 @@ -193,18 +194,12 @@ ADD_ID_TO_FREELIST(PXENVBDDEV_DEVICE_DAT
    9.32    DeviceData->shadow_free = Id;
    9.33  }
    9.34  
    9.35 -static HANDLE XenVbdDev_ScsiPortThreadHandle;
    9.36 -static KEVENT XenVbdDev_ScsiPortThreadEvent;
    9.37 +//static HANDLE XenVbdDev_ScsiPortThreadHandle;
    9.38 +//static KEVENT XenVbdDev_ScsiPortThreadEvent;
    9.39  
    9.40  static VOID
    9.41  XenVbdDev_Interrupt(PVOID DeviceExtension)
    9.42  {
    9.43 -  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
    9.44 -
    9.45 -  KeSetEvent(&XenVbdDev_ScsiPortThreadEvent, 1, FALSE);
    9.46 -
    9.47 -  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    9.48 -/*
    9.49    PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
    9.50    PSCSI_REQUEST_BLOCK Srb;
    9.51    RING_IDX i, rp;
    9.52 @@ -215,6 +210,9 @@ XenVbdDev_Interrupt(PVOID DeviceExtensio
    9.53    int BlockCount;
    9.54    KIRQL KIrql;
    9.55    int notify;
    9.56 +  KAPC_STATE ApcState;
    9.57 +  PIRP Irp;
    9.58 +  SCSI_REQUEST_BLOCK TmpSrb;
    9.59  
    9.60    //!!!IRQL_DISPATCH!!!
    9.61  
    9.62 @@ -256,7 +254,26 @@ XenVbdDev_Interrupt(PVOID DeviceExtensio
    9.63  
    9.64        FreePages(DeviceData->shadow[rep->id].Mdl);
    9.65        Srb->SrbStatus = SRB_STATUS_SUCCESS;
    9.66 -      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
    9.67 +      //KdPrint((__DRIVER_NAME "     Attaching to Process %08x\n", DeviceData->Process));
    9.68 +      //KeStackAttachProcess(DeviceData->Process, &ApcState);
    9.69 +      //KdPrint((__DRIVER_NAME "     Attached\n"));
    9.70 +      //ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
    9.71 +      //KdPrint((__DRIVER_NAME "     Detaching\n"));
    9.72 +      //KeUnstackDetachProcess(&ApcState);
    9.73 +      //KdPrint((__DRIVER_NAME "     Detached\n"));
    9.74 +
    9.75 +/*
    9.76 +      RtlZeroMemory(&TmpSrb, sizeof(SCSI_REQUEST_BLOCK));
    9.77 +      TmpSrb.Length = SCSI_REQUEST_BLOCK_SIZE;
    9.78 +      TmpSrb.PathId = LunInfo->PathId;
    9.79 +      TmpSrb.TargetId = LunInfo->TargetId;
    9.80 +      TmpSrb.Lun = LunInfo->Lun;
    9.81 +      TmpSrb.Function = SRB_FUNCTION_CLAIM_DEVICE;
    9.82 +
    9.83 +      Irp = IoBuildDeviceIoControlRequest(IOCTL_SCSI_EXECUTE_NONE, PortDeviceObject, NULL, 0, NULL, 0, TRUE, &Event, &IoStatusBlock);
    9.84 +
    9.85 +      IoCallDriver(DeviceData->DeviceObject, Irp);
    9.86 +*/
    9.87  
    9.88        ADD_ID_TO_FREELIST(DeviceData, rep->id);
    9.89      }
    9.90 @@ -278,11 +295,12 @@ XenVbdDev_Interrupt(PVOID DeviceExtensio
    9.91  //  KeReleaseSpinLock(&DeviceData->Lock, KIrql);
    9.92  
    9.93    KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    9.94 -*/
    9.95 +
    9.96    return;
    9.97  }
    9.98  
    9.99 -static void
   9.100 +/*
   9.101 +static VOID
   9.102  XenVbdDev_ScsiPortThreadProc(PVOID DeviceExtension)
   9.103  {
   9.104    PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
   9.105 @@ -298,7 +316,7 @@ XenVbdDev_ScsiPortThreadProc(PVOID Devic
   9.106  
   9.107    //!!!IRQL_DISPATCH!!!
   9.108  
   9.109 -  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
   9.110 +  KdPrint((__DRIVER_NAME " --> ScsiPortThreadProc\n"));
   9.111  
   9.112    for(;;)
   9.113    {
   9.114 @@ -359,33 +377,69 @@ XenVbdDev_ScsiPortThreadProc(PVOID Devic
   9.115    }
   9.116  }
   9.117  
   9.118 +static VOID
   9.119 +XenVbdDev_StartThread(PVOID DeviceExtension)
   9.120 +{
   9.121 +  NTSTATUS Status;
   9.122 +  OBJECT_ATTRIBUTES oa;
   9.123 +
   9.124 +  KdPrint((__DRIVER_NAME " --> StartThread\n"));
   9.125 +
   9.126 +  InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
   9.127 +  Status = PsCreateSystemThread(&XenVbdDev_ScsiPortThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenVbdDev_ScsiPortThreadProc, DeviceExtension);
   9.128 +
   9.129 +  KdPrint((__DRIVER_NAME " <-- StartThread\n"));
   9.130 +}
   9.131 +*/
   9.132 +
   9.133  static BOOLEAN
   9.134  XenVbdDev_HwScsiInitialize(PVOID DeviceExtension)
   9.135  {
   9.136    PXENVBDDEV_DEVICE_DATA DeviceData = (PXENVBDDEV_DEVICE_DATA)DeviceExtension;
   9.137    unsigned int i;
   9.138 -  OBJECT_ATTRIBUTES oa;
   9.139    NTSTATUS Status;
   9.140  
   9.141 +  KdPrint((__DRIVER_NAME " --> HwScsiInitialize\n"));
   9.142 +
   9.143    GntTblInterface = DeviceData->ScsiData->GntTblInterface;
   9.144  
   9.145 +  KdPrint((__DRIVER_NAME "     A\n"));
   9.146 +
   9.147    DeviceData->ScsiData->IsrContext = DeviceExtension;
   9.148  // might we need a barrier here???
   9.149    DeviceData->ScsiData->IsrRoutine = XenVbdDev_Interrupt;
   9.150  
   9.151 +  KdPrint((__DRIVER_NAME "     B\n"));
   9.152 +
   9.153    DeviceData->shadow = ExAllocatePoolWithTag(NonPagedPool, sizeof(blkif_shadow_t) * BLK_RING_SIZE, XENVBDDEV_POOL_TAG);
   9.154 +
   9.155 +  KdPrint((__DRIVER_NAME "     C - %08x\n", DeviceData->shadow));
   9.156 +
   9.157    memset(DeviceData->shadow, 0, sizeof(blkif_shadow_t) * BLK_RING_SIZE);
   9.158    for (i = 0; i < BLK_RING_SIZE; i++)
   9.159      DeviceData->shadow[i].req.id = i + 1;
   9.160    DeviceData->shadow_free = 0;
   9.161    DeviceData->shadow[BLK_RING_SIZE - 1].req.id = 0x0fffffff;
   9.162  
   9.163 +  KdPrint((__DRIVER_NAME "     D\n"));
   9.164 +
   9.165    KeInitializeSpinLock(&DeviceData->Lock);
   9.166  
   9.167 -  KeInitializeEvent(&XenVbdDev_ScsiPortThreadEvent, SynchronizationEvent, FALSE);
   9.168 +  KdPrint((__DRIVER_NAME "     E\n"));
   9.169  
   9.170 -  InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
   9.171 -  Status = PsCreateSystemThread(&XenVbdDev_ScsiPortThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenVbdDev_ScsiPortThreadProc, DeviceExtension);
   9.172 +//  KeInitializeEvent(&XenVbdDev_ScsiPortThreadEvent, SynchronizationEvent, FALSE);
   9.173 +
   9.174 +  KdPrint((__DRIVER_NAME "     F\n"));
   9.175 +
   9.176 +//  Status = PsCreateSystemThread(&XenVbdDev_ScsiPortThreadHandle, THREAD_ALL_ACCESS, &oa, NULL, NULL, XenVbdDev_ScsiPortThreadProc, DeviceExtension);
   9.177 +
   9.178 +//  ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbdDev_StartThread, 1);
   9.179 +
   9.180 +  DeviceData->Process = IoGetCurrentProcess();
   9.181 +  KdPrint((__DRIVER_NAME "     Process = %08x\n", DeviceData->Process));
   9.182 +
   9.183 +  KdPrint((__DRIVER_NAME " <-- HwScsiInitialize\n"));
   9.184 +
   9.185  
   9.186    return TRUE;
   9.187  }
   9.188 @@ -514,6 +568,8 @@ XenVbdDev_HwScsiStartIo(PVOID DeviceExte
   9.189  
   9.190    KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
   9.191  
   9.192 +  KdPrint((__DRIVER_NAME "     Process = %08x\n", IoGetCurrentProcess()));
   9.193 +
   9.194    if (Srb->TargetId != 0 || Srb->Lun != 0)
   9.195    {
   9.196      Srb->SrbStatus = SRB_STATUS_NO_DEVICE;
    10.1 --- a/xenvbddev/xenvbddev.h	Fri Nov 30 21:33:49 2007 +1100
    10.2 +++ b/xenvbddev/xenvbddev.h	Sat Dec 01 23:33:51 2007 +1100
    10.3 @@ -1,6 +1,7 @@
    10.4  #if !defined(_XENVBDDEV_H_)
    10.5  #define _XENVBDDEV_H_
    10.6  
    10.7 +#include <ntifs.h>
    10.8  #include <ntddk.h>
    10.9  #include <wdm.h>
   10.10  #include <wdf.h>
   10.11 @@ -41,6 +42,8 @@ struct
   10.12  {
   10.13    PXENVBDDEV_SCSI_DATA ScsiData;
   10.14  
   10.15 +  PEPROCESS Process;
   10.16 +
   10.17    KSPIN_LOCK Lock;
   10.18  
   10.19    blkif_shadow_t *shadow;