2011-02-28 13:02:24 +03:00
/ *
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; version 2
* of t h e L i c e n s e .
*
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a l t e r n a t i v e - a s m . h >
# include < a s m / f r a m e . h >
# include < a s m / d w a r f2 . h >
2011-03-27 05:57:18 +04:00
# ifdef C O N F I G _ S M P
# define S E G _ P R E F I X % g s :
# else
# define S E G _ P R E F I X
# endif
2011-02-28 13:02:24 +03:00
.text
/ *
* Inputs :
* % rsi : m e m o r y l o c a t i o n t o c o m p a r e
* % rax : l o w 6 4 b i t s o f o l d v a l u e
* % rdx : h i g h 6 4 b i t s o f o l d v a l u e
* % rbx : l o w 6 4 b i t s o f n e w v a l u e
* % rcx : h i g h 6 4 b i t s o f n e w v a l u e
* % al : O p e r a t i o n s u c c e s s f u l
* /
ENTRY( t h i s _ c p u _ c m p x c h g 1 6 b _ e m u )
CFI_ S T A R T P R O C
#
# Emulate ' c m p x c h g 1 6 b % g s : ( % r s i ) ' e x c e p t w e r e t u r n t h e r e s u l t i n % a l n o t
# via t h e Z F . C a l l e r w i l l a c c e s s % a l t o g e t r e s u l t .
#
# Note t h a t t h i s i s o n l y u s e f u l f o r a c p u o p s o p e r a t i o n . M e a n i n g t h a t w e
# do * n o t * h a v e a f u l l y a t o m i c o p e r a t i o n b u t j u s t a n o p e r a t i o n t h a t i s
# * atomic* o n a s i n g l e c p u ( a s p r o v i d e d b y t h e t h i s _ c p u _ x x c l a s s o f
# macros) .
#
this_cpu_cmpxchg16b_emu :
pushf
cli
2011-03-27 05:57:18 +04:00
cmpq S E G _ P R E F I X ( % r s i ) , % r a x
2011-02-28 13:02:24 +03:00
jne n o t _ s a m e
2011-03-27 05:57:18 +04:00
cmpq S E G _ P R E F I X 8 ( % r s i ) , % r d x
2011-02-28 13:02:24 +03:00
jne n o t _ s a m e
2011-03-27 05:57:18 +04:00
movq % r b x , S E G _ P R E F I X ( % r s i )
movq % r c x , S E G _ P R E F I X 8 ( % r s i )
2011-02-28 13:02:24 +03:00
popf
mov $ 1 , % a l
ret
not_same :
popf
xor % a l ,% a l
ret
CFI_ E N D P R O C
ENDPROC( t h i s _ c p u _ c m p x c h g 1 6 b _ e m u )