2011-11-22 17:30:29 +00:00
/ *
* arch/ a r m / m m / p r o c - v7 - 3 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 .
* Copyright ( C ) 2 0 1 1 A R M L t d .
* Author : Catalin M a r i n a s < c a t a l i n . m a r i n a s @arm.com>
* based o n a r c h / a r m / m m / p r o c - v7 - 2 l e v e l . S
*
* 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 ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e , S u i t e 3 3 0 , B o s t o n , M A 0 2 1 1 1 - 1 3 0 7 U S A
* /
# define T T B _ I R G N _ N C ( 0 < < 8 )
# define T T B _ I R G N _ W B W A ( 1 < < 8 )
# define T T B _ I R G N _ W T ( 2 < < 8 )
# define T T B _ I R G N _ W B ( 3 < < 8 )
# define T T B _ R G N _ N C ( 0 < < 1 0 )
# define T T B _ R G N _ O C _ W B W A ( 1 < < 1 0 )
# define T T B _ R G N _ O C _ W T ( 2 < < 1 0 )
# define T T B _ R G N _ O C _ W B ( 3 < < 1 0 )
# define T T B _ S ( 3 < < 1 2 )
# define T T B _ E A E ( 1 < < 3 1 )
/* 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 _ 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 ( p h y s i c a l a d d r e s s o f
* the n e w T T B ) .
* /
ENTRY( c p u _ v7 _ s w i t c h _ m m )
# ifdef C O N F I G _ M M U
2013-02-11 12:25:05 +01:00
mmid r1 , r1 @ get mm->context.id
2013-02-15 13:30:58 +01:00
asid r3 , r1
2011-11-22 17:30:29 +00:00
mov r3 , r3 , l s l #( 48 - 3 2 ) @ ASID
mcrr p15 , 0 , r0 , r3 , c2 @ set TTB 0
isb
# endif
mov p c , l r
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 3 t r a n s l a t i o n t a b l e e n t r y
* - pte - P T E v a l u e t o s t o r e ( 6 4 - b i t i n r2 a n d r3 )
* /
ENTRY( c p u _ v7 _ s e t _ p t e _ e x t )
# ifdef C O N F I G _ M M U
2012-07-19 11:51:05 +01:00
tst r2 , #L _ P T E _ V A L I D
2011-11-22 17:30:29 +00:00
beq 1 f
2012-09-01 05:22:12 +01:00
tst r3 , #1 < < ( 5 7 - 3 2 ) @ L_PTE_NONE
bicne r2 , #L _ P T E _ V A L I D
bne 1 f
2011-11-22 17:30:29 +00:00
tst r3 , #1 < < ( 5 5 - 3 2 ) @ L_PTE_DIRTY
orreq r2 , #L _ P T E _ R D O N L Y
1 : strd r2 , r3 , [ r0 ]
2013-04-03 17:16:57 +01:00
ALT_ S M P ( m o v p c , l r )
ALT_ U P ( m c r p15 , 0 , r0 , c7 , c10 , 1 ) @ flush_pte
2011-11-22 17:30:29 +00:00
# endif
mov p c , l r
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 f o r L P A E ( d e f i n e d i n p g t a b l e - 3 l e v e l . h ) :
*
* n = A t t r I n d x [ 2 : 0 ]
*
* n M A I R
* UNCACHED 0 0 0 0 0 0 0 0 0 0 0
* BUFFERABLE 0 0 1 0 1 0 0 0 1 0 0
* DEV_ W C 0 0 1 0 1 0 0 0 1 0 0
* WRITETHROUGH 0 1 0 1 0 1 0 1 0 1 0
* WRITEBACK 0 1 1 1 1 1 0 1 1 1 0
* DEV_ C A C H E D 0 1 1 1 1 1 0 1 1 1 0
* DEV_ S H A R E D 1 0 0 0 0 0 0 0 1 0 0
* DEV_ N O N S H A R E D 1 0 0 0 0 0 0 0 1 0 0
* unused 1 0 1
* unused 1 1 0
* WRITEALLOC 1 1 1 1 1 1 1 1 1 1 1
* /
.equ PRRR, 0 x e e a a44 0 0 @ MAIR0
.equ NMRR, 0 x f f00 0 0 0 4 @ MAIR1
/ *
* 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 .
* - \ ttbr1 u p d a t e d .
* /
.macro v7 _ t t b _ s e t u p , z e r o , t t b r0 , t t b r1 , t m p
ldr \ t m p , =swapper_pg_dir @ swapper_pg_dir virtual address
cmp \ t t b r1 , \ t m p @ PHYS_OFFSET > PAGE_OFFSET? (branch below)
mrc p15 , 0 , \ t m p , c2 , c0 , 2 @ TTB control register
orr \ t m p , \ t m p , #T T B _ E A E
ALT_ S M P ( o r r \ t m p , \ t m p , #T T B _ F L A G S _ S M P )
ALT_ U P ( o r r \ t m p , \ t m p , #T T B _ F L A G S _ U P )
ALT_ S M P ( o r r \ t m p , \ t m p , #T T B _ F L A G S _ S M P < < 16 )
ALT_ U P ( o r r \ t m p , \ t m p , #T T B _ F L A G S _ U P < < 16 )
/ *
* TTBR0 / T T B R 1 s p l i t ( P A G E _ O F F S E T ) :
* 0x40000000 : T0 S Z = 2 , T 1 S Z = 0 ( n o t u s e d )
* 0x80000000 : T0 S Z = 0 , T 1 S Z = 1
* 0xc0000000 : T0 S Z = 0 , T 1 S Z = 2
*
* Only u s e t h i s f e a t u r e i f P H Y S _ O F F S E T < = P A G E _ O F F S E T , o t h e r w i s e
* booting s e c o n d a r y C P U s w o u l d e n d u p u s i n g T T B R 1 f o r t h e i d e n t i t y
* mapping s e t u p i n T T B R 0 .
* /
bhi 9 0 0 1 f @ PHYS_OFFSET > PAGE_OFFSET?
orr \ t m p , \ t m p , #( ( ( P A G E _ O F F S E T > > 30 ) - 1 ) < < 1 6 ) @ TTBCR.T1SZ
# if d e f i n e d C O N F I G _ V M S P L I T _ 2 G
/* PAGE_OFFSET == 0x80000000, T1SZ == 1 */
add \ t t b r1 , \ t t b r1 , #1 < < 4 @ skip two L1 entries
# elif d e f i n e d C O N F I G _ V M S P L I T _ 3 G
/* PAGE_OFFSET == 0xc0000000, T1SZ == 2 */
add \ t t b r1 , \ t t b r1 , #4096 * ( 1 + 3 ) @ only L2 used, skip pgd+3*pmd
# endif
/* CONFIG_VMSPLIT_1G does not need TTBR1 adjustment */
9001 : mcr p15 , 0 , \ t m p , c2 , c0 , 2 @ TTB control register
mcrr p15 , 1 , \ t t b r1 , \ z e r o , c2 @ load TTBR1
.endm
_ _ CPUINIT
/ *
* AT
* TFR E V X F I H D L R S
* .EEE . .EE PUI. . T A 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
* 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 .111 1101 < we w a n t
* /
.align 2
.type v7 _ c r v a l , #o b j e c t
v7_crval :
crval c l e a r =0x0120c302 , m m u s e t =0x30c23c7d , u c s e t =0x00c01c7c
.previous