2005-04-16 15:20:36 -07:00
/ * $ Id : dtlb_ b a s e . S ,v 1 . 1 7 2 0 0 1 / 1 0 / 1 1 2 2 : 3 3 : 5 2 d a v e m E x p $
* dtlb_ b a s e . S : F r o n t e n d t o D T L B m i s s r e p l a c e m e n t s t r a t e g y .
* This i s i n c l u d e d d i r e c t l y i n t o t h e t r a p t a b l e .
*
* Copyright ( C ) 1 9 9 6 ,1 9 9 8 D a v i d S . M i l l e r ( d a v e m @redhat.com)
* Copyright ( C ) 1 9 9 7 ,1 9 9 8 J a k u b J e l i n e k ( j j @ultra.linux.cz)
* /
# include < a s m / p g t a b l e . h >
# include < a s m / m m u . h >
/ * % g1 T L B _ S F S R ( % g 1 + % g 1 = = T L B _ T A G _ A C C E S S )
* % g2 ( K E R N _ H I G H B I T S | K E R N _ L O W B I T S )
* % g3 V P T E b a s e ( 0 x f f f f f f f e 0 0 0 0 0 0 0 0 ) S p i t f i r e / B l a c k b i r d ( 4 4 - b i t V A s p a c e )
* ( 0 xffe0 0 0 0 0 0 0 0 0 0 0 0 0 ) C h e e t a h ( 6 4 - b i t V A s p a c e )
* % g7 _ _ p a ( c u r r e n t - > m m - > p g d )
*
* The V P T E b a s e v a l u e i s c o m p l e t e l y m a g i c , b u t n o t e t h a t
* few p l a c e s i n t h e k e r n e l o t h e r t h a n t h e s e T L B m i s s
* handlers k n o w a n y t h i n g a b o u t t h e V P T E m e c h a n i s m o r
* how i t w o r k s ( s e e V P T E _ S I Z E , T A S K _ S I Z E a n d P T R S _ P E R _ P G D ) .
* Consider t h e 4 4 - b i t V A D D R U l t r a - I / I I c a s e a s a n e x a m p l e :
*
* VA[ 0 : ( 1 < < 4 3 ) ] p r o d u c e V P T E i n d e x [ % g 3 : 0 ]
* VA[ 0 : - ( 1 < < 4 3 ) ] p r o d u c e V P T E i n d e x [ % g 3 - ( 1 < < ( 4 3 - P A G E _ S H I F T + 3 ) ) : % g 3 ]
*
* For C h e e t a h ' s 6 4 - b i t V A D D R s p a c e t h i s i s :
*
* VA[ 0 : ( 1 < < 6 3 ) ] p r o d u c e V P T E i n d e x [ % g 3 : 0 ]
* VA[ 0 : - ( 1 < < 6 3 ) ] p r o d u c e V P T E i n d e x [ % g 3 - ( 1 < < ( 6 3 - P A G E _ S H I F T + 3 ) ) : % g 3 ]
*
* If y o u ' r e p a y i n g a t t e n t i o n y o u ' l l n o t i c e t h a t t h i s m e a n s h a l f o f
* the V P T E t a b l e i s a b o v e % g 3 a n d h a l f i s b e l o w , l o w V A a d d r e s s e s
* map p r o g r e s s i v e l y u p w a r d s f r o m % g 3 , a n d h i g h V A a d d r e s s e s m a p
* progressively u p w a r d s t o w a r d s % g 3 . T h i s t r i c k w a s n e e d e d t o m a k e
* the s a m e 8 i n s t r u c t i o n h a n d l e r w o r k b o t h f o r S p i t f i r e / B l a c k b i r d ' s
* peculiar V A s p a c e h o l e c o n f i g u r a t i o n a n d t h e f u l l 6 4 - b i t V A s p a c e
* one o f C h e e t a h a t t h e s a m e t i m e .
* /
/ * Ways w e c a n g e t h e r e :
*
* 1 ) Nucleus l o a d s a n d s t o r e s t o / f r o m P A - - > V A d i r e c t m a p p i n g s .
* 2 ) Nucleus l o a d s a n d s t o r e s t o / f r o m v m a l l o c ( ) a r e a s .
* 3 ) User l o a d s a n d s t o r e s .
* 4 ) User s p a c e a c c e s s e s b y n u c l e u s a t t l 0
* /
# if P A G E _ S H I F T = = 1 3
/ *
* To c o m p u t e v p t e o f f s e t , w e n e e d t o d o ( ( a d d r > > 1 3 ) < < 3 ) ,
* which c a n b e o p t i m i z e d t o ( a d d r > > 1 0 ) i f b i t s 1 0 / 1 1 / 1 2 c a n
* be g u a r a n t e e d t o b e 0 . . . m m u _ c o n t e x t . h d o e s g u a r a n t e e t h i s
* by o n l y u s i n g 1 0 b i t s i n t h e h w c o n t e x t v a l u e .
* /
2005-10-12 12:22:46 -07:00
# define C R E A T E _ V P T E _ O F F S E T 1 ( r1 , r2 ) n o p
2005-04-16 15:20:36 -07:00
# define C R E A T E _ V P T E _ O F F S E T 2 ( r1 , r2 ) \
srax r1 , 1 0 , r2
# else
# define C R E A T E _ V P T E _ O F F S E T 1 ( r1 , r2 ) \
srax r1 , P A G E _ S H I F T , r2
# define C R E A T E _ V P T E _ O F F S E T 2 ( r1 , r2 ) \
sllx r2 , 3 , r2
# endif
/* DTLB ** ICACHE line 1: Quick user TLB misses */
2005-10-12 12:22:46 -07:00
mov T L B _ S F S R , % g 1
2005-04-16 15:20:36 -07:00
ldxa [ % g 1 + % g 1 ] A S I _ D M M U , % g 4 ! G e t T A G _ A C C E S S
andcc % g 4 , T A G _ C O N T E X T _ B I T S , % g 0 ! F r o m N u c l e u s ?
from_tl1_trap :
rdpr % t l , % g 5 ! F o r T L = =3 t e s t
CREATE_ V P T E _ O F F S E T 1 ( % g 4 , % g 6 ) ! C r e a t e V P T E o f f s e t
2005-09-21 18:50:51 -07:00
be,p n % x c c , k v m a p ! Y e p , s p e c i a l p r o c e s s i n g
2005-04-16 15:20:36 -07:00
CREATE_ V P T E _ O F F S E T 2 ( % g 4 , % g 6 ) ! C r e a t e V P T E o f f s e t
cmp % g 5 , 4 ! L a s t t r a p l e v e l ?
/* DTLB ** ICACHE line 2: User finish + quick kernel TLB misses */
2005-10-12 12:22:46 -07:00
be,p n % x c c , l o n g p a t h ! Y e p , c a n n o t r i s k V P T E m i s s
nop ! d e l a y s l o t
2005-04-16 15:20:36 -07:00
ldxa [ % g 3 + % g 6 ] A S I _ S , % g 5 ! L o a d V P T E
1 : brgez,p n % g 5 , l o n g p a t h ! I n v a l i d , b r a n c h o u t
nop ! D e l a y - s l o t
9 : stxa % g 5 , [ % g 0 ] A S I _ D T L B _ D A T A _ I N ! R e l o a d T L B
retry ! T r a p r e t u r n
2005-09-21 18:50:51 -07:00
nop
2005-04-16 15:20:36 -07:00
/* DTLB ** ICACHE line 3: winfixups+real_faults */
longpath :
rdpr % p s t a t e , % g 5 ! M o v e i n t o a l t e r n a t e g l o b a l s
wrpr % g 5 , P S T A T E _ A G | P S T A T E _ M G , % p s t a t e
rdpr % t l , % g 4 ! S e e w h e r e w e c a m e f r o m .
cmp % g 4 , 1 ! I s e t r a p / r t r a p w i n d o w f a u l t ?
mov T L B _ T A G _ A C C E S S , % g 4 ! P r e p a r e f o r f a u l t p r o c e s s i n g
ldxa [ % g 4 ] A S I _ D M M U , % g 5 ! L o a d f a u l t i n g V A p a g e
be,p t % x c c , s p a r c64 _ r e a l f a u l t _ c o m m o n ! J u m p t o n o r m a l f a u l t h a n d l i n g
mov F A U L T _ C O D E _ D T L B , % g 4 ! I t w a s r e a d f r o m D T L B
/* DTLB ** ICACHE line 4: Unused... */
ba,a ,p t % x c c , w i n f i x _ t r a m p o l i n e ! C a l l w i n d o w f i x u p c o d e
nop
nop
nop
nop
nop
nop
2005-10-12 12:22:46 -07:00
nop
2005-04-16 15:20:36 -07:00
# undef C R E A T E _ V P T E _ O F F S E T 1
# undef C R E A T E _ V P T E _ O F F S E T 2