@ -20,48 +20,62 @@
*
* Flush t h e w h o l e D - c a c h e .
*
* Corrupted r e g i s t e r s : r0 - r5 , r 7 , r9 - r11
* Corrupted r e g i s t e r s : r0 - r7 , r9 - r11 ( r6 o n l y i n T h u m b m o d e )
*
* - mm - m m _ s t r u c t d e s c r i b i n g a d d r e s s s p a c e
* /
ENTRY( v7 _ f l u s h _ d c a c h e _ a l l )
dmb @ ensure ordering with previous memory accesses
mrc p15 , 1 , r0 , c0 , c0 , 1 @ read clidr
ands r3 , r0 , #0x7000000 @ extract loc from clidr
mov r3 , r3 , l s r #23 @ left align loc bit field
mov r3 , r0 , l s r #23 @ move LoC into position
ands r3 , r3 , #7 < < 1 @ extract LoC*2 from clidr
beq f i n i s h e d @ if loc is 0, then no need to clean
start_flush_levels :
mov r10 , #0 @ start clean at cache level 0
loop1 :
flush_levels :
add r2 , r10 , r10 , l s r #1 @ work out 3x current cache level
mov r1 , r0 , l s r r2 @ extract cache type bits from clidr
and r1 , r1 , #7 @ mask of the bits for current cache only
cmp r1 , #2 @ see what cache we have at this level
blt s k i p @ skip if no cache, or just i-cache
# ifdef C O N F I G _ P R E E M P T
save_ a n d _ d i s a b l e _ i r q s _ n o t r a c e r9 @ make cssr&csidr read atomic
# endif
mcr p15 , 2 , r10 , c0 , c0 , 0 @ select current cache level in cssr
isb @ isb to sych the new cssr&csidr
mrc p15 , 1 , r1 , c0 , c0 , 0 @ read the new csidr
# ifdef C O N F I G _ P R E E M P T
restore_ i r q s _ n o t r a c e r9
# endif
and r2 , r1 , #7 @ extract the length of the cache lines
add r2 , r2 , #4 @ add 4 (line length offset)
ldr r4 , =0x3ff
movw r4 , # 0x3ff
ands r4 , r4 , r1 , l s r #3 @ find maximum number on the way size
clz r5 , r4 @ find bit position of way size increment
ldr r7 , = 0x7fff
movw r7 , # 0x7fff
ands r7 , r7 , r1 , l s r #13 @ extract max number of the index size
loop1 :
mov r9 , r7 @ create working copy of max index
loop2 :
mov r9 , r4 @ create working copy of max way size
loop3 :
orr r11 , r10 , r9 , l s l r5 @ factor way and cache number into r11
orr r11 , r11 , r7 , l s l r2 @ factor index number into r11
ARM( o r r r11 , r10 , r4 , l s l r5 ) @ factor way and cache number into r11
THUMB( l s l r6 , r4 , r5 )
THUMB( o r r r11 , r10 , r6 ) @ factor way and cache number into r11
ARM( o r r r11 , r11 , r9 , l s l r2 ) @ factor index number into r11
THUMB( l s l r6 , r9 , r2 )
THUMB( o r r r11 , r11 , r6 ) @ factor index number into r11
mcr p15 , 0 , r11 , c7 , c14 , 2 @ clean & invalidate by set/way
subs r9 , r9 , #1 @ decrement the way
bge l o o p3
subs r7 , r7 , #1 @ decrement the index
subs r9 , r9 , #1 @ decrement the index
bge l o o p2
subs r4 , r4 , #1 @ decrement the way
bge l o o p1
skip :
add r10 , r10 , #2 @ increment cache number
cmp r3 , r10
bgt l o o p1
bgt f l u s h _ l e v e l s
finished :
mov r10 , #0 @ swith back to cache level 0
mcr p15 , 2 , r10 , c0 , c0 , 0 @ select current cache level in cssr
dsb s t
isb
mov p c , l r
ret l r
ENDPROC( v7 _ f l u s h _ d c a c h e _ a l l )