win-pvdrivers

changeset 386:193ef493dfcb

merge with head
author James Harper <james.harper@bendigoit.com.au>
date Fri Jul 11 11:31:40 2008 +1000 (2008-07-11)
parents e556065b2f1a 3c8f2fa47a18
children 48df739c66d4
files
line diff
     1.1 --- a/common/include/public/io/blkif.h	Fri Jul 11 11:19:12 2008 +1000
     1.2 +++ b/common/include/public/io/blkif.h	Fri Jul 11 11:31:40 2008 +1000
     1.3 @@ -133,4 +133,5 @@ DEFINE_RING_TYPES(blkif, struct blkif_re
     1.4   * tab-width: 4
     1.5   * indent-tabs-mode: nil
     1.6   * End:
     1.7 - */
     1.8 \ No newline at end of file
     1.9 + */
    1.10 +
     2.1 --- a/common/include/public/io/protocols.h	Fri Jul 11 11:19:12 2008 +1000
     2.2 +++ b/common/include/public/io/protocols.h	Fri Jul 11 11:31:40 2008 +1000
     2.3 @@ -18,4 +18,5 @@
     2.4  # error arch fixup needed here
     2.5  #endif
     2.6  
     2.7 -#endif
     2.8 \ No newline at end of file
     2.9 +#endif
    2.10 +
     3.1 --- a/mingw/mingw_extras.c	Fri Jul 11 11:19:12 2008 +1000
     3.2 +++ b/mingw/mingw_extras.c	Fri Jul 11 11:31:40 2008 +1000
     3.3 @@ -6,9 +6,58 @@
     3.4   * Copyright Andy Grover <andy.grover@oracle.com> 
     3.5   * and licensed under the GPLv2.
     3.6   */
     3.7 -
     3.8 +
     3.9  #include <ntddk.h>
    3.10  #include "mingw_extras.h"
    3.11 +
    3.12 +NTSTATUS bit_scan_forward(unsigned long *index, unsigned long mask)
    3.13 +{
    3.14 +  int i;
    3.15 +
    3.16 +  for (i = 0; i < sizeof(unsigned long)*8; i++)
    3.17 +  {
    3.18 +    if (mask & (1 << i)) {
    3.19 +      *index = i + 1;
    3.20 +      KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    3.21 +      return 1;
    3.22 +    }
    3.23 +  }
    3.24 +
    3.25 +  KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    3.26 +
    3.27 +  return 0;
    3.28 +}
    3.29 +
    3.30 +/**
    3.31 +  From linux include/asm-i386/bitops.h
    3.32 + */
    3.33 +int synch_set_bit(int nr, volatile long * addr)
    3.34 +{
    3.35 +  int oldbit;
    3.36 +
    3.37 +  __asm__ __volatile__( "lock;"
    3.38 +    "btsl %2,%1\n\tsbbl %0,%0"
    3.39 +    :"=r" (oldbit),"+m" (*(volatile long *) addr)
    3.40 +    :"Ir" (nr) : "memory");
    3.41 +
    3.42 +  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    3.43 +
    3.44 +  return oldbit;
    3.45 +}
    3.46 +
    3.47 +int synch_clear_bit(int nr, volatile long * addr)
    3.48 +{
    3.49 +  int oldbit;
    3.50 +
    3.51 +  __asm__ __volatile__( "lock;"
    3.52 +    "btrl %2,%1\n\tsbbl %0,%0"
    3.53 +    :"=r" (oldbit),"+m" (*(volatile long *) addr)
    3.54 +    :"Ir" (nr) : "memory");
    3.55 +
    3.56 +  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    3.57 +
    3.58 +  return oldbit;
    3.59 +}
    3.60  
    3.61  NTSTATUS
    3.62  RtlStringCbPrintfW(
    3.63 @@ -594,4 +643,4 @@ int vsnprintf(char *buf, size_t size, co
    3.64  	return str-buf;
    3.65  }
    3.66  /* ----- END Other people's code --------- */
    3.67 -
    3.68 +
     4.1 --- a/mingw/mingw_extras.h	Fri Jul 11 11:19:12 2008 +1000
     4.2 +++ b/mingw/mingw_extras.h	Fri Jul 11 11:31:40 2008 +1000
     4.3 @@ -1,5 +1,9 @@
     4.4  #include <stdio.h>
     4.5  
     4.6 +NTSTATUS bit_scan_forward(unsigned long *index, unsigned long mask);
     4.7 +int synch_set_bit(int nr, volatile long * addr);
     4.8 +int synch_clear_bit(int nr, volatile long * addr);
     4.9 +
    4.10  /* windows wchar 2 bytes, Linux's is 4! */
    4.11  typedef unsigned short win_wchar_t;
    4.12  
    4.13 @@ -8,10 +12,5 @@ RtlStringCbPrintfW(
    4.14    win_wchar_t *dest_str,
    4.15    size_t dest_size,
    4.16    win_wchar_t *format,
    4.17 -  ...);
    4.18 -
    4.19 -/* stuff needed for xennet */
    4.20 -#include <ndis.h>
    4.21 +  ...);
    4.22  
    4.23 -//#define GCCNOANON u.s2.
    4.24 -
     5.1 --- a/mingw/w32api.diff	Fri Jul 11 11:19:12 2008 +1000
     5.2 +++ b/mingw/w32api.diff	Fri Jul 11 11:31:40 2008 +1000
     5.3 @@ -1,19 +1,19 @@
     5.4 -diff -r 79e257d5a1f7 include/ddk/ndis.h
     5.5 ---- a/include/ddk/ndis.h	Tue Jul 08 22:16:37 2008 -0700
     5.6 -+++ b/include/ddk/ndis.h	Wed Jul 09 00:34:21 2008 -0700
     5.7 +diff -r 8a2d0356d23d include/ddk/ndis.h
     5.8 +--- a/include/ddk/ndis.h	Wed Jul 09 12:54:30 2008 -0700
     5.9 ++++ b/include/ddk/ndis.h	Wed Jul 09 12:54:42 2008 -0700
    5.10  @@ -52,12 +52,16 @@ extern "C" {
    5.11   #if defined(NDIS50_MINIPORT)
    5.12   #ifndef NDIS50
    5.13   #define NDIS50
    5.14 -+#define NDIS_MINIPORT_MAJOR_VERSION 5
    5.15 -+#define NDIS_MINIPORT_MINOR_VERSION 0
    5.16 ++#define NDIS_MINIPORT_MAJOR_VERSION 5
    5.17 ++#define NDIS_MINIPORT_MINOR_VERSION 0
    5.18   #endif
    5.19   #endif /* NDIS50_MINIPORT */
    5.20   
    5.21   #if defined(NDIS51_MINIPORT)
    5.22   #ifndef NDIS51
    5.23   #define NDIS51
    5.24 -+#define NDIS_MINIPORT_MAJOR_VERSION 5
    5.25 ++#define NDIS_MINIPORT_MAJOR_VERSION 5
    5.26  +#define NDIS_MINIPORT_MINOR_VERSION 1
    5.27   #endif
    5.28   #endif /* NDIS51_MINIPORT */
    5.29 @@ -240,9 +240,9 @@ diff -r 79e257d5a1f7 include/ddk/ndis.h
    5.30   NDISAPI
    5.31   VOID
    5.32   DDKAPI
    5.33 -diff -r 79e257d5a1f7 include/ddk/ntddndis.h
    5.34 ---- a/include/ddk/ntddndis.h	Tue Jul 08 22:16:37 2008 -0700
    5.35 -+++ b/include/ddk/ntddndis.h	Wed Jul 09 00:34:21 2008 -0700
    5.36 +diff -r 8a2d0356d23d include/ddk/ntddndis.h
    5.37 +--- a/include/ddk/ntddndis.h	Wed Jul 09 12:54:30 2008 -0700
    5.38 ++++ b/include/ddk/ntddndis.h	Wed Jul 09 12:54:42 2008 -0700
    5.39  @@ -179,6 +179,13 @@ typedef struct _NDIS_PNP_CAPABILITIES {
    5.40   #define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS    0x00800000
    5.41   #define NDIS_MINIPORT_64BITS_DMA                      0x01000000
    5.42 @@ -257,9 +257,26 @@ diff -r 79e257d5a1f7 include/ddk/ntddndi
    5.43   #pragma pack(pop)
    5.44   
    5.45   #ifdef __cplusplus
    5.46 -diff -r 79e257d5a1f7 include/ddk/winddk.h
    5.47 ---- a/include/ddk/winddk.h	Tue Jul 08 22:16:37 2008 -0700
    5.48 -+++ b/include/ddk/winddk.h	Wed Jul 09 00:34:21 2008 -0700
    5.49 +diff -r 8a2d0356d23d include/ddk/scsi.h
    5.50 +--- a/include/ddk/scsi.h	Wed Jul 09 12:54:30 2008 -0700
    5.51 ++++ b/include/ddk/scsi.h	Wed Jul 09 12:54:42 2008 -0700
    5.52 +@@ -1272,6 +1272,13 @@ typedef struct _SENSE_DATA {
    5.53 + #define IOCTL_SCSI_MINIPORT_NOT_QUORUM_CAPABLE  ((FILE_DEVICE_SCSI << 16) + 0x0520)
    5.54 + #define IOCTL_SCSI_MINIPORT_NOT_CLUSTER_CAPABLE ((FILE_DEVICE_SCSI << 16) + 0x0521)
    5.55 + 
    5.56 ++/* READ_TOC formats */
    5.57 ++#define READ_TOC_FORMAT_TOC         0x00
    5.58 ++#define READ_TOC_FORMAT_SESSION     0x01
    5.59 ++#define READ_TOC_FORMAT_FULL_TOC    0x02
    5.60 ++#define READ_TOC_FORMAT_PMA         0x03
    5.61 ++#define READ_TOC_FORMAT_ATIP        0x04
    5.62 ++
    5.63 + /* Read Capacity Data. Returned in Big Endian format */
    5.64 + typedef struct _READ_CAPACITY_DATA {
    5.65 +   ULONG  LogicalBlockAddress;
    5.66 +diff -r 8a2d0356d23d include/ddk/winddk.h
    5.67 +--- a/include/ddk/winddk.h	Wed Jul 09 12:54:30 2008 -0700
    5.68 ++++ b/include/ddk/winddk.h	Wed Jul 09 12:54:42 2008 -0700
    5.69  @@ -4896,6 +4896,10 @@ RtlStringFromGUID(
    5.70     /*IN*/ REFGUID  Guid, 
    5.71     /*OUT*/ PUNICODE_STRING  GuidString);
    5.72 @@ -293,20 +310,16 @@ diff -r 79e257d5a1f7 include/ddk/winddk.
    5.73  -#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
    5.74  -
    5.75  -#else
    5.76 --
    5.77 --NTOSAPI
    5.78 --VOID
    5.79 --DDKAPI
    5.80 -+NTOSAPI
    5.81 -+VOID
    5.82 -+DDKAPI
    5.83 ++NTOSAPI
    5.84 ++VOID
    5.85 ++DDKAPI
    5.86  +KeRaiseIrql(
    5.87  +  /*IN*/ KIRQL new_irql,
    5.88 -+  /*OUT*/ PKIRQL old_irql);
    5.89 -+
    5.90 -+NTOSAPI
    5.91 -+VOID
    5.92 -+DDKAPI
    5.93 ++  /*OUT*/ PKIRQL old_irql);
    5.94 + 
    5.95 + NTOSAPI
    5.96 + VOID
    5.97 + DDKAPI
    5.98   KeLowerIrql(
    5.99  -  /*IN*/ KIRQL  NewIrql);
   5.100  -
   5.101 @@ -321,9 +334,9 @@ diff -r 79e257d5a1f7 include/ddk/winddk.
   5.102   
   5.103   NTOSAPI
   5.104   KIRQL
   5.105 -diff -r 79e257d5a1f7 lib/ddk/ndis.def
   5.106 ---- a/lib/ddk/ndis.def	Tue Jul 08 22:16:37 2008 -0700
   5.107 -+++ b/lib/ddk/ndis.def	Wed Jul 09 00:34:21 2008 -0700
   5.108 +diff -r 8a2d0356d23d lib/ddk/ndis.def
   5.109 +--- a/lib/ddk/ndis.def	Wed Jul 09 12:54:30 2008 -0700
   5.110 ++++ b/lib/ddk/ndis.def	Wed Jul 09 12:54:42 2008 -0700
   5.111  @@ -130,8 +130,8 @@ NdisImmediateReadSharedMemory@16
   5.112   ;NdisImmediateWritePortUlong
   5.113   ;NdisImmediateWritePortUshort
   5.114 @@ -371,3 +384,15 @@ diff -r 79e257d5a1f7 lib/ddk/ndis.def
   5.115   ;NdisSetPacketStatus
   5.116   ;NdisSetProtocolFilter
   5.117   ;NdisSetTimer
   5.118 +diff -r 8a2d0356d23d lib/ddk/scsiport.def
   5.119 +--- a/lib/ddk/scsiport.def	Wed Jul 09 12:54:30 2008 -0700
   5.120 ++++ b/lib/ddk/scsiport.def	Wed Jul 09 12:54:42 2008 -0700
   5.121 +@@ -8,7 +8,7 @@ ScsiPortFlushDma@4
   5.122 + ScsiPortFlushDma@4
   5.123 + ScsiPortFreeDeviceBase@8
   5.124 + ScsiPortGetBusData@24
   5.125 +-ScsiPortGetDeviceBase@24
   5.126 ++ScsiPortGetDeviceBase@28
   5.127 + ScsiPortGetLogicalUnit@16
   5.128 + ScsiPortGetPhysicalAddress@16
   5.129 + ScsiPortGetSrb@20
     6.1 --- a/xenpci/evtchn.c	Fri Jul 11 11:19:12 2008 +1000
     6.2 +++ b/xenpci/evtchn.c	Fri Jul 11 11:31:40 2008 +1000
     6.3 @@ -20,59 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  #include "xenpci.h"
     6.5  
     6.6  #if defined(__MINGW32__)
     6.7 -/* mingw-runtime 3.13 lacks certain lowlevel intrinsics */
     6.8 -NTSTATUS BitScanForward(unsigned long *index, unsigned long mask)
     6.9 -{
    6.10 -  int i;
    6.11 -
    6.12 -  for (i = 0; i < sizeof(unsigned long)*8; i++)
    6.13 -  {
    6.14 -    if (mask & (1 << i)) {
    6.15 -      *index = i + 1;
    6.16 -      KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    6.17 -      return 1;
    6.18 -    }
    6.19 -  }
    6.20 -
    6.21 -  KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    6.22 -
    6.23 -  return 0;
    6.24 -}
    6.25 -
    6.26 -/**
    6.27 -  From linux include/asm-i386/bitops.h
    6.28 - */
    6.29 -static inline int test_and_set_bit(int nr, volatile long * addr)
    6.30 -{
    6.31 -  int oldbit;
    6.32 -
    6.33 -  __asm__ __volatile__( "lock;"
    6.34 -    "btsl %2,%1\n\tsbbl %0,%0"
    6.35 -    :"=r" (oldbit),"+m" (*(volatile long *) addr)
    6.36 -    :"Ir" (nr) : "memory");
    6.37 -
    6.38 -  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    6.39 -
    6.40 -  return oldbit;
    6.41 -}
    6.42 -static inline int test_and_clear_bit(int nr, volatile long * addr)
    6.43 -{
    6.44 -  int oldbit;
    6.45 -
    6.46 -  __asm__ __volatile__( "lock;"
    6.47 -    "btrl %2,%1\n\tsbbl %0,%0"
    6.48 -    :"=r" (oldbit),"+m" (*(volatile long *) addr)
    6.49 -    :"Ir" (nr) : "memory");
    6.50 -
    6.51 -  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    6.52 -
    6.53 -  return oldbit;
    6.54 -}
    6.55 -
    6.56    #define xchg(p1, p2) InterlockedExchange((xen_long_t * volatile)p1, p2)
    6.57 -  #define synch_clear_bit(p1, p2) test_and_clear_bit(p1, p2)
    6.58 -  #define synch_set_bit(p1, p2) test_and_set_bit(p1, p2)
    6.59 -  #define bit_scan_forward(p1, p2) BitScanForward(p1, p2)
    6.60 +  /* rest implemented in mingw_extras.c */
    6.61  #elif defined(_X86_)
    6.62    #define xchg(p1, p2) _InterlockedExchange(p1, p2)
    6.63    #define synch_clear_bit(p1, p2) _interlockedbittestandreset(p2, p1)
     7.1 --- a/xenpci/hypercall_x86_mingw.h	Fri Jul 11 11:19:12 2008 +1000
     7.2 +++ b/xenpci/hypercall_x86_mingw.h	Fri Jul 11 11:31:40 2008 +1000
     7.3 @@ -23,28 +23,34 @@
     7.4  #define __STR(x) #x
     7.5  #define STR(x) __STR(x)
     7.6  
     7.7 -#if 0
     7.8 -#define HYPERCALL_STR(name)                                     \
     7.9 -	"mov $stub_addr,%%eax; "                                      \
    7.10 -	"add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "              \
    7.11 -	"call *%%eax"
    7.12 -#endif
    7.13 -
    7.14 -#define HYPERCALL_STR(name)                                     \
    7.15 -	"mov %3,%%eax; "                                      \
    7.16 -	"add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "              \
    7.17 -	"call *%%eax"
    7.18 -
    7.19  #define _hypercall2(type, name, a1, a2)                         \
    7.20  ({                                                              \
    7.21    long __res, __ign1, __ign2;                                   \
    7.22    asm volatile (                                                \
    7.23 -    HYPERCALL_STR(name)                                         \
    7.24 +	  "mov %3,%%eax; "                                            \
    7.25 +	  "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "            \
    7.26 +  	"call *%%eax"                                               \
    7.27      : "=a" (__res), "=b" (__ign1), "=c" (__ign2)                \
    7.28      : "1" ((long)(a1)), "2" ((long)(a2)), "r" (xpdd->hypercall_stubs) \
    7.29      : "memory" );                                               \
    7.30    (type)__res;                                                  \
    7.31  })
    7.32 +
    7.33 +#define _hypercall3(type, name, a1, a2, a3)			                \
    7.34 +({								                                              \
    7.35 +	long __res, __ign1, __ign2, __ign3;			                      \
    7.36 +	asm volatile (						                                    \
    7.37 +	  "mov %4,%%eax; "                                            \
    7.38 +	  "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "            \
    7.39 +  	"call *%%eax"                                               \
    7.40 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	            \
    7.41 +		"=d" (__ign3)					                                      \
    7.42 +		: "1" ((long)(a1)), "2" ((long)(a2)),		                    \
    7.43 +		"3" ((long)(a3)), "r" (xpdd->hypercall_stubs)		            \
    7.44 +		: "memory" );					                                      \
    7.45 +	(type)__res;						                                      \
    7.46 +})
    7.47 +
    7.48  
    7.49  static __inline void __cpuid(uint32_t output[4], uint32_t op)
    7.50  {
    7.51 @@ -90,4 +96,13 @@ HYPERVISOR_event_channel_op(PXENPCI_DEVI
    7.52  {
    7.53  	return _hypercall2(int, event_channel_op, cmd, arg);
    7.54  }
    7.55 -
    7.56 +
    7.57 static inline int
    7.58 +HYPERVISOR_grant_table_op(
    7.59 +  PXENPCI_DEVICE_DATA xpdd,
    7.60 +  unsigned int cmd,
    7.61 +  void *uop,
    7.62 +  unsigned int count)
    7.63 +{
    7.64 +	return _hypercall3(int, grant_table_op, cmd, uop, count);
    7.65 +}
    7.66 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/xenvbd/makefile.mingw	Fri Jul 11 11:31:40 2008 +1000
     8.3 @@ -0,0 +1,7 @@
     8.4 +W32API_PATH=/home/agrover/temp/w32api-3.11
     8.5 +
     8.6 +CFLAGS = -Wall -L$(W32API_PATH)/lib/ddk -I$(W32API_PATH)/include/ddk -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas
     8.7 +
     8.8 +xenvbd.sys: xenvbd.c scsiport.c ../mingw/mingw_extras.c
     8.9 +	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -s -shared -Wl,--entry,_load@8 -nostdlib $^ -lntoskrnl -lhal -lscsiport
    8.10 +
     9.1 --- a/xenvbd/scsiport.c	Fri Jul 11 11:19:12 2008 +1000
     9.2 +++ b/xenvbd/scsiport.c	Fri Jul 11 11:31:40 2008 +1000
     9.3 @@ -132,7 +132,7 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
     9.4    xvdd->event_channel = 0;
     9.5    
     9.6    ptr = xvdd->device_base;
     9.7 -  while((type = GET_XEN_INIT_RSP(&ptr, &setting, &value)) != XEN_INIT_TYPE_END)
     9.8 +  while((type = GET_XEN_INIT_RSP(&ptr, (PVOID) &setting, (PVOID) &value)) != XEN_INIT_TYPE_END)
     9.9    {
    9.10      switch(type)
    9.11      {
    9.12 @@ -238,8 +238,20 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
    9.13      return SP_RETURN_BAD_CONFIG;
    9.14    }
    9.15  
    9.16 -  /* for some reason total_sectors is measured in 512 byte sectors always, so correct this to be in bytes_per_sectors */
    9.17 -  xvdd->total_sectors /= xvdd->bytes_per_sector / 512;
    9.18 +  /* for some reason total_sectors is measured in 512 byte sectors always, so correct this to be in bytes_per_sectors */
    9.19 +#ifdef __MINGW32__
    9.20 +  /* mingw can't divide, so shift instead (assumes bps is ^2 and at least 512) */
    9.21 +  {
    9.22 +    ULONG num_512_byte_sectors = xvdd->bytes_per_sector / 512;
    9.23 +    ULONG index;
    9.24 +
    9.25 +    bit_scan_forward(&index, num_512_byte_sectors);
    9.26 +    xvdd->total_sectors <<= index-1;
    9.27 +  }
    9.28 +#else
    9.29 +  xvdd->total_sectors /= xvdd->bytes_per_sector / 512;
    9.30 +#endif
    9.31 +
    9.32  
    9.33    xvdd->shadow_free = 0;
    9.34    memset(xvdd->shadows, 0, sizeof(blkif_shadow_t) * SHADOW_ENTRIES);
    9.35 @@ -412,7 +424,7 @@ XenVbd_HwScsiTimer(PVOID DeviceExtension
    9.36    ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbd_HwScsiTimer, RESUME_CHECK_TIMER_INTERVAL);
    9.37  }
    9.38  
    9.39 -static ULONG
    9.40 +static ULONG DDKAPI
    9.41  XenVbd_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
    9.42  {
    9.43  //  PACCESS_RANGE AccessRange;
    9.44 @@ -490,7 +502,7 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    9.45    return SP_RETURN_FOUND;
    9.46  }
    9.47  
    9.48 -static BOOLEAN
    9.49 +static BOOLEAN DDKAPI
    9.50  XenVbd_HwScsiInitialize(PVOID DeviceExtension)
    9.51  {
    9.52    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)DeviceExtension;
    9.53 @@ -655,7 +667,7 @@ XenVbd_MakeAutoSense(PXENVBD_DEVICE_DATA
    9.54    srb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID;
    9.55  }
    9.56  
    9.57 -static BOOLEAN
    9.58 +static BOOLEAN DDKAPI
    9.59  XenVbd_HwScsiInterrupt(PVOID DeviceExtension)
    9.60  {
    9.61    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)DeviceExtension;
    9.62 @@ -790,7 +802,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    9.63    return FALSE; /* we just don't know... */
    9.64  }
    9.65  
    9.66 -static BOOLEAN
    9.67 +static BOOLEAN DDKAPI
    9.68  XenVbd_HwScsiStartIo(PVOID DeviceExtension, PSCSI_REQUEST_BLOCK Srb)
    9.69  {
    9.70    PUCHAR DataBuffer;
    9.71 @@ -1096,7 +1108,7 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
    9.72    return TRUE;
    9.73  }
    9.74  
    9.75 -static BOOLEAN
    9.76 +static BOOLEAN DDKAPI
    9.77  XenVbd_HwScsiResetBus(PVOID DeviceExtension, ULONG PathId)
    9.78  {
    9.79    UNREFERENCED_PARAMETER(DeviceExtension);
    9.80 @@ -1113,7 +1125,7 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
    9.81    return TRUE;
    9.82  }
    9.83  
    9.84 -static BOOLEAN
    9.85 +static BOOLEAN DDKAPI
    9.86  XenVbd_HwScsiAdapterState(PVOID DeviceExtension, PVOID Context, BOOLEAN SaveState)
    9.87  {
    9.88    UNREFERENCED_PARAMETER(DeviceExtension);
    9.89 @@ -1128,7 +1140,7 @@ XenVbd_HwScsiAdapterState(PVOID DeviceEx
    9.90    return TRUE;
    9.91  }
    9.92  
    9.93 -static SCSI_ADAPTER_CONTROL_STATUS
    9.94 +static SCSI_ADAPTER_CONTROL_STATUS DDKAPI
    9.95  XenVbd_HwScsiAdapterControl(PVOID DeviceExtension, SCSI_ADAPTER_CONTROL_TYPE ControlType, PVOID Parameters)
    9.96  {
    9.97    SCSI_ADAPTER_CONTROL_STATUS Status = ScsiAdapterControlSuccess;
    10.1 --- a/xenvbd/xenvbd.c	Fri Jul 11 11:19:12 2008 +1000
    10.2 +++ b/xenvbd/xenvbd.c	Fri Jul 11 11:31:40 2008 +1000
    10.3 @@ -16,7 +16,8 @@ You should have received a copy of the G
    10.4  along with this program; if not, write to the Free Software
    10.5  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    10.6  */
    10.7 -
    10.8 +
    10.9 +#define INITGUID
   10.10  #include "xenvbd.h"
   10.11  #include <io/blkif.h>
   10.12  #include <scsi.h>
   10.13 @@ -29,9 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fi
   10.14  
   10.15  #pragma warning(disable: 4127)
   10.16  
   10.17 +#ifdef ALLOC_PRAGMA
   10.18  DRIVER_INITIALIZE DriverEntry;
   10.19 -
   10.20 -#ifdef ALLOC_PRAGMA
   10.21  #pragma alloc_text (INIT, DriverEntry)
   10.22  #endif
   10.23  
    11.1 --- a/xenvbd/xenvbd.h	Fri Jul 11 11:19:12 2008 +1000
    11.2 +++ b/xenvbd/xenvbd.h	Fri Jul 11 11:31:40 2008 +1000
    11.3 @@ -19,17 +19,25 @@ Foundation, Inc., 51 Franklin Street, Fi
    11.4  
    11.5  #if !defined(_XENVBD_H_)
    11.6  #define _XENVBD_H_
    11.7 +
    11.8 +#ifdef __MINGW32__
    11.9 +#include <ntddk.h>
   11.10 +#include "../mingw/mingw_extras.h"
   11.11 +
   11.12 +#else
   11.13 +#define DDKAPI
   11.14  
   11.15  #include <ntifs.h>
   11.16  #include <ntddk.h>
   11.17  #include <wdm.h>
   11.18  #include <initguid.h>
   11.19 +#define NTSTRSAFE_LIB
   11.20 +#include <ntstrsafe.h>
   11.21 +#endif
   11.22 +
   11.23  #include <ntdddisk.h>
   11.24  #include <srb.h>
   11.25  
   11.26 -#define NTSTRSAFE_LIB
   11.27 -#include <ntstrsafe.h>
   11.28 -
   11.29  #define __DRIVER_NAME "XenVbd"
   11.30  
   11.31  #include <xen_windows.h>
   11.32 @@ -140,4 +148,5 @@ struct
   11.33  VOID
   11.34  XenVbd_FillInitCallbacks(PHW_INITIALIZATION_DATA HwInitializationData);
   11.35  
   11.36 -#endif
   11.37 \ No newline at end of file
   11.38 +#endif
   11.39 +