win-pvdrivers

changeset 380:5b2a37528899

using hypercall3's again, add support in mingw. remove duplicate code from evtchn.c
author Andy Grover <andy.grover@oracle.com>
date Wed Jul 09 12:33:23 2008 -0700 (2008-07-09)
parents 8c83b0ebcb05
children 1dd27f353684
files xenpci/evtchn.c xenpci/hypercall_x86_mingw.h
line diff
     1.1 --- a/xenpci/evtchn.c	Wed Jul 09 12:32:12 2008 -0700
     1.2 +++ b/xenpci/evtchn.c	Wed Jul 09 12:33:23 2008 -0700
     1.3 @@ -20,59 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #include "xenpci.h"
     1.5  
     1.6  #if defined(__MINGW32__)
     1.7 -/* mingw-runtime 3.13 lacks certain lowlevel intrinsics */
     1.8 -NTSTATUS BitScanForward(unsigned long *index, unsigned long mask)
     1.9 -{
    1.10 -  int i;
    1.11 -
    1.12 -  for (i = 0; i < sizeof(unsigned long)*8; i++)
    1.13 -  {
    1.14 -    if (mask & (1 << i)) {
    1.15 -      *index = i + 1;
    1.16 -      KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    1.17 -      return 1;
    1.18 -    }
    1.19 -  }
    1.20 -
    1.21 -  KdPrint((__FUNC__ __LINE__ " Check that I work as expected!\n"));
    1.22 -
    1.23 -  return 0;
    1.24 -}
    1.25 -
    1.26 -/**
    1.27 -  From linux include/asm-i386/bitops.h
    1.28 - */
    1.29 -static inline int test_and_set_bit(int nr, volatile long * addr)
    1.30 -{
    1.31 -  int oldbit;
    1.32 -
    1.33 -  __asm__ __volatile__( "lock;"
    1.34 -    "btsl %2,%1\n\tsbbl %0,%0"
    1.35 -    :"=r" (oldbit),"+m" (*(volatile long *) addr)
    1.36 -    :"Ir" (nr) : "memory");
    1.37 -
    1.38 -  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    1.39 -
    1.40 -  return oldbit;
    1.41 -}
    1.42 -static inline int test_and_clear_bit(int nr, volatile long * addr)
    1.43 -{
    1.44 -  int oldbit;
    1.45 -
    1.46 -  __asm__ __volatile__( "lock;"
    1.47 -    "btrl %2,%1\n\tsbbl %0,%0"
    1.48 -    :"=r" (oldbit),"+m" (*(volatile long *) addr)
    1.49 -    :"Ir" (nr) : "memory");
    1.50 -
    1.51 -  KdPrint((__FUNC__ " Check that I work as expected!\n"));
    1.52 -
    1.53 -  return oldbit;
    1.54 -}
    1.55 -
    1.56    #define xchg(p1, p2) InterlockedExchange((xen_long_t * volatile)p1, p2)
    1.57 -  #define synch_clear_bit(p1, p2) test_and_clear_bit(p1, p2)
    1.58 -  #define synch_set_bit(p1, p2) test_and_set_bit(p1, p2)
    1.59 -  #define bit_scan_forward(p1, p2) BitScanForward(p1, p2)
    1.60 +  /* rest implemented in mingw_extras.c */
    1.61  #elif defined(_X86_)
    1.62    #define xchg(p1, p2) _InterlockedExchange(p1, p2)
    1.63    #define synch_clear_bit(p1, p2) _interlockedbittestandreset(p2, p1)
     2.1 --- a/xenpci/hypercall_x86_mingw.h	Wed Jul 09 12:32:12 2008 -0700
     2.2 +++ b/xenpci/hypercall_x86_mingw.h	Wed Jul 09 12:33:23 2008 -0700
     2.3 @@ -39,12 +39,30 @@
     2.4  ({                                                              \
     2.5    long __res, __ign1, __ign2;                                   \
     2.6    asm volatile (                                                \
     2.7 -    HYPERCALL_STR(name)                                         \
     2.8 +	  "mov %3,%%eax; "                                            \
     2.9 +	  "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "            \
    2.10 +  	"call *%%eax"                                               \
    2.11      : "=a" (__res), "=b" (__ign1), "=c" (__ign2)                \
    2.12      : "1" ((long)(a1)), "2" ((long)(a2)), "r" (xpdd->hypercall_stubs) \
    2.13      : "memory" );                                               \
    2.14    (type)__res;                                                  \
    2.15  })
    2.16 +
    2.17 +#define _hypercall3(type, name, a1, a2, a3)			                \
    2.18 +({								                                              \
    2.19 +	long __res, __ign1, __ign2, __ign3;			                      \
    2.20 +	asm volatile (						                                    \
    2.21 +	  "mov %4,%%eax; "                                            \
    2.22 +	  "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "            \
    2.23 +  	"call *%%eax"                                               \
    2.24 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	            \
    2.25 +		"=d" (__ign3)					                                      \
    2.26 +		: "1" ((long)(a1)), "2" ((long)(a2)),		                    \
    2.27 +		"3" ((long)(a3)), "r" (xpdd->hypercall_stubs)		            \
    2.28 +		: "memory" );					                                      \
    2.29 +	(type)__res;						                                      \
    2.30 +})
    2.31 +
    2.32  
    2.33  static __inline void __cpuid(uint32_t output[4], uint32_t op)
    2.34  {
    2.35 @@ -90,4 +108,10 @@ HYPERVISOR_event_channel_op(PXENPCI_DEVI
    2.36  {
    2.37  	return _hypercall2(int, event_channel_op, cmd, arg);
    2.38  }
    2.39 -
    2.40 +
    2.41 static inline int
    2.42 +HYPERVISOR_grant_table_op(PXENPCI_DEVICE_DATA xpdd,	unsigned int cmd, void *uop,
    2.43 + unsigned int count)
    2.44 +{
    2.45 +	return _hypercall3(int, grant_table_op, cmd, uop, count);
    2.46 +}
    2.47 +