win-pvdrivers

changeset 340:2be08f708250

move KeGetCurrentProcessorNumber fix to xenpci.h
Add kdprints to new functions with inline asm to make sure they get verified to work properly
Add missing intrinsic to gnttbl.c
Add next file to makefile
author Andy Grover <andy.grover@oracle.com>
date Sun Jun 22 18:14:30 2008 -0700 (2008-06-22)
parents 9e3eb0ed57b1
children 744c19115142 f6841337b2c2
files xenpci/evtchn.c xenpci/gnttbl.c xenpci/makefile.mingw xenpci/xenpci.h
line diff
     1.1 --- a/xenpci/evtchn.c	Sun Jun 22 17:32:05 2008 -0700
     1.2 +++ b/xenpci/evtchn.c	Sun Jun 22 18:14:30 2008 -0700
     1.3 @@ -20,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #include "xenpci.h"
     1.5  
     1.6  #if defined(__MINGW32__)
     1.7 -
     1.8 -/* mingw-runtime 3.13 is buggy */
     1.9 -#undef KeGetCurrentProcessorNumber
    1.10 -#define KeGetCurrentProcessorNumber() \
    1.11 -  ((ULONG)KeGetCurrentKPCR()->Number)
    1.12 -
    1.13  /* mingw-runtime 3.13 lacks certain lowlevel intrinsics */
    1.14  NTSTATUS BitScanForward(unsigned long *index, unsigned long mask)
    1.15  {
    1.16 @@ -35,9 +29,13 @@ NTSTATUS BitScanForward(unsigned long *i
    1.17    {
    1.18      if (mask & (1 << i)) {
    1.19        *index = i + 1;
    1.20 +      KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    1.21        return 1;
    1.22      }
    1.23    }
    1.24 +
    1.25 +  KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    1.26 +
    1.27    return 0;
    1.28  }
    1.29  
    1.30 @@ -52,7 +50,9 @@ static inline int test_and_set_bit(int n
    1.31      "btsl %2,%1\n\tsbbl %0,%0"
    1.32      :"=r" (oldbit),"+m" (*(volatile long *) addr)
    1.33      :"Ir" (nr) : "memory");
    1.34 -  
    1.35 +
    1.36 +  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    1.37 +
    1.38    return oldbit;
    1.39  }
    1.40  static inline int test_and_clear_bit(int nr, volatile long * addr)
    1.41 @@ -63,6 +63,9 @@ static inline int test_and_clear_bit(int
    1.42      "btrl %2,%1\n\tsbbl %0,%0"
    1.43      :"=r" (oldbit),"+m" (*(volatile long *) addr)
    1.44      :"Ir" (nr) : "memory");
    1.45 +
    1.46 +  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    1.47 +
    1.48    return oldbit;
    1.49  }
    1.50  
     2.1 --- a/xenpci/gnttbl.c	Sun Jun 22 17:32:05 2008 -0700
     2.2 +++ b/xenpci/gnttbl.c	Sun Jun 22 18:14:30 2008 -0700
     2.3 @@ -101,6 +101,27 @@ GntTbl_GrantAccess(
     2.4    return ref;
     2.5  }
     2.6  
     2.7 +#ifdef __MINGW32__
     2.8 +/* from linux/include/asm-i386/cmpxchg.h */
     2.9 +static inline short InterlockedCompareExchange16(
    2.10 +  short volatile *dest,
    2.11 +  short exch,
    2.12 +  short comp)
    2.13 +{
    2.14 +  unsigned long prev;
    2.15 +
    2.16 +  __asm__ __volatile__("lock;"
    2.17 +    "cmpxchgw %w1,%2"
    2.18 +    : "=a"(prev)
    2.19 +    : "r"(exch), "m"(*(dest)), "0"(comp)
    2.20 +    : "memory");
    2.21 +
    2.22 +  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    2.23 +
    2.24 +  return prev;
    2.25 +}
    2.26 +#endif
    2.27 +
    2.28  BOOLEAN
    2.29  GntTbl_EndAccess(
    2.30    PVOID Context,
     3.1 --- a/xenpci/makefile.mingw	Sun Jun 22 17:32:05 2008 -0700
     3.2 +++ b/xenpci/makefile.mingw	Sun Jun 22 18:14:30 2008 -0700
     3.3 @@ -1,6 +1,6 @@
     3.4  CFLAGS = -Wall -I/usr/i586-mingw32msvc/include/ddk/ -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas
     3.5  
     3.6 -xenpci.sys: xenpci.c xenbus.c evtchn.c gnttbl.c
     3.7 +xenpci.sys: xenpci.c xenbus.c evtchn.c gnttbl.c xenpci_fdo.c
     3.8  	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -s -shared -Wl,--entry,_load@8 -nostdlib $^ -lntoskrnl -lhal
     3.9  
    3.10  test.exe: test.c kexec.h
     4.1 --- a/xenpci/xenpci.h	Sun Jun 22 17:32:05 2008 -0700
     4.2 +++ b/xenpci/xenpci.h	Sun Jun 22 18:14:30 2008 -0700
     4.3 @@ -27,6 +27,10 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  
     4.5  #ifdef __MINGW32__
     4.6  #define KeMemoryBarrier() asm("mfence;")
     4.7 +/* mingw-runtime 3.13 is buggy */
     4.8 +#undef KeGetCurrentProcessorNumber
     4.9 +#define KeGetCurrentProcessorNumber() \
    4.10 +  ((ULONG)KeGetCurrentKPCR()->Number)
    4.11  #else
    4.12  #define DDKAPI
    4.13  #include <wdm.h>