@ -97,114 +97,14 @@ ENTRY(stext)
* /
ldr r13 , =__mmap_switched @ address to jump to after
@ mmu has been enabled
adr l r , B S Y M ( _ _ e n a b l e _ m m u ) @ return (PIC) address
adr l r , B S Y M ( 1 f ) @ return (PIC) address
ARM( a d d p c , r10 , #P R O C I N F O _ I N I T F U N C )
THUMB( a d d r12 , r10 , #P R O C I N F O _ I N I T F U N C )
THUMB( m o v p c , r12 )
1 : b _ _ e n a b l e _ m m u
ENDPROC( s t e x t )
.ltorg
# if d e f i n e d ( C O N F I G _ S M P )
ENTRY( s e c o n d a r y _ s t a r t u p )
/ *
* Common e n t r y p o i n t f o r s e c o n d a r y C P U s .
*
* Ensure t h a t w e ' r e i n S V C m o d e , a n d I R Q s a r e d i s a b l e d . L o o k u p
* the p r o c e s s o r t y p e - t h e r e i s n o n e e d t o c h e c k t h e m a c h i n e t y p e
* as i t h a s a l r e a d y b e e n v a l i d a t e d b y t h e p r i m a r y p r o c e s s o r .
* /
setmode P S R _ F _ B I T | P S R _ I _ B I T | S V C _ M O D E , r9
mrc p15 , 0 , r9 , c0 , c0 @ get processor id
bl _ _ l o o k u p _ p r o c e s s o r _ t y p e
movs r10 , r5 @ invalid processor?
moveq r0 , #' p ' @ yes, error 'p'
beq _ _ e r r o r
/ *
* Use t h e p a g e t a b l e s s u p p l i e d f r o m _ _ c p u _ u p .
* /
adr r4 , _ _ s e c o n d a r y _ d a t a
ldmia r4 , { r5 , r7 , r12 } @ address to jump to after
sub r4 , r4 , r5 @ mmu has been enabled
ldr r4 , [ r7 , r4 ] @ get secondary_data.pgdir
adr l r , B S Y M ( _ _ e n a b l e _ m m u ) @ return address
mov r13 , r12 @ __secondary_switched address
ARM( a d d p c , r10 , #P R O C I N F O _ I N I T F U N C ) @ i n i t i a l i s e p r o c e s s o r
@ (return control reg)
THUMB( a d d r12 , r10 , #P R O C I N F O _ I N I T F U N C )
THUMB( m o v p c , r12 )
ENDPROC( s e c o n d a r y _ s t a r t u p )
/ *
* r6 = & s e c o n d a r y _ d a t a
* /
ENTRY( _ _ s e c o n d a r y _ s w i t c h e d )
ldr s p , [ r7 , #4 ] @ get secondary_data.stack
mov f p , #0
b s e c o n d a r y _ s t a r t _ k e r n e l
ENDPROC( _ _ s e c o n d a r y _ s w i t c h e d )
.type _ _ secondary_ d a t a , % o b j e c t
__secondary_data :
.long .
.long secondary_data
.long __secondary_switched
# endif / * d e f i n e d ( C O N F I G _ S M P ) * /
/ *
* Setup c o m m o n b i t s b e f o r e f i n a l l y e n a b l i n g t h e M M U . E s s e n t i a l l y
* this i s j u s t l o a d i n g t h e p a g e t a b l e p o i n t e r a n d d o m a i n a c c e s s
* registers.
* /
__enable_mmu :
# ifdef C O N F I G _ A L I G N M E N T _ T R A P
orr r0 , r0 , #C R _ A
# else
bic r0 , r0 , #C R _ A
# endif
# ifdef C O N F I G _ C P U _ D C A C H E _ D I S A B L E
bic r0 , r0 , #C R _ C
# endif
# ifdef C O N F I G _ C P U _ B P R E D I C T _ D I S A B L E
bic r0 , r0 , #C R _ Z
# endif
# ifdef C O N F I G _ C P U _ I C A C H E _ D I S A B L E
bic r0 , r0 , #C R _ I
# endif
mov r5 , #( d o m a i n _ v a l ( D O M A I N _ U S E R , D O M A I N _ M A N A G E R ) | \
domain_ v a l ( D O M A I N _ K E R N E L , D O M A I N _ M A N A G E R ) | \
domain_ v a l ( D O M A I N _ T A B L E , D O M A I N _ M A N A G E R ) | \
domain_ v a l ( D O M A I N _ I O , D O M A I N _ C L I E N T ) )
mcr p15 , 0 , r5 , c3 , c0 , 0 @ load domain access register
mcr p15 , 0 , r4 , c2 , c0 , 0 @ load page table pointer
b _ _ t u r n _ m m u _ o n
ENDPROC( _ _ e n a b l e _ m m u )
/ *
* Enable t h e M M U . T h i s c o m p l e t e l y c h a n g e s t h e s t r u c t u r e o f t h e v i s i b l e
* memory s p a c e . Y o u w i l l n o t b e a b l e t o t r a c e e x e c u t i o n t h r o u g h t h i s .
* If y o u h a v e a n e n q u i r y a b o u t t h i s , * p l e a s e * c h e c k t h e l i n u x - a r m - k e r n e l
* mailing l i s t a r c h i v e s B E F O R E s e n d i n g a n o t h e r p o s t t o t h e l i s t .
*
* r0 = c p #15 c o n t r o l r e g i s t e r
* r1 3 = * v i r t u a l * a d d r e s s t o j u m p t o u p o n c o m p l e t i o n
*
* other r e g i s t e r s d e p e n d o n t h e f u n c t i o n c a l l e d u p o n c o m p l e t i o n
* /
.align 5
__turn_mmu_on :
mov r0 , r0
mcr p15 , 0 , r0 , c1 , c0 , 0 @ write control reg
mrc p15 , 0 , r3 , c0 , c0 , 0 @ read id reg
mov r3 , r3
mov r3 , r13
mov p c , r3
__enable_mmu_end :
ENDPROC( _ _ t u r n _ m m u _ o n )
/ *
* Setup t h e i n i t i a l p a g e t a b l e s . W e o n l y s e t u p t h e b a r e s t
* amount w h i c h a r e r e q u i r e d t o g e t t h e k e r n e l r u n n i n g , w h i c h
@ -349,4 +249,106 @@ __enable_mmu_loc:
.long __enable_mmu
.long __enable_mmu_end
# if d e f i n e d ( C O N F I G _ S M P )
_ _ CPUINIT
ENTRY( s e c o n d a r y _ s t a r t u p )
/ *
* Common e n t r y p o i n t f o r s e c o n d a r y C P U s .
*
* Ensure t h a t w e ' r e i n S V C m o d e , a n d I R Q s a r e d i s a b l e d . L o o k u p
* the p r o c e s s o r t y p e - t h e r e i s n o n e e d t o c h e c k t h e m a c h i n e t y p e
* as i t h a s a l r e a d y b e e n v a l i d a t e d b y t h e p r i m a r y p r o c e s s o r .
* /
setmode P S R _ F _ B I T | P S R _ I _ B I T | S V C _ M O D E , r9
mrc p15 , 0 , r9 , c0 , c0 @ get processor id
bl _ _ l o o k u p _ p r o c e s s o r _ t y p e
movs r10 , r5 @ invalid processor?
moveq r0 , #' p ' @ yes, error 'p'
beq _ _ e r r o r _ p
/ *
* Use t h e p a g e t a b l e s s u p p l i e d f r o m _ _ c p u _ u p .
* /
adr r4 , _ _ s e c o n d a r y _ d a t a
ldmia r4 , { r5 , r7 , r12 } @ address to jump to after
sub r4 , r4 , r5 @ mmu has been enabled
ldr r4 , [ r7 , r4 ] @ get secondary_data.pgdir
adr l r , B S Y M ( _ _ e n a b l e _ m m u ) @ return address
mov r13 , r12 @ __secondary_switched address
ARM( a d d p c , r10 , #P R O C I N F O _ I N I T F U N C ) @ i n i t i a l i s e p r o c e s s o r
@ (return control reg)
THUMB( a d d r12 , r10 , #P R O C I N F O _ I N I T F U N C )
THUMB( m o v p c , r12 )
ENDPROC( s e c o n d a r y _ s t a r t u p )
/ *
* r6 = & s e c o n d a r y _ d a t a
* /
ENTRY( _ _ s e c o n d a r y _ s w i t c h e d )
ldr s p , [ r7 , #4 ] @ get secondary_data.stack
mov f p , #0
b s e c o n d a r y _ s t a r t _ k e r n e l
ENDPROC( _ _ s e c o n d a r y _ s w i t c h e d )
.type _ _ secondary_ d a t a , % o b j e c t
__secondary_data :
.long .
.long secondary_data
.long __secondary_switched
# endif / * d e f i n e d ( C O N F I G _ S M P ) * /
/ *
* Setup c o m m o n b i t s b e f o r e f i n a l l y e n a b l i n g t h e M M U . E s s e n t i a l l y
* this i s j u s t l o a d i n g t h e p a g e t a b l e p o i n t e r a n d d o m a i n a c c e s s
* registers.
* /
__enable_mmu :
# ifdef C O N F I G _ A L I G N M E N T _ T R A P
orr r0 , r0 , #C R _ A
# else
bic r0 , r0 , #C R _ A
# endif
# ifdef C O N F I G _ C P U _ D C A C H E _ D I S A B L E
bic r0 , r0 , #C R _ C
# endif
# ifdef C O N F I G _ C P U _ B P R E D I C T _ D I S A B L E
bic r0 , r0 , #C R _ Z
# endif
# ifdef C O N F I G _ C P U _ I C A C H E _ D I S A B L E
bic r0 , r0 , #C R _ I
# endif
mov r5 , #( d o m a i n _ v a l ( D O M A I N _ U S E R , D O M A I N _ M A N A G E R ) | \
domain_ v a l ( D O M A I N _ K E R N E L , D O M A I N _ M A N A G E R ) | \
domain_ v a l ( D O M A I N _ T A B L E , D O M A I N _ M A N A G E R ) | \
domain_ v a l ( D O M A I N _ I O , D O M A I N _ C L I E N T ) )
mcr p15 , 0 , r5 , c3 , c0 , 0 @ load domain access register
mcr p15 , 0 , r4 , c2 , c0 , 0 @ load page table pointer
b _ _ t u r n _ m m u _ o n
ENDPROC( _ _ e n a b l e _ m m u )
/ *
* Enable t h e M M U . T h i s c o m p l e t e l y c h a n g e s t h e s t r u c t u r e o f t h e v i s i b l e
* memory s p a c e . Y o u w i l l n o t b e a b l e t o t r a c e e x e c u t i o n t h r o u g h t h i s .
* If y o u h a v e a n e n q u i r y a b o u t t h i s , * p l e a s e * c h e c k t h e l i n u x - a r m - k e r n e l
* mailing l i s t a r c h i v e s B E F O R E s e n d i n g a n o t h e r p o s t t o t h e l i s t .
*
* r0 = c p #15 c o n t r o l r e g i s t e r
* r1 3 = * v i r t u a l * a d d r e s s t o j u m p t o u p o n c o m p l e t i o n
*
* other r e g i s t e r s d e p e n d o n t h e f u n c t i o n c a l l e d u p o n c o m p l e t i o n
* /
.align 5
__turn_mmu_on :
mov r0 , r0
mcr p15 , 0 , r0 , c1 , c0 , 0 @ write control reg
mrc p15 , 0 , r3 , c0 , c0 , 0 @ read id reg
mov r3 , r3
mov r3 , r13
mov p c , r3
__enable_mmu_end :
ENDPROC( _ _ t u r n _ m m u _ o n )
# include " h e a d - c o m m o n . S "