2008-12-18 19:13:42 +00:00
/ *
* This f i l e c o n t a i n s l o w - l e v e l f u n c t i o n s f o r p e r f o r m i n g v a r i o u s
* types o f T L B i n v a l i d a t i o n s o n v a r i o u s p r o c e s s o r s w i t h n o h a s h
* table.
*
* This f i l e i m p l e m e n t s t h e f o l l o w i n g f u n c t i o n s f o r a l l n o - h a s h
* processors. S o m e a r e n ' t i m p l e m e n t e d f o r s o m e v a r i a n t s . S o m e
* are i n l i n e i n t l b f l u s h . h
*
* - tlbil_ v a
* - tlbil_ p i d
* - tlbil_ a l l
* - tlbivax_ b c a s t ( n o t y e t )
*
* Code m o s t l y m o v e d o v e r f r o m m i s c _ 3 2 . S
*
* Copyright ( C ) 1 9 9 5 - 1 9 9 6 G a r y T h o m a s ( g d t @linuxppc.org)
*
* Partially r e w r i t t e n b y C o r t D o u g a n ( c o r t @cs.nmt.edu)
* Paul M a c k e r r a s , K u m a r G a l a a n d B e n j a m i n H e r r e n s c h m i d t .
*
* 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 / c p u t a b l e . h >
# include < a s m / m m u . 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 >
# include < a s m / p r o c e s s o r . h >
# if d e f i n e d ( C O N F I G _ 4 0 x )
/ *
* 4 0 x i m p l e m e n t a t i o n n e e d s o n l y t l b i l _ v a
* /
2009-07-23 23:15:24 +00:00
_ GLOBAL( _ _ t l b i l _ v a )
2008-12-18 19:13:42 +00:00
/ * We r u n t h e s e a r c h w i t h i n t e r r u p t s d i s a b l e d b e c a u s e w e h a v e t o c h a n g e
* the P I D a n d I d o n ' t w a n t t o p r e e m p t w h e n t h a t h a p p e n s .
* /
mfmsr r5
mfspr r6 ,S P R N _ P I D
wrteei 0
mtspr S P R N _ P I D ,r4
tlbsx. r3 , 0 , r3
mtspr S P R N _ P I D ,r6
wrtee r5
bne 1 f
sync
/ * There a r e o n l y 6 4 T L B e n t r i e s , s o r3 < 6 4 , w h i c h m e a n s b i t 2 5 i s
* clear. S i n c e 2 5 i s t h e V b i t i n t h e T L B _ T A G , l o a d i n g t h i s v a l u e
* will i n v a l i d a t e t h e T L B e n t r y . * /
tlbwe r3 , r3 , T L B _ T A G
isync
1 : blr
# elif d e f i n e d ( C O N F I G _ 8 x x )
/ *
* Nothing t o d o f o r 8 x x , e v e r y t h i n g i s i n l i n e
* /
# elif d e f i n e d ( C O N F I G _ 4 4 x )
/ *
* 4 4 0 implementation u s e s t l b s x / w e f o r t l b i l _ v a a n d a f u l l s w e e p
* of t h e T L B f o r e v e r y t h i n g e l s e .
* /
2009-07-23 23:15:24 +00:00
_ GLOBAL( _ _ t l b i l _ v a )
2008-12-18 19:13:42 +00:00
mfspr r5 ,S P R N _ M M U C R
rlwimi r5 ,r4 ,0 ,2 4 ,3 1 / * S e t T I D * /
2008-12-18 19:13:46 +00:00
/ * We h a v e t o r u n t h e s e a r c h w i t h i n t e r r u p t s d i s a b l e d , o t h e r w i s e
* an i n t e r r u p t w h i c h c a u s e s a T L B m i s s c a n c l o b b e r t h e M M U C R
* between t h e m t s p r a n d t h e t l b s x .
*
* Critical a n d M a c h i n e C h e c k i n t e r r u p t s t a k e c a r e o f s a v i n g
* and r e s t o r i n g M M U C R , s o o n l y n o r m a l i n t e r r u p t s h a v e t o b e
* taken c a r e o f .
* /
2008-12-18 19:13:42 +00:00
mfmsr r4
2008-12-18 19:13:46 +00:00
wrteei 0
2008-12-18 19:13:42 +00:00
mtspr S P R N _ M M U C R ,r5
tlbsx. r3 , 0 , r3
2008-12-18 19:13:46 +00:00
wrtee r4
2008-12-18 19:13:42 +00:00
bne 1 f
sync
/ * There a r e o n l y 6 4 T L B e n t r i e s , s o r3 < 6 4 ,
* which m e a n s b i t 2 2 , i s c l e a r . S i n c e 2 2 i s
* the V b i t i n t h e T L B _ P A G E I D , l o a d i n g t h i s
* value w i l l i n v a l i d a t e t h e T L B e n t r y .
* /
tlbwe r3 , r3 , P P C 4 4 x _ T L B _ P A G E I D
isync
1 : blr
_ GLOBAL( _ t l b i l _ a l l )
_ GLOBAL( _ t l b i l _ p i d )
li r3 ,0
sync
/* Load high watermark */
lis r4 ,t l b _ 4 4 x _ h w a t e r @ha
lwz r5 ,t l b _ 4 4 x _ h w a t e r @l(r4)
1 : tlbwe r3 ,r3 ,P P C 4 4 x _ T L B _ P A G E I D
addi r3 ,r3 ,1
cmpw 0 ,r3 ,r5
ble 1 b
isync
blr
# elif d e f i n e d ( C O N F I G _ F S L _ B O O K E )
/ *
2009-02-10 22:26:06 -06:00
* FSL B o o k E i m p l e m e n t a t i o n s .
*
* Since f e a t u r e s e c t i o n s a r e u s i n g _ S E C T I O N _ E L S E w e n e e d
* to h a v e t h e l a r g e r c o d e p a t h b e f o r e t h e _ S E C T I O N _ E L S E
2008-12-18 19:13:42 +00:00
* /
/ *
* Flush M M U T L B o n t h e l o c a l p r o c e s s o r
* /
_ GLOBAL( _ t l b i l _ a l l )
2009-02-10 22:26:06 -06:00
BEGIN_ M M U _ F T R _ S E C T I O N
li r3 ,( M M U C S R 0 _ T L B F I ) @l
mtspr S P R N _ M M U C S R 0 , r3
1 :
mfspr r3 ,S P R N _ M M U C S R 0
andi. r3 ,r3 ,M M U C S R 0 _ T L B F I @l
bne 1 b
MMU_ F T R _ S E C T I O N _ E L S E
2009-04-23 08:51:22 -05:00
PPC_ T L B I L X _ A L L ( 0 ,0 )
2009-02-10 22:26:06 -06:00
ALT_ M M U _ F T R _ S E C T I O N _ E N D _ I F C L R ( M M U _ F T R _ U S E _ T L B I L X )
msync
isync
blr
_ GLOBAL( _ t l b i l _ p i d )
BEGIN_ M M U _ F T R _ S E C T I O N
slwi r3 ,r3 ,1 6
mfmsr r10
wrteei 0
mfspr r4 ,S P R N _ M A S 6 / * s a v e M A S 6 * /
mtspr S P R N _ M A S 6 ,r3
PPC_ T L B I L X _ P I D ( 0 ,0 )
mtspr S P R N _ M A S 6 ,r4 / * r e s t o r e M A S 6 * /
wrtee r10
MMU_ F T R _ S E C T I O N _ E L S E
2008-12-18 19:13:42 +00:00
li r3 ,( M M U C S R 0 _ T L B F I ) @l
mtspr S P R N _ M M U C S R 0 , r3
1 :
mfspr r3 ,S P R N _ M M U C S R 0
andi. r3 ,r3 ,M M U C S R 0 _ T L B F I @l
bne 1 b
2009-02-10 22:26:06 -06:00
ALT_ M M U _ F T R _ S E C T I O N _ E N D _ I F S E T ( M M U _ F T R _ U S E _ T L B I L X )
2008-12-18 19:13:42 +00:00
msync
isync
blr
/ *
* Flush M M U T L B f o r a p a r t i c u l a r a d d r e s s , b u t o n l y o n t h e l o c a l p r o c e s s o r
* ( no b r o a d c a s t )
* /
2009-07-23 23:15:24 +00:00
_ GLOBAL( _ _ t l b i l _ v a )
2008-12-18 19:13:42 +00:00
mfmsr r10
wrteei 0
slwi r4 ,r4 ,1 6
2009-02-10 22:26:06 -06:00
ori r4 ,r4 ,( M A S 6 _ I S I Z E ( B O O K 3 E _ P A G E S Z _ 4 K ) ) @l
2008-12-18 19:13:42 +00:00
mtspr S P R N _ M A S 6 ,r4 / * a s s u m e A S =0 f o r n o w * /
2009-02-10 22:26:06 -06:00
BEGIN_ M M U _ F T R _ S E C T I O N
2008-12-18 19:13:42 +00:00
tlbsx 0 ,r3
mfspr r4 ,S P R N _ M A S 1 / * c h e c k v a l i d * /
andis. r3 ,r4 ,M A S 1 _ V A L I D @h
beq 1 f
rlwinm r4 ,r4 ,0 ,1 ,3 1
mtspr S P R N _ M A S 1 ,r4
tlbwe
2009-02-10 22:26:06 -06:00
MMU_ F T R _ S E C T I O N _ E L S E
PPC_ T L B I L X _ V A ( 0 ,r3 )
ALT_ M M U _ F T R _ S E C T I O N _ E N D _ I F C L R ( M M U _ F T R _ U S E _ T L B I L X )
2008-12-18 19:13:42 +00:00
msync
isync
1 : wrtee r10
blr
2009-07-23 23:15:47 +00:00
# elif d e f i n e d ( C O N F I G _ P P C _ B O O K 3 E )
/ *
* New B o o k 3 E ( > = 2 . 0 6 ) i m p l e m e n t a t i o n
*
* Note : We m a y b e a b l e t o g e t a w a y w i t h o u t t h e i n t e r r u p t m a s k i n g s t u f f
* if w e s a v e / r e s t o r e M A S 6 o n e x c e p t i o n s t h a t m i g h t m o d i f y i t
* /
_ GLOBAL( _ t l b i l _ p i d )
slwi r4 ,r3 ,M A S 6 _ S P I D _ S H I F T
mfmsr r10
wrteei 0
mtspr S P R N _ M A S 6 ,r4
PPC_ T L B I L X _ P I D ( 0 ,0 )
wrtee r10
msync
isync
blr
_ GLOBAL( _ t l b i l _ p i d _ n o i n d )
slwi r4 ,r3 ,M A S 6 _ S P I D _ S H I F T
mfmsr r10
ori r4 ,r4 ,M A S 6 _ S I N D
wrteei 0
mtspr S P R N _ M A S 6 ,r4
PPC_ T L B I L X _ P I D ( 0 ,0 )
wrtee r10
msync
isync
blr
_ GLOBAL( _ t l b i l _ a l l )
PPC_ T L B I L X _ A L L ( 0 ,0 )
msync
isync
blr
_ GLOBAL( _ t l b i l _ v a )
mfmsr r10
wrteei 0
cmpwi c r0 ,r6 ,0
slwi r4 ,r4 ,M A S 6 _ S P I D _ S H I F T
rlwimi r4 ,r5 ,M A S 6 _ I S I Z E _ S H I F T ,M A S 6 _ I S I Z E _ M A S K
beq 1 f
rlwimi r4 ,r6 ,M A S 6 _ S I N D _ S H I F T ,M A S 6 _ S I N D
1 : mtspr S P R N _ M A S 6 ,r4 / * a s s u m e A S =0 f o r n o w * /
PPC_ T L B I L X _ V A ( 0 ,r3 )
msync
isync
wrtee r10
blr
_ GLOBAL( _ t l b i v a x _ b c a s t )
mfmsr r10
wrteei 0
cmpwi c r0 ,r6 ,0
slwi r4 ,r4 ,M A S 6 _ S P I D _ S H I F T
rlwimi r4 ,r5 ,M A S 6 _ I S I Z E _ S H I F T ,M A S 6 _ I S I Z E _ M A S K
beq 1 f
rlwimi r4 ,r6 ,M A S 6 _ S I N D _ S H I F T ,M A S 6 _ S I N D
1 : mtspr S P R N _ M A S 6 ,r4 / * a s s u m e A S =0 f o r n o w * /
PPC_ T L B I V A X ( 0 ,r3 )
eieio
tlbsync
sync
wrtee r10
blr
_ GLOBAL( s e t _ c o n t e x t )
# ifdef C O N F I G _ B D I _ S W I T C H
/ * Context s w i t c h t h e P T E p o i n t e r f o r t h e A b a t r o n B D I 2 0 0 0 .
* The P G D I R i s t h e s e c o n d p a r a m e t e r .
* /
lis r5 , a b a t r o n _ p t e p t r s @h
ori r5 , r5 , a b a t r o n _ p t e p t r s @l
stw r4 , 0 x4 ( r5 )
# endif
mtspr S P R N _ P I D ,r3
isync / * F o r c e c o n t e x t c h a n g e * /
blr
2009-04-23 22:56:11 +10:00
# else
2008-12-18 19:13:42 +00:00
# error U n s u p p o r t e d p r o c e s s o r t y p e !
# endif