direct-io.hg

changeset 5501:ef4d0fa7f7c0

bitkeeper revision 1.1713.2.9 (42b3588569-8TLyTABHy5VPCdbAQmQ)

Implement cmpxchg_user for ia64 (hopefully correct :-)

Signed-off-by: Dan Magenheimer <dan.magenheimer@hp.com>
author djm@kirby.fc.hp.com
date Fri Jun 17 23:11:01 2005 +0000 (2005-06-17)
parents bb1b5a578752
children 14b5ff859896
files xen/arch/ia64/grant_table.c xen/include/asm-ia64/xensystem.h
line diff
     1.1 --- a/xen/arch/ia64/grant_table.c	Fri Jun 17 21:22:39 2005 +0000
     1.2 +++ b/xen/arch/ia64/grant_table.c	Fri Jun 17 23:11:01 2005 +0000
     1.3 @@ -35,10 +35,7 @@
     1.4  #ifdef __ia64__
     1.5  #define __addr_ok(a) 1	// FIXME-ia64: a variant of access_ok??
     1.6  // FIXME-ia64: need to implement real cmpxchg_user on ia64
     1.7 -#define cmpxchg_user(_p,_o,_n) ((*_p == _o) ? ((*_p = _n), 0) : ((_o = *_p), 0))
     1.8 -// FIXME-ia64: the following are meaningless on ia64? move to some header file
     1.9 -#define put_page(x) do { } while (0)
    1.10 -#define put_page_type(x) do { } while (0)
    1.11 +//#define cmpxchg_user(_p,_o,_n) ((*_p == _o) ? ((*_p = _n), 0) : ((_o = *_p), 0))
    1.12  // FIXME-ia64: these belong in an asm/grant_table.h... PAGE_SIZE different
    1.13  #undef ORDER_GRANT_FRAMES
    1.14  //#undef NUM_GRANT_FRAMES
     2.1 --- a/xen/include/asm-ia64/xensystem.h	Fri Jun 17 21:22:39 2005 +0000
     2.2 +++ b/xen/include/asm-ia64/xensystem.h	Fri Jun 17 23:11:01 2005 +0000
     2.3 @@ -61,5 +61,37 @@ extern struct task_struct *vmx_ia64_swit
     2.4  } while (0)
     2.5  #endif // CONFIG_VTI
     2.6  
     2.7 +#define __cmpxchg_user(ptr, new, old, _size)				\
     2.8 +({									\
     2.9 +	register long __gu_r8 asm ("r8");				\
    2.10 +	register long __gu_r9 asm ("r9");				\
    2.11 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));			\
    2.12 +	asm volatile ("mov %2=r0;;\n"					\
    2.13 +		"[1:]\tcmpxchg"_size".acq %0=[%3],%4,ar.ccv\n"		\
    2.14 +		"\t.xdata4 \"__ex_table\", 1b-., 1f.+4\n"		\
    2.15 +		"[1:]"							\
    2.16 +		: "=r"(old), "=r"(__gu_r9), "=r"(__gu_r8) :		\
    2.17 +		"r"(ptr), "r"(new) : "memory");				\
    2.18 +	(old) = __gu_r9;						\
    2.19 +	__gu_r8;							\
    2.20 +})
    2.21 +
    2.22 +
    2.23 +// NOTE: Xen defines args as pointer,old,new whereas ia64 uses pointer,new,old
    2.24 +//  so reverse them here
    2.25 +#define cmpxchg_user(_p,_o,_n)					\
    2.26 +({								\
    2.27 +	register long _rc;					\
    2.28 +	ia64_mf();						\
    2.29 +	switch ( sizeof(*(_p)) ) {				\
    2.30 +	    case 1: _rc = __cmpxchg_user(_p,_n,_o,"1"); break;	\
    2.31 +	    case 2: _rc = __cmpxchg_user(_p,_n,_o,"2"); break;	\
    2.32 +	    case 4: _rc = __cmpxchg_user(_p,_n,_o,"4"); break;	\
    2.33 +	    case 8: _rc = __cmpxchg_user(_p,_n,_o,"8"); break;	\
    2.34 +	}							\
    2.35 +	ia64_mf();						\
    2.36 +	_rc;							\
    2.37 +})
    2.38 +
    2.39  #endif // __ASSEMBLY__
    2.40  #endif // _ASM_IA64_XENSYSTEM_H