2012-03-05 15:49:28 +04:00
/ *
* Cache m a i n t e n a n c e
*
* Copyright ( C ) 2 0 0 1 D e e p B l u e S o l u t i o n s L t d .
* Copyright ( C ) 2 0 1 2 A R M L t d .
*
* 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 .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y 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
* along w i t h t h i s p r o g r a m . I f n o t , s e e < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > .
* /
2014-12-01 13:53:08 +03:00
# include < l i n u x / e r r n o . h >
2012-03-05 15:49:28 +04:00
# 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 >
# include < a s m / a s s e m b l e r . h >
2014-11-14 18:54:10 +03:00
# include < a s m / c p u f e a t u r e . h >
# include < a s m / a l t e r n a t i v e - a s m . h >
2012-03-05 15:49:28 +04:00
# include " p r o c - m a c r o s . S "
/ *
* flush_ i c a c h e _ r a n g e ( s t a r t ,e n d )
*
* Ensure t h a t t h e I a n d D c a c h e s a r e c o h e r e n t w i t h i n s p e c i f i e d r e g i o n .
* This i s t y p i c a l l y u s e d w h e n c o d e h a s b e e n w r i t t e n t o a m e m o r y r e g i o n ,
* and w i l l b e e x e c u t e d .
*
* - start - v i r t u a l s t a r t a d d r e s s o f r e g i o n
* - end - v i r t u a l e n d a d d r e s s o f r e g i o n
* /
ENTRY( f l u s h _ i c a c h e _ r a n g e )
/* FALLTHROUGH */
/ *
* _ _ flush_ c a c h e _ u s e r _ r a n g e ( s t a r t ,e n d )
*
* Ensure t h a t t h e I a n d D c a c h e s a r e c o h e r e n t w i t h i n s p e c i f i e d r e g i o n .
* This i s t y p i c a l l y u s e d w h e n c o d e h a s b e e n w r i t t e n t o a m e m o r y r e g i o n ,
* and w i l l b e e x e c u t e d .
*
* - start - v i r t u a l s t a r t a d d r e s s o f r e g i o n
* - end - v i r t u a l e n d a d d r e s s o f r e g i o n
* /
ENTRY( _ _ f l u s h _ c a c h e _ u s e r _ r a n g e )
dcache_ l i n e _ s i z e x2 , x3
sub x3 , x2 , #1
bic x4 , x0 , x3
1 :
USER( 9 f , d c c v a u , x4 ) / / c l e a n D l i n e t o P o U
add x4 , x4 , x2
cmp x4 , x1
b. l o 1 b
2014-05-02 19:24:15 +04:00
dsb i s h
2012-03-05 15:49:28 +04:00
icache_ l i n e _ s i z e x2 , x3
sub x3 , x2 , #1
bic x4 , x0 , x3
1 :
USER( 9 f , i c i v a u , x4 ) / / i n v a l i d a t e I l i n e P o U
add x4 , x4 , x2
cmp x4 , x1
b. l o 1 b
2014-05-02 19:24:15 +04:00
dsb i s h
2012-03-05 15:49:28 +04:00
isb
2014-12-01 13:53:08 +03:00
mov x0 , #0
ret
9 :
mov x0 , #- E F A U L T
2012-03-05 15:49:28 +04:00
ret
ENDPROC( f l u s h _ i c a c h e _ r a n g e )
ENDPROC( _ _ f l u s h _ c a c h e _ u s e r _ r a n g e )
/ *
2014-01-21 05:17:47 +04:00
* _ _ flush_ d c a c h e _ a r e a ( k a d d r , s i z e )
2012-03-05 15:49:28 +04:00
*
* Ensure t h a t t h e d a t a h e l d i n t h e p a g e k a d d r i s w r i t t e n b a c k t o t h e
* page i n q u e s t i o n .
*
* - kaddr - k e r n e l a d d r e s s
* - size - s i z e i n q u e s t i o n
* /
ENTRY( _ _ f l u s h _ d c a c h e _ a r e a )
dcache_ l i n e _ s i z e x2 , x3
add x1 , x0 , x1
sub x3 , x2 , #1
bic x0 , x0 , x3
1 : dc c i v a c , x0 / / c l e a n & i n v a l i d a t e D l i n e / u n i f i e d l i n e
add x0 , x0 , x2
cmp x0 , x1
b. l o 1 b
dsb s y
ret
ENDPROC( _ _ f l u s h _ d c a c h e _ a r e a )
2013-05-21 20:35:19 +04:00
2014-03-26 22:25:55 +04:00
/ *
* _ _ inval_ c a c h e _ r a n g e ( s t a r t , e n d )
* - start - s t a r t a d d r e s s o f r e g i o n
* - end - e n d a d d r e s s o f r e g i o n
* /
ENTRY( _ _ i n v a l _ c a c h e _ r a n g e )
/* FALLTHROUGH */
2013-05-21 20:35:19 +04:00
/ *
* _ _ dma_ i n v _ r a n g e ( s t a r t , e n d )
* - start - v i r t u a l s t a r t a d d r e s s o f r e g i o n
* - end - v i r t u a l e n d a d d r e s s o f r e g i o n
* /
__dma_inv_range :
dcache_ l i n e _ s i z e x2 , x3
sub x3 , x2 , #1
2014-04-01 21:32:55 +04:00
tst x1 , x3 / / e n d c a c h e l i n e a l i g n e d ?
2013-05-21 20:35:19 +04:00
bic x1 , x1 , x3
2014-04-01 21:32:55 +04:00
b. e q 1 f
dc c i v a c , x1 / / c l e a n & i n v a l i d a t e D / U l i n e
1 : tst x0 , x3 / / s t a r t c a c h e l i n e a l i g n e d ?
bic x0 , x0 , x3
b. e q 2 f
dc c i v a c , x0 / / c l e a n & i n v a l i d a t e D / U l i n e
b 3 f
2 : dc i v a c , x0 / / i n v a l i d a t e D / U l i n e
3 : add x0 , x0 , x2
2013-05-21 20:35:19 +04:00
cmp x0 , x1
2014-04-01 21:32:55 +04:00
b. l o 2 b
2013-05-21 20:35:19 +04:00
dsb s y
ret
2014-03-26 22:25:55 +04:00
ENDPROC( _ _ i n v a l _ c a c h e _ r a n g e )
2013-05-21 20:35:19 +04:00
ENDPROC( _ _ d m a _ i n v _ r a n g e )
/ *
* _ _ dma_ c l e a n _ r a n g e ( s t a r t , e n d )
* - start - v i r t u a l s t a r t a d d r e s s o f r e g i o n
* - end - v i r t u a l e n d a d d r e s s o f r e g i o n
* /
__dma_clean_range :
dcache_ l i n e _ s i z e x2 , x3
sub x3 , x2 , #1
bic x0 , x0 , x3
2014-11-14 18:54:10 +03:00
1 : alternative_ i n s n " d c c v a c , x0 " , " d c c i v a c , x0 " , A R M 6 4 _ W O R K A R O U N D _ C L E A N _ C A C H E
2013-05-21 20:35:19 +04:00
add x0 , x0 , x2
cmp x0 , x1
b. l o 1 b
dsb s y
ret
ENDPROC( _ _ d m a _ c l e a n _ r a n g e )
/ *
* _ _ dma_ f l u s h _ r a n g e ( s t a r t , e n d )
* - start - v i r t u a l s t a r t a d d r e s s o f r e g i o n
* - end - v i r t u a l e n d a d d r e s s o f r e g i o n
* /
ENTRY( _ _ d m a _ f l u s h _ r a n g e )
dcache_ l i n e _ s i z e x2 , x3
sub x3 , x2 , #1
bic x0 , x0 , x3
1 : dc c i v a c , x0 / / c l e a n & i n v a l i d a t e D / U l i n e
add x0 , x0 , x2
cmp x0 , x1
b. l o 1 b
dsb s y
ret
ENDPROC( _ _ d m a _ f l u s h _ r a n g e )
/ *
* _ _ dma_ m a p _ a r e a ( s t a r t , s i z e , d i r )
* - start - k e r n e l v i r t u a l s t a r t a d d r e s s
* - size - s i z e o f r e g i o n
* - dir - D M A d i r e c t i o n
* /
ENTRY( _ _ d m a _ m a p _ a r e a )
add x1 , x1 , x0
cmp w2 , #D M A _ F R O M _ D E V I C E
b. e q _ _ d m a _ i n v _ r a n g e
b _ _ d m a _ c l e a n _ r a n g e
ENDPROC( _ _ d m a _ m a p _ a r e a )
/ *
* _ _ dma_ u n m a p _ a r e a ( s t a r t , s i z e , d i r )
* - start - k e r n e l v i r t u a l s t a r t a d d r e s s
* - size - s i z e o f r e g i o n
* - dir - D M A d i r e c t i o n
* /
ENTRY( _ _ d m a _ u n m a p _ a r e a )
add x1 , x1 , x0
cmp w2 , #D M A _ T O _ D E V I C E
b. n e _ _ d m a _ i n v _ r a n g e
ret
ENDPROC( _ _ d m a _ u n m a p _ a r e a )