2010-01-13 05:16:42 +03:00
/ *
* x8 6 - 6 4 r w s e m w r a p p e r s
*
* This i n t e r f a c e s t h e i n l i n e a s m c o d e t o t h e s l o w - p a t h
* C r o u t i n e s . W e n e e d t o s a v e t h e c a l l - c l o b b e r e d r e g s
* that t h e a s m d o e s n o t m a r k a s c l o b b e r e d , a n d m o v e t h e
* argument f r o m % r a x t o % r d i .
*
* NOTE! W e d o n ' t n e e d t o s a v e % r a x , b e c a u s e t h e f u n c t i o n s
* will a l w a y s r e t u r n t h e s e m a p h o r e p o i n t e r i n % r a x ( w h i c h
* is a l s o t h e i n p u t a r g u m e n t t o t h e s e h e l p e r s )
*
* The f o l l o w i n g c a n c l o b b e r % r d x b e c a u s e t h e a s m c l o b b e r s i t :
* call_ r w s e m _ d o w n _ w r i t e _ f a i l e d
* call_ r w s e m _ w a k e
* but % r d i , % r s i , % r c x , % r8 - r11 a l w a y s n e e d s a v i n g .
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / r w l o c k . 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 >
# define s a v e _ c o m m o n _ r e g s \
2011-02-28 18:31:59 +03:00
pushq_ c f i % r d i ; CFI_REL_OFFSET rdi, 0; \
pushq_ c f i % r s i ; CFI_REL_OFFSET rsi, 0; \
pushq_ c f i % r c x ; CFI_REL_OFFSET rcx, 0; \
pushq_ c f i % r8 ; CFI_REL_OFFSET r8, 0; \
pushq_ c f i % r9 ; CFI_REL_OFFSET r9, 0; \
pushq_ c f i % r10 ; CFI_REL_OFFSET r10, 0; \
pushq_ c f i % r11 ; CFI_REL_OFFSET r11, 0
2010-01-13 05:16:42 +03:00
# define r e s t o r e _ c o m m o n _ r e g s \
2011-02-28 18:31:59 +03:00
popq_ c f i % r11 ; CFI_RESTORE r11; \
popq_ c f i % r10 ; CFI_RESTORE r10; \
popq_ c f i % r9 ; CFI_RESTORE r9; \
popq_ c f i % r8 ; CFI_RESTORE r8; \
popq_ c f i % r c x ; CFI_RESTORE rcx; \
popq_ c f i % r s i ; CFI_RESTORE rsi; \
popq_ c f i % r d i ; CFI_RESTORE rdi
2010-01-13 05:16:42 +03:00
/* Fix up special calling conventions */
ENTRY( c a l l _ r w s e m _ d o w n _ r e a d _ f a i l e d )
2011-02-28 18:31:59 +03:00
CFI_ S T A R T P R O C
2010-01-13 05:16:42 +03:00
save_ c o m m o n _ r e g s
2011-02-28 18:31:59 +03:00
pushq_ c f i % r d x
CFI_ R E L _ O F F S E T r d x , 0
2010-01-13 05:16:42 +03:00
movq % r a x ,% r d i
call r w s e m _ d o w n _ r e a d _ f a i l e d
2011-02-28 18:31:59 +03:00
popq_ c f i % r d x
CFI_ R E S T O R E r d x
2010-01-13 05:16:42 +03:00
restore_ c o m m o n _ r e g s
ret
2011-02-28 18:31:59 +03:00
CFI_ E N D P R O C
ENDPROC( c a l l _ r w s e m _ d o w n _ r e a d _ f a i l e d )
2010-01-13 05:16:42 +03:00
ENTRY( c a l l _ r w s e m _ d o w n _ w r i t e _ f a i l e d )
2011-02-28 18:31:59 +03:00
CFI_ S T A R T P R O C
2010-01-13 05:16:42 +03:00
save_ c o m m o n _ r e g s
movq % r a x ,% r d i
call r w s e m _ d o w n _ w r i t e _ f a i l e d
restore_ c o m m o n _ r e g s
ret
2011-02-28 18:31:59 +03:00
CFI_ E N D P R O C
ENDPROC( c a l l _ r w s e m _ d o w n _ w r i t e _ f a i l e d )
2010-01-13 05:16:42 +03:00
ENTRY( c a l l _ r w s e m _ w a k e )
2011-02-28 18:31:59 +03:00
CFI_ S T A R T P R O C
2010-05-04 16:42:53 +04:00
decl % e d x / * d o n o t h i n g i f s t i l l o u t s t a n d i n g a c t i v e r e a d e r s * /
2010-01-13 05:16:42 +03:00
jnz 1 f
save_ c o m m o n _ r e g s
movq % r a x ,% r d i
call r w s e m _ w a k e
restore_ c o m m o n _ r e g s
1 : ret
2011-02-28 18:31:59 +03:00
CFI_ E N D P R O C
ENDPROC( c a l l _ r w s e m _ w a k e )
2010-01-13 05:16:42 +03:00
/* Fix up special calling conventions */
ENTRY( c a l l _ r w s e m _ d o w n g r a d e _ w a k e )
2011-02-28 18:31:59 +03:00
CFI_ S T A R T P R O C
2010-01-13 05:16:42 +03:00
save_ c o m m o n _ r e g s
2011-02-28 18:31:59 +03:00
pushq_ c f i % r d x
CFI_ R E L _ O F F S E T r d x , 0
2010-01-13 05:16:42 +03:00
movq % r a x ,% r d i
call r w s e m _ d o w n g r a d e _ w a k e
2011-02-28 18:31:59 +03:00
popq_ c f i % r d x
CFI_ R E S T O R E r d x
2010-01-13 05:16:42 +03:00
restore_ c o m m o n _ r e g s
ret
2011-02-28 18:31:59 +03:00
CFI_ E N D P R O C
ENDPROC( c a l l _ r w s e m _ d o w n g r a d e _ w a k e )