2019-06-04 11:11:33 +03:00
/* SPDX-License-Identifier: GPL-2.0-only */
2011-11-22 21:30:28 +04:00
/ *
* arch/ a r m / m m / p r o c - v7 - 2 l e v e l . S
*
* 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 .
* /
# define T T B _ S ( 1 < < 1 )
# define T T B _ R G N _ N C ( 0 < < 3 )
# define T T B _ R G N _ O C _ W B W A ( 1 < < 3 )
# define T T B _ R G N _ O C _ W T ( 2 < < 3 )
# define T T B _ R G N _ O C _ W B ( 3 < < 3 )
# define T T B _ N O S ( 1 < < 5 )
# define T T B _ I R G N _ N C ( ( 0 < < 0 ) | ( 0 < < 6 ) )
# define T T B _ I R G N _ W B W A ( ( 0 < < 0 ) | ( 1 < < 6 ) )
# define T T B _ I R G N _ W T ( ( 1 < < 0 ) | ( 0 < < 6 ) )
# define T T B _ I R G N _ W B ( ( 1 < < 0 ) | ( 1 < < 6 ) )
/* PTWs cacheable, inner WB not shareable, outer WB not shareable */
# define T T B _ F L A G S _ U P T T B _ I R G N _ W B | T T B _ R G N _ O C _ W B
# define P M D _ F L A G S _ U P P M D _ S E C T _ W B
/* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */
# define T T B _ F L A G S _ S M P T T B _ I R G N _ W B W A | T T B _ S | T T B _ N O S | T T B _ R G N _ O C _ W B W A
# define P M D _ F L A G S _ S M P P M D _ S E C T _ W B W A | P M D _ S E C T _ S
/ *
* cpu_ v7 _ s w i t c h _ m m ( p g d _ p h y s , t s k )
*
* Set t h e t r a n s l a t i o n t a b l e b a s e p o i n t e r t o b e p g d _ p h y s
*
* - pgd_ p h y s - p h y s i c a l a d d r e s s o f n e w T T B
*
* It i s a s s u m e d t h a t :
* - we a r e n o t u s i n g s p l i t p a g e t a b l e s
2015-05-04 17:22:41 +03:00
*
* Note t h a t w e a l w a y s n e e d t o f l u s h B T A C / B T B i f I B E i s s e t
* even o n C o r t e x - A 8 r e v i s i o n s n o t a f f e c t e d b y 4 3 0 9 7 3 .
* If I B E i s n o t s e t , t h e f l u s h B T A C / B T B w o n ' t d o a n y t h i n g .
2011-11-22 21:30:28 +04:00
* /
2015-04-07 17:35:24 +03:00
ENTRY( c p u _ v7 _ s w i t c h _ m m )
# ifdef C O N F I G _ M M U
mmid r1 , r1 @ get mm->context.id
ALT_ S M P ( o r r r0 , r0 , #T T B _ F L A G S _ S M P )
ALT_ U P ( o r r r0 , r0 , #T T B _ F L A G S _ U P )
2012-07-06 18:43:03 +04:00
# ifdef C O N F I G _ P I D _ I N _ C O N T E X T I D R
mrc p15 , 0 , r2 , c13 , c0 , 1 @ read current context ID
lsr r2 , r2 , #8 @ extract the PID
bfi r1 , r2 , #8 , #24 @ insert into new context ID
# endif
2011-11-22 21:30:28 +04:00
# ifdef C O N F I G _ A R M _ E R R A T A _ 7 5 4 3 2 2
dsb
# endif
mcr p15 , 0 , r1 , c13 , c0 , 1 @ set context ID
isb
2011-05-31 18:38:43 +04:00
mcr p15 , 0 , r0 , c2 , c0 , 0 @ set TTB 0
isb
2011-11-22 21:30:28 +04:00
# endif
2014-06-30 19:29:12 +04:00
bx l r
2011-11-22 21:30:28 +04:00
ENDPROC( c p u _ v7 _ s w i t c h _ m m )
/ *
* cpu_ v7 _ s e t _ p t e _ e x t ( p t e p , p t e )
*
* Set a l e v e l 2 t r a n s l a t i o n t a b l e e n t r y .
*
* - ptep - p o i n t e r t o l e v e l 2 t r a n s l a t i o n t a b l e e n t r y
* ( hardware v e r s i o n i s s t o r e d a t + 2 0 4 8 b y t e s )
* - pte - P T E v a l u e t o s t o r e
* - ext - v a l u e f o r e x t e n d e d P T E b i t s
* /
ENTRY( c p u _ v7 _ s e t _ p t e _ e x t )
# ifdef C O N F I G _ M M U
str r1 , [ r0 ] @ linux version
bic r3 , r1 , #0x000003f0
bic r3 , r3 , #P T E _ T Y P E _ M A S K
orr r3 , r3 , r2
orr r3 , r3 , #P T E _ E X T _ A P 0 | 2
tst r1 , #1 < < 4
orrne r3 , r3 , #P T E _ E X T _ T E X ( 1 )
eor r1 , r1 , #L _ P T E _ D I R T Y
tst r1 , #L _ P T E _ R D O N L Y | L _ P T E _ D I R T Y
orrne r3 , r3 , #P T E _ E X T _ A P X
tst r1 , #L _ P T E _ U S E R
orrne r3 , r3 , #P T E _ E X T _ A P 1
tst r1 , #L _ P T E _ X N
orrne r3 , r3 , #P T E _ E X T _ X N
tst r1 , #L _ P T E _ Y O U N G
2012-07-19 14:51:05 +04:00
tstne r1 , #L _ P T E _ V A L I D
2012-09-01 08:22:12 +04:00
eorne r1 , r1 , #L _ P T E _ N O N E
tstne r1 , #L _ P T E _ N O N E
2011-11-22 21:30:28 +04:00
moveq r3 , #0
ARM( s t r r3 , [ r0 , #2048 ] ! )
THUMB( a d d r0 , r0 , #2048 )
THUMB( s t r r3 , [ r0 ] )
2013-07-15 17:26:19 +04:00
ALT_ S M P ( W ( n o p ) )
2013-04-03 20:16:57 +04:00
ALT_ U P ( m c r p15 , 0 , r0 , c7 , c10 , 1 ) @ flush_pte
2011-11-22 21:30:28 +04:00
# endif
2014-06-30 19:29:12 +04:00
bx l r
2011-11-22 21:30:28 +04:00
ENDPROC( c p u _ v7 _ s e t _ p t e _ e x t )
/ *
* Memory r e g i o n a t t r i b u t e s w i t h S C T L R . T R E =1
*
* n = T E X [ 0 ] ,C ,B
* TR = P R R R [ 2 n + 1 : 2 n ] - m e m o r y t y p e
* IR = N M R R [ 2 n + 1 : 2 n ] - i n n e r c a c h e a b l e p r o p e r t y
* OR = N M R R [ 2 n + 1 7 : 2 n + 1 6 ] - o u t e r c a c h e a b l e p r o p e r t y
*
* n T R I R O R
* UNCACHED 0 0 0 0 0
* BUFFERABLE 0 0 1 1 0 0 0 0 0
* WRITETHROUGH 0 1 0 1 0 1 0 1 0
* WRITEBACK 0 1 1 1 0 1 1 1 1
* reserved 1 1 0
* WRITEALLOC 1 1 1 1 0 0 1 0 1
* DEV_ S H A R E D 1 0 0 0 1
* DEV_ N O N S H A R E D 1 0 0 0 1
* DEV_ W C 0 0 1 1 0
* DEV_ C A C H E D 0 1 1 1 0
*
* Other a t t r i b u t e s :
*
* DS0 = P R R R [ 1 6 ] = 0 - d e v i c e s h a r e a b l e p r o p e r t y
* DS1 = P R R R [ 1 7 ] = 1 - d e v i c e s h a r e a b l e p r o p e r t y
* NS0 = P R R R [ 1 8 ] = 0 - n o r m a l s h a r e a b l e p r o p e r t y
* NS1 = P R R R [ 1 9 ] = 1 - n o r m a l s h a r e a b l e p r o p e r t y
* NOS = P R R R [ 2 4 + n ] = 1 - n o t o u t e r s h a r e a b l e
* /
.equ PRRR, 0 x f f0 a81 a8
.equ NMRR, 0 x40 e 0 4 0 e 0
/ *
* Macro f o r s e t t i n g u p t h e T T B R x a n d T T B C R r e g i s t e r s .
* - \ ttb0 a n d \ t t b1 u p d a t e d w i t h t h e c o r r e s p o n d i n g f l a g s .
* /
2015-04-04 22:09:46 +03:00
.macro v7 _ t t b _ s e t u p , z e r o , t t b r0 l , t t b r0 h , t t b r1 , t m p
2011-11-22 21:30:28 +04:00
mcr p15 , 0 , \ z e r o , c2 , c0 , 2 @ TTB control register
2015-04-04 22:09:46 +03:00
ALT_ S M P ( o r r \ t t b r0 l , \ t t b r0 l , #T T B _ F L A G S _ S M P )
ALT_ U P ( o r r \ t t b r0 l , \ t t b r0 l , #T T B _ F L A G S _ U P )
2011-11-22 21:30:28 +04:00
ALT_ S M P ( o r r \ t t b r1 , \ t t b r1 , #T T B _ F L A G S _ S M P )
ALT_ U P ( o r r \ t t b r1 , \ t t b r1 , #T T B _ F L A G S _ U P )
mcr p15 , 0 , \ t t b r1 , c2 , c0 , 1 @ load TTB1
.endm
/ * AT
* TFR E V X F I D L R S
* .EEE . .EE PUI. . T . T 4 R V I Z W R S B L D P W C A M
* rxxx r r x x x x x0 0 1 0 1 x x x x x x x x x11 1 x x x x < f o r c e d
2012-08-31 03:57:03 +04:00
* 0 1 0 1 1 0 0 0 1 1 1 1 0 0 .111 1101 < we w a n t
2011-11-22 21:30:28 +04:00
* /
.align 2
.type v7 _ c r v a l , #o b j e c t
v7_crval :
2012-08-31 03:57:03 +04:00
crval c l e a r =0x2120c302 , m m u s e t =0x10c03c7d , u c s e t =0x00c01c7c