Arm32 flush cache函数
函数:flush_cache_all
定义:
#define flush_cache_all() __cpuc_flush_kern_all()
从sharkl3的32 bit的System.map文件看,此函数最终对应的是下面的函数
v7_flush_kern_cache_all
ENTRY(v7_flush_kern_cache_all)
ARM( stmfd sp!, {r4-r5, r7, r9-r11, lr} )
THUMB( stmfd sp!, {r4-r7, r9-r11, lr} )
bl v7_flush_dcache_all
mov r0, #0
ALT_SMP(mcr p15, 0, r0, c7, c1, 0) @ invalidate I-cache inner shareable
ALT_UP(mcr p15, 0, r0, c7, c5, 0) @ I+BTB cache invalidate
ARM( ldmfd sp!, {r4-r5, r7, r9-r11, lr} )
THUMB( ldmfd sp!, {r4-r7, r9-r11, lr} )
ret lr
ENDPROC(v7_flush_kern_cache_all)
其实从config中的CONFIG_CPU_CACHE_V7=y也可以看出。
v7_flush_dcache_all
ENTRY(v7_flush_dcache_all)
dmb @ ensure ordering with previous memory accesses
mrc p15, 1, r0, c0, c0, 1 @ read clidr
CLIDR寄存器介绍 读出来的值是0xc3000123 说明sharkl3中包含L1、L2、L3三级cache
ICB, [31:30]
0b10 L2 cache is the highest inner level.
0b11 L3 cache is the highest inner level.
LoC, [26:24]
0b010 L3 cache is not implemented.
0b011 L2 and L3 cache are implemented.
这个寄存器的值仅表明集成到core的cache,不包括外挂cache的信息。
mov r3, r0, lsr #23 @ move LoC into position
ands r3, r3, #7 << 1 @ extract LoC*2 from clidr r3是cache_level的个数
beq finished @ if loc is 0, then no need to clean
start_flush_levels:</