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 )
2012-07-16 15:37:06 -04:00
# ifndef _ _ A R M E B _ _
# define r p g d l r0
# define r p g d h r1
# else
# define r p g d l r1
# define r p g d h r0
# endif
2011-11-22 17:30:29 +00:00
/ *
* 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
2012-07-16 15:37:06 -04:00
mmid r2 , r2
asid r2 , r2
orr r p g d h , r p g d h , r2 , l s l #( 48 - 3 2 ) @ upper 32-bits of pgd
mcrr p15 , 0 , r p g d l , r p g d h , c2 @ set TTB 0
2011-11-22 17:30:29 +00:00
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-07-15 14:26:19 +01:00
ALT_ S M P ( W ( n o p ) )
2013-04-03 17:16:57 +01:00
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
2012-07-21 15:55:04 -04:00
mov \ t m p , \ t m p , l s r #A R C H _ P G D _ S H I F T
2012-07-21 19:47:52 -04:00
cmp \ t t b r1 , \ t m p @ PHYS_OFFSET > PAGE_OFFSET?
2011-11-22 17:30:29 +00:00
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 )
/ *
2012-07-21 19:47:52 -04:00
* Only u s e s p l i t T T B R s i f P H Y S _ O F F S E T < = P A G E _ O F F S E T ( c m p a b o v e ) ,
* otherwise b o o t i n g 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
* identity m a p p i n g s e t u p i n T T B R 0 .
2011-11-22 17:30:29 +00:00
* /
2012-07-21 19:47:52 -04:00
orrls \ t m p , \ t m p , #T T B R 1 _ S I Z E @ TTBCR.T1SZ
mcr p15 , 0 , \ t m p , c2 , c0 , 2 @ TTBCR
2012-07-21 15:55:04 -04:00
mov \ t m p , \ t t b r1 , l s r #( 32 - A R C H _ P G D _ S H I F T ) @ upper bits
mov \ t t b r1 , \ t t b r1 , l s l #A R C H _ P G D _ S H I F T @ l o w e r b i t s
2012-07-21 19:47:52 -04:00
addls \ t t b r1 , \ t t b r1 , #T T B R 1 _ O F F S E T
mcrr p15 , 1 , \ t t b r1 , \ z e r o , c2 @ load TTBR1
2012-07-21 15:55:04 -04:00
mov \ t m p , \ t t b r0 , l s r #( 32 - A R C H _ P G D _ S H I F T ) @ upper bits
mov \ t t b r0 , \ t t b r0 , l s l #A R C H _ P G D _ S H I F T @ l o w e r b i t s
mcrr p15 , 0 , \ t t b r0 , \ z e r o , c2 @ load TTBR0
mcrr p15 , 1 , \ t t b r1 , \ z e r o , c2 @ load TTBR1
mcrr p15 , 0 , \ t t b r0 , \ z e r o , c2 @ load TTBR0
2011-11-22 17:30:29 +00:00
.endm
/ *
* 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