2009-05-26 18:30:10 +04:00
/ *
* Miscellaneous l o w - l e v e l M M U f u n c t i o n s .
*
* Copyright ( C ) 2 0 0 8 - 2 0 0 9 M i c h a l S i m e k < m o n s t r @monstr.eu>
* Copyright ( C ) 2 0 0 8 - 2 0 0 9 P e t a L o g i x
* Copyright ( C ) 2 0 0 7 X i l i n x , I n c . A l l r i g h t s r e s e r v e d .
*
* Derived f r o m a r c h / p p c / k e r n e l / m i s c . S
*
* 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
* Public L i c e n s e . 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
* archive f o r m o r e d e t a i l s .
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / s y s . h >
# include < a s m / u n i s t d . h >
# include < l i n u x / e r r n o . h >
# include < a s m / m m u . h >
# include < a s m / p a g e . h >
.text
/ *
* Flush M M U T L B
*
* We a v o i d f l u s h i n g t h e p i n n e d 0 , 1 a n d p o s s i b l y 2 e n t r i e s .
* /
.globl _ tlbia;
2010-03-23 10:09:32 +03:00
.type _ tlbia, @function
2009-05-26 18:30:10 +04:00
.align 4 ;
_tlbia :
2010-02-08 18:41:38 +03:00
lwi r12 , r0 , t l b _ s k i p ;
2009-05-26 18:30:10 +04:00
/* isync */
_tlbia_1 :
mts r t l b x , r12
nop
mts r t l b h i , r0 / * f l u s h : e n s u r e V i s c l e a r * /
nop
2010-02-08 18:41:38 +03:00
rsubi r11 , r12 , M I C R O B L A Z E _ T L B _ S I Z E - 1
2009-05-26 18:30:10 +04:00
bneid r11 , _ t l b i a _ 1 / * l o o p f o r a l l e n t r i e s * /
2010-02-08 18:41:38 +03:00
addik r12 , r12 , 1
2009-05-26 18:30:10 +04:00
/* sync */
rtsd r15 , 8
nop
2010-03-23 10:09:32 +03:00
.size _ tlbia, . - _ t l b i a
2009-05-26 18:30:10 +04:00
/ *
* 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 ( i n r5 )
* /
.globl _ tlbie;
2010-03-23 10:09:32 +03:00
.type _ tlbie, @function
2009-05-26 18:30:10 +04:00
.align 4 ;
_tlbie :
mts r t l b s x , r5 / * l o o k u p t h e a d d r e s s i n T L B * /
nop
mfs r12 , r t l b x / * R e t r i e v e i n d e x * /
nop
blti r12 , _ t l b i e _ 1 / * C h e c k i f f o u n d * /
mts r t l b h i , r0 / * f l u s h : e n s u r e V i s c l e a r * /
nop
_tlbie_1 :
rtsd r15 , 8
nop
2010-03-23 10:09:32 +03:00
.size _ tlbie, . - _ t l b i e
2009-05-26 18:30:10 +04:00
/ *
* Allocate T L B e n t r y f o r e a r l y c o n s o l e
* /
.globl early_ c o n s o l e _ r e g _ t l b _ a l l o c ;
2010-03-23 10:09:32 +03:00
.type early_ c o n s o l e _ r e g _ t l b _ a l l o c , @function
2009-05-26 18:30:10 +04:00
.align 4 ;
early_console_reg_tlb_alloc :
/ *
* Load a T L B e n t r y f o r t h e U A R T , s o t h a t m i c r o b l a z e _ p r o g r e s s ( ) c a n u s e
* the U A R T s n i c e a n d e a r l y . W e u s e a 4 k r e a l = =virtual m a p p i n g .
* /
2010-02-08 18:41:38 +03:00
lwi r4 , r0 , t l b _ s k i p
2010-06-04 14:57:06 +04:00
mts r t l b x , r4 / * T L B s l o t 6 3 * /
2009-05-26 18:30:10 +04:00
or r4 ,r5 ,r0
andi r4 ,r4 ,0 x f f f f f00 0
ori r4 ,r4 ,( T L B _ W R | T L B _ I | T L B _ M | T L B _ G )
andi r5 ,r5 ,0 x f f f f f00 0
ori r5 ,r5 ,( T L B _ V A L I D | T L B _ P A G E S Z ( P A G E S Z _ 4 K ) )
mts r t l b l o ,r4 / * L o a d t h e d a t a p o r t i o n o f t h e e n t r y * /
nop
mts r t l b h i ,r5 / * L o a d t h e t a g p o r t i o n o f t h e e n t r y * /
nop
2010-02-08 18:41:38 +03:00
lwi r5 , r0 , t l b _ s k i p
addik r5 , r5 , 1
swi r5 , r0 , t l b _ s k i p
2009-05-26 18:30:10 +04:00
rtsd r15 , 8
nop
2010-03-23 10:09:32 +03:00
.size early_ c o n s o l e _ r e g _ t l b _ a l l o c , . - e a r l y _ c o n s o l e _ r e g _ t l b _ a l l o c