2007-06-21 07:34:16 +04:00
/ *
* This f i l e c o n t a i n s s e q u e n c e s o f c o d e t h a t w i l l b e c o p i e d t o a
2008-05-07 07:41:26 +04:00
* fixed l o c a t i o n , d e f i n e d i n < a s m / f i x e d _ c o d e . h > . T h e i n t e r r u p t
2007-06-21 07:34:16 +04:00
* handlers e n s u r e t h a t t h e s e s e q u e n c e s a p p e a r t o b e a t o m i c w h e n
* executed f r o m u s e r s p a c e .
* These a r e a l i g n e d t o 1 6 b y t e s , s o t h a t w e h a v e s o m e s p a c e t o r e p l a c e
* these s e q u e n c e s w i t h s o m e t h i n g e l s e ( e . g . k e r n e l t r a p s i f w e e v e r d o
* BF5 6 1 S M P ) .
2009-09-24 18:11:24 +04:00
*
* Copyright 2 0 0 7 - 2 0 0 8 A n a l o g D e v i c e s I n c .
*
* Licensed u n d e r t h e G P L - 2 o r l a t e r .
2007-06-21 07:34:16 +04:00
* /
2009-09-24 18:11:24 +04:00
2007-06-21 07:34:16 +04:00
# include < l i n u x / l i n k a g e . h >
2008-11-18 12:48:22 +03:00
# include < l i n u x / i n i t . h >
2007-07-12 18:58:21 +04:00
# include < l i n u x / u n i s t d . h >
2007-06-21 07:34:16 +04:00
# include < a s m / e n t r y . h >
2008-11-18 12:48:22 +03:00
_ _ INIT
2007-06-21 07:34:16 +04:00
ENTRY( _ f i x e d _ c o d e _ s t a r t )
.align 16
ENTRY( _ s i g r e t u r n _ s t u b )
P0 = _ _ N R _ r t _ s i g r e t u r n ;
EXCPT 0 ;
/* Speculative execution paranoia. */
0 : JUMP. S 0 b ;
ENDPROC ( _ s i g r e t u r n _ s t u b )
.align 16
/ *
* Atomic s w a p , 8 b i t .
* Inputs : P0 : memory a d d r e s s t o u s e
* R1 : value t o s t o r e
* Output : R0 : old c o n t e n t s o f t h e m e m o r y a d d r e s s , z e r o e x t e n d e d .
* /
ENTRY( _ a t o m i c _ x c h g 3 2 )
R0 = [ P 0 ] ;
[ P0 ] = R 1 ;
rts;
ENDPROC ( _ a t o m i c _ x c h g 3 2 )
.align 16
/ *
* Compare a n d s w a p , 3 2 b i t .
* Inputs : P0 : memory a d d r e s s t o u s e
* R1 : compare v a l u e
* R2 : new v a l u e t o s t o r e
* The n e w v a l u e i s s t o r e d i f t h e c o n t e n t s o f t h e m e m o r y
* address i s e q u a l t o t h e c o m p a r e v a l u e .
* Output : R0 : old c o n t e n t s o f t h e m e m o r y a d d r e s s .
* /
ENTRY( _ a t o m i c _ c a s32 )
R0 = [ P 0 ] ;
CC = R 0 = = R 1 ;
IF ! C C J U M P 1 f ;
[ P0 ] = R 2 ;
1 :
rts;
ENDPROC ( _ a t o m i c _ c a s32 )
.align 16
/ *
* Atomic a d d , 3 2 b i t .
* Inputs : P0 : memory a d d r e s s t o u s e
* R0 : value t o a d d
* Outputs : R0 : new c o n t e n t s o f t h e m e m o r y a d d r e s s .
* R1 : previous c o n t e n t s o f t h e m e m o r y a d d r e s s .
* /
ENTRY( _ a t o m i c _ a d d32 )
R1 = [ P 0 ] ;
R0 = R 1 + R 0 ;
[ P0 ] = R 0 ;
rts;
ENDPROC ( _ a t o m i c _ a d d32 )
.align 16
/ *
* Atomic s u b , 3 2 b i t .
* Inputs : P0 : memory a d d r e s s t o u s e
* R0 : value t o s u b t r a c t
* Outputs : R0 : new c o n t e n t s o f t h e m e m o r y a d d r e s s .
* R1 : previous c o n t e n t s o f t h e m e m o r y a d d r e s s .
* /
ENTRY( _ a t o m i c _ s u b32 )
R1 = [ P 0 ] ;
R0 = R 1 - R 0 ;
[ P0 ] = R 0 ;
rts;
ENDPROC ( _ a t o m i c _ s u b32 )
.align 16
/ *
* Atomic i o r , 3 2 b i t .
* Inputs : P0 : memory a d d r e s s t o u s e
* R0 : value t o i o r
* Outputs : R0 : new c o n t e n t s o f t h e m e m o r y a d d r e s s .
* R1 : previous c o n t e n t s o f t h e m e m o r y a d d r e s s .
* /
ENTRY( _ a t o m i c _ i o r32 )
R1 = [ P 0 ] ;
R0 = R 1 | R 0 ;
[ P0 ] = R 0 ;
rts;
ENDPROC ( _ a t o m i c _ i o r32 )
.align 16
/ *
2008-03-04 03:44:14 +03:00
* Atomic a n d , 3 2 b i t .
2007-06-21 07:34:16 +04:00
* Inputs : P0 : memory a d d r e s s t o u s e
2008-03-04 03:44:14 +03:00
* R0 : value t o a n d
2007-06-21 07:34:16 +04:00
* Outputs : R0 : new c o n t e n t s o f t h e m e m o r y a d d r e s s .
* R1 : previous c o n t e n t s o f t h e m e m o r y a d d r e s s .
* /
ENTRY( _ a t o m i c _ a n d32 )
R1 = [ P 0 ] ;
R0 = R 1 & R 0 ;
[ P0 ] = R 0 ;
rts;
2008-03-04 03:44:14 +03:00
ENDPROC ( _ a t o m i c _ a n d32 )
2007-06-21 07:34:16 +04:00
.align 16
/ *
2008-03-04 03:44:14 +03:00
* Atomic x o r , 3 2 b i t .
2007-06-21 07:34:16 +04:00
* Inputs : P0 : memory a d d r e s s t o u s e
2008-03-04 03:44:14 +03:00
* R0 : value t o x o r
2007-06-21 07:34:16 +04:00
* Outputs : R0 : new c o n t e n t s o f t h e m e m o r y a d d r e s s .
* R1 : previous c o n t e n t s o f t h e m e m o r y a d d r e s s .
* /
ENTRY( _ a t o m i c _ x o r32 )
R1 = [ P 0 ] ;
R0 = R 1 ^ R 0 ;
[ P0 ] = R 0 ;
rts;
2008-03-04 03:44:14 +03:00
ENDPROC ( _ a t o m i c _ x o r32 )
2007-06-21 07:34:16 +04:00
2007-10-29 13:23:28 +03:00
.align 16
/ *
* safe_ u s e r _ i n s t r u c t i o n
* Four N O P S a r e e n o u g h t o a l l o w t h e p i p e l i n e t o s p e c u l a t i v i l y l o a d
* execute a n y t h i n g i t w a n t s . A f t e r t h a t , t h i n g s h a v e g o n e b a d , a n d
* we a r e s t u c k - s o p a n i c . S i n c e w e m i g h t b e i n u s e r s p a c e , w e c a n ' t
* call p a n i c , s o j u s t c a u s e a u n h a n d l e d e x c e p t i o n , t h i s s h o u l d c a u s e
* a d u m p o f t h e t r a c e b u f f e r s o w e c a n t e l l w e r e w e a r e , a n d a r e b o o t
* /
ENTRY( _ s a f e _ u s e r _ i n s t r u c t i o n )
NOP; NOP; NOP; NOP;
EXCPT 0 x4 ;
ENDPROC( _ s a f e _ u s e r _ i n s t r u c t i o n )
2007-06-21 07:34:16 +04:00
ENTRY( _ f i x e d _ c o d e _ e n d )
2008-11-18 12:48:22 +03:00
_ _ FINIT