2005-04-17 02:20:36 +04:00
/ *
* r2 3 0 0 _ s w i t c h . S : R 2 3 0 0 s p e c i f i c t a s k s w i t c h i n g c o d e .
*
* Copyright ( C ) 1 9 9 4 , 1 9 9 5 , 1 9 9 6 , 1 9 9 9 b y R a l f B a e c h l e
* Copyright ( C ) 1 9 9 4 , 1 9 9 5 , 1 9 9 6 b y A n d r e a s B u s s e
*
* Multi- c p u a b s t r a c t i o n a n d m a c r o s f o r e a s i e r r e a d i n g :
* Copyright ( C ) 1 9 9 6 D a v i d S . M i l l e r ( d m @engr.sgi.com)
*
* Further m o d i f i c a t i o n s t o m a k e t h i s w o r k :
* Copyright ( c ) 1 9 9 8 - 2 0 0 0 H a r a l d K o e r f g e n
* /
# include < l i n u x / c o n f i g . h >
# include < a s m / a s m . h >
# include < a s m / c a c h e c t l . h >
# 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 >
# include < a s m / o f f s e t . h >
# include < a s m / p a g e . h >
# include < a s m / r e g d e f . h >
# include < a s m / s t a c k f r a m e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / a s m m a c r o . h >
.set mips1
.align 5
/ *
* Offset t o t h e c u r r e n t p r o c e s s s t a t u s f l a g s , t h e f i r s t 3 2 b y t e s o f t h e
* stack a r e n o t u s e d .
* /
# define S T _ O F F ( _ T H R E A D _ S I Z E - 3 2 - P T _ S I Z E + P T _ S T A T U S )
/ *
* FPU c o n t e x t i s s a v e d i f f t h e p r o c e s s h a s u s e d i t ' s F P U i n t h e c u r r e n t
* time s l i c e a s i n d i c a t e d b y T I F _ U S E D F P U . I n a n y c a s e , t h e C U 1 b i t f o r u s e r
2005-09-04 02:56:17 +04:00
* space S T A T U S r e g i s t e r s h o u l d b e 0 , s o t h a t a p r o c e s s * a l w a y s * s t a r t s i t s
2005-04-17 02:20:36 +04:00
* userland w i t h F P U d i s a b l e d a f t e r e a c h c o n t e x t s w i t c h .
*
* FPU w i l l b e e n a b l e d a s s o o n a s t h e p r o c e s s a c c e s s e s F P U a g a i n , t h r o u g h
* do_ c p u ( ) t r a p .
* /
/ *
* task_ s t r u c t * r e s u m e ( t a s k _ s t r u c t * p r e v , t a s k _ s t r u c t * n e x t ,
* struct t h r e a d _ i n f o * n e x t _ t i ) )
* /
LEAF( r e s u m e )
# ifndef C O N F I G _ C P U _ H A S _ L L S C
sw z e r o , l l _ b i t
# endif
mfc0 t 1 , C P 0 _ S T A T U S
sw t 1 , T H R E A D _ S T A T U S ( a0 )
cpu_ s a v e _ n o n s c r a t c h a0
sw r a , T H R E A D _ R E G 3 1 ( a0 )
2005-09-04 02:56:17 +04:00
/ *
2005-04-17 02:20:36 +04:00
* check i f w e n e e d t o s a v e F P U r e g i s t e r s
* /
lw t 3 , T A S K _ T H R E A D _ I N F O ( a0 )
lw t 0 , T I _ F L A G S ( t 3 )
li t 1 , _ T I F _ U S E D F P U
and t 2 , t 0 , t 1
beqz t 2 , 1 f
nor t 1 , z e r o , t 1
and t 0 , t 0 , t 1
sw t 0 , T I _ F L A G S ( t 3 )
/ *
* clear s a v e d u s e r s t a c k C U 1 b i t
* /
lw t 0 , S T _ O F F ( t 3 )
li t 1 , ~ S T 0 _ C U 1
and t 0 , t 0 , t 1
sw t 0 , S T _ O F F ( t 3 )
fpu_ s a v e _ s i n g l e a0 , t 0 # c l o b b e r s t 0
1 :
/ *
* The o r d e r o f r e s t o r i n g t h e r e g i s t e r s t a k e s c a r e o f t h e r a c e
* updating $ 2 8 , $ 2 9 a n d k e r n e l s p w i t h o u t d i s a b l i n g i n t s .
* /
move $ 2 8 , a2
cpu_ r e s t o r e _ n o n s c r a t c h a1
addiu t 1 , $ 2 8 , _ T H R E A D _ S I Z E - 3 2
sw t 1 , k e r n e l s p
mfc0 t 1 , C P 0 _ S T A T U S / * D o w e r e a l l y n e e d t h i s ? * /
li a3 , 0 x f f01
and t 1 , a3
lw a2 , T H R E A D _ S T A T U S ( a1 )
nor a3 , $ 0 , a3
and a2 , a3
or a2 , t 1
mtc0 a2 , C P 0 _ S T A T U S
move v0 , a0
jr r a
END( r e s u m e )
/ *
* 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 )
fpu_ s a v e _ s i n g l e a0 , 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 )
fpu_ r e s t o r e _ s i n g l e a0 , 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 )
/ *
* Load t h e F P U w i t h s i g n a l l i n g N A N S . T h i s b i t p a t t e r n w e ' r e u s i n g h a s
* the p r o p e r t y t h a t n o m a t t e r w h e t h e r c o n s i d e r e d a s s i n g l e o r a s d o u b l e
* precision r e p r e s e n t s s i g n a l i n g N A N S .
*
* We i n i t i a l i z e f c r31 t o r o u n d i n g t o n e a r e s t , n o e x c e p t i o n s .
* /
# define F P U _ D E F A U L T 0 x00 0 0 0 0 0 0
LEAF( _ i n i t _ f p u )
mfc0 t 0 , C P 0 _ S T A T U S
li t 1 , S T 0 _ C U 1
or t 0 , t 1
mtc0 t 0 , C P 0 _ S T A T U S
li t 1 , F P U _ D E F A U L T
ctc1 t 1 , f c r31
li t 0 , - 1
mtc1 t 0 , $ f0
mtc1 t 0 , $ f1
mtc1 t 0 , $ f2
mtc1 t 0 , $ f3
mtc1 t 0 , $ f4
mtc1 t 0 , $ f5
mtc1 t 0 , $ f6
mtc1 t 0 , $ f7
mtc1 t 0 , $ f8
mtc1 t 0 , $ f9
mtc1 t 0 , $ f10
mtc1 t 0 , $ f11
mtc1 t 0 , $ f12
mtc1 t 0 , $ f13
mtc1 t 0 , $ f14
mtc1 t 0 , $ f15
mtc1 t 0 , $ f16
mtc1 t 0 , $ f17
mtc1 t 0 , $ f18
mtc1 t 0 , $ f19
mtc1 t 0 , $ f20
mtc1 t 0 , $ f21
mtc1 t 0 , $ f22
mtc1 t 0 , $ f23
mtc1 t 0 , $ f24
mtc1 t 0 , $ f25
mtc1 t 0 , $ f26
mtc1 t 0 , $ f27
mtc1 t 0 , $ f28
mtc1 t 0 , $ f29
mtc1 t 0 , $ f30
mtc1 t 0 , $ f31
jr r a
END( _ i n i t _ f p u )