2005-04-16 15:20:36 -07:00
/ *
* linux/ a r c h / a r m / m m / p r o c - v6 . 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 .
*
* 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 i s t h e " s h e l l " o f t h e A R M v6 p r o c e s s o r s u p p o r t .
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
# include < a s m / c o n s t a n t s . h >
# include < a s m / p r o c i n f o . h >
# include < a s m / p g t a b l e . h >
# include " p r o c - m a c r o s . S "
# define D _ C A C H E _ L I N E _ S I Z E 3 2
.macro cpsie, f l a g s
.ifc \ flags, f
.long 0xf1080040
.exitm
.endif
.ifc \ flags, i
.long 0xf1080080
.exitm
.endif
.ifc \ flags, i f
.long 0xf10800c0
.exitm
.endif
.err
.endm
.macro cpsid, f l a g s
.ifc \ flags, f
.long 0xf10c0040
.exitm
.endif
.ifc \ flags, i
.long 0xf10c0080
.exitm
.endif
.ifc \ flags, i f
.long 0xf10c00c0
.exitm
.endif
.err
.endm
ENTRY( c p u _ v6 _ p r o c _ i n i t )
mov p c , l r
ENTRY( c p u _ v6 _ p r o c _ f i n )
mov p c , l r
/ *
* cpu_ v6 _ r e s e t ( l o c )
*
* Perform a s o f t r e s e t o f t h e s y s t e m . P u t t h e C P U i n t o t h e
* same s t a t e a s i t w o u l d b e i f i t h a d b e e n r e s e t , a n d b r a n c h
* to w h a t w o u l d b e t h e r e s e t v e c t o r .
*
* - loc - l o c a t i o n t o j u m p t o f o r s o f t r e s e t
*
* It i s a s s u m e d t h a t :
* /
.align 5
ENTRY( c p u _ v6 _ r e s e t )
mov p c , r0
/ *
* cpu_ v6 _ d o _ i d l e ( )
*
* Idle t h e p r o c e s s o r ( e g , w a i t f o r i n t e r r u p t ) .
*
* IRQs a r e a l r e a d y d i s a b l e d .
* /
ENTRY( c p u _ v6 _ d o _ i d l e )
mcr p15 , 0 , r1 , c7 , c0 , 4 @ wait for interrupt
mov p c , l r
ENTRY( c p u _ v6 _ d c a c h e _ c l e a n _ a r e a )
# ifndef T L B _ C A N _ R E A D _ F R O M _ L 1 _ C A C H E
1 : mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
add r0 , r0 , #D _ C A C H E _ L I N E _ S I Z E
subs r1 , r1 , #D _ C A C H E _ L I N E _ S I Z E
bhi 1 b
# endif
mov p c , l r
/ *
* cpu_ a r m 9 2 6 _ 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
* /
ENTRY( c p u _ v6 _ s w i t c h _ m m )
mov r2 , #0
ldr r1 , [ r1 , #M M _ C O N T E X T _ I D ] @ g e t m m - > c o n t e x t . i d
2005-08-15 16:53:38 +01:00
mcr p15 , 0 , r2 , c7 , c5 , 6 @ flush BTAC/BTB
2005-04-16 15:20:36 -07:00
mcr p15 , 0 , r2 , c7 , c10 , 4 @ drain write buffer
mcr p15 , 0 , r0 , c2 , c0 , 0 @ set TTB 0
mcr p15 , 0 , r1 , c13 , c0 , 1 @ set context ID
mov p c , l r
/ *
* cpu_ v6 _ s e t _ p t e ( 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 - 1 0 2 4 b y t e s )
* - pte - P T E v a l u e t o s t o r e
*
* Permissions :
* 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
2005-06-24 21:27:39 +01:00
* 1 1 0 x 0 1 0 r / w r / o
* 1 1 x0 0 1 0 r / w r / o
2005-04-16 15:20:36 -07:00
* 1 1 1 1 0 1 1 r/ w r / w
* /
ENTRY( c p u _ v6 _ s e t _ p t e )
str r1 , [ r0 ] , #- 2048 @ linux version
2005-08-10 16:18:35 +01:00
bic r2 , r1 , #0x000007f0
2005-04-16 15:20:36 -07:00
bic r2 , r2 , #0x00000003
2005-08-10 16:15:32 +01:00
orr r2 , r2 , #P T E _ E X T _ A P 0 | 2
2005-04-16 15:20:36 -07:00
tst r1 , #L _ P T E _ W R I T E
tstne r1 , #L _ P T E _ D I R T Y
2005-08-10 16:15:32 +01:00
orreq r2 , r2 , #P T E _ E X T _ A P X
2005-04-16 15:20:36 -07:00
tst r1 , #L _ P T E _ U S E R
2005-08-10 16:18:35 +01:00
orrne r2 , r2 , #P T E _ E X T _ A P 1
2005-08-10 16:15:32 +01:00
tstne r2 , #P T E _ E X T _ A P X
bicne r2 , r2 , #P T E _ E X T _ A P X | P T E _ E X T _ A P 0
2005-04-16 15:20:36 -07:00
tst r1 , #L _ P T E _ Y O U N G
2005-08-10 16:15:32 +01:00
biceq r2 , r2 , #P T E _ E X T _ A P X | P T E _ E X T _ A P _ M A S K
2005-04-16 15:20:36 -07:00
@ tst r1, #L_PTE_EXEC
2005-08-10 16:15:32 +01:00
@ orreq r2, r2, #PTE_EXT_XN
2005-04-16 15:20:36 -07:00
tst r1 , #L _ P T E _ P R E S E N T
moveq r2 , #0
str r2 , [ r0 ]
mcr p15 , 0 , r0 , c7 , c10 , 1 @ flush_pte
mov p c , l r
cpu_v6_name :
.asciz " Some R a n d o m V 6 P r o c e s s o r "
.align
.section " .text .init " , # alloc, #e x e c i n s t r
/ *
* _ _ v6 _ s e t u p
*
* Initialise T L B , C a c h e s , a n d M M U s t a t e r e a d y t o s w i t c h t h e M M U
* on. R e t u r n i n r0 t h e n e w C P 1 5 C 1 c o n t r o l r e g i s t e r s e t t i n g .
*
* We a u t o m a t i c a l l y d e t e c t i f w e h a v e a H a r v a r d c a c h e , a n d u s e t h e
* Harvard c a c h e c o n t r o l i n s t r u c t i o n s i n s e a d o f t h e u n i f i e d c a c h e
* control i n s t r u c t i o n s .
*
* This s h o u l d b e a b l e t o c o v e r a l l A R M v6 c o r e s .
*
* It i s a s s u m e d t h a t :
* - cache t y p e r e g i s t e r i s i m p l e m e n t e d
* /
__v6_setup :
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c14 , 0 @ clean+invalidate D cache
mcr p15 , 0 , r0 , c7 , c5 , 0 @ invalidate I cache
mcr p15 , 0 , r0 , c7 , c15 , 0 @ clean+invalidate cache
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer
mcr p15 , 0 , r0 , c8 , c7 , 0 @ invalidate I + D TLBs
mcr p15 , 0 , r0 , c2 , c0 , 2 @ TTB control register
mcr p15 , 0 , r4 , c2 , c0 , 1 @ load TTB1
# ifdef C O N F I G _ V F P
mrc p15 , 0 , r0 , c1 , c0 , 2
2005-07-06 23:06:03 +01:00
orr r0 , r0 , #( 0xf < < 2 0 )
2005-04-16 15:20:36 -07:00
mcr p15 , 0 , r0 , c1 , c0 , 2 @ Enable full access to VFP
# endif
mrc p15 , 0 , r0 , c1 , c0 , 0 @ read control register
ldr r5 , v6 _ c r1 _ c l e a r @ get mask for bits to clear
bic r0 , r0 , r5 @ clear bits them
ldr r5 , v6 _ c r1 _ s e t @ get mask for bits to set
orr r0 , r0 , r5 @ set them
mov p c , l r @ return to head.S:__ret
/ *
* V X F I D L R
* . . . . . . .E PUI. . T . T 4 R V I Z F R S B L D P W C A M
* rrrr r r r 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
* 0 1 1 0 0 0 1 1 1 .00 .111 1101 < we w a n t
* /
.type v6 _ c r1 _ c l e a r , #o b j e c t
.type v6 _ c r1 _ s e t , #o b j e c t
v6_cr1_clear :
.word 0x01e0fb7f
v6_cr1_set :
.word 0x00c0387d
.type v6 _ p r o c e s s o r _ f u n c t i o n s , #o b j e c t
ENTRY( v6 _ p r o c e s s o r _ f u n c t i o n s )
.word v6_early_abort
.word cpu_v6_proc_init
.word cpu_v6_proc_fin
.word cpu_v6_reset
.word cpu_v6_do_idle
.word cpu_v6_dcache_clean_area
.word cpu_v6_switch_mm
.word cpu_v6_set_pte
.size v6 _ p r o c e s s o r _ f u n c t i o n s , . - v6 _ p r o c e s s o r _ f u n c t i o n s
.type cpu_ a r c h _ n a m e , #o b j e c t
cpu_arch_name :
.asciz " armv6 "
.size cpu_ a r c h _ n a m e , . - c p u _ a r c h _ n a m e
.type cpu_ e l f _ n a m e , #o b j e c t
cpu_elf_name :
.asciz " v6 "
.size cpu_ e l f _ n a m e , . - c p u _ e l f _ n a m e
.align
.section " .proc .info " , # alloc, #e x e c i n s t r
/ *
* Match a n y A R M v6 p r o c e s s o r c o r e .
* /
.type _ _ v6 _ p r o c _ i n f o , #o b j e c t
__v6_proc_info :
.long 0x0007b000
.long 0x0007f000
.long PMD_TYPE_SECT | \
PMD_ S E C T _ B U F F E R A B L E | \
PMD_ S E C T _ C A C H E A B L E | \
PMD_ S E C T _ A P _ W R I T E | \
PMD_ S E C T _ A P _ R E A D
b _ _ v6 _ s e t u p
.long cpu_arch_name
.long cpu_elf_name
.long HWCAP_ S W P | H W C A P _ H A L F | H W C A P _ T H U M B | H W C A P _ F A S T _ M U L T | H W C A P _ V F P | H W C A P _ E D S P | H W C A P _ J A V A
.long cpu_v6_name
.long v6_processor_functions
.long v6wbi_tlb_fns
.long v6_user_fns
.long v6_cache_fns
.size _ _ v6 _ p r o c _ i n f o , . - _ _ v6 _ p r o c _ i n f o