win-pvdrivers

changeset 124:edbeec8025e8

Updates to xenvbd to try and get it to do a memory dump.
Started changes to make the code compile under AMD64.
author James Harper <james.harper@bendigoit.com.au>
date Wed Jan 16 21:11:53 2008 +1100 (2008-01-16)
parents 99969d3c2c62
children 403f2c20466e
files TODO.txt common/include/hypercall.h common/include/xen_windows.h xennet/sources xennet/xennet.c xenpci/evtchn.c xenpci/gnttbl.c xenpci/hypercall_x86.h xenpci/xenpci.c xenpci/xenpci.h xenvbd/sources xenvbd/xenvbd.c
line diff
     1.1 --- a/TODO.txt	Tue Jan 15 13:33:03 2008 +1100
     1.2 +++ b/TODO.txt	Wed Jan 16 21:11:53 2008 +1100
     1.3 @@ -2,7 +2,7 @@ The source code still needs a tidy up. T
     1.4  get to that as soon as I figure out what coding style to use and where.
     1.5  
     1.6  Known problems or things that need doing to make it properly useful:
     1.7 -. Test under envirnments other than 32-bit PAE Windows 2003. Almost certainly won't work under 64 bit
     1.8 +. Test under environments other than 32-bit PAE Windows 2003. Almost certainly won't work under 64 bit
     1.9  . No power management
    1.10  . Almost certainly won't support migration or suspend/resume.
    1.11  . Reports of problems on Intel systems
    1.12 @@ -11,7 +11,8 @@ Known problems or things that need doing
    1.13  
    1.14  TODO:
    1.15  . Do some performance testing
    1.16 -. network adapters (vif) (Andy Grover is looking at this)
    1.17  . virtual scsi (eg a front end for the scsi passthrough stuff)
    1.18  . balloon drivers (this should actually be pretty easy)
    1.19  . Write an installer for the above binaries to automate everything
    1.20 +. Fix crash dump under vbd (currently just hangs)
    1.21 +. Correctly handle CD changes
     2.1 --- a/common/include/hypercall.h	Tue Jan 15 13:33:03 2008 +1100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,153 +0,0 @@
     2.4 -/*
     2.5 -PV Drivers for Windows Xen HVM Domains
     2.6 -Copyright (C) 2007 James Harper
     2.7 -
     2.8 -This program is free software; you can redistribute it and/or
     2.9 -modify it under the terms of the GNU General Public License
    2.10 -as published by the Free Software Foundation; either version 2
    2.11 -of the License, or (at your option) any later version.
    2.12 -
    2.13 -This program is distributed in the hope that it will be useful,
    2.14 -but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.16 -GNU General Public License for more details.
    2.17 -
    2.18 -You should have received a copy of the GNU General Public License
    2.19 -along with this program; if not, write to the Free Software
    2.20 -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2.21 -*/
    2.22 -
    2.23 -#include "xenpci.h"
    2.24 -
    2.25 -static __inline int
    2.26 -HYPERVISOR_memory_op(WDFDEVICE Device, int cmd, void *arg)
    2.27 -{
    2.28 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    2.29 -  long __res;
    2.30 -  __asm {
    2.31 -    mov ebx, cmd
    2.32 -    mov ecx, arg
    2.33 -    mov eax, hypercall_stubs
    2.34 -    add eax, (__HYPERVISOR_memory_op * 32)
    2.35 -    call eax
    2.36 -    mov [__res], eax
    2.37 -  }
    2.38 -  return __res;
    2.39 -}
    2.40 -
    2.41 -static __inline int
    2.42 -HYPERVISOR_xen_version(WDFDEVICE Device, int cmd, void *arg)
    2.43 -{
    2.44 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    2.45 -  long __res;
    2.46 -  __asm {
    2.47 -    mov ebx, cmd
    2.48 -    mov ecx, arg
    2.49 -    mov eax, hypercall_stubs
    2.50 -    add eax, (__HYPERVISOR_xen_version * 32)
    2.51 -    call eax
    2.52 -    mov [__res], eax
    2.53 -  }
    2.54 -  return __res;
    2.55 -}
    2.56 -
    2.57 -static __inline int
    2.58 -HYPERVISOR_grant_table_op(WDFDEVICE Device, int cmd, void *uop, unsigned int count)
    2.59 -{
    2.60 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    2.61 -  long __res;
    2.62 -  __asm {
    2.63 -    mov ebx, cmd
    2.64 -    mov ecx, uop
    2.65 -    mov edx, count
    2.66 -    mov eax, hypercall_stubs
    2.67 -    add eax, (__HYPERVISOR_grant_table_op * 32)
    2.68 -    call eax
    2.69 -    mov [__res], eax
    2.70 -  }
    2.71 -  return __res;
    2.72 -}
    2.73 -
    2.74 -static __inline int
    2.75 -HYPERVISOR_mmu_update(WDFDEVICE Device, mmu_update_t *req, int count, int *success_count, domid_t domid)
    2.76 -{
    2.77 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    2.78 -  long __res;
    2.79 -  long _domid = (long)domid;
    2.80 -  __asm {
    2.81 -    mov ebx, req
    2.82 -    mov ecx, count
    2.83 -    mov edx, success_count
    2.84 -    mov edi, _domid
    2.85 -    mov eax, hypercall_stubs
    2.86 -    add eax, (__HYPERVISOR_mmu_update * 32)
    2.87 -    call eax
    2.88 -    mov [__res], eax
    2.89 -  }
    2.90 -  return __res;
    2.91 -}
    2.92 -
    2.93 -static __inline int
    2.94 -HYPERVISOR_console_io(WDFDEVICE Device, int cmd, int count, char *string)
    2.95 -{
    2.96 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    2.97 -  long __res;
    2.98 -  __asm {
    2.99 -    mov ebx, cmd
   2.100 -    mov ecx, count
   2.101 -    mov edx, string
   2.102 -    mov eax, hypercall_stubs
   2.103 -    add eax, (__HYPERVISOR_console_io * 32)
   2.104 -    call eax
   2.105 -    mov [__res], eax
   2.106 -  }
   2.107 -  return __res;
   2.108 -}
   2.109 -
   2.110 -static __inline int
   2.111 -HYPERVISOR_hvm_op(WDFDEVICE Device, int op, struct xen_hvm_param *arg)
   2.112 -{
   2.113 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
   2.114 -  long __res;
   2.115 -  __asm {
   2.116 -    mov ebx, op
   2.117 -    mov ecx, arg
   2.118 -    mov eax, hypercall_stubs
   2.119 -    add eax, (__HYPERVISOR_hvm_op * 32)
   2.120 -    call eax
   2.121 -    mov [__res], eax
   2.122 -  }
   2.123 -  return __res;
   2.124 -}
   2.125 -
   2.126 -static __inline int
   2.127 -HYPERVISOR_event_channel_op(WDFDEVICE Device, int cmd, void *op)
   2.128 -{
   2.129 -  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
   2.130 -  long __res;
   2.131 -  __asm {
   2.132 -    mov ebx, cmd
   2.133 -    mov ecx, op
   2.134 -    mov eax, hypercall_stubs
   2.135 -    add eax, (__HYPERVISOR_event_channel_op * 32)
   2.136 -    call eax
   2.137 -    mov [__res], eax
   2.138 -  }
   2.139 -  return __res;
   2.140 -}
   2.141 -
   2.142 -static __inline ULONGLONG
   2.143 -hvm_get_parameter(WDFDEVICE Device, int hvm_param)
   2.144 -{
   2.145 -  struct xen_hvm_param a;
   2.146 -  int retval;
   2.147 -
   2.148 -  KdPrint((__DRIVER_NAME " --> hvm_get_parameter\n"));
   2.149 -  a.domid = DOMID_SELF;
   2.150 -  a.index = hvm_param;
   2.151 -  //a.value = via;
   2.152 -  retval = HYPERVISOR_hvm_op(Device, HVMOP_get_param, &a);
   2.153 -  KdPrint((__DRIVER_NAME " hvm_get_parameter retval = %d\n", retval));
   2.154 -  KdPrint((__DRIVER_NAME " <-- hvm_get_parameter\n"));
   2.155 -  return a.value;
   2.156 -}
     3.1 --- a/common/include/xen_windows.h	Tue Jan 15 13:33:03 2008 +1100
     3.2 +++ b/common/include/xen_windows.h	Wed Jan 16 21:11:53 2008 +1100
     3.3 @@ -5,7 +5,19 @@
     3.4  #pragma warning( disable : 4214 ) // nonstandard extension used : bit field types other than int
     3.5  
     3.6  #define __XEN_INTERFACE_VERSION__ 0x00030205
     3.7 -#define __i386__
     3.8 +#if defined(_AMD64_)
     3.9 +  #define __x86_64__
    3.10 +#else 
    3.11 +  #if defined(_IA64_)
    3.12 +    #define __ia64__
    3.13 +  #else
    3.14 +    #if defined(_X86_)
    3.15 +      #define __i386__
    3.16 +    #else
    3.17 +      #error Unknown architecture
    3.18 +    #endif
    3.19 +  #endif
    3.20 +#endif
    3.21  typedef INT8 int8_t;
    3.22  typedef UINT8 uint8_t;
    3.23  typedef INT16 int16_t;
     4.1 --- a/xennet/sources	Tue Jan 15 13:33:03 2008 +1100
     4.2 +++ b/xennet/sources	Wed Jan 16 21:11:53 2008 +1100
     4.3 @@ -1,7 +1,7 @@
     4.4  TARGETNAME=XENNET
     4.5  TARGETTYPE=DRIVER
     4.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     4.7 -VERSION=0.5.0.85
     4.8 +VERSION=0.5.0.86
     4.9  KMDF_VERSION=1
    4.10  MSC_WARNING_LEVEL=/W4
    4.11  INF_NAME=xennet
     5.1 --- a/xennet/xennet.c	Tue Jan 15 13:33:03 2008 +1100
     5.2 +++ b/xennet/xennet.c	Wed Jan 16 21:11:53 2008 +1100
     5.3 @@ -154,7 +154,7 @@ static void
     5.4  add_id_to_freelist(struct xennet_info *xi, unsigned short id)
     5.5  {
     5.6    xi->tx_pkts[id] = xi->tx_pkts[0];
     5.7 -  xi->tx_pkts[0]  = (void *)(unsigned long)id;
     5.8 +  xi->tx_pkts[0]  = (void *)id;
     5.9    xi->tx_pkt_ids_used--;
    5.10  }
    5.11  
    5.12 @@ -770,7 +770,7 @@ XenNet_Init(
    5.13  
    5.14    /* Initialize tx_pkts as a free chain containing every entry. */
    5.15    for (i = 0; i < NET_TX_RING_SIZE+1; i++) {
    5.16 -    xi->tx_pkts[i] = (void *)((unsigned long) i+1);
    5.17 +    xi->tx_pkts[i] = i + 1;
    5.18      xi->grant_tx_ref[i] = GRANT_INVALID_REF;
    5.19    }
    5.20  
    5.21 @@ -1214,7 +1214,7 @@ XenNet_SetInformation(
    5.22    PNDIS_TASK_TCP_IP_CHECKSUM nttic;
    5.23    int offset;
    5.24  
    5.25 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.26 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.27  
    5.28    UNREFERENCED_PARAMETER(MiniportAdapterContext);
    5.29    UNREFERENCED_PARAMETER(InformationBufferLength);
    5.30 @@ -1395,7 +1395,7 @@ XenNet_SetInformation(
    5.31        status = NDIS_STATUS_NOT_SUPPORTED;
    5.32        break;
    5.33    }
    5.34 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.35 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.36    return status;
    5.37  }
    5.38  
     6.1 --- a/xenpci/evtchn.c	Tue Jan 15 13:33:03 2008 +1100
     6.2 +++ b/xenpci/evtchn.c	Wed Jan 16 21:11:53 2008 +1100
     6.3 @@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  */
     6.5  
     6.6  #include "xenpci.h"
     6.7 -#include "hypercall.h"
     6.8  
     6.9  static VOID
    6.10  EvtChn_DpcBounce(WDFDPC Dpc)
     7.1 --- a/xenpci/gnttbl.c	Tue Jan 15 13:33:03 2008 +1100
     7.2 +++ b/xenpci/gnttbl.c	Wed Jan 16 21:11:53 2008 +1100
     7.3 @@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     7.4  */
     7.5  
     7.6  #include "xenpci.h"
     7.7 -#include <hypercall.h>
     7.8  
     7.9  static void
    7.10  put_free_entry(WDFDEVICE Device, grant_ref_t ref)
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/xenpci/hypercall_x86.h	Wed Jan 16 21:11:53 2008 +1100
     8.3 @@ -0,0 +1,151 @@
     8.4 +/*
     8.5 +PV Drivers for Windows Xen HVM Domains
     8.6 +Copyright (C) 2007 James Harper
     8.7 +
     8.8 +This program is free software; you can redistribute it and/or
     8.9 +modify it under the terms of the GNU General Public License
    8.10 +as published by the Free Software Foundation; either version 2
    8.11 +of the License, or (at your option) any later version.
    8.12 +
    8.13 +This program is distributed in the hope that it will be useful,
    8.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.16 +GNU General Public License for more details.
    8.17 +
    8.18 +You should have received a copy of the GNU General Public License
    8.19 +along with this program; if not, write to the Free Software
    8.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    8.21 +*/
    8.22 +
    8.23 +static __inline int
    8.24 +HYPERVISOR_memory_op(WDFDEVICE Device, int cmd, void *arg)
    8.25 +{
    8.26 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    8.27 +  long __res;
    8.28 +  __asm {
    8.29 +    mov ebx, cmd
    8.30 +    mov ecx, arg
    8.31 +    mov eax, hypercall_stubs
    8.32 +    add eax, (__HYPERVISOR_memory_op * 32)
    8.33 +    call eax
    8.34 +    mov [__res], eax
    8.35 +  }
    8.36 +  return __res;
    8.37 +}
    8.38 +
    8.39 +static __inline int
    8.40 +HYPERVISOR_xen_version(WDFDEVICE Device, int cmd, void *arg)
    8.41 +{
    8.42 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    8.43 +  long __res;
    8.44 +  __asm {
    8.45 +    mov ebx, cmd
    8.46 +    mov ecx, arg
    8.47 +    mov eax, hypercall_stubs
    8.48 +    add eax, (__HYPERVISOR_xen_version * 32)
    8.49 +    call eax
    8.50 +    mov [__res], eax
    8.51 +  }
    8.52 +  return __res;
    8.53 +}
    8.54 +
    8.55 +static __inline int
    8.56 +HYPERVISOR_grant_table_op(WDFDEVICE Device, int cmd, void *uop, unsigned int count)
    8.57 +{
    8.58 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    8.59 +  long __res;
    8.60 +  __asm {
    8.61 +    mov ebx, cmd
    8.62 +    mov ecx, uop
    8.63 +    mov edx, count
    8.64 +    mov eax, hypercall_stubs
    8.65 +    add eax, (__HYPERVISOR_grant_table_op * 32)
    8.66 +    call eax
    8.67 +    mov [__res], eax
    8.68 +  }
    8.69 +  return __res;
    8.70 +}
    8.71 +
    8.72 +static __inline int
    8.73 +HYPERVISOR_mmu_update(WDFDEVICE Device, mmu_update_t *req, int count, int *success_count, domid_t domid)
    8.74 +{
    8.75 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    8.76 +  long __res;
    8.77 +  long _domid = (long)domid;
    8.78 +  __asm {
    8.79 +    mov ebx, req
    8.80 +    mov ecx, count
    8.81 +    mov edx, success_count
    8.82 +    mov edi, _domid
    8.83 +    mov eax, hypercall_stubs
    8.84 +    add eax, (__HYPERVISOR_mmu_update * 32)
    8.85 +    call eax
    8.86 +    mov [__res], eax
    8.87 +  }
    8.88 +  return __res;
    8.89 +}
    8.90 +
    8.91 +static __inline int
    8.92 +HYPERVISOR_console_io(WDFDEVICE Device, int cmd, int count, char *string)
    8.93 +{
    8.94 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
    8.95 +  long __res;
    8.96 +  __asm {
    8.97 +    mov ebx, cmd
    8.98 +    mov ecx, count
    8.99 +    mov edx, string
   8.100 +    mov eax, hypercall_stubs
   8.101 +    add eax, (__HYPERVISOR_console_io * 32)
   8.102 +    call eax
   8.103 +    mov [__res], eax
   8.104 +  }
   8.105 +  return __res;
   8.106 +}
   8.107 +
   8.108 +static __inline int
   8.109 +HYPERVISOR_hvm_op(WDFDEVICE Device, int op, struct xen_hvm_param *arg)
   8.110 +{
   8.111 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
   8.112 +  long __res;
   8.113 +  __asm {
   8.114 +    mov ebx, op
   8.115 +    mov ecx, arg
   8.116 +    mov eax, hypercall_stubs
   8.117 +    add eax, (__HYPERVISOR_hvm_op * 32)
   8.118 +    call eax
   8.119 +    mov [__res], eax
   8.120 +  }
   8.121 +  return __res;
   8.122 +}
   8.123 +
   8.124 +static __inline int
   8.125 +HYPERVISOR_event_channel_op(WDFDEVICE Device, int cmd, void *op)
   8.126 +{
   8.127 +  char *hypercall_stubs = GetDeviceData(Device)->hypercall_stubs;
   8.128 +  long __res;
   8.129 +  __asm {
   8.130 +    mov ebx, cmd
   8.131 +    mov ecx, op
   8.132 +    mov eax, hypercall_stubs
   8.133 +    add eax, (__HYPERVISOR_event_channel_op * 32)
   8.134 +    call eax
   8.135 +    mov [__res], eax
   8.136 +  }
   8.137 +  return __res;
   8.138 +}
   8.139 +
   8.140 +static __inline ULONGLONG
   8.141 +hvm_get_parameter(WDFDEVICE Device, int hvm_param)
   8.142 +{
   8.143 +  struct xen_hvm_param a;
   8.144 +  int retval;
   8.145 +
   8.146 +  KdPrint((__DRIVER_NAME " --> hvm_get_parameter\n"));
   8.147 +  a.domid = DOMID_SELF;
   8.148 +  a.index = hvm_param;
   8.149 +  //a.value = via;
   8.150 +  retval = HYPERVISOR_hvm_op(Device, HVMOP_get_param, &a);
   8.151 +  KdPrint((__DRIVER_NAME " hvm_get_parameter retval = %d\n", retval));
   8.152 +  KdPrint((__DRIVER_NAME " <-- hvm_get_parameter\n"));
   8.153 +  return a.value;
   8.154 +}
     9.1 --- a/xenpci/xenpci.c	Tue Jan 15 13:33:03 2008 +1100
     9.2 +++ b/xenpci/xenpci.c	Wed Jan 16 21:11:53 2008 +1100
     9.3 @@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     9.4  */
     9.5  
     9.6  #include "xenpci.h"
     9.7 -#include "hypercall.h"
     9.8  #include <stdlib.h>
     9.9  
    9.10  #define SYSRQ_PATH "control/sysrq"
    10.1 --- a/xenpci/xenpci.h	Tue Jan 15 13:33:03 2008 +1100
    10.2 +++ b/xenpci/xenpci.h	Wed Jan 16 21:11:53 2008 +1100
    10.3 @@ -143,6 +143,8 @@ typedef struct {
    10.4  
    10.5  WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetDeviceData);
    10.6  
    10.7 +#include "hypercall_x86.h"
    10.8 +
    10.9  typedef unsigned long xenbus_transaction_t;
   10.10  typedef uint32_t XENSTORE_RING_IDX;
   10.11  
    11.1 --- a/xenvbd/sources	Tue Jan 15 13:33:03 2008 +1100
    11.2 +++ b/xenvbd/sources	Wed Jan 16 21:11:53 2008 +1100
    11.3 @@ -1,7 +1,7 @@
    11.4  TARGETNAME=XENVBD
    11.5  TARGETTYPE=DRIVER
    11.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
    11.7 -VERSION=0.5.0.9
    11.8 +VERSION=0.5.0.15
    11.9  KMDF_VERSION=1
   11.10  MSC_WARNING_LEVEL=/W4
   11.11  INF_NAME=xenvbd
    12.1 --- a/xenvbd/xenvbd.c	Tue Jan 15 13:33:03 2008 +1100
    12.2 +++ b/xenvbd/xenvbd.c	Wed Jan 16 21:11:53 2008 +1100
    12.3 @@ -43,7 +43,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    12.4    ULONG Status;
    12.5    HW_INITIALIZATION_DATA HwInitializationData;
    12.6  
    12.7 -  KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
    12.8 +  KdPrint((__DRIVER_NAME " --> "__FUNCTION__ "\n"));
    12.9    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   12.10  
   12.11    RtlZeroMemory(&HwInitializationData, sizeof(HW_INITIALIZATION_DATA));
   12.12 @@ -61,17 +61,12 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   12.13    HwInitializationData.SpecificLuExtensionSize = 0;
   12.14    HwInitializationData.SrbExtensionSize = 0;
   12.15    HwInitializationData.NumberOfAccessRanges = 1;
   12.16 -
   12.17 -  //HwInitializationData.MapBuffers = FALSE;
   12.18    HwInitializationData.MapBuffers = TRUE;
   12.19 -
   12.20    HwInitializationData.NeedPhysicalAddresses = FALSE;
   12.21 -//  HwInitializationData.NeedPhysicalAddresses = TRUE;
   12.22 -
   12.23 -  HwInitializationData.TaggedQueuing = TRUE; //FALSE;
   12.24 +  HwInitializationData.TaggedQueuing = TRUE;
   12.25    HwInitializationData.AutoRequestSense = FALSE;
   12.26    HwInitializationData.MultipleRequestPerLu = FALSE;
   12.27 -  HwInitializationData.ReceiveEvent = FALSE; // check this
   12.28 +  HwInitializationData.ReceiveEvent = FALSE;
   12.29    HwInitializationData.VendorIdLength = 0;
   12.30    HwInitializationData.VendorId = NULL;
   12.31    HwInitializationData.DeviceIdLength = 0;
   12.32 @@ -85,7 +80,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   12.33      KdPrint((__DRIVER_NAME " ScsiPortInitialize failed with status 0x%08x\n", Status));
   12.34    }
   12.35  
   12.36 -  KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
   12.37 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   12.38  
   12.39    return Status;
   12.40  }
   12.41 @@ -108,9 +103,6 @@ ADD_ID_TO_FREELIST(PXENVBD_TARGET_DATA T
   12.42    TargetData->shadow_free = Id;
   12.43  }
   12.44  
   12.45 -//static HANDLE XenVbd_ScsiPortThreadHandle;
   12.46 -//static KEVENT XenVbd_ScsiPortThreadEvent;
   12.47 -
   12.48  static BOOLEAN
   12.49  XenVbd_Interrupt(PKINTERRUPT Interrupt, PVOID DeviceExtension)
   12.50  {
   12.51 @@ -383,10 +375,20 @@ XenVbd_BackEndStateHandler(char *Path, P
   12.52  
   12.53    case XenbusStateClosing:
   12.54      KdPrint((__DRIVER_NAME "     Backend State Changed to Closing\n"));  
   12.55 +    // this behaviour is only to properly close down to then restart in the case of a dump
   12.56 +    RtlStringCbCopyA(TmpPath, 128, TargetData->Path);
   12.57 +    RtlStringCbCatA(TmpPath, 128, "/state");
   12.58 +    DeviceData->XenDeviceData->XenInterface.XenBus_Printf(DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context, XBT_NIL, TmpPath, "%d", XenbusStateClosed);
   12.59 +    KdPrint((__DRIVER_NAME "     Set Frontend state to Closed\n"));
   12.60      break;
   12.61  
   12.62    case XenbusStateClosed:
   12.63      KdPrint((__DRIVER_NAME "     Backend State Changed to Closed\n"));  
   12.64 +    // this behaviour is only to properly close down to then restart in the case of a dump
   12.65 +    RtlStringCbCopyA(TmpPath, 128, TargetData->Path);
   12.66 +    RtlStringCbCatA(TmpPath, 128, "/state");
   12.67 +    DeviceData->XenDeviceData->XenInterface.XenBus_Printf(DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context, XBT_NIL, TmpPath, "%d", XenbusStateInitialising);
   12.68 +    KdPrint((__DRIVER_NAME "     Set Frontend state to Initialising\n"));
   12.69      break;
   12.70  
   12.71    default:
   12.72 @@ -447,6 +449,20 @@ XenVbd_WatchHandler(char *Path, PVOID De
   12.73        VacantTarget->Present = 1;
   12.74        KeReleaseSpinLock(&DeviceData->Lock, OldIrql);
   12.75  
   12.76 +      DeviceData->XenDeviceData->XenInterface.XenBus_Read(
   12.77 +        DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   12.78 +        XBT_NIL, Path, &Value);
   12.79 +
   12.80 +      if (Value == NULL)
   12.81 +      {
   12.82 +        KdPrint((__DRIVER_NAME "     blank state?\n"));
   12.83 +        break;
   12.84 +      }
   12.85 +      if (atoi(Value) != XenbusStateInitialising)
   12.86 +        DeviceData->XenDeviceData->XenInterface.XenBus_Printf(
   12.87 +          DeviceData->XenDeviceData->XenInterface.InterfaceHeader.Context,
   12.88 +          XBT_NIL, Path, "%d", XenbusStateClosing);
   12.89 +
   12.90        RtlStringCbCopyA(VacantTarget->Path, 128, Bits[0]);
   12.91        RtlStringCbCatA(VacantTarget->Path, 128, "/");
   12.92        RtlStringCbCatA(VacantTarget->Path, 128, Bits[1]);
   12.93 @@ -501,6 +517,10 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
   12.94    KdPrint((__DRIVER_NAME " --> HwScsiFindAdapter\n"));
   12.95    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   12.96  
   12.97 +  // testing this for dump mode
   12.98 +  if (KeGetCurrentIrql() > ConfigInfo->BusInterruptLevel)
   12.99 +    ConfigInfo->BusInterruptLevel = KeGetCurrentIrql();
  12.100 +
  12.101    KdPrint((__DRIVER_NAME "     BusInterruptLevel = %d\n", ConfigInfo->BusInterruptLevel));
  12.102    KdPrint((__DRIVER_NAME "     BusInterruptVector = %d\n", ConfigInfo->BusInterruptVector));
  12.103  
  12.104 @@ -592,8 +612,8 @@ XenVbd_CheckBusEnumeratedTimer(PVOID Dev
  12.105  {
  12.106    PXENVBD_DEVICE_DATA DeviceData = (PXENVBD_DEVICE_DATA)DeviceExtension;
  12.107  
  12.108 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  12.109 -  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
  12.110 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  12.111 +//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
  12.112  
  12.113    if (DeviceData->EnumeratedDevices >= DeviceData->TotalInitialDevices)
  12.114    {
  12.115 @@ -605,7 +625,7 @@ XenVbd_CheckBusEnumeratedTimer(PVOID Dev
  12.116    {
  12.117      ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbd_CheckBusEnumeratedTimer, 100000);
  12.118    }
  12.119 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  12.120 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  12.121  }
  12.122  
  12.123  static VOID 
  12.124 @@ -624,12 +644,12 @@ XenVbd_CheckBusChangedTimer(PVOID Device
  12.125  static BOOLEAN
  12.126  XenVbd_HwScsiInitialize(PVOID DeviceExtension)
  12.127  {
  12.128 -  KdPrint((__DRIVER_NAME " --> HwScsiInitialize\n"));
  12.129 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  12.130    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
  12.131  
  12.132    ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbd_CheckBusEnumeratedTimer, 100000);
  12.133  
  12.134 -  KdPrint((__DRIVER_NAME " <-- HwScsiInitialize\n"));
  12.135 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  12.136  
  12.137    return TRUE;
  12.138  }