2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / a r m / m m / p r o c - s a11 0 0 . S
*
* Copyright ( C ) 1 9 9 7 - 2 0 0 2 R u s s e l l K i n g
*
* 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 .
*
* MMU f u n c t i o n s f o r S A 1 1 0
*
* These a r e t h e l o w l e v e l a s s e m b l e r f o r p e r f o r m i n g c a c h e a n d T L B
* functions o n t h e S t r o n g A R M - 1 1 0 0 a n d S t r o n g A R M - 1 1 1 0 .
*
* Note t h a t S A 1 1 0 0 a n d S A 1 1 1 0 s h a r e e v e r y t h i n g b u t t h e i r n a m e a n d C P U I D .
*
* 1 2 - jun- 2 0 0 0 , E r i k M o u w ( J . A . K . M o u w @its.tudelft.nl):
* Flush t h e r e a d b u f f e r a t c o n t e x t s w i t c h e s
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / i n i t . h >
# include < a s m / a s s e m b l e r . h >
2005-09-09 23:08:59 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / p r o c i n f o . h >
# include < a s m / h a r d w a r e . h >
# include < a s m / p g t a b l e . h >
/ *
* the c a c h e l i n e s i z e o f t h e I a n d D c a c h e
* /
# define D C A C H E L I N E S I Z E 3 2
# define F L U S H _ O F F S E T 3 2 7 6 8
.macro flush_1100_dcache rd, r a , r e
ldr \ r d , =flush_base
ldr \ r a , [ \ r d ]
eor \ r a , \ r a , #F L U S H _ O F F S E T
str \ r a , [ \ r d ]
add \ r e , \ r a , #8192 @ only necessary for 8k
1001 : ldr \ r d , [ \ r a ] , #D C A C H E L I N E S I Z E
teq \ r e , \ r a
bne 1 0 0 1 b
# ifdef F L U S H _ B A S E _ M I N I C A C H E
add \ r a , \ r a , #F L U S H _ B A S E _ M I N I C A C H E - F L U S H _ B A S E
add \ r e , \ r a , #512 @ only 512 bytes
1002 : ldr \ r d , [ \ r a ] , #D C A C H E L I N E S I Z E
teq \ r e , \ r a
bne 1 0 0 2 b
# endif
.endm
.data
flush_base :
.long FLUSH_BASE
.text
_ _ INIT
/ *
* cpu_ s a11 0 0 _ p r o c _ i n i t ( )
* /
ENTRY( c p u _ s a11 0 0 _ p r o c _ i n i t )
mov r0 , #0
mcr p15 , 0 , r0 , c15 , c1 , 2 @ Enable clock switching
mcr p15 , 0 , r0 , c9 , c0 , 5 @ Allow read-buffer operations from userland
mov p c , l r
.previous
/ *
* cpu_ s a11 0 0 _ p r o c _ f i n ( )
*
* Prepare t h e C P U f o r r e s e t :
* - Disable i n t e r r u p t s
* - Clean a n d t u r n o f f c a c h e s .
* /
ENTRY( c p u _ s a11 0 0 _ p r o c _ f i n )
stmfd s p ! , { l r }
mov i p , #P S R _ F _ B I T | P S R _ I _ B I T | S V C _ M O D E
msr c p s r _ c , i p
flush_ 1 1 0 0 _ d c a c h e r0 , r1 , r2 @ clean caches
mov r0 , #0
mcr p15 , 0 , r0 , c15 , c2 , 2 @ Disable clock switching
mrc p15 , 0 , r0 , c1 , c0 , 0 @ ctrl register
bic r0 , r0 , #0x1000 @ ...i............
bic r0 , r0 , #0x000e @ ............wca.
mcr p15 , 0 , r0 , c1 , c0 , 0 @ disable caches
ldmfd s p ! , { p c }
/ *
* cpu_ s a11 0 0 _ 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 : location t o j u m p t o f o r s o f t r e s e t
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ r e s e t )
mov i p , #0
mcr p15 , 0 , i p , c7 , c7 , 0 @ invalidate I,D caches
mcr p15 , 0 , i p , c7 , c10 , 4 @ drain WB
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
mrc p15 , 0 , i p , c1 , c0 , 0 @ ctrl register
bic i p , i p , #0x000f @ ............wcam
bic i p , i p , #0x1100 @ ...i...s........
mcr p15 , 0 , i p , c1 , c0 , 0 @ ctrl register
mov p c , r0
/ *
* cpu_ s a11 0 0 _ d o _ i d l e ( t y p e )
*
* Cause t h e p r o c e s s o r t o i d l e
*
* type : call t y p e :
* 0 = slow i d l e
* 1 = fast i d l e
* 2 = switch t o s l o w p r o c e s s o r c l o c k
* 3 = switch t o f a s t p r o c e s s o r c l o c k
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ d o _ i d l e )
mov r0 , r0 @ 4 nop padding
mov r0 , r0
mov r0 , r0
mov r0 , r0 @ 4 nop padding
mov r0 , r0
mov r0 , r0
mov r0 , #0
ldr r1 , =UNCACHEABLE_ADDR @ ptr to uncacheable address
@ --- aligned to a cache line
mcr p15 , 0 , r0 , c15 , c2 , 2 @ disable clock switching
ldr r1 , [ r1 , #0 ] @ force switch to MCLK
mcr p15 , 0 , r0 , c15 , c8 , 2 @ wait for interrupt
mov r0 , r0 @ safety
mcr p15 , 0 , r0 , c15 , c1 , 2 @ enable clock switching
mov p c , l r
/* ================================= CACHE ================================ */
/ *
* cpu_ s a11 0 0 _ d c a c h e _ c l e a n _ a r e a ( a d d r ,s z )
*
* Clean t h e s p e c i f i e d e n t r y o f a n y c a c h e s s u c h t h a t t h e M M U
* translation f e t c h e s w i l l o b t a i n c o r r e c t d a t a .
*
* addr : cache- u n a l i g n e d v i r t u a l a d d r e s s
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ d c a c h e _ c l e a n _ a r e a )
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
mov p c , l r
/* =============================== PageTable ============================== */
/ *
* cpu_ s a11 0 0 _ s w i t c h _ m m ( p g d )
*
* Set t h e t r a n s l a t i o n b a s e p o i n t e r t o b e a s d e s c r i b e d b y p g d .
*
* pgd : new p a g e t a b l e s
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ s w i t c h _ m m )
flush_ 1 1 0 0 _ d c a c h e r3 , i p , r1
mov i p , #0
mcr p15 , 0 , i p , c7 , c5 , 0 @ invalidate I cache
mcr p15 , 0 , i p , c9 , c0 , 0 @ invalidate RB
mcr p15 , 0 , i p , c7 , c10 , 4 @ drain WB
mcr p15 , 0 , r0 , c2 , c0 , 0 @ load page table pointer
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
mov p c , l r
/ *
* cpu_ s a11 0 0 _ s e t _ p t e ( p t e p , p t e )
*
* Set a P T E a n d f l u s h i t o u t
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ s e t _ p t e )
str r1 , [ r0 ] , #- 2048 @ linux version
eor r1 , 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
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 r1 , #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 r1 , #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 r1 , #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
str r2 , [ r0 ] @ hardware version
mov r0 , r0
mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain WB
mov p c , l r
_ _ INIT
.type _ _ sa1 1 0 0 _ s e t u p , #f u n c t i o n
__sa1100_setup :
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c7 @ invalidate I,D caches on v4
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer on v4
mcr p15 , 0 , r0 , c8 , c7 @ invalidate I,D TLBs on v4
mrc p15 , 0 , r0 , c1 , c0 @ get control register v4
ldr r5 , s a11 0 0 _ c r1 _ c l e a r
bic r0 , r0 , r5
ldr r5 , s a11 0 0 _ c r1 _ s e t
orr r0 , r0 , r5
mov p c , l r
.size _ _ sa1 1 0 0 _ s e t u p , . - _ _ s a11 0 0 _ s e t u p
/ *
* R
* .RVI ZFRS BLDP W C A M
* . .11 0001 . .11 1101
*
* /
.type sa1 1 0 0 _ c r1 _ c l e a r , #o b j e c t
.type sa1 1 0 0 _ c r1 _ s e t , #o b j e c t
sa1100_cr1_clear :
.word 0x3f3f
sa1100_cr1_set :
.word 0x313d
_ _ INITDATA
/ *
* Purpose : F u n c t i o n p o i n t e r s u s e d t o a c c e s s a b o v e f u n c t i o n s - a l l c a l l s
* come t h r o u g h t h e s e
* /
/ *
* SA1 1 0 0 a n d S A 1 1 1 0 s h a r e t h e s a m e f u n c t i o n c a l l s
* /
.type sa1 1 0 0 _ 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( s a11 0 0 _ p r o c e s s o r _ f u n c t i o n s )
.word v4_early_abort
.word cpu_sa1100_proc_init
.word cpu_sa1100_proc_fin
.word cpu_sa1100_reset
.word cpu_sa1100_do_idle
.word cpu_sa1100_dcache_clean_area
.word cpu_sa1100_switch_mm
.word cpu_sa1100_set_pte
.size sa1 1 0 0 _ p r o c e s s o r _ f u n c t i o n s , . - s a11 0 0 _ p r o c e s s o r _ f u n c t i o n s
.section " .rodata "
.type cpu_ a r c h _ n a m e , #o b j e c t
cpu_arch_name :
.asciz " armv4 "
.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 " v4 "
.size cpu_ e l f _ n a m e , . - c p u _ e l f _ n a m e
.type cpu_ s a11 0 0 _ n a m e , #o b j e c t
cpu_sa1100_name :
.asciz " StrongARM- 1 1 0 0 "
.size cpu_ s a11 0 0 _ n a m e , . - c p u _ s a11 0 0 _ n a m e
.type cpu_ s a11 1 0 _ n a m e , #o b j e c t
cpu_sa1110_name :
.asciz " StrongARM- 1 1 1 0 "
.size cpu_ s a11 1 0 _ n a m e , . - c p u _ s a11 1 0 _ n a m e
.align
.section " .proc .info " , # alloc, #e x e c i n s t r
.type _ _ sa1 1 0 0 _ p r o c _ i n f o ,#o b j e c t
__sa1100_proc_info :
.long 0x4401a110
.long 0xfffffff0
.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 _ _ s a11 0 0 _ s e t u p
.long cpu_arch_name
.long cpu_elf_name
.long HWCAP_SWP | HWCAP_ H A L F | H W C A P _ 2 6 B I T | H W C A P _ F A S T _ M U L T
.long cpu_sa1100_name
.long sa1100_processor_functions
.long v4wb_tlb_fns
.long v4_mc_user_fns
.long v4wb_cache_fns
.size _ _ sa1 1 0 0 _ p r o c _ i n f o , . - _ _ s a11 0 0 _ p r o c _ i n f o
.type _ _ sa1 1 1 0 _ p r o c _ i n f o ,#o b j e c t
__sa1110_proc_info :
.long 0x6901b110
.long 0xfffffff0
.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 _ _ s a11 0 0 _ s e t u p
.long cpu_arch_name
.long cpu_elf_name
.long HWCAP_SWP | HWCAP_ H A L F | H W C A P _ 2 6 B I T | H W C A P _ F A S T _ M U L T
.long cpu_sa1110_name
.long sa1100_processor_functions
.long v4wb_tlb_fns
.long v4_mc_user_fns
.long v4wb_cache_fns
.size _ _ sa1 1 1 0 _ p r o c _ i n f o , . - _ _ s a11 1 0 _ p r o c _ i n f o