2005-04-17 02:20:36 +04:00
/ *
* This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* License. S e e t h e f i l e " C O P Y I N G " i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* for m o r e d e t a i l s .
*
* Copyright ( C ) 1 9 9 6 , 9 8 , 9 9 , 2 0 0 0 , 0 1 R a l f B a e c h l e
*
* Multi- a r c h a b s t r a c t i o n a n d a s m m a c r o s f o r e a s i e r r e a d i n g :
2011-04-05 01:15:29 +04:00
* Copyright ( C ) 1 9 9 6 D a v i d S . M i l l e r ( d a v e m @davemloft.net)
2005-04-17 02:20:36 +04:00
*
* Carsten L a n g g a a r d , c a r s t e n l @mips.com
* Copyright ( C ) 2 0 0 0 M I P S T e c h n o l o g i e s , I n c .
* Copyright ( C ) 1 9 9 9 , 2 0 0 1 S i l i c o n G r a p h i c s , I n c .
* /
# include < a s m / a s m . h >
2015-06-22 14:20:59 +03:00
# include < a s m / a s m m a c r o . h >
2005-04-17 02:20:36 +04:00
# include < a s m / e r r n o . h >
2017-06-05 21:21:28 +03:00
# include < a s m / e x p o r t . h >
2005-04-17 02:20:36 +04:00
# include < a s m / f p r e g d e f . h >
# include < a s m / m i p s r e g s . h >
2005-09-10 00:32:31 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / r e g d e f . h >
2014-11-07 16:13:54 +03:00
/* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
# undef f p
2005-04-17 02:20:36 +04:00
.macro EX insn, r e g , s r c
.set push
2014-11-07 16:13:54 +03:00
SET_ H A R D F L O A T
2005-04-17 02:20:36 +04:00
.set nomacro
.ex \ @: \insn \reg, \src
.set pop
.section _ _ ex_ t a b l e ," a "
PTR . e x \ @, fault
.previous
.endm
2017-06-05 21:21:28 +03:00
/ *
* Save a t h r e a d ' s f p c o n t e x t .
* /
LEAF( _ s a v e _ f p )
EXPORT_ S Y M B O L ( _ s a v e _ f p )
2017-07-04 01:41:47 +03:00
# if d e f i n e d ( C O N F I G _ 6 4 B I T ) | | d e f i n e d ( C O N F I G _ C P U _ M I P S R 2 ) | | \
defined( C O N F I G _ C P U _ M I P S R 6 )
2017-06-05 21:21:28 +03:00
mfc0 t 0 , C P 0 _ S T A T U S
# endif
fpu_ s a v e _ d o u b l e a0 t 0 t 1 # c l o b b e r s t 1
jr r a
END( _ s a v e _ f p )
/ *
* Restore a t h r e a d ' s f p c o n t e x t .
* /
LEAF( _ r e s t o r e _ f p )
2017-07-04 01:41:47 +03:00
# if d e f i n e d ( C O N F I G _ 6 4 B I T ) | | d e f i n e d ( C O N F I G _ C P U _ M I P S R 2 ) | | \
defined( C O N F I G _ C P U _ M I P S R 6 )
2017-06-05 21:21:28 +03:00
mfc0 t 0 , C P 0 _ S T A T U S
# endif
fpu_ r e s t o r e _ d o u b l e a0 t 0 t 1 # c l o b b e r s t 1
jr r a
END( _ r e s t o r e _ f p )
# ifdef C O N F I G _ C P U _ H A S _ M S A
/ *
* Save a t h r e a d ' s M S A v e c t o r c o n t e x t .
* /
LEAF( _ s a v e _ m s a )
EXPORT_ S Y M B O L ( _ s a v e _ m s a )
msa_ s a v e _ a l l a0
jr r a
END( _ s a v e _ m s a )
/ *
* Restore a t h r e a d ' s M S A v e c t o r c o n t e x t .
* /
LEAF( _ r e s t o r e _ m s a )
msa_ r e s t o r e _ a l l a0
jr r a
END( _ r e s t o r e _ m s a )
LEAF( _ i n i t _ m s a _ u p p e r )
msa_ i n i t _ a l l _ u p p e r
jr r a
END( _ i n i t _ m s a _ u p p e r )
# endif
2005-04-17 02:20:36 +04:00
.set noreorder
2005-05-31 15:49:19 +04:00
2015-07-27 22:58:15 +03:00
/ * *
* _ save_ f p _ c o n t e x t ( ) - s a v e F P c o n t e x t f r o m t h e F P U
* @a0 - pointer to fpregs field of sigcontext
* @a1 - pointer to fpc_csr field of sigcontext
*
* Save F P c o n t e x t , i n c l u d i n g t h e 3 2 F P d a t a r e g i s t e r s a n d t h e F P
* control & s t a t u s r e g i s t e r , f r o m t h e F P U t o s i g n a l c o n t e x t .
* /
2005-04-17 02:20:36 +04:00
LEAF( _ s a v e _ f p _ c o n t e x t )
2014-11-07 16:13:54 +03:00
.set push
SET_ H A R D F L O A T
2005-04-17 02:20:36 +04:00
cfc1 t 1 , f c r31
2014-11-07 16:13:54 +03:00
.set pop
2005-04-17 02:20:36 +04:00
2017-07-04 01:41:47 +03:00
# if d e f i n e d ( C O N F I G _ 6 4 B I T ) | | d e f i n e d ( C O N F I G _ C P U _ M I P S R 2 ) | | \
defined( C O N F I G _ C P U _ M I P S R 6 )
2013-11-22 17:12:07 +04:00
.set push
2014-11-07 16:13:54 +03:00
SET_ H A R D F L O A T
2017-07-04 01:41:47 +03:00
# ifdef C O N F I G _ C P U _ M I P S R 2
2014-11-07 16:13:54 +03:00
.set mips32r2
.set fp=64
2013-11-22 17:12:07 +04:00
mfc0 t 0 , C P 0 _ S T A T U S
sll t 0 , t 0 , 5
bgez t 0 , 1 f # s k i p s t o r i n g o d d i f F R = 0
nop
# endif
2005-04-17 02:20:36 +04:00
/* Store the 16 odd double precision registers */
2015-07-27 22:58:15 +03:00
EX s d c1 $ f1 , 8 ( a0 )
EX s d c1 $ f3 , 2 4 ( a0 )
EX s d c1 $ f5 , 4 0 ( a0 )
EX s d c1 $ f7 , 5 6 ( a0 )
EX s d c1 $ f9 , 7 2 ( a0 )
EX s d c1 $ f11 , 8 8 ( a0 )
EX s d c1 $ f13 , 1 0 4 ( a0 )
EX s d c1 $ f15 , 1 2 0 ( a0 )
EX s d c1 $ f17 , 1 3 6 ( a0 )
EX s d c1 $ f19 , 1 5 2 ( a0 )
EX s d c1 $ f21 , 1 6 8 ( a0 )
EX s d c1 $ f23 , 1 8 4 ( a0 )
EX s d c1 $ f25 , 2 0 0 ( a0 )
EX s d c1 $ f27 , 2 1 6 ( a0 )
EX s d c1 $ f29 , 2 3 2 ( a0 )
EX s d c1 $ f31 , 2 4 8 ( a0 )
2013-11-22 17:12:07 +04:00
1 : .set p o p
2005-04-17 02:20:36 +04:00
# endif
2014-11-07 16:13:54 +03:00
.set push
SET_ H A R D F L O A T
2005-04-17 02:20:36 +04:00
/* Store the 16 even double precision registers */
2015-07-27 22:58:15 +03:00
EX s d c1 $ f0 , 0 ( a0 )
EX s d c1 $ f2 , 1 6 ( a0 )
EX s d c1 $ f4 , 3 2 ( a0 )
EX s d c1 $ f6 , 4 8 ( a0 )
EX s d c1 $ f8 , 6 4 ( a0 )
EX s d c1 $ f10 , 8 0 ( a0 )
EX s d c1 $ f12 , 9 6 ( a0 )
EX s d c1 $ f14 , 1 1 2 ( a0 )
EX s d c1 $ f16 , 1 2 8 ( a0 )
EX s d c1 $ f18 , 1 4 4 ( a0 )
EX s d c1 $ f20 , 1 6 0 ( a0 )
EX s d c1 $ f22 , 1 7 6 ( a0 )
EX s d c1 $ f24 , 1 9 2 ( a0 )
EX s d c1 $ f26 , 2 0 8 ( a0 )
EX s d c1 $ f28 , 2 2 4 ( a0 )
EX s d c1 $ f30 , 2 4 0 ( a0 )
EX s w t 1 , 0 ( a1 )
2005-04-17 02:20:36 +04:00
jr r a
li v0 , 0 # s u c c e s s
2014-11-07 16:13:54 +03:00
.set pop
2005-04-17 02:20:36 +04:00
END( _ s a v e _ f p _ c o n t e x t )
2015-07-27 22:58:15 +03:00
/ * *
* _ restore_ f p _ c o n t e x t ( ) - r e s t o r e F P c o n t e x t t o t h e F P U
* @a0 - pointer to fpregs field of sigcontext
* @a1 - pointer to fpc_csr field of sigcontext
*
* Restore F P c o n t e x t , i n c l u d i n g t h e 3 2 F P d a t a r e g i s t e r s a n d t h e F P
* control & s t a t u s r e g i s t e r , f r o m s i g n a l c o n t e x t t o t h e F P U .
2005-04-17 02:20:36 +04:00
* /
LEAF( _ r e s t o r e _ f p _ c o n t e x t )
2015-07-27 22:58:15 +03:00
EX l w t 1 , 0 ( a1 )
2013-11-22 17:12:07 +04:00
2017-07-04 01:41:47 +03:00
# if d e f i n e d ( C O N F I G _ 6 4 B I T ) | | d e f i n e d ( C O N F I G _ C P U _ M I P S R 2 ) | | \
defined( C O N F I G _ C P U _ M I P S R 6 )
2013-11-22 17:12:07 +04:00
.set push
2014-11-07 16:13:54 +03:00
SET_ H A R D F L O A T
2017-07-04 01:41:47 +03:00
# ifdef C O N F I G _ C P U _ M I P S R 2
2014-11-07 16:13:54 +03:00
.set mips32r2
.set fp=64
2013-11-22 17:12:07 +04:00
mfc0 t 0 , C P 0 _ S T A T U S
sll t 0 , t 0 , 5
bgez t 0 , 1 f # s k i p l o a d i n g o d d i f F R = 0
nop
# endif
2015-07-27 22:58:15 +03:00
EX l d c1 $ f1 , 8 ( a0 )
EX l d c1 $ f3 , 2 4 ( a0 )
EX l d c1 $ f5 , 4 0 ( a0 )
EX l d c1 $ f7 , 5 6 ( a0 )
EX l d c1 $ f9 , 7 2 ( a0 )
EX l d c1 $ f11 , 8 8 ( a0 )
EX l d c1 $ f13 , 1 0 4 ( a0 )
EX l d c1 $ f15 , 1 2 0 ( a0 )
EX l d c1 $ f17 , 1 3 6 ( a0 )
EX l d c1 $ f19 , 1 5 2 ( a0 )
EX l d c1 $ f21 , 1 6 8 ( a0 )
EX l d c1 $ f23 , 1 8 4 ( a0 )
EX l d c1 $ f25 , 2 0 0 ( a0 )
EX l d c1 $ f27 , 2 1 6 ( a0 )
EX l d c1 $ f29 , 2 3 2 ( a0 )
EX l d c1 $ f31 , 2 4 8 ( a0 )
2013-11-22 17:12:07 +04:00
1 : .set p o p
2005-04-17 02:20:36 +04:00
# endif
2014-11-07 16:13:54 +03:00
.set push
SET_ H A R D F L O A T
2015-07-27 22:58:15 +03:00
EX l d c1 $ f0 , 0 ( a0 )
EX l d c1 $ f2 , 1 6 ( a0 )
EX l d c1 $ f4 , 3 2 ( a0 )
EX l d c1 $ f6 , 4 8 ( a0 )
EX l d c1 $ f8 , 6 4 ( a0 )
EX l d c1 $ f10 , 8 0 ( a0 )
EX l d c1 $ f12 , 9 6 ( a0 )
EX l d c1 $ f14 , 1 1 2 ( a0 )
EX l d c1 $ f16 , 1 2 8 ( a0 )
EX l d c1 $ f18 , 1 4 4 ( a0 )
EX l d c1 $ f20 , 1 6 0 ( a0 )
EX l d c1 $ f22 , 1 7 6 ( a0 )
EX l d c1 $ f24 , 1 9 2 ( a0 )
EX l d c1 $ f26 , 2 0 8 ( a0 )
EX l d c1 $ f28 , 2 2 4 ( a0 )
EX l d c1 $ f30 , 2 4 0 ( a0 )
2014-02-07 18:31:33 +04:00
ctc1 t 1 , f c r31
2014-11-07 16:13:54 +03:00
.set pop
2005-04-17 02:20:36 +04:00
jr r a
li v0 , 0 # s u c c e s s
END( _ r e s t o r e _ f p _ c o n t e x t )
2015-06-22 14:20:59 +03:00
# ifdef C O N F I G _ C P U _ H A S _ M S A
.macro op_one_wr op, i d x , b a s e
.align 4
\ idx : \ op \ i d x , 0 , \ b a s e
jr r a
nop
.endm
.macro op_msa_wr name, o p
LEAF( \ n a m e )
.set push
.set noreorder
sll t 0 , a0 , 4
PTR_ L A t 1 , 0 f
PTR_ A D D U t 0 , t 0 , t 1
jr t 0
nop
op_ o n e _ w r \ o p , 0 , a1
op_ o n e _ w r \ o p , 1 , a1
op_ o n e _ w r \ o p , 2 , a1
op_ o n e _ w r \ o p , 3 , a1
op_ o n e _ w r \ o p , 4 , a1
op_ o n e _ w r \ o p , 5 , a1
op_ o n e _ w r \ o p , 6 , a1
op_ o n e _ w r \ o p , 7 , a1
op_ o n e _ w r \ o p , 8 , a1
op_ o n e _ w r \ o p , 9 , a1
op_ o n e _ w r \ o p , 1 0 , a1
op_ o n e _ w r \ o p , 1 1 , a1
op_ o n e _ w r \ o p , 1 2 , a1
op_ o n e _ w r \ o p , 1 3 , a1
op_ o n e _ w r \ o p , 1 4 , a1
op_ o n e _ w r \ o p , 1 5 , a1
op_ o n e _ w r \ o p , 1 6 , a1
op_ o n e _ w r \ o p , 1 7 , a1
op_ o n e _ w r \ o p , 1 8 , a1
op_ o n e _ w r \ o p , 1 9 , a1
op_ o n e _ w r \ o p , 2 0 , a1
op_ o n e _ w r \ o p , 2 1 , a1
op_ o n e _ w r \ o p , 2 2 , a1
op_ o n e _ w r \ o p , 2 3 , a1
op_ o n e _ w r \ o p , 2 4 , a1
op_ o n e _ w r \ o p , 2 5 , a1
op_ o n e _ w r \ o p , 2 6 , a1
op_ o n e _ w r \ o p , 2 7 , a1
op_ o n e _ w r \ o p , 2 8 , a1
op_ o n e _ w r \ o p , 2 9 , a1
op_ o n e _ w r \ o p , 3 0 , a1
op_ o n e _ w r \ o p , 3 1 , a1
.set pop
END( \ n a m e )
.endm
op_ m s a _ w r r e a d _ m s a _ w r _ b , s t _ b
op_ m s a _ w r r e a d _ m s a _ w r _ h , s t _ h
op_ m s a _ w r r e a d _ m s a _ w r _ w , s t _ w
op_ m s a _ w r r e a d _ m s a _ w r _ d , s t _ d
op_ m s a _ w r w r i t e _ m s a _ w r _ b , l d _ b
op_ m s a _ w r w r i t e _ m s a _ w r _ h , l d _ h
op_ m s a _ w r w r i t e _ m s a _ w r _ w , l d _ w
op_ m s a _ w r w r i t e _ m s a _ w r _ d , l d _ d
2015-07-27 22:58:22 +03:00
# endif / * C O N F I G _ C P U _ H A S _ M S A * /
# ifdef C O N F I G _ C P U _ H A S _ M S A
.macro save_msa_upper wr, o f f , b a s e
.set push
.set noat
# ifdef C O N F I G _ 6 4 B I T
2016-04-15 12:07:23 +03:00
copy_ s _ d \ w r , 1
2015-07-27 22:58:22 +03:00
EX s d $ 1 , \ o f f ( \ b a s e )
# elif d e f i n e d ( C O N F I G _ C P U _ L I T T L E _ E N D I A N )
2016-04-15 12:07:23 +03:00
copy_ s _ w \ w r , 2
2015-07-27 22:58:22 +03:00
EX s w $ 1 , \ o f f ( \ b a s e )
2016-04-15 12:07:23 +03:00
copy_ s _ w \ w r , 3
2015-07-27 22:58:22 +03:00
EX s w $ 1 , ( \ o f f + 4 ) ( \ b a s e )
# else / * C O N F I G _ C P U _ B I G _ E N D I A N * /
2016-04-15 12:07:23 +03:00
copy_ s _ w \ w r , 2
2015-07-27 22:58:22 +03:00
EX s w $ 1 , ( \ o f f + 4 ) ( \ b a s e )
2016-04-15 12:07:23 +03:00
copy_ s _ w \ w r , 3
2015-07-27 22:58:22 +03:00
EX s w $ 1 , \ o f f ( \ b a s e )
# endif
.set pop
.endm
LEAF( _ s a v e _ m s a _ a l l _ u p p e r )
save_ m s a _ u p p e r 0 , 0 x00 , a0
save_ m s a _ u p p e r 1 , 0 x08 , a0
save_ m s a _ u p p e r 2 , 0 x10 , a0
save_ m s a _ u p p e r 3 , 0 x18 , a0
save_ m s a _ u p p e r 4 , 0 x20 , a0
save_ m s a _ u p p e r 5 , 0 x28 , a0
save_ m s a _ u p p e r 6 , 0 x30 , a0
save_ m s a _ u p p e r 7 , 0 x38 , a0
save_ m s a _ u p p e r 8 , 0 x40 , a0
save_ m s a _ u p p e r 9 , 0 x48 , a0
save_ m s a _ u p p e r 1 0 , 0 x50 , a0
save_ m s a _ u p p e r 1 1 , 0 x58 , a0
save_ m s a _ u p p e r 1 2 , 0 x60 , a0
save_ m s a _ u p p e r 1 3 , 0 x68 , a0
save_ m s a _ u p p e r 1 4 , 0 x70 , a0
save_ m s a _ u p p e r 1 5 , 0 x78 , a0
save_ m s a _ u p p e r 1 6 , 0 x80 , a0
save_ m s a _ u p p e r 1 7 , 0 x88 , a0
save_ m s a _ u p p e r 1 8 , 0 x90 , a0
save_ m s a _ u p p e r 1 9 , 0 x98 , a0
save_ m s a _ u p p e r 2 0 , 0 x a0 , a0
save_ m s a _ u p p e r 2 1 , 0 x a8 , a0
save_ m s a _ u p p e r 2 2 , 0 x b0 , a0
save_ m s a _ u p p e r 2 3 , 0 x b8 , a0
save_ m s a _ u p p e r 2 4 , 0 x c0 , a0
save_ m s a _ u p p e r 2 5 , 0 x c8 , a0
save_ m s a _ u p p e r 2 6 , 0 x d0 , a0
save_ m s a _ u p p e r 2 7 , 0 x d8 , a0
save_ m s a _ u p p e r 2 8 , 0 x e 0 , a0
save_ m s a _ u p p e r 2 9 , 0 x e 8 , a0
save_ m s a _ u p p e r 3 0 , 0 x f0 , a0
save_ m s a _ u p p e r 3 1 , 0 x f8 , a0
jr r a
li v0 , 0
END( _ s a v e _ m s a _ a l l _ u p p e r )
.macro restore_msa_upper wr, o f f , b a s e
.set push
.set noat
# ifdef C O N F I G _ 6 4 B I T
EX l d $ 1 , \ o f f ( \ b a s e )
insert_ d \ w r , 1
# elif d e f i n e d ( C O N F I G _ C P U _ L I T T L E _ E N D I A N )
EX l w $ 1 , \ o f f ( \ b a s e )
insert_ w \ w r , 2
EX l w $ 1 , ( \ o f f + 4 ) ( \ b a s e )
insert_ w \ w r , 3
# else / * C O N F I G _ C P U _ B I G _ E N D I A N * /
EX l w $ 1 , ( \ o f f + 4 ) ( \ b a s e )
insert_ w \ w r , 2
EX l w $ 1 , \ o f f ( \ b a s e )
insert_ w \ w r , 3
# endif
.set pop
.endm
LEAF( _ r e s t o r e _ m s a _ a l l _ u p p e r )
restore_ m s a _ u p p e r 0 , 0 x00 , a0
restore_ m s a _ u p p e r 1 , 0 x08 , a0
restore_ m s a _ u p p e r 2 , 0 x10 , a0
restore_ m s a _ u p p e r 3 , 0 x18 , a0
restore_ m s a _ u p p e r 4 , 0 x20 , a0
restore_ m s a _ u p p e r 5 , 0 x28 , a0
restore_ m s a _ u p p e r 6 , 0 x30 , a0
restore_ m s a _ u p p e r 7 , 0 x38 , a0
restore_ m s a _ u p p e r 8 , 0 x40 , a0
restore_ m s a _ u p p e r 9 , 0 x48 , a0
restore_ m s a _ u p p e r 1 0 , 0 x50 , a0
restore_ m s a _ u p p e r 1 1 , 0 x58 , a0
restore_ m s a _ u p p e r 1 2 , 0 x60 , a0
restore_ m s a _ u p p e r 1 3 , 0 x68 , a0
restore_ m s a _ u p p e r 1 4 , 0 x70 , a0
restore_ m s a _ u p p e r 1 5 , 0 x78 , a0
restore_ m s a _ u p p e r 1 6 , 0 x80 , a0
restore_ m s a _ u p p e r 1 7 , 0 x88 , a0
restore_ m s a _ u p p e r 1 8 , 0 x90 , a0
restore_ m s a _ u p p e r 1 9 , 0 x98 , a0
restore_ m s a _ u p p e r 2 0 , 0 x a0 , a0
restore_ m s a _ u p p e r 2 1 , 0 x a8 , a0
restore_ m s a _ u p p e r 2 2 , 0 x b0 , a0
restore_ m s a _ u p p e r 2 3 , 0 x b8 , a0
restore_ m s a _ u p p e r 2 4 , 0 x c0 , a0
restore_ m s a _ u p p e r 2 5 , 0 x c8 , a0
restore_ m s a _ u p p e r 2 6 , 0 x d0 , a0
restore_ m s a _ u p p e r 2 7 , 0 x d8 , a0
restore_ m s a _ u p p e r 2 8 , 0 x e 0 , a0
restore_ m s a _ u p p e r 2 9 , 0 x e 8 , a0
restore_ m s a _ u p p e r 3 0 , 0 x f0 , a0
restore_ m s a _ u p p e r 3 1 , 0 x f8 , a0
jr r a
li v0 , 0
END( _ r e s t o r e _ m s a _ a l l _ u p p e r )
2015-06-22 14:20:59 +03:00
# endif / * C O N F I G _ C P U _ H A S _ M S A * /
2007-02-01 22:54:13 +03:00
.set reorder
2016-02-23 13:29:20 +03:00
.type fault, @function
2005-04-17 02:20:36 +04:00
.ent fault
fault : li v0 , - E F A U L T # f a i l u r e
jr r a
.end fault