2010-02-19 13:00:40 +03:00
/ *
* FPU h e l p e r c o d e t o u s e F P U o p e r a t i o n s f r o m i n s i d e t h e k e r n e l
*
* Copyright ( C ) 2 0 1 0 A l e x a n d e r G r a f ( a g r a f @suse.de)
*
* 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 .
*
* /
# include < a s m / r e g . h >
# include < a s m / p a g e . h >
# include < a s m / m m u . h >
# include < a s m / p g t a b l e . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / c a c h e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / a s m - o f f s e t s . h >
/* Instructions operating on single parameters */
/ *
* Single o p e r a t i o n w i t h o n e i n p u t o p e r a n d
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( s h o r t * ) & r e s u l t
* R5 = ( s h o r t * ) & p a r a m 1
* /
# define F P S _ O N E _ I N ( n a m e ) \
_ GLOBAL( f p s _ ## n a m e ) ; \
lfd 0 ,0 ( r3 ) ; /* load up fpscr value */ \
MTFSF_ L ( 0 ) ; \
lfs 0 ,0 ( r5 ) ; \
\
name 0 ,0 ; \
\
stfs 0 ,0 ( r4 ) ; \
mffs 0 ; \
stfd 0 ,0 ( r3 ) ; /* save new fpscr value */ \
blr
/ *
* Single o p e r a t i o n w i t h t w o i n p u t o p e r a n d s
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( s h o r t * ) & r e s u l t
* R5 = ( s h o r t * ) & p a r a m 1
* R6 = ( s h o r t * ) & p a r a m 2
* /
# define F P S _ T W O _ I N ( n a m e ) \
_ GLOBAL( f p s _ ## n a m e ) ; \
lfd 0 ,0 ( r3 ) ; /* load up fpscr value */ \
MTFSF_ L ( 0 ) ; \
lfs 0 ,0 ( r5 ) ; \
lfs 1 ,0 ( r6 ) ; \
\
name 0 ,0 ,1 ; \
\
stfs 0 ,0 ( r4 ) ; \
mffs 0 ; \
stfd 0 ,0 ( r3 ) ; /* save new fpscr value */ \
blr
/ *
* Single o p e r a t i o n w i t h t h r e e i n p u t o p e r a n d s
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( s h o r t * ) & r e s u l t
* R5 = ( s h o r t * ) & p a r a m 1
* R6 = ( s h o r t * ) & p a r a m 2
* R7 = ( s h o r t * ) & p a r a m 3
* /
# define F P S _ T H R E E _ I N ( n a m e ) \
_ GLOBAL( f p s _ ## n a m e ) ; \
lfd 0 ,0 ( r3 ) ; /* load up fpscr value */ \
MTFSF_ L ( 0 ) ; \
lfs 0 ,0 ( r5 ) ; \
lfs 1 ,0 ( r6 ) ; \
lfs 2 ,0 ( r7 ) ; \
\
name 0 ,0 ,1 ,2 ; \
\
stfs 0 ,0 ( r4 ) ; \
mffs 0 ; \
stfd 0 ,0 ( r3 ) ; /* save new fpscr value */ \
blr
FPS_ O N E _ I N ( f r e s )
FPS_ O N E _ I N ( f r s q r t e )
FPS_ O N E _ I N ( f s q r t s )
FPS_ T W O _ I N ( f a d d s )
FPS_ T W O _ I N ( f d i v s )
FPS_ T W O _ I N ( f m u l s )
FPS_ T W O _ I N ( f s u b s )
FPS_ T H R E E _ I N ( f m a d d s )
FPS_ T H R E E _ I N ( f m s u b s )
FPS_ T H R E E _ I N ( f n m a d d s )
FPS_ T H R E E _ I N ( f n m s u b s )
FPS_ T H R E E _ I N ( f s e l )
/* Instructions operating on double parameters */
/ *
* Beginning o f d o u b l e i n s t r u c t i o n p r o c e s s i n g
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & r e s u l t
* R6 = ( d o u b l e * ) & p a r a m 1
* R7 = ( d o u b l e * ) & p a r a m 2 [ l o a d _ t w o ]
* R8 = ( d o u b l e * ) & p a r a m 3 [ l o a d _ t h r e e ]
* LR = i n s t r u c t i o n c a l l f u n c t i o n
* /
fpd_load_three :
lfd 2 ,0 ( r8 ) / * l o a d p a r a m 3 * /
fpd_load_two :
lfd 1 ,0 ( r7 ) / * l o a d p a r a m 2 * /
fpd_load_one :
lfd 0 ,0 ( r6 ) / * l o a d p a r a m 1 * /
fpd_load_none :
lfd 3 ,0 ( r3 ) / * l o a d u p f p s c r v a l u e * /
MTFSF_ L ( 3 )
lwz r6 , 0 ( r4 ) / * l o a d c r * /
mtcr r6
blr
/ *
* End o f d o u b l e i n s t r u c t i o n p r o c e s s i n g
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & r e s u l t
* LR = c a l l e r o f i n s t r u c t i o n c a l l f u n c t i o n
* /
fpd_return :
mfcr r6
stfd 0 ,0 ( r5 ) / * s a v e r e s u l t * /
mffs 0
stfd 0 ,0 ( r3 ) / * s a v e n e w f p s c r v a l u e * /
stw r6 ,0 ( r4 ) / * s a v e n e w c r v a l u e * /
blr
/ *
* Double o p e r a t i o n w i t h n o i n p u t o p e r a n d
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & r e s u l t
* /
# define F P D _ N O N E _ I N ( n a m e ) \
_ GLOBAL( f p d _ ## n a m e ) ; \
mflr r12 ; \
bl f p d _ l o a d _ n o n e ; \
mtlr r12 ; \
\
name. 0 ; /* call instruction */ \
b f p d _ r e t u r n
/ *
* Double o p e r a t i o n w i t h o n e i n p u t o p e r a n d
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & r e s u l t
* R6 = ( d o u b l e * ) & p a r a m 1
* /
# define F P D _ O N E _ I N ( n a m e ) \
_ GLOBAL( f p d _ ## n a m e ) ; \
mflr r12 ; \
bl f p d _ l o a d _ o n e ; \
mtlr r12 ; \
\
name. 0 ,0 ; /* call instruction */ \
b f p d _ r e t u r n
/ *
* Double o p e r a t i o n w i t h t w o i n p u t o p e r a n d s
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & r e s u l t
* R6 = ( d o u b l e * ) & p a r a m 1
* R7 = ( d o u b l e * ) & p a r a m 2
* R8 = ( d o u b l e * ) & p a r a m 3
* /
# define F P D _ T W O _ I N ( n a m e ) \
_ GLOBAL( f p d _ ## n a m e ) ; \
mflr r12 ; \
bl f p d _ l o a d _ t w o ; \
mtlr r12 ; \
\
name. 0 ,0 ,1 ; /* call instruction */ \
b f p d _ r e t u r n
/ *
* CR D o u b l e o p e r a t i o n w i t h t w o i n p u t o p e r a n d s
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & p a r a m 1
* R6 = ( d o u b l e * ) & p a r a m 2
* R7 = ( d o u b l e * ) & p a r a m 3
* /
# define F P D _ T W O _ I N _ C R ( n a m e ) \
_ GLOBAL( f p d _ ## n a m e ) ; \
lfd 1 ,0 ( r6 ) ; /* load param2 */ \
lfd 0 ,0 ( r5 ) ; /* load param1 */ \
lfd 3 ,0 ( r3 ) ; /* load up fpscr value */ \
MTFSF_ L ( 3 ) ; \
lwz r6 , 0 ( r4 ) ; /* load cr */ \
mtcr r6 ; \
\
name 0 ,0 ,1 ; /* call instruction */ \
mfcr r6 ; \
mffs 0 ; \
stfd 0 ,0 ( r3 ) ; /* save new fpscr value */ \
stw r6 ,0 ( r4 ) ; /* save new cr value */ \
blr
/ *
* Double o p e r a t i o n w i t h t h r e e i n p u t o p e r a n d s
*
* R3 = ( d o u b l e * ) & f p s c r
* R4 = ( u 3 2 * ) & c r
* R5 = ( d o u b l e * ) & r e s u l t
* R6 = ( d o u b l e * ) & p a r a m 1
* R7 = ( d o u b l e * ) & p a r a m 2
* R8 = ( d o u b l e * ) & p a r a m 3
* /
# define F P D _ T H R E E _ I N ( n a m e ) \
_ GLOBAL( f p d _ ## n a m e ) ; \
mflr r12 ; \
bl f p d _ l o a d _ t h r e e ; \
mtlr r12 ; \
\
name. 0 ,0 ,1 ,2 ; /* call instruction */ \
b f p d _ r e t u r n
FPD_ O N E _ I N ( f s q r t s )
FPD_ O N E _ I N ( f r s q r t e s )
FPD_ O N E _ I N ( f r e s )
FPD_ O N E _ I N ( f r s p )
FPD_ O N E _ I N ( f c t i w )
FPD_ O N E _ I N ( f c t i w z )
FPD_ O N E _ I N ( f s q r t )
FPD_ O N E _ I N ( f r e )
FPD_ O N E _ I N ( f r s q r t e )
FPD_ O N E _ I N ( f n e g )
FPD_ O N E _ I N ( f a b s )
FPD_ T W O _ I N ( f a d d s )
FPD_ T W O _ I N ( f s u b s )
FPD_ T W O _ I N ( f d i v s )
FPD_ T W O _ I N ( f m u l s )
FPD_ T W O _ I N _ C R ( f c m p u )
FPD_ T W O _ I N ( f c p s g n )
FPD_ T W O _ I N ( f d i v )
FPD_ T W O _ I N ( f a d d )
FPD_ T W O _ I N ( f m u l )
FPD_ T W O _ I N _ C R ( f c m p o )
FPD_ T W O _ I N ( f s u b )
FPD_ T H R E E _ I N ( f m s u b s )
FPD_ T H R E E _ I N ( f m a d d s )
FPD_ T H R E E _ I N ( f n m s u b s )
FPD_ T H R E E _ I N ( f n m a d d s )
FPD_ T H R E E _ I N ( f s e l )
FPD_ T H R E E _ I N ( f m s u b )
FPD_ T H R E E _ I N ( f m a d d )
FPD_ T H R E E _ I N ( f n m s u b )
FPD_ T H R E E _ I N ( f n m a d d )
2010-05-31 23:59:13 +04:00
_ GLOBAL( k v m _ c v t _ f d )
lfs 0 ,0 ( r3 )
stfd 0 ,0 ( r4 )
blr
_ GLOBAL( k v m _ c v t _ d f )
lfd 0 ,0 ( r3 )
stfs 0 ,0 ( r4 )
blr