2006-09-26 10:52:29 +02:00
/ *
* i3 8 6 s e m a p h o r e i m p l e m e n t a t i o n .
*
* ( C) C o p y r i g h t 1 9 9 9 L i n u s T o r v a l d s
*
* Portions C o p y r i g h t 1 9 9 9 R e d H a t , I n c .
*
* 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 ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
*
* rw s e m a p h o r e s i m p l e m e n t e d N o v e m b e r 1 9 9 9 b y B e n j a m i n L a H a i s e < b c r l @kvack.org>
* /
# 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 >
2007-10-17 18:04:38 +02:00
# 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 >
2006-09-26 10:52:29 +02:00
# include < a s m / d w a r f2 . h >
/ *
* The s e m a p h o r e o p e r a t i o n s h a v e a s p e c i a l c a l l i n g s e q u e n c e t h a t
* allow u s t o d o a s i m p l e r i n - l i n e v e r s i o n o f t h e m . T h e s e r o u t i n e s
* need t o c o n v e r t t h a t s e q u e n c e b a c k i n t o t h e C s e q u e n c e w h e n
* there i s c o n t e n t i o n o n t h e s e m a p h o r e .
*
* % eax c o n t a i n s t h e s e m a p h o r e p o i n t e r o n e n t r y . S a v e t h e C - c l o b b e r e d
* registers ( % e a x , % e d x a n d % e c x ) e x c e p t % e a x w h i s h i s e i t h e r a r e t u r n
* value o r j u s t c l o b b e r e d . .
* /
.section .sched .text
ENTRY( _ _ d o w n _ f a i l e d )
CFI_ S T A R T P R O C
FRAME
pushl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e d x ,0
pushl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
call _ _ d o w n
popl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e c x
popl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e d x
ENDFRAME
ret
CFI_ E N D P R O C
END( _ _ d o w n _ f a i l e d )
ENTRY( _ _ d o w n _ f a i l e d _ i n t e r r u p t i b l e )
CFI_ S T A R T P R O C
FRAME
pushl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e d x ,0
pushl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
call _ _ d o w n _ i n t e r r u p t i b l e
popl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e c x
popl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e d x
ENDFRAME
ret
CFI_ E N D P R O C
END( _ _ d o w n _ f a i l e d _ i n t e r r u p t i b l e )
ENTRY( _ _ d o w n _ f a i l e d _ t r y l o c k )
CFI_ S T A R T P R O C
FRAME
pushl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e d x ,0
pushl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
call _ _ d o w n _ t r y l o c k
popl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e c x
popl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e d x
ENDFRAME
ret
CFI_ E N D P R O C
END( _ _ d o w n _ f a i l e d _ t r y l o c k )
ENTRY( _ _ u p _ w a k e u p )
CFI_ S T A R T P R O C
FRAME
pushl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e d x ,0
pushl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
call _ _ u p
popl % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e c x
popl % e d x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
CFI_ R E S T O R E e d x
ENDFRAME
ret
CFI_ E N D P R O C
END( _ _ u p _ w a k e u p )
/ *
* rw s p i n l o c k f a l l b a c k s
* /
# ifdef C O N F I G _ S M P
ENTRY( _ _ w r i t e _ l o c k _ f a i l e d )
CFI_ S T A R T P R O C s i m p l e
FRAME
2 : LOCK_ P R E F I X
addl $ R W _ L O C K _ B I A S ,( % e a x )
1 : rep; nop
cmpl $ R W _ L O C K _ B I A S ,( % e a x )
jne 1 b
LOCK_ P R E F I X
subl $ R W _ L O C K _ B I A S ,( % e a x )
jnz 2 b
ENDFRAME
ret
CFI_ E N D P R O C
END( _ _ w r i t e _ l o c k _ f a i l e d )
ENTRY( _ _ r e a d _ l o c k _ f a i l e d )
CFI_ S T A R T P R O C
FRAME
2 : LOCK_ P R E F I X
incl ( % e a x )
1 : rep; nop
cmpl $ 1 ,( % e a x )
js 1 b
LOCK_ P R E F I X
decl ( % e a x )
js 2 b
ENDFRAME
ret
CFI_ E N D P R O C
END( _ _ r e a d _ l o c k _ f a i l e d )
# endif
2006-09-26 10:52:31 +02:00
2006-10-05 18:47:22 +02:00
# ifdef C O N F I G _ R W S E M _ X C H G A D D _ A L G O R I T H M
2006-09-26 10:52:31 +02: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 )
CFI_ S T A R T P R O C
push % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
push % e d x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e d x ,0
call r w s e m _ d o w n _ r e a d _ f a i l e d
pop % e d x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
pop % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
ret
CFI_ E N D P R O C
END( c a l l _ r w s e m _ d o w n _ r e a d _ f a i l e d )
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 )
CFI_ S T A R T P R O C
push % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
calll r w s e m _ d o w n _ w r i t e _ f a i l e d
pop % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
ret
CFI_ E N D P R O C
END( c a l l _ r w s e m _ d o w n _ w r i t e _ f a i l e d )
ENTRY( c a l l _ r w s e m _ w a k e )
CFI_ S T A R T P R O C
decw % 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 * /
jnz 1 f
push % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
call r w s e m _ w a k e
pop % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
1 : ret
CFI_ E N D P R O C
END( c a l l _ r w s e m _ w a k e )
/* 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 )
CFI_ S T A R T P R O C
push % e c x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e c x ,0
push % e d x
CFI_ A D J U S T _ C F A _ O F F S E T 4
CFI_ R E L _ O F F S E T e d x ,0
call r w s e m _ d o w n g r a d e _ w a k e
pop % e d x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
pop % e c x
CFI_ A D J U S T _ C F A _ O F F S E T - 4
ret
CFI_ E N D P R O C
END( c a l l _ r w s e m _ d o w n g r a d e _ w a k e )
2006-10-05 18:47:22 +02:00
# endif