2011-02-28 11:02:24 +01: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 / d w a r f2 . h >
2014-09-24 08:37:00 +01:00
# include < a s m / p e r c p u . h >
2011-03-26 20:57:18 -05:00
2011-02-28 11:02:24 +01: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) .
#
2014-09-24 08:37:00 +01:00
pushfq_ c f i
2011-02-28 11:02:24 +01:00
cli
2014-09-24 08:37:00 +01:00
cmpq P E R _ C P U _ V A R ( ( % r s i ) ) , % r a x
jne . L n o t _ s a m e
cmpq P E R _ C P U _ V A R ( 8 ( % r s i ) ) , % r d x
jne . L n o t _ s a m e
2011-02-28 11:02:24 +01:00
2014-09-24 08:37:00 +01:00
movq % r b x , P E R _ C P U _ V A R ( ( % r s i ) )
movq % r c x , P E R _ C P U _ V A R ( 8 ( % r s i ) )
2011-02-28 11:02:24 +01:00
2014-09-24 08:37:00 +01:00
CFI_ R E M E M B E R _ S T A T E
popfq_ c f i
2011-02-28 11:02:24 +01:00
mov $ 1 , % a l
ret
2014-09-24 08:37:00 +01:00
CFI_ R E S T O R E _ S T A T E
.Lnot_same :
popfq_ c f i
2011-02-28 11:02:24 +01:00
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 )