win-pvdrivers

changeset 328:c563a0f32b2f

mingw cleanups
author Andy Grover <andy.grover@oracle.com>
date Thu Jun 19 16:50:57 2008 -0700 (2008-06-19)
parents 2705232c28d9
children daa0a9b0fef0
files common/include/public/io/xs_wire.h common/include/xen_windows.h xenpci/hypercall_x86_mingw.h xenpci/xenbus.c xenpci/xenpci.c xenpci/xenpci.h
line diff
     1.1 --- a/common/include/public/io/xs_wire.h	Thu Jun 19 15:30:47 2008 -0700
     1.2 +++ b/common/include/public/io/xs_wire.h	Thu Jun 19 16:50:57 2008 -0700
     1.3 @@ -25,6 +25,7 @@
     1.4  
     1.5  #ifndef _XS_WIRE_H
     1.6  #define _XS_WIRE_H
     1.7 +#include <errno.h>
     1.8  
     1.9  enum xsd_sockmsg_type
    1.10  {
     2.1 --- a/common/include/xen_windows.h	Thu Jun 19 15:30:47 2008 -0700
     2.2 +++ b/common/include/xen_windows.h	Thu Jun 19 16:50:57 2008 -0700
     2.3 @@ -35,8 +35,11 @@ typedef UINT32 uint32_t;
     2.4  typedef UINT64 uint64_t;
     2.5  #endif
     2.6  
     2.7 -#ifdef __MINGW32__
     2.8 -#define RtlStringCbCopyA(dst, dst_len, src) strncpy(dst, src, dst_len)
     2.9 +#ifdef __MINGW32__
    2.10 +#include <stdio.h>
    2.11 +#define RtlStringCbCopyA(dst, dst_len, src) strncpy(dst, src, dst_len)
    2.12 +#define RtlStringCbPrintfA(args...) snprintf(args)
    2.13 +#define RtlStringCbVPrintfA(args...) vsnprintf(args)
    2.14  #endif
    2.15  #include <xen.h>
    2.16  
    2.17 @@ -56,7 +59,6 @@ typedef UINT64 uint64_t;
    2.18  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    2.19  
    2.20  typedef unsigned long xenbus_transaction_t;
    2.21 -typedef uint32_t XENSTORE_RING_IDX;
    2.22  
    2.23  #define XBT_NIL ((xenbus_transaction_t)0)
    2.24  
    2.25 @@ -65,7 +67,7 @@ typedef uint32_t XENSTORE_RING_IDX;
    2.26  #define wmb() KeMemoryBarrier()
    2.27  #define mb() KeMemoryBarrier()
    2.28  
    2.29 -static char **
    2.30 +static inline char **
    2.31  SplitString(char *String, char Split, int MaxParts, int *Count)
    2.32  {
    2.33    char **RetVal;
    2.34 @@ -100,7 +102,7 @@ SplitString(char *String, char Split, in
    2.35    return RetVal;
    2.36  }
    2.37  
    2.38 -static VOID
    2.39 +static inline VOID
    2.40  FreeSplitString(char **Bits, int Count)
    2.41  {
    2.42    int i;
    2.43 @@ -140,19 +142,19 @@ AllocatePagesExtra(int Pages, int ExtraS
    2.44    return Mdl;
    2.45  }
    2.46  
    2.47 -static PMDL
    2.48 +static inline PMDL
    2.49  AllocatePages(int Pages)
    2.50  {
    2.51    return AllocatePagesExtra(Pages, 0);
    2.52  }
    2.53  
    2.54 -static PMDL
    2.55 +static inline PMDL
    2.56  AllocatePage()
    2.57  {
    2.58    return AllocatePagesExtra(1, 0);
    2.59  }
    2.60  
    2.61 -static PMDL
    2.62 +static inline PMDL
    2.63  AllocateUncachedPage()
    2.64  {
    2.65    PMDL mdl;
    2.66 @@ -165,7 +167,7 @@ AllocateUncachedPage()
    2.67    return mdl;
    2.68  }  
    2.69  
    2.70 -static VOID
    2.71 +static inline VOID
    2.72  FreeUncachedPage(PMDL mdl)
    2.73  {
    2.74    PVOID buf = MmGetMdlVirtualAddress(mdl);
    2.75 @@ -174,7 +176,7 @@ FreeUncachedPage(PMDL mdl)
    2.76    MmFreeNonCachedMemory(buf, PAGE_SIZE);
    2.77  }
    2.78  
    2.79 -static VOID
    2.80 +static inline VOID
    2.81  FreePages(PMDL Mdl)
    2.82  {
    2.83    PVOID Buf = MmGetMdlVirtualAddress(Mdl);
     3.1 --- a/xenpci/hypercall_x86_mingw.h	Thu Jun 19 15:30:47 2008 -0700
     3.2 +++ b/xenpci/hypercall_x86_mingw.h	Thu Jun 19 16:50:57 2008 -0700
     3.3 @@ -24,13 +24,15 @@
     3.4  #define STR(x) __STR(x)
     3.5  
     3.6  #define HYPERCALL_STR(name)					\
     3.7 -	"mov $xpdd->hypercall_stubs,%%eax; "				\
     3.8 +	"mov $stub_addr,%%eax; "			    \
     3.9  	"add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "	\
    3.10  	"call *%%eax"
    3.11  
    3.12  #define _hypercall2(type, name, a1, a2)                         \
    3.13  ({                                                              \
    3.14 -        long __res, __ign1, __ign2;                             \
    3.15 +        long __res, __ign1, __ign2;                             \
    3.16 +        char *stub_addr;                                        \
    3.17 +        stub_addr = xpdd->hypercall_stubs;                      \
    3.18          asm volatile (                                          \
    3.19                  HYPERCALL_STR(name)                             \
    3.20                  : "=a" (__res), "=b" (__ign1), "=c" (__ign2)    \
    3.21 @@ -87,8 +89,8 @@ static __inline void __writemsr(uint32_t
    3.22    hi = value >> 32;
    3.23    lo = value & 0xFFFFFFFF;
    3.24  
    3.25 -  __asm__ __volatile__("wrmsr" \
    3.26 -                       : /* no outputs */ \
    3.27 +  __asm__ __volatile__("wrmsr"
    3.28 +                       : /* no outputs */
    3.29                         : "c" (msr), "a" (lo), "d" (hi));
    3.30  }
    3.31  
     4.1 --- a/xenpci/xenbus.c	Thu Jun 19 15:30:47 2008 -0700
     4.2 +++ b/xenpci/xenbus.c	Thu Jun 19 16:50:57 2008 -0700
     4.3 @@ -29,11 +29,11 @@ struct write_req {
     4.4      unsigned len;
     4.5  };
     4.6  
     4.7 -static void
     4.8 +static DDKAPI void
     4.9  XenBus_ReadThreadProc(PVOID StartContext);
    4.10 -static void
    4.11 +static DDKAPI void
    4.12  XenBus_WatchThreadProc(PVOID StartContext);
    4.13 -static BOOLEAN
    4.14 +static DDKAPI BOOLEAN
    4.15  XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext);
    4.16  
    4.17  static int allocate_xenbus_id(PXENPCI_DEVICE_DATA xpdd)
    4.18 @@ -442,7 +442,7 @@ XenBus_List(
    4.19    return NULL;
    4.20  }
    4.21  
    4.22 -static void
    4.23 +static DDKAPI void
    4.24  XenBus_ReadThreadProc(PVOID StartContext)
    4.25  {
    4.26    int NewWriteIndex;
    4.27 @@ -518,7 +518,7 @@ XenBus_ReadThreadProc(PVOID StartContext
    4.28    }
    4.29  }
    4.30  
    4.31 -static void
    4.32 +static DDKAPI void
    4.33  XenBus_WatchThreadProc(PVOID StartContext)
    4.34  {
    4.35    int index;
    4.36 @@ -802,7 +802,7 @@ XenBus_EndTransaction(
    4.37    return NULL;
    4.38  }
    4.39  
    4.40 -static BOOLEAN
    4.41 +static DDKAPI BOOLEAN
    4.42  XenBus_Interrupt(PKINTERRUPT Interrupt, PVOID ServiceContext)
    4.43  {
    4.44    PXENPCI_DEVICE_DATA xpdd = ServiceContext;
     5.1 --- a/xenpci/xenpci.c	Thu Jun 19 15:30:47 2008 -0700
     5.2 +++ b/xenpci/xenpci.c	Thu Jun 19 16:50:57 2008 -0700
     5.3 @@ -31,10 +31,6 @@ DRIVER_INITIALIZE DriverEntry;
     5.4  
     5.5  #pragma warning(disable : 4200) // zero-sized array
     5.6  
     5.7 -#ifndef __MINGW32__
     5.8 -#define DDKAPI
     5.9 -#endif
    5.10 -
    5.11  static DDKAPI NTSTATUS
    5.12  XenPci_Pnp(PDEVICE_OBJECT device_object, PIRP irp)
    5.13  {
     6.1 --- a/xenpci/xenpci.h	Thu Jun 19 15:30:47 2008 -0700
     6.2 +++ b/xenpci/xenpci.h	Thu Jun 19 16:50:57 2008 -0700
     6.3 @@ -24,8 +24,11 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  #define EISCONN 127
     6.5  
     6.6  #include <ntddk.h>
     6.7 -
     6.8 -#ifndef __MINGW32__
     6.9 +
    6.10 +#ifdef __MINGW32__
    6.11 +#define KeMemoryBarrier() asm("mfence;")
    6.12 +#else
    6.13 +#define DDKAPI
    6.14  #include <wdm.h>
    6.15  //#include <wdf.h>
    6.16  #include <initguid.h>