win-pvdrivers

changeset 195:da58a35a8a31

Oops... haven't checked in in a while. 0.8.2 and 3 are somewhere in here :)
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 26 23:06:38 2008 +1100 (2008-02-26)
parents d767540b82c0
children a3bf7c523a4f
files common.inc makedist.bat target/install.bat xenenum/xenenum.c xenhide/xenhide.c xennet/xennet.c xennet/xennet.h xenpci/xenpci.c xenvbd/xenvbd.c xenvbd/xenvbd.h
line diff
     1.1 --- a/common.inc	Fri Feb 22 14:56:36 2008 +1100
     1.2 +++ b/common.inc	Tue Feb 26 23:06:38 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.0.0
     1.5 +VERSION=0.8.3.0
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/makedist.bat	Fri Feb 22 14:56:36 2008 +1100
     2.2 +++ b/makedist.bat	Tue Feb 26 23:06:38 2008 +1100
     2.3 @@ -1,6 +1,9 @@
     2.4  @echo off
     2.5 +cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk W2K && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.6 +cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WXP && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.7 +cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WNET && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.8  cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk x64 WNET && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.9 -cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WNET && CD \Projects\win-pvdrivers.hg && build -cZg"
    2.10 -cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WXP && CD \Projects\win-pvdrivers.hg && build -cZg"
    2.11 +cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WLH && CD \Projects\win-pvdrivers.hg && build -cZg"
    2.12 +cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk x64 WLH && CD \Projects\win-pvdrivers.hg && build -cZg"
    2.13  xcopy target\* dist /E /EXCLUDE:exclude.txt /I /D /Y
    2.14  copy doc\*.txt dist
     3.1 --- a/target/install.bat	Fri Feb 22 14:56:36 2008 +1100
     3.2 +++ b/target/install.bat	Tue Feb 26 23:06:38 2008 +1100
     3.3 @@ -1,27 +1,86 @@
     3.4  @ECHO OFF
     3.5  
     3.6 -ver | find "Version 5.2." > nul
     3.7 -if %ERRORLEVEL% == 0 goto ver_2003
     3.8 +ver | find "Version 5.0." > nul
     3.9 +if %ERRORLEVEL% == 0 goto ver_2k
    3.10  
    3.11  ver | find "Version 5.1." > nul
    3.12  if %ERRORLEVEL% == 0 goto ver_xp
    3.13  
    3.14 -echo No automatic install available or machine not supported.
    3.15 -goto exit
    3.16 +ver | find "Version 5.2." > nul
    3.17 +if %ERRORLEVEL% == 0 goto ver_2k3
    3.18  
    3.19 -:ver_2003
    3.20 -echo Windows 2003 Detected... Installing...
    3.21 -shutdownmon -i
    3.22 -cd winnet
    3.23 -dpinst.exe /LM
    3.24 -echo Done
    3.25 +ver | find "Version 6.0." > nul
    3.26 +if %ERRORLEVEL% == 0 goto ver_2k8
    3.27 +
    3.28 +echo No automatic install available or machine not supported.
    3.29  goto exit
    3.30  
    3.31  :ver_xp
    3.32  echo Windows XP Detected... Installing...
    3.33  shutdownmon -i
    3.34  cd winxp
    3.35 -dpinst.exe /LM
    3.36 +copy /y ..\common\i386\wdfcoinstaller* i386 >nul
    3.37 +copy /y ..\common\i386\dpinst.exe . >nul
    3.38 +dpinst.exe /LM /SA
    3.39 +cd ..
    3.40 +echo Done
    3.41 +goto exit
    3.42 +
    3.43 +:ver_2k
    3.44 +echo Windows 2000 Detected... Installing...
    3.45 +shutdownmon -i
    3.46 +cd win2k
    3.47 +copy /y ..\common\i386\wdfcoinstaller* i386 >nul
    3.48 +copy /y ..\common\i386\dpinst.exe . >nul
    3.49 +dpinst.exe /LM /SA
    3.50 +cd ..
    3.51 +echo Done
    3.52 +goto exit
    3.53 +
    3.54 +
    3.55 +:ver_2k3
    3.56 +if %PROCESSOR_ARCHITECTURE% == AMD64 goto ver_2k3_amd64
    3.57 +echo Windows 2003 (i386) Detected... Installing...
    3.58 +shutdownmon -i
    3.59 +cd winnet
    3.60 +copy /y ..\common\i386\wdfcoinstaller* i386 >nul
    3.61 +copy /y ..\common\i386\dpinst.exe . >nul
    3.62 +dpinst.exe /LM /SA
    3.63 +cd ..
    3.64 +echo Done
    3.65 +goto exit
    3.66 +
    3.67 +:ver_2k3_amd64
    3.68 +echo Windows 2003 (amd64) Detected... Installing...
    3.69 +shutdownmon -i
    3.70 +cd winnet
    3.71 +copy /y ..\common\amd64\wdfcoinstaller* amd64 >nul
    3.72 +copy /y ..\common\amd64\dpinst.exe . >nul
    3.73 +dpinst.exe /LM /SA
    3.74 +cd ..
    3.75 +echo Done
    3.76 +goto exit
    3.77 +
    3.78 +:ver_2k8
    3.79 +if %PROCESSOR_ARCHITECTURE% == AMD64 goto ver_2k8_amd64
    3.80 +echo Windows Vista/2008 (i386) Detected... Installing...
    3.81 +shutdownmon -i
    3.82 +cd winlh
    3.83 +copy /y ..\common\i386\wdfcoinstaller* i386 >nul
    3.84 +copy /y ..\common\i386\dpinst.exe . >nul
    3.85 +dpinst.exe /LM /SA
    3.86 +cd ..
    3.87 +echo Done
    3.88 +goto exit
    3.89 +
    3.90 +:ver_2k8_amd64
    3.91 +echo Windows Vista/2008 (amd64) Detected... Installing...
    3.92 +shutdownmon -i
    3.93 +cd winlh
    3.94 +copy /y ..\common\amd64\wdfcoinstaller* amd64 >nul
    3.95 +copy /y ..\common\amd64\dpinst.exe . >nul
    3.96 +dpinst.exe /LM /SA
    3.97 +cd ..
    3.98  echo Done
    3.99  goto exit
   3.100  
     4.1 --- a/xenenum/xenenum.c	Fri Feb 22 14:56:36 2008 +1100
     4.2 +++ b/xenenum/xenenum.c	Tue Feb 26 23:06:38 2008 +1100
     4.3 @@ -215,17 +215,20 @@ XenEnum_D0EntryPostInterruptsEnabled(WDF
     4.4    PdoDeviceData->WatchContext = Device;
     4.5    xedd->AutoEnumerate = PdoDeviceData->AutoEnumerate;
     4.6  
     4.7 -  // TODO: Should probably do this in an EvtChildListScanForChildren
     4.8 -  msg = xedd->XenInterface.XenBus_List(xedd->XenInterface.InterfaceHeader.Context, XBT_NIL, PdoDeviceData->Path, &Devices);
     4.9 -  if (!msg)
    4.10 +  if (xedd->AutoEnumerate)
    4.11    {
    4.12 -    for (i = 0; Devices[i]; i++)
    4.13 +    // TODO: Should probably do this in an EvtChildListScanForChildren
    4.14 +    msg = xedd->XenInterface.XenBus_List(xedd->XenInterface.InterfaceHeader.Context, XBT_NIL, PdoDeviceData->Path, &Devices);
    4.15 +    if (!msg)
    4.16      {
    4.17 -      KdPrint((__DRIVER_NAME "     found existing device %s\n", Devices[i]));
    4.18 -      KdPrint((__DRIVER_NAME "     faking watch event for %s/%s", PdoDeviceData->Path, Devices[i]));
    4.19 -      RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "%s/%s", PdoDeviceData->Path, Devices[i]);
    4.20 -      XenEnum_WatchHandler(buffer, Device);
    4.21 -      //ExFreePoolWithTag(Devices[i], XENPCI_POOL_TAG);
    4.22 +      for (i = 0; Devices[i]; i++)
    4.23 +      {
    4.24 +        KdPrint((__DRIVER_NAME "     found existing device %s\n", Devices[i]));
    4.25 +        KdPrint((__DRIVER_NAME "     faking watch event for %s/%s", PdoDeviceData->Path, Devices[i]));
    4.26 +        RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "%s/%s", PdoDeviceData->Path, Devices[i]);
    4.27 +        XenEnum_WatchHandler(buffer, Device);
    4.28 +        //ExFreePoolWithTag(Devices[i], XENPCI_POOL_TAG);
    4.29 +      }
    4.30      }
    4.31    }
    4.32  
     5.1 --- a/xenhide/xenhide.c	Fri Feb 22 14:56:36 2008 +1100
     5.2 +++ b/xenhide/xenhide.c	Tue Feb 26 23:06:38 2008 +1100
     5.3 @@ -161,19 +161,19 @@ XenHide_AddDevice(
     5.4    ULONG Length;
     5.5    WCHAR Buffer[1000];
     5.6  
     5.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     5.8 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     5.9  
    5.10    Length = 1000;
    5.11    status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyDeviceDescription, Length, Buffer, &Length);
    5.12 -  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyDeviceDescription = %ws\n", status, Buffer));
    5.13 +//  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyDeviceDescription = %ws\n", status, Buffer));
    5.14  
    5.15    if (!NT_SUCCESS(status) || wcscmp(Buffer, L"PCI bus") != 0)
    5.16    {
    5.17 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.18 +//    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.19      return STATUS_SUCCESS;
    5.20    }
    5.21  
    5.22 -  KdPrint((__DRIVER_NAME " Found\n")); 
    5.23 +//  KdPrint((__DRIVER_NAME " Found\n")); 
    5.24  
    5.25    status = IoCreateDevice (DriverObject,
    5.26      sizeof(DEVICE_EXTENSION),
    5.27 @@ -207,7 +207,7 @@ XenHide_AddDevice(
    5.28        KdPrint((__DRIVER_NAME "     IoRegisterDeviceInterface failed 0x%08x\n", status));
    5.29        return status;
    5.30      }
    5.31 -    KdPrint((__DRIVER_NAME "     IoRegisterDeviceInterface complete, SymbolicLinkName = %wZ\n", &DeviceExtension->InterfaceName));
    5.32 +//    KdPrint((__DRIVER_NAME "     IoRegisterDeviceInterface complete, SymbolicLinkName = %wZ\n", &DeviceExtension->InterfaceName));
    5.33      status = IoSetDeviceInterfaceState(&DeviceExtension->InterfaceName, TRUE);
    5.34      if (!NT_SUCCESS(status))
    5.35      {
    5.36 @@ -217,12 +217,12 @@ XenHide_AddDevice(
    5.37    }
    5.38    else
    5.39    {
    5.40 -    KdPrint((__DRIVER_NAME "     Not registering Interface\n"));
    5.41 +//    KdPrint((__DRIVER_NAME "     Not registering Interface\n"));
    5.42    }
    5.43  
    5.44    deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    5.45  
    5.46 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.47 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.48  
    5.49    return STATUS_SUCCESS;
    5.50  }
    5.51 @@ -250,8 +250,8 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    5.52    UNREFERENCED_PARAMETER(DeviceObject);
    5.53    UNREFERENCED_PARAMETER(Context);
    5.54  
    5.55 -  KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
    5.56 -  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    5.57 +//  KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
    5.58 +//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    5.59  
    5.60    Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
    5.61  
    5.62 @@ -302,7 +302,7 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    5.63      break;
    5.64    }
    5.65      
    5.66 -  KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
    5.67 +//  KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
    5.68  
    5.69    return Irp->IoStatus.Status;
    5.70  }
    5.71 @@ -325,18 +325,18 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
    5.72    PIO_STACK_LOCATION Stack;
    5.73    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    5.74  
    5.75 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.76 -  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    5.77 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.78 +//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    5.79  
    5.80    Stack = IoGetCurrentIrpStackLocation(Irp);
    5.81  
    5.82    switch (Stack->MinorFunction) {
    5.83    case IRP_MN_QUERY_DEVICE_RELATIONS:
    5.84 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
    5.85 +//    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
    5.86      switch (Stack->Parameters.QueryDeviceRelations.Type)
    5.87      {
    5.88      case BusRelations:
    5.89 -      KdPrint((__DRIVER_NAME "       BusRelations\n"));
    5.90 +//      KdPrint((__DRIVER_NAME "       BusRelations\n"));
    5.91        IoCopyCurrentIrpStackLocationToNext(Irp);
    5.92        IoSetCompletionRoutine(Irp, XenHide_IoCompletion, DeviceExtension, TRUE, TRUE, TRUE);
    5.93        break;  
    5.94 @@ -352,7 +352,7 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
    5.95  
    5.96    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
    5.97  
    5.98 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
    5.99 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   5.100  
   5.101    return Status;
   5.102  }
     6.1 --- a/xennet/xennet.c	Fri Feb 22 14:56:36 2008 +1100
     6.2 +++ b/xennet/xennet.c	Tue Feb 26 23:06:38 2008 +1100
     6.3 @@ -26,9 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  #define wmb() KeMemoryBarrier()
     6.5  #define mb() KeMemoryBarrier()
     6.6  
     6.7 -#if !defined (NDIS51_MINIPORT)
     6.8 -#error requires NDIS 5.1 compilation environment
     6.9 -#endif
    6.10 +//#if !defined (NDIS51_MINIPORT)
    6.11 +//#error requires NDIS 5.1 compilation environment
    6.12 +//#endif
    6.13  
    6.14  #define GRANT_INVALID_REF 0
    6.15  
    6.16 @@ -1060,7 +1060,7 @@ XenNet_QueryInformation(
    6.17        temp_data = XN_MAX_PKT_SIZE;
    6.18        break;
    6.19      case OID_GEN_DRIVER_VERSION:
    6.20 -      temp_data = (NDIS_MAJOR_VER << 8) | NDIS_MINOR_VER;
    6.21 +      temp_data = (NDIS_MINIPORT_MAJOR_VERSION << 8) | NDIS_MINIPORT_MINOR_VERSION;
    6.22        len = 2;
    6.23        break;
    6.24      case OID_GEN_MAXIMUM_TOTAL_SIZE:
    6.25 @@ -1748,8 +1748,8 @@ DriverEntry(
    6.26    }
    6.27  
    6.28    /* NDIS 5.1 driver */
    6.29 -  mini_chars.MajorNdisVersion = NDIS_MAJOR_VER;
    6.30 -  mini_chars.MinorNdisVersion = NDIS_MINOR_VER;
    6.31 +  mini_chars.MajorNdisVersion = NDIS_MINIPORT_MAJOR_VERSION;
    6.32 +  mini_chars.MinorNdisVersion = NDIS_MINIPORT_MINOR_VERSION;
    6.33  
    6.34    mini_chars.HaltHandler = XenNet_Halt;
    6.35    mini_chars.InitializeHandler = XenNet_Init;
    6.36 @@ -1760,9 +1760,14 @@ DriverEntry(
    6.37    /* added in v.4 -- use multiple pkts interface */
    6.38    mini_chars.ReturnPacketHandler = XenNet_ReturnPacket;
    6.39    mini_chars.SendPacketsHandler = XenNet_SendPackets;
    6.40 +
    6.41 +#if defined (NDIS51_MINIPORT)
    6.42    /* added in v.5.1 */
    6.43    mini_chars.PnPEventNotifyHandler = XenNet_PnPEventNotify;
    6.44    mini_chars.AdapterShutdownHandler = XenNet_Shutdown;
    6.45 +#else
    6.46 +  // something else here
    6.47 +#endif
    6.48  
    6.49    /* set up upper-edge interface */
    6.50    status = NdisMRegisterMiniport(ndis_wrapper_handle, &mini_chars, sizeof(mini_chars));
     7.1 --- a/xennet/xennet.h	Fri Feb 22 14:56:36 2008 +1100
     7.2 +++ b/xennet/xennet.h	Tue Feb 26 23:06:38 2008 +1100
     7.3 @@ -26,10 +26,12 @@ Foundation, Inc., 51 Franklin Street, Fi
     7.4  #include <wdfminiport.h>
     7.5  #include <initguid.h>
     7.6  #define NDIS_MINIPORT_DRIVER
     7.7 -#define NDIS51_MINIPORT 1
     7.8 +#if NTDDI_VERSION < NTDDI_WINXP
     7.9 +# define NDIS50_MINIPORT 1
    7.10 +#else
    7.11 +# define NDIS51_MINIPORT 1
    7.12 +#endif
    7.13  #include <ndis.h>
    7.14 -#define NDIS_MAJOR_VER 5
    7.15 -#define NDIS_MINOR_VER 1
    7.16  
    7.17  #define NTSTRSAFE_LIB
    7.18  #include <ntstrsafe.h>
     8.1 --- a/xenpci/xenpci.c	Fri Feb 22 14:56:36 2008 +1100
     8.2 +++ b/xenpci/xenpci.c	Tue Feb 26 23:06:38 2008 +1100
     8.3 @@ -846,6 +846,11 @@ XenPCI_XenBusWatchHandler(char *Path, PV
     8.4    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
     8.5  }
     8.6  
     8.7 +struct {
     8.8 +  ULONG do_spin;
     8.9 +  ULONG nr_spinning;
    8.10 +} typedef SUSPEND_INFO, *PSUSPEND_INFO;
    8.11 +
    8.12  static void
    8.13  XenBus_ShutdownHandler(char *Path, PVOID Data)
    8.14  {
    8.15 @@ -855,6 +860,11 @@ XenBus_ShutdownHandler(char *Path, PVOID
    8.16    xenbus_transaction_t xbt;
    8.17    int retry;
    8.18    PSHUTDOWN_MSG_ENTRY Entry;
    8.19 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    8.20 +  KAFFINITY ActiveProcessorMask = 0;
    8.21 +  ULONG ActiveProcessorCount;
    8.22 +  int i;
    8.23 +  PSUSPEND_INFO suspend_info;
    8.24  
    8.25    UNREFERENCED_PARAMETER(Path);
    8.26  
    8.27 @@ -909,11 +919,33 @@ XenBus_ShutdownHandler(char *Path, PVOID
    8.28  
    8.29    if (Value != NULL && strlen(Value) != 0)
    8.30    {
    8.31 -    Entry = (PSHUTDOWN_MSG_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, XENPCI_POOL_TAG);
    8.32 -    Entry->Ptr = 0;
    8.33 -    RtlStringCbPrintfA(Entry->Buf, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, "%s\n", Value);
    8.34 -    InsertTailList(&ShutdownMsgList, &Entry->ListEntry);
    8.35 -    WdfIoQueueStart(ReadQueue);
    8.36 +    if (strcmp(Value, "suspend") == 0)
    8.37 +    {
    8.38 +#if 0
    8.39 +// this won't work this way... 
    8.40 +      if (!xpdd->suspending)
    8.41 +      {
    8.42 +        suspend_info = ExAllocatePoolWithTag(NonPagedPool, sizeof(SUSPEND_INFO), XENPCI_POOL_TAG);
    8.43 +        RtlZeroMemory(suspend_info, sizeof(SUSPEND_INFO);
    8.44 +        xpdd->suspending = 1;
    8.45 +        ActiveProcessorCount = KeQueryActiveProcessorCount(&ActiveProcessorMask);
    8.46 +        for (i = 0; i < ActiveProcessorCount; i++)
    8.47 +        {
    8.48 +          Dpc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KDPC), XENPCI_POOL_TAG);
    8.49 +          KeInitializeDpc(&Dpc, XenPci_Suspend, xpdd);
    8.50 +          KeSetTargetProcessorDpc(&Dpc, i);
    8.51 +          KeInsertQueueDpc(&Dpc, suspend_info, NULL);
    8.52 +        }
    8.53 +#endif
    8.54 +    }
    8.55 +    else
    8.56 +    {
    8.57 +      Entry = (PSHUTDOWN_MSG_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, XENPCI_POOL_TAG);
    8.58 +      Entry->Ptr = 0;
    8.59 +      RtlStringCbPrintfA(Entry->Buf, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, "%s\n", Value);
    8.60 +      InsertTailList(&ShutdownMsgList, &Entry->ListEntry);
    8.61 +      WdfIoQueueStart(ReadQueue);
    8.62 +    }
    8.63    }
    8.64  
    8.65    XenPCI_FreeMem(Value);
     9.1 --- a/xenvbd/xenvbd.c	Fri Feb 22 14:56:36 2008 +1100
     9.2 +++ b/xenvbd/xenvbd.c	Tue Feb 26 23:06:38 2008 +1100
     9.3 @@ -34,7 +34,7 @@ XenVbd_HwScsiAdapterControl(PVOID Device
     9.4  #pragma alloc_text (INIT, DriverEntry)
     9.5  #endif
     9.6  
     9.7 -//static BOOLEAN AutoEnumerate;
     9.8 +static BOOLEAN DumpMode;
     9.9  
    9.10  NTSTATUS
    9.11  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    9.12 @@ -56,7 +56,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    9.13    HwInitializationData.HwResetBus = XenVbd_HwScsiResetBus;
    9.14    HwInitializationData.HwDmaStarted = NULL;
    9.15    HwInitializationData.HwAdapterState = XenVbd_HwScsiAdapterState;
    9.16 -  HwInitializationData.DeviceExtensionSize = sizeof(XENVBD_DEVICE_DATA);
    9.17 +  HwInitializationData.DeviceExtensionSize = sizeof(XENVBD_DEVICE_EXTENSION); //sizeof(XENVBD_DEVICE_DATA);
    9.18    HwInitializationData.SpecificLuExtensionSize = 0;
    9.19    HwInitializationData.SrbExtensionSize = 0;
    9.20    HwInitializationData.NumberOfAccessRanges = 1;
    9.21 @@ -72,6 +72,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    9.22    HwInitializationData.DeviceId = NULL;
    9.23    HwInitializationData.HwAdapterControl = XenVbd_HwScsiAdapterControl;
    9.24  
    9.25 +  DumpMode = FALSE;
    9.26 +
    9.27    Status = ScsiPortInitialize(DriverObject, RegistryPath, &HwInitializationData, NULL);
    9.28  
    9.29    if(!NT_SUCCESS(Status))
    9.30 @@ -109,11 +111,17 @@ XenVbd_Interrupt(PKINTERRUPT Interrupt, 
    9.31  
    9.32    UNREFERENCED_PARAMETER(Interrupt);
    9.33  
    9.34 -//  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
    9.35 +if (DumpMode)
    9.36 +{
    9.37 +  KdPrint((__DRIVER_NAME " --> Interrupt\n"));
    9.38 +}
    9.39  
    9.40    TargetData->PendingInterrupt = TRUE;
    9.41  
    9.42 -//  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    9.43 +if (DumpMode)
    9.44 +{
    9.45 +  KdPrint((__DRIVER_NAME " <-- Interrupt\n"));
    9.46 +}
    9.47  
    9.48    return TRUE;
    9.49  }
    9.50 @@ -142,7 +150,10 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    9.51    PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)TargetData->DeviceData;
    9.52    int more_to_do = TRUE;
    9.53  
    9.54 -//  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
    9.55 +if (DumpMode)
    9.56 +{
    9.57 +  KdPrint((__DRIVER_NAME " --> HwScsiInterruptTarget\n"));
    9.58 +}
    9.59  
    9.60    while (more_to_do)
    9.61    {
    9.62 @@ -187,32 +198,31 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
    9.63          break;
    9.64        case 2:
    9.65          Srb = TargetData->shadow[rep->id].Srb;
    9.66 -        BlockCount = (Srb->Cdb[7] << 8) | Srb->Cdb[8];
    9.67 +        if (Srb != NULL)
    9.68 +        {
    9.69 +          BlockCount = (Srb->Cdb[7] << 8) | Srb->Cdb[8];
    9.70    
    9.71 -        if (rep->status == BLKIF_RSP_OKAY)
    9.72 -          Srb->SrbStatus = SRB_STATUS_SUCCESS;
    9.73 -        else
    9.74 -        {
    9.75 -          KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
    9.76 -          if (Srb->Cdb[0] == SCSIOP_READ)
    9.77 -            KdPrint((__DRIVER_NAME "     Operation = Read\n"));
    9.78 +          if (rep->status == BLKIF_RSP_OKAY)
    9.79 +            Srb->SrbStatus = SRB_STATUS_SUCCESS;
    9.80            else
    9.81 -            KdPrint((__DRIVER_NAME "     Operation = Write\n"));     
    9.82 -          KdPrint((__DRIVER_NAME "     Sector = %08X, Count = %d\n", TargetData->shadow[rep->id].req.sector_number, BlockCount));
    9.83 -          Srb->SrbStatus = SRB_STATUS_ERROR;
    9.84 +          {
    9.85 +            KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
    9.86 +            if (Srb->Cdb[0] == SCSIOP_READ)
    9.87 +              KdPrint((__DRIVER_NAME "     Operation = Read\n"));
    9.88 +            else
    9.89 +              KdPrint((__DRIVER_NAME "     Operation = Write\n"));     
    9.90 +            KdPrint((__DRIVER_NAME "     Sector = %08X, Count = %d\n", TargetData->shadow[rep->id].req.sector_number, BlockCount));
    9.91 +            Srb->SrbStatus = SRB_STATUS_ERROR;
    9.92 +          }
    9.93 +          if (Srb->Cdb[0] == SCSIOP_READ)
    9.94 +            memcpy(Srb->DataBuffer, TargetData->shadow[rep->id].Buf, BlockCount * TargetData->BytesPerSector);
    9.95 +    
    9.96 +          ScsiPortNotification(RequestComplete, DeviceData->DeviceExtension, Srb);
    9.97 +          if (!DumpMode)
    9.98 +            ScsiPortNotification(NextLuRequest, DeviceData->DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
    9.99 +          else
   9.100 +            ScsiPortNotification(NextRequest, DeviceData->DeviceExtension);
   9.101          }
   9.102 -/*
   9.103 -        for (j = 0; j < TargetData->shadow[rep->id].req.nr_segments; j++)
   9.104 -          DeviceData->XenDeviceData->XenInterface.GntTbl_EndAccess(
   9.105 -            DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   9.106 -            TargetData->shadow[rep->id].req.seg[j].gref);
   9.107 -*/
   9.108 -        if (Srb->Cdb[0] == SCSIOP_READ)
   9.109 -          memcpy(Srb->DataBuffer, TargetData->shadow[rep->id].Buf, BlockCount * TargetData->BytesPerSector);
   9.110 -  
   9.111 -        ScsiPortNotification(RequestComplete, DeviceData, Srb);
   9.112 -        ScsiPortNotification(NextLuRequest, DeviceData, Srb->PathId, Srb->TargetId, Srb->Lun);
   9.113 -
   9.114          ADD_ID_TO_FREELIST(TargetData, rep->id);
   9.115        }
   9.116      }
   9.117 @@ -229,7 +239,10 @@ XenVbd_HwScsiInterruptTarget(PVOID Devic
   9.118      }
   9.119    }
   9.120  
   9.121 -//  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
   9.122 +if (DumpMode)
   9.123 +{
   9.124 +  KdPrint((__DRIVER_NAME " <-- HwScsiInterruptTarget\n"));
   9.125 +}
   9.126  }
   9.127  
   9.128  static BOOLEAN
   9.129 @@ -239,9 +252,12 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
   9.130    PXENVBD_TARGET_DATA TargetData;
   9.131    int i, j;
   9.132  
   9.133 -//  KdPrint((__DRIVER_NAME " --> HwScsiInterrupt\n"));
   9.134 +if (DumpMode)
   9.135 +{
   9.136 +  KdPrint((__DRIVER_NAME " --> HwScsiInterrupt\n"));
   9.137 +}
   9.138  
   9.139 -  DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
   9.140 +  DeviceData = ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData;
   9.141  
   9.142    KeMemoryBarrier();
   9.143    for (i = 0; i < SCSI_BUSES; i++)
   9.144 @@ -249,12 +265,15 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
   9.145      for (j = 0; j < SCSI_TARGETS_PER_BUS; j++)
   9.146      {
   9.147        TargetData = &DeviceData->BusData[i].TargetData[j];
   9.148 -      if (TargetData->PendingInterrupt)
   9.149 +      if (TargetData->PendingInterrupt || (TargetData->Present && DumpMode))
   9.150          XenVbd_HwScsiInterruptTarget(TargetData);
   9.151        TargetData->PendingInterrupt = FALSE;
   9.152      }
   9.153    }
   9.154 -//  KdPrint((__DRIVER_NAME " <-- HwScsiInterrupt\n"));
   9.155 +if (DumpMode)
   9.156 +{
   9.157 +  KdPrint((__DRIVER_NAME " <-- HwScsiInterrupt\n"));
   9.158 +}
   9.159  
   9.160    return FALSE;
   9.161  }
   9.162 @@ -614,31 +633,37 @@ XenVbd_WatchHandler(char *Path, PVOID De
   9.163    return;
   9.164  }
   9.165  
   9.166 -static ULONG
   9.167 -XenVbd_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
   9.168 +static VOID
   9.169 +XenVbd_EnumerateExisting(PXENVBD_DEVICE_DATA DeviceData)
   9.170  {
   9.171 -  ULONG i, j;
   9.172 -  PACCESS_RANGE AccessRange;
   9.173 -  PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
   9.174 +  char *msg;
   9.175 +  ULONG i;
   9.176    char **VbdDevices;
   9.177 -  char *msg;
   9.178    char buffer[128];
   9.179 +  int TotalInitialDevices = 0;
   9.180  
   9.181 -  UNREFERENCED_PARAMETER(HwContext);
   9.182 -  UNREFERENCED_PARAMETER(BusInformation);
   9.183 -  UNREFERENCED_PARAMETER(ArgumentString);
   9.184 -  KeInitializeSpinLock(&DeviceData->Lock);
   9.185 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));  
   9.186 -  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   9.187 +  msg = DeviceData->XenDeviceData->XenInterface.XenBus_List(
   9.188 +    DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   9.189 +    XBT_NIL, "device/vbd", &VbdDevices);
   9.190 +  if (!msg)
   9.191 +  {
   9.192 +    for (i = 0; VbdDevices[i]; i++)
   9.193 +    {
   9.194 +      KdPrint((__DRIVER_NAME "     found existing vbd device %s\n", VbdDevices[i]));
   9.195 +      RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "device/vbd/%s/state", VbdDevices[i]);
   9.196 +      XenVbd_WatchHandler(buffer, DeviceData);
   9.197 +      TotalInitialDevices++;
   9.198 +    }  
   9.199 +  }
   9.200 +  DeviceData->TotalInitialDevices = TotalInitialDevices;
   9.201 +}
   9.202  
   9.203 -  // testing this for dump mode
   9.204 -//  if (KeGetCurrentIrql() > ConfigInfo->BusInterruptLevel)
   9.205 -//    ConfigInfo->BusInterruptLevel = KeGetCurrentIrql();
   9.206 -
   9.207 -  KdPrint((__DRIVER_NAME "     BusInterruptLevel = %d\n", ConfigInfo->BusInterruptLevel));
   9.208 -  KdPrint((__DRIVER_NAME "     BusInterruptVector = %d\n", ConfigInfo->BusInterruptVector));
   9.209 -
   9.210 -  KdPrint((__DRIVER_NAME "     AccessRanges = %d\n", ConfigInfo->NumberOfAccessRanges));
   9.211 +static PXENPCI_XEN_DEVICE_DATA
   9.212 +XenVbd_GetXenDeviceData(PPORT_CONFIGURATION_INFORMATION ConfigInfo)
   9.213 +{
   9.214 +  int i;
   9.215 +  PACCESS_RANGE AccessRange;
   9.216 +  PXENPCI_XEN_DEVICE_DATA XenDeviceData = NULL;
   9.217  
   9.218    for (i = 0; i < ConfigInfo->NumberOfAccessRanges; i++)
   9.219    {
   9.220 @@ -647,19 +672,111 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
   9.221      switch (i)
   9.222      {
   9.223      case 0:
   9.224 -      DeviceData->XenDeviceData = (PVOID)(xen_ulong_t)AccessRange->RangeStart.QuadPart;
   9.225 -      KdPrint((__DRIVER_NAME "     Mapped to virtual address %p\n", DeviceData->XenDeviceData));
   9.226 -      KdPrint((__DRIVER_NAME "     Magic = %08x\n", DeviceData->XenDeviceData->Magic));
   9.227 -      if (DeviceData->XenDeviceData->Magic != XEN_DATA_MAGIC)
   9.228 -      {
   9.229 -        KdPrint((__DRIVER_NAME "     Invalid Magic Number\n"));
   9.230 -        return SP_RETURN_NOT_FOUND;
   9.231 -      }
   9.232 +      XenDeviceData = (PVOID)(xen_ulong_t)AccessRange->RangeStart.QuadPart;
   9.233 +      KdPrint((__DRIVER_NAME "     Mapped to virtual address %p\n", XenDeviceData));
   9.234 +      KdPrint((__DRIVER_NAME "     Magic = %08x\n", XenDeviceData->Magic));
   9.235        break;
   9.236      default:
   9.237        break;
   9.238      }
   9.239    }
   9.240 +  return XenDeviceData;
   9.241 +}
   9.242 +
   9.243 +static VOID
   9.244 +XenVbd_InitDeviceData(PXENVBD_DEVICE_DATA DeviceData, PPORT_CONFIGURATION_INFORMATION ConfigInfo)
   9.245 +{
   9.246 +  ULONG i, j;
   9.247 +  PXENPCI_XEN_DEVICE_DATA XenDeviceData;
   9.248 +
   9.249 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));  
   9.250 +
   9.251 +  KeInitializeSpinLock(&DeviceData->Lock);
   9.252 +
   9.253 +  DeviceData->XenDeviceData = XenVbd_GetXenDeviceData(ConfigInfo);
   9.254 +
   9.255 +  for (i = 0; i < SCSI_BUSES; i++)
   9.256 +  {
   9.257 +    for (j = 0; j < SCSI_TARGETS_PER_BUS; j++)
   9.258 +    {
   9.259 +      DeviceData->BusData[i].TargetData[j].Present = 0;
   9.260 +      DeviceData->BusData[i].TargetData[j].DeviceData = DeviceData;
   9.261 +    }
   9.262 +  }
   9.263 +
   9.264 +  DeviceData->XenDeviceData->WatchContext = DeviceData;
   9.265 +  KeMemoryBarrier();
   9.266 +  DeviceData->XenDeviceData->WatchHandler = XenVbd_WatchHandler;
   9.267 +
   9.268 +  DeviceData->EnumeratedDevices = 0;
   9.269 +  DeviceData->TotalInitialDevices = 0;
   9.270 +
   9.271 +  if (DeviceData->XenDeviceData->AutoEnumerate)
   9.272 +  {
   9.273 +    DeviceData->TotalInitialDevices = SCSI_BUSES * SCSI_TARGETS_PER_BUS;
   9.274 +    XenVbd_EnumerateExisting(DeviceData);
   9.275 +  }
   9.276 +
   9.277 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.278 +}
   9.279 +
   9.280 +static ULONG
   9.281 +XenVbd_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
   9.282 +{
   9.283 +  ULONG i, j, k;
   9.284 +  PACCESS_RANGE AccessRange;
   9.285 +  PXENVBD_DEVICE_DATA DeviceData; // = ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData;
   9.286 +  ULONG status;
   9.287 +  PXENPCI_XEN_DEVICE_DATA XenDeviceData;
   9.288 +
   9.289 +  UNREFERENCED_PARAMETER(HwContext);
   9.290 +  UNREFERENCED_PARAMETER(BusInformation);
   9.291 +  UNREFERENCED_PARAMETER(ArgumentString);
   9.292 +
   9.293 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));  
   9.294 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   9.295 +
   9.296 +  KdPrint((__DRIVER_NAME "     BusInterruptLevel = %d\n", ConfigInfo->BusInterruptLevel));
   9.297 +  KdPrint((__DRIVER_NAME "     BusInterruptVector = %d\n", ConfigInfo->BusInterruptVector));
   9.298 +
   9.299 +  KdPrint((__DRIVER_NAME "     AccessRanges = %d\n", ConfigInfo->NumberOfAccessRanges));
   9.300 +
   9.301 +  if (KeGetCurrentIrql() == PASSIVE_LEVEL)
   9.302 +  {
   9.303 +    DeviceData = ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData = ExAllocatePoolWithTag(NonPagedPool, sizeof(XENVBD_DEVICE_DATA), XENVBD_POOL_TAG);
   9.304 +    XenVbd_InitDeviceData(DeviceData, ConfigInfo);
   9.305 +    if (DeviceData->XenDeviceData->Magic != XEN_DATA_MAGIC)
   9.306 +      return SP_RETURN_NOT_FOUND;
   9.307 +  }
   9.308 +  else
   9.309 +  {
   9.310 +    DumpMode = TRUE;
   9.311 +    XenDeviceData = XenVbd_GetXenDeviceData(ConfigInfo);
   9.312 +    if (XenDeviceData == NULL || XenDeviceData->Magic != XEN_DATA_MAGIC)
   9.313 +    {
   9.314 +      return SP_RETURN_NOT_FOUND;
   9.315 +    }
   9.316 +    DeviceData = XenDeviceData->WatchContext;
   9.317 +    ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData = DeviceData;
   9.318 +    DeviceData->XenDeviceData->WatchHandler = XenVbd_WatchHandler;
   9.319 +
   9.320 +
   9.321 +    for (i = 0; i < SCSI_BUSES; i++)
   9.322 +    {
   9.323 +      for (j = 0; j < SCSI_TARGETS_PER_BUS; j++)
   9.324 +      {
   9.325 +        for (k = 0; k < max(BLK_RING_SIZE, BLK_OTHER_RING_SIZE); k++)
   9.326 +        {
   9.327 +          if (DeviceData->BusData[i].TargetData[j].Present)
   9.328 +            DeviceData->BusData[i].TargetData[j].shadow[k].Srb = NULL;
   9.329 +        }
   9.330 +      }
   9.331 +    }
   9.332 +  }
   9.333 +  KdPrint((__DRIVER_NAME "     DeviceData = %p\n", DeviceData));
   9.334 +
   9.335 +  DeviceData->DeviceExtension = DeviceExtension;
   9.336 +
   9.337  #if defined(__x86_64__)
   9.338    ConfigInfo->Master = TRUE; // Won't work under x64 without this...
   9.339  #endif
   9.340 @@ -674,47 +791,13 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
   9.341    }
   9.342    ConfigInfo->MaximumNumberOfLogicalUnits = 1;
   9.343    ConfigInfo->MaximumNumberOfTargets = SCSI_TARGETS_PER_BUS;
   9.344 -//  ConfigInfo->TaggedQueueing = TRUE;
   9.345    if (ConfigInfo->Dma64BitAddresses == SCSI_DMA64_SYSTEM_SUPPORTED)
   9.346      ConfigInfo->Dma64BitAddresses = SCSI_DMA64_MINIPORT_SUPPORTED;
   9.347 +
   9.348    // This all has to be initialized here as the real Initialize routine
   9.349    // is called at DIRQL, and the XenBus stuff has to be called at
   9.350    // <= DISPATCH_LEVEL
   9.351  
   9.352 -  for (i = 0; i < SCSI_BUSES; i++)
   9.353 -  {
   9.354 -    for (j = 0; j < SCSI_TARGETS_PER_BUS; j++)
   9.355 -    {
   9.356 -      DeviceData->BusData[i].TargetData[j].Present = 0;
   9.357 -      DeviceData->BusData[i].TargetData[j].DeviceData = DeviceData;
   9.358 -    }
   9.359 -  }
   9.360 -
   9.361 -  DeviceData->XenDeviceData->WatchContext = DeviceExtension;
   9.362 -  KeMemoryBarrier();
   9.363 -  DeviceData->XenDeviceData->WatchHandler = XenVbd_WatchHandler;
   9.364 -
   9.365 -//  KeInitializeEvent(&DeviceData->WaitDevicesEvent, SynchronizationEvent, FALSE);  
   9.366 -  DeviceData->EnumeratedDevices = 0;
   9.367 -  DeviceData->TotalInitialDevices = 0;
   9.368 -
   9.369 -  if (DeviceData->XenDeviceData->AutoEnumerate)
   9.370 -  {
   9.371 -    msg = DeviceData->XenDeviceData->XenInterface.XenBus_List(
   9.372 -      DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   9.373 -      XBT_NIL, "device/vbd", &VbdDevices);
   9.374 -    if (!msg)
   9.375 -    {
   9.376 -      for (i = 0; VbdDevices[i]; i++)
   9.377 -      {
   9.378 -        KdPrint((__DRIVER_NAME "     found existing vbd device %s\n", VbdDevices[i]));
   9.379 -        RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "device/vbd/%s/state", VbdDevices[i]);
   9.380 -        XenVbd_WatchHandler(buffer, DeviceData);
   9.381 -        DeviceData->TotalInitialDevices++;
   9.382 -      }  
   9.383 -    }
   9.384 -  }
   9.385 -
   9.386    *Again = FALSE;
   9.387  
   9.388    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));  
   9.389 @@ -728,11 +811,13 @@ XenVbd_CheckBusChangedTimer(PVOID Device
   9.390  static VOID 
   9.391  XenVbd_CheckBusEnumeratedTimer(PVOID DeviceExtension)
   9.392  {
   9.393 -  PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
   9.394 +  PXENVBD_DEVICE_DATA DeviceData = ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData;
   9.395  
   9.396 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.397 -//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   9.398 -
   9.399 +if (DumpMode)
   9.400 +{
   9.401 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   9.402 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   9.403 +}
   9.404    if (DeviceData->EnumeratedDevices >= DeviceData->TotalInitialDevices)
   9.405    {
   9.406      DeviceData->BusChangePending = 0;
   9.407 @@ -743,17 +828,20 @@ XenVbd_CheckBusEnumeratedTimer(PVOID Dev
   9.408    {
   9.409      ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbd_CheckBusEnumeratedTimer, 100000);
   9.410    }
   9.411 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.412 +if (DumpMode)
   9.413 +{
   9.414 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.415 +}
   9.416  }
   9.417  
   9.418  static VOID 
   9.419  XenVbd_CheckBusChangedTimer(PVOID DeviceExtension)
   9.420  {
   9.421 -  PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
   9.422 +  PXENVBD_DEVICE_DATA DeviceData = ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData;
   9.423  
   9.424    if (DeviceData->BusChangePending)
   9.425    {
   9.426 -    ScsiPortNotification(BusChangeDetected, DeviceData, 0);
   9.427 +    ScsiPortNotification(BusChangeDetected, DeviceExtension, 0);
   9.428      DeviceData->BusChangePending = 0;
   9.429    }
   9.430    ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbd_CheckBusChangedTimer, 1000000);
   9.431 @@ -901,13 +989,16 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   9.432  {
   9.433    PUCHAR DataBuffer;
   9.434    PCDB cdb;
   9.435 -  PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
   9.436 +  PXENVBD_DEVICE_DATA DeviceData = ((PXENVBD_DEVICE_EXTENSION)DeviceExtension)->XenVbdDeviceData;
   9.437    PXENVBD_TARGET_DATA TargetData;
   9.438    unsigned int i;
   9.439    int notify;
   9.440  
   9.441 -//  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
   9.442 -//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   9.443 +if (DumpMode)
   9.444 +{
   9.445 +  KdPrint((__DRIVER_NAME " --> HwScsiStartIo PathId = %d, TargetId = %d, Lun = %d\n", Srb->PathId, Srb->TargetId, Srb->Lun));
   9.446 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   9.447 +}
   9.448  
   9.449    // If we haven't enumerated all the devices yet then just defer the request
   9.450    // A timer will issue a NextRequest to get things started again...
   9.451 @@ -943,7 +1034,10 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   9.452    {
   9.453    case SRB_FUNCTION_EXECUTE_SCSI:
   9.454      cdb = (PCDB)Srb->Cdb;
   9.455 -//    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   9.456 +if (DumpMode)
   9.457 +{
   9.458 +    KdPrint((__DRIVER_NAME "     SRB_FUNCTION_EXECUTE_SCSI\n"));
   9.459 +}
   9.460      switch(cdb->CDB6GENERIC.OperationCode)
   9.461      {
   9.462      case SCSIOP_TEST_UNIT_READY:
   9.463 @@ -958,10 +1052,6 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   9.464        KdPrint((__DRIVER_NAME "     (LUN = %d, EVPD = %d, Page Code = %02X)\n", Srb->Cdb[1] >> 5, Srb->Cdb[1] & 1, Srb->Cdb[2]));
   9.465        KdPrint((__DRIVER_NAME "     (Length = %d)\n", Srb->DataTransferLength));
   9.466        KdPrint((__DRIVER_NAME "     (Srb->Databuffer = %08x)\n", Srb->DataBuffer));
   9.467 -//      KdPrint((__DRIVER_NAME "     PhysicalAddress.LowPart = %08x\n", ScsiPortGetPhysicalAddress(DeviceData, Srb, Srb->DataBuffer, &Length).LowPart));
   9.468 -//      DataBuffer = ScsiPortGetVirtualAddress(DeviceData, ScsiPortGetPhysicalAddress(DeviceData, Srb, Srb->DataBuffer, &Length));
   9.469 -//      KdPrint((__DRIVER_NAME "     (Databuffer = %08x)\n", DataBuffer));
   9.470 -//      break;
   9.471        DataBuffer = Srb->DataBuffer;
   9.472        RtlZeroMemory(DataBuffer, Srb->DataTransferLength);
   9.473        Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.474 @@ -1108,18 +1198,28 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   9.475        break;
   9.476      case SCSIOP_READ:
   9.477      case SCSIOP_WRITE:
   9.478 -//      KdPrint((__DRIVER_NAME "     Command = READ/WRITE\n"));
   9.479 +if (DumpMode)
   9.480 +{
   9.481 +      KdPrint((__DRIVER_NAME "     Command = READ/WRITE\n"));
   9.482 +}
   9.483        XenVbd_PutSrbOnRing(TargetData, Srb);
   9.484        RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&TargetData->Ring, notify);
   9.485        if (notify)
   9.486          DeviceData->XenDeviceData->XenInterface.EvtChn_Notify(
   9.487            DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   9.488            TargetData->EventChannel);
   9.489 -      if (!RING_FULL(&TargetData->Ring))
   9.490 +      if (!RING_FULL(&TargetData->Ring) && !DumpMode)
   9.491          ScsiPortNotification(NextLuRequest, DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
   9.492        else
   9.493          ScsiPortNotification(NextRequest, DeviceExtension);
   9.494        break;
   9.495 +    case SCSIOP_VERIFY:
   9.496 +      // Should we do more here?
   9.497 +      KdPrint((__DRIVER_NAME "     Command = VERIFY\n"));
   9.498 +      Srb->SrbStatus = SRB_STATUS_SUCCESS; //SRB_STATUS_INVALID_REQUEST;
   9.499 +      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);      
   9.500 +      ScsiPortNotification(NextLuRequest, DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
   9.501 +      break;
   9.502      case SCSIOP_REPORT_LUNS:
   9.503        KdPrint((__DRIVER_NAME "     Command = REPORT_LUNS\n"));
   9.504        Srb->SrbStatus = SRB_STATUS_SUCCESS; //SRB_STATUS_INVALID_REQUEST;
   9.505 @@ -1171,6 +1271,12 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   9.506        ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
   9.507        ScsiPortNotification(NextRequest, DeviceExtension, NULL);
   9.508        break;
   9.509 +    case SCSIOP_START_STOP_UNIT:
   9.510 +      KdPrint((__DRIVER_NAME "     Command = SCSIOP_START_STOP_UNIT\n"));
   9.511 +      Srb->SrbStatus = SRB_STATUS_SUCCESS;
   9.512 +      ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
   9.513 +      ScsiPortNotification(NextRequest, DeviceExtension, NULL);
   9.514 +      break;
   9.515      default:
   9.516        KdPrint((__DRIVER_NAME "     Unhandled EXECUTE_SCSI Command = %02X\n", Srb->Cdb[0]));
   9.517        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
   9.518 @@ -1207,8 +1313,10 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   9.519      break;
   9.520    }
   9.521  
   9.522 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.523 -
   9.524 +if (DumpMode)
   9.525 +{
   9.526 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   9.527 +}
   9.528    return TRUE;
   9.529  }
   9.530  
    10.1 --- a/xenvbd/xenvbd.h	Fri Feb 22 14:56:36 2008 +1100
    10.2 +++ b/xenvbd/xenvbd.h	Tue Feb 26 23:06:38 2008 +1100
    10.3 @@ -117,6 +117,13 @@ struct
    10.4  
    10.5    LONG EnumeratedDevices;
    10.6    int TotalInitialDevices;
    10.7 +
    10.8 +  PVOID DeviceExtension;
    10.9  } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
   10.10  
   10.11 +struct
   10.12 +{
   10.13 +  PXENVBD_DEVICE_DATA XenVbdDeviceData;  
   10.14 +} typedef XENVBD_DEVICE_EXTENSION, *PXENVBD_DEVICE_EXTENSION;
   10.15 +
   10.16  #endif