2005-04-16 15:20:36 -07:00
/ *
* We n e e d c o n s t a n t s . h f o r :
* VMA_ V M _ M M
* VMA_ V M _ F L A G S
* VM_ E X E C
* /
2005-09-09 21:08:59 +02:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / t h r e a d _ i n f o . h >
/ *
* vma_ v m _ m m - g e t m m p o i n t e r f r o m v m a p o i n t e r ( v m a - > v m _ m m )
* /
.macro vma_ v m _ m m , r d , r n
ldr \ r d , [ \ r n , #V M A _ V M _ M M ]
.endm
/ *
* vma_ v m _ f l a g s - g e t v m a - > v m _ f l a g s
* /
.macro vma_ v m _ f l a g s , r d , r n
ldr \ r d , [ \ r n , #V M A _ V M _ F L A G S ]
.endm
.macro tsk_ m m , r d , r n
ldr \ r d , [ \ r n , #T I _ T A S K ]
ldr \ r d , [ \ r d , #T S K _ A C T I V E _ M M ]
.endm
/ *
* act_ m m - g e t c u r r e n t - > a c t i v e _ m m
* /
.macro act_ m m , r d
bic \ r d , s p , #8128
bic \ r d , \ r d , #63
ldr \ r d , [ \ r d , #T I _ T A S K ]
ldr \ r d , [ \ r d , #T S K _ A C T I V E _ M M ]
.endm
/ *
* mmid - g e t c o n t e x t i d f r o m m m p o i n t e r ( m m - > c o n t e x t . i d )
* /
.macro mmid, r d , r n
ldr \ r d , [ \ r n , #M M _ C O N T E X T _ I D ]
.endm
/ *
* mask_ a s i d - m a s k t h e A S I D f r o m t h e c o n t e x t I D
* /
.macro asid, r d , r n
and \ r d , \ r n , #255
.endm
2006-06-29 15:09:57 +01:00
.macro crval, c l e a r , m m u s e t , u c s e t
# ifdef C O N F I G _ M M U
.word \ clear
.word \ mmuset
# else
.word \ clear
.word \ ucset
# endif
.endm
2007-05-08 22:27:46 +01:00
/ *
* cache_ l i n e _ s i z e - g e t t h e c a c h e l i n e s i z e f r o m t h e C S I D R r e g i s t e r
* ( available o n A R M v7 + ) . I t a s s u m e s t h a t t h e C S S R r e g i s t e r w a s c o n f i g u r e d
* to a c c e s s t h e L 1 d a t a c a c h e C S I D R .
* /
.macro dcache_ l i n e _ s i z e , r e g , t m p
mrc p15 , 1 , \ t m p , c0 , c0 , 0 @ read CSIDR
and \ t m p , \ t m p , #7 @ cache line size encoding
mov \ r e g , #16 @ size offset
mov \ r e g , \ r e g , l s l \ t m p @ actual cache line size
.endm
2008-09-06 17:19:08 +01:00
/ *
* Sanity c h e c k t h e P T E c o n f i g u r a t i o n f o r t h e c o d e b e l o w - w h i c h m a k e s
* certain a s s u m p t i o n s a b o u t h o w t h e s e b i t s a r e l a y e d o u t .
* /
# if L _ P T E _ S H A R E D ! = P T E _ E X T _ S H A R E D
# error P T E s h a r e d b i t m i s m a t c h
# endif
# if L _ P T E _ B U F F E R A B L E ! = P T E _ B U F F E R A B L E
# error P T E b u f f e r a b l e b i t m i s m a t c h
# endif
# if L _ P T E _ C A C H E A B L E ! = P T E _ C A C H E A B L E
# error P T E c a c h e a b l e b i t m i s m a t c h
# endif
# if ( L _ P T E _ E X E C + L _ P T E _ U S E R + L _ P T E _ W R I T E + L _ P T E _ D I R T Y + L _ P T E _ Y O U N G + \
L_ P T E _ F I L E + L _ P T E _ P R E S E N T ) > L _ P T E _ S H A R E D
# error I n v a l i d L i n u x P T E b i t s e t t i n g s
# endif
/ *
* The A R M v6 a n d A R M v7 s e t _ p t e _ e x t t r a n s l a t i o n f u n c t i o n .
*
* Permission t r a n s l a t i o n :
* YUWD A P X A P 1 A P 0 S V C U s e r
* 0 xxx 0 0 0 n o a c c n o a c c
* 1 0 0 x 1 0 1 r / o n o a c c
* 1 0 x0 1 0 1 r / o n o a c c
* 1 0 1 1 0 0 1 r/ w n o a c c
* 1 1 0 x 0 1 0 r / w r / o
* 1 1 x0 0 1 0 r / w r / o
* 1 1 1 1 0 1 1 r/ w r / w
* /
2008-09-06 21:07:45 +01:00
.macro armv6_mt_table pfx
\ pfx\ ( ) _ m t _ t a b l e :
.long 0x00 @ L_PTE_MT_UNCACHED
.long PTE_ E X T _ T E X ( 1 ) @ L_PTE_MT_BUFFERABLE
.long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
.long PTE_CACHEABLE | PTE_ B U F F E R A B L E @ L_PTE_MT_WRITEBACK
.long PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED
.long 0x00 @ unused
.long 0x00 @ L_PTE_MT_MINICACHE (not present)
.long PTE_ E X T _ T E X ( 1 ) | P T E _ C A C H E A B L E | P T E _ B U F F E R A B L E @ L_PTE_MT_WRITEALLOC
.long 0x00 @ unused
.long PTE_ E X T _ T E X ( 1 ) @ L_PTE_MT_DEV_WC
.long 0x00 @ unused
.long PTE_CACHEABLE | PTE_ B U F F E R A B L E @ L_PTE_MT_DEV_CACHED
.long PTE_ E X T _ T E X ( 2 ) @ L_PTE_MT_DEV_NONSHARED
2008-09-07 12:42:51 +01:00
.long 0x00 @ unused
2008-09-06 21:07:45 +01:00
.long 0x00 @ unused
.long 0x00 @ unused
.endm
.macro armv6_set_pte_ext pfx
2008-09-06 17:19:08 +01:00
str r1 , [ r0 ] , #- 2048 @ linux version
2008-09-06 21:07:45 +01:00
bic r3 , r1 , #0x000003fc
2008-09-06 17:19:08 +01:00
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
2008-09-06 21:07:45 +01:00
adr i p , \ p f x \ ( ) _ m t _ t a b l e
and r2 , r1 , #L _ P T E _ M T _ M A S K
ldr r2 , [ i p , r2 ]
2008-09-06 17:19:08 +01:00
tst r1 , #L _ P T E _ W R I T E
tstne r1 , #L _ P T E _ D I R T Y
orreq 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
tstne r3 , #P T E _ E X T _ A P X
bicne r3 , r3 , #P T E _ E X T _ A P X | P T E _ E X T _ A P 0
tst r1 , #L _ P T E _ E X E C
orreq r3 , r3 , #P T E _ E X T _ X N
2008-09-06 21:07:45 +01:00
orr r3 , r3 , r2
2008-09-06 17:19:08 +01:00
tst r1 , #L _ P T E _ Y O U N G
tstne r1 , #L _ P T E _ P R E S E N T
moveq r3 , #0
str r3 , [ r0 ]
mcr p15 , 0 , r0 , c7 , c10 , 1 @ flush_pte
.endm
/ *
* The A R M v3 , A R M v4 a n d A R M v5 s e t _ p t e _ e x t t r a n s l a t i o n f u n c t i o n ,
* covering m o s t C P U s e x c e p t X s c a l e a n d X s c a l e 3 .
*
* Permission t r a n s l a t i o n :
* YUWD A P S V C U s e r
* 0 xxx 0 x00 n o a c c n o a c c
* 1 0 0 x 0 x00 r / o n o a c c
* 1 0 x0 0 x00 r / o n o a c c
* 1 0 1 1 0 x5 5 r / w n o a c c
* 1 1 0 x 0 x a a r / w r / o
* 1 1 x0 0 x a a r / w r / o
* 1 1 1 1 0 xff r / w r / w
* /
.macro armv3_set_pte_ext wc_ d i s a b l e =1
str r1 , [ r0 ] , #- 2048 @ linux version
eor r3 , r1 , #L _ P T E _ P R E S E N T | L _ P T E _ Y O U N G | L _ P T E _ W R I T E | L _ P T E _ D I R T Y
bic r2 , r1 , #P T E _ S M A L L _ A P _ M A S K @ k e e p C , B b i t s
bic r2 , r2 , #P T E _ T Y P E _ M A S K
orr r2 , r2 , #P T E _ T Y P E _ S M A L L
tst r3 , #L _ P T E _ U S E R @ u s e r ?
orrne r2 , r2 , #P T E _ S M A L L _ A P _ U R O _ S R W
tst r3 , #L _ P T E _ W R I T E | L _ P T E _ D I R T Y @ w r i t e a n d d i r t y ?
orreq r2 , r2 , #P T E _ S M A L L _ A P _ U N O _ S R W
tst r3 , #L _ P T E _ P R E S E N T | L _ P T E _ Y O U N G @ p r e s e n t a n d y o u n g ?
movne r2 , #0
.if \ wc_ d i s a b l e
# ifdef C O N F I G _ C P U _ D C A C H E _ W R I T E T H R O U G H
tst r2 , #P T E _ C A C H E A B L E
bicne r2 , r2 , #P T E _ B U F F E R A B L E
# endif
.endif
str r2 , [ r0 ] @ hardware version
.endm
/ *
* Xscale s e t _ p t e _ e x t t r a n s l a t i o n , s p l i t i n t o t w o h a l v e s t o c o p e
* with w o r k - a r o u n d s . r3 m u s t b e p r e s e r v e d b y c o d e b e t w e e n t h e s e
* two m a c r o s .
*
* Permission t r a n s l a t i o n :
* YUWD A P S V C U s e r
* 0 xxx 0 0 n o a c c n o a c c
* 1 0 0 x 0 0 r / o n o a c c
* 1 0 x0 0 0 r / o n o a c c
* 1 0 1 1 0 1 r/ w n o a c c
* 1 1 0 x 1 0 r / w r / o
* 1 1 x0 1 0 r / w r / o
* 1 1 1 1 1 1 r/ w r / w
* /
.macro xscale_set_pte_ext_prologue
str r1 , [ r0 ] , #- 2048 @ linux version
eor r3 , r1 , #L _ P T E _ P R E S E N T | L _ P T E _ Y O U N G | L _ P T E _ W R I T E | L _ P T E _ D I R T Y
bic r2 , r1 , #P T E _ S M A L L _ A P _ M A S K @ k e e p C , B b i t s
orr r2 , r2 , #P T E _ T Y P E _ E X T @ e x t e n d e d p a g e
tst r3 , #L _ P T E _ U S E R @ u s e r ?
orrne r2 , r2 , #P T E _ E X T _ A P _ U R O _ S R W @ y e s - > u s e r r / o , s y s t e m r / w
tst r3 , #L _ P T E _ W R I T E | L _ P T E _ D I R T Y @ w r i t e a n d d i r t y ?
orreq r2 , r2 , #P T E _ E X T _ A P _ U N O _ S R W @ y e s - > u s e r n / a , s y s t e m r / w
@ combined with user -> user r/w
.endm
.macro xscale_set_pte_ext_epilogue
tst r3 , #L _ P T E _ P R E S E N T | L _ P T E _ Y O U N G @ p r e s e n t a n d y o u n g ?
movne r2 , #0 @ no -> fault
str r2 , [ r0 ] @ hardware version
mov i p , #0
mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean L1 D line
mcr p15 , 0 , i p , c7 , c10 , 4 @ data write barrier
.endm