2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / a r m / m m / c a c h e - v4 w t . S
*
* Copyright ( C ) 1 9 9 7 - 2 0 0 2 R u s s e l l k i n g
*
* 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
* it 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 v e r s i o n 2 a s
* published 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 .
*
* ARMv4 w r i t e t h r o u g h c a c h e o p e r a t i o n s s u p p o r t .
*
* We a s s u m e t h a t t h e w r i t e b u f f e r i s n o t e n a b l e d .
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / i n i t . h >
2008-08-04 13:41:28 +04:00
# include < a s m / a r c h / h a r d w a r e . h >
2005-04-17 02:20:36 +04:00
# include < a s m / p a g e . h >
# include " p r o c - m a c r o s . S "
/ *
* The s i z e o f o n e d a t a c a c h e l i n e .
* /
# define C A C H E _ D L I N E S I Z E 3 2
/ *
* The n u m b e r o f d a t a c a c h e s e g m e n t s .
* /
# define C A C H E _ D S E G M E N T S 8
/ *
* The n u m b e r o f l i n e s i n a c a c h e s e g m e n t .
* /
# define C A C H E _ D E N T R I E S 6 4
/ *
* This i s t h e s i z e a t w h i c h i t b e c o m e s m o r e e f f i c i e n t t o
* clean t h e w h o l e c a c h e , r a t h e r t h a n u s i n g t h e i n d i v i d u a l
* cache l i n e m a i n t a i n e n c e i n s t r u c t i o n s .
*
* * * * This n e e d s b e n c h m a r k i n g
* /
# define C A C H E _ D L I M I T 1 6 3 8 4
/ *
* flush_ u s e r _ c a c h e _ a l l ( )
*
* Invalidate a l l c a c h e e n t r i e s i n a p a r t i c u l a r a d d r e s s
* space.
* /
ENTRY( v4 w t _ f l u s h _ u s e r _ c a c h e _ a l l )
/* FALLTHROUGH */
/ *
* flush_ k e r n _ c a c h e _ a l l ( )
*
* Clean a n d i n v a l i d a t e t h e e n t i r e c a c h e .
* /
ENTRY( v4 w t _ f l u s h _ k e r n _ c a c h e _ a l l )
mov r2 , #V M _ E X E C
mov i p , #0
__flush_whole_cache :
tst r2 , #V M _ E X E C
mcrne p15 , 0 , i p , c7 , c5 , 0 @ invalidate I cache
mcr p15 , 0 , i p , c7 , c6 , 0 @ invalidate D cache
mov p c , l r
/ *
* flush_ u s e r _ c a c h e _ r a n g e ( s t a r t , e n d , f l a g s )
*
* Clean a n d i n v a l i d a t e a r a n g e o f c a c h e e n t r i e s i n t h e s p e c i f i e d
* address s p a c e .
*
* - start - s t a r t a d d r e s s ( i n c l u s i v e , p a g e a l i g n e d )
* - end - e n d a d d r e s s ( e x c l u s i v e , p a g e a l i g n e d )
* - flags - v m a _ a r e a _ s t r u c t f l a g s d e s c r i b i n g a d d r e s s s p a c e
* /
ENTRY( v4 w t _ f l u s h _ u s e r _ c a c h e _ r a n g e )
sub r3 , r1 , r0 @ calculate total size
cmp r3 , #C A C H E _ D L I M I T
bhs _ _ f l u s h _ w h o l e _ c a c h e
1 : mcr p15 , 0 , r0 , c7 , c6 , 1 @ invalidate D entry
tst r2 , #V M _ E X E C
mcrne p15 , 0 , r0 , c7 , c5 , 1 @ invalidate I entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov p c , l r
/ *
* coherent_ k e r n _ r a n g e ( s t a r t , e n d )
*
* Ensure c o h e r e n c y b e t w e e n t h e I c a c h e a n d t h e D c a c h e i n t h e
* region d e s c r i b e d b y s t a r t . I f y o u h a v e n o n - s n o o p i n g
* Harvard c a c h e s , y o u n e e d t o i m p l e m e n t t h i s f u n c t i o n .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
ENTRY( v4 w t _ c o h e r e n t _ k e r n _ r a n g e )
/* FALLTRHOUGH */
/ *
* coherent_ u s e r _ r a n g e ( s t a r t , e n d )
*
* Ensure c o h e r e n c y b e t w e e n t h e I c a c h e a n d t h e D c a c h e i n t h e
* region d e s c r i b e d b y s t a r t . I f y o u h a v e n o n - s n o o p i n g
* Harvard c a c h e s , y o u n e e d t o i m p l e m e n t t h i s f u n c t i o n .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
ENTRY( v4 w t _ c o h e r e n t _ u s e r _ r a n g e )
bic r0 , r0 , #C A C H E _ D L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c5 , 1 @ invalidate I entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov p c , l r
/ *
* flush_ k e r n _ d c a c h e _ p a g e ( v o i d * p a g e )
*
* Ensure n o D c a c h e a l i a s i n g o c c u r s , e i t h e r w i t h i t s e l f o r
* the I c a c h e
*
* - addr - p a g e a l i g n e d a d d r e s s
* /
ENTRY( v4 w t _ f l u s h _ k e r n _ d c a c h e _ p a g e )
mov r2 , #0
mcr p15 , 0 , r2 , c7 , c5 , 0 @ invalidate I cache
add r1 , r0 , #P A G E _ S Z
/* fallthrough */
/ *
* dma_ i n v _ r a n g e ( s t a r t , e n d )
*
* Invalidate ( d i s c a r d ) t h e s p e c i f i e d v i r t u a l a d d r e s s r a n g e .
* May n o t w r i t e b a c k a n y e n t r i e s . I f ' s t a r t ' o r ' e n d '
* are n o t c a c h e l i n e a l i g n e d , t h o s e l i n e s m u s t b e w r i t t e n
* back.
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
ENTRY( v4 w t _ d m a _ i n v _ r a n g e )
bic r0 , r0 , #C A C H E _ D L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c6 , 1 @ invalidate D entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
/* FALLTHROUGH */
/ *
* dma_ c l e a n _ r a n g e ( s t a r t , e n d )
*
* Clean t h e s p e c i f i e d v i r t u a l a d d r e s s r a n g e .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
ENTRY( v4 w t _ d m a _ c l e a n _ r a n g e )
mov p c , l r
/ *
* dma_ f l u s h _ r a n g e ( s t a r t , e n d )
*
* Clean a n d i n v a l i d a t e t h e s p e c i f i e d v i r t u a l a d d r e s s r a n g e .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
.globl v4wt_dma_flush_range
.equ v4 w t _ d m a _ f l u s h _ r a n g e , v4 w t _ d m a _ i n v _ r a n g e
_ _ INITDATA
.type v4 w t _ c a c h e _ f n s , #o b j e c t
ENTRY( v4 w t _ c a c h e _ f n s )
.long v4wt_flush_kern_cache_all
.long v4wt_flush_user_cache_all
.long v4wt_flush_user_cache_range
.long v4wt_coherent_kern_range
.long v4wt_coherent_user_range
.long v4wt_flush_kern_dcache_page
.long v4wt_dma_inv_range
.long v4wt_dma_clean_range
.long v4wt_dma_flush_range
.size v4 w t _ c a c h e _ f n s , . - v4 w t _ c a c h e _ f n s