免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3843 | 回复: 4

清空cache的疑惑? [复制链接]

论坛徽章:
0
发表于 2011-09-14 00:18 |显示全部楼层
/*
*        flush_kern_cache_all()
*
*        Clean and invalidate the entire cache.
*/
ENTRY(arm926_flush_kern_cache_all)
        mov        r2, #VM_EXEC
        mov        ip, #0
__flush_whole_cache:
#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
        mcr        p15, 0, ip, c7, c6, 0                @ invalidate D cache
#else
1:        mrc        p15, 0, r15, c7, c14, 3         @ test,clean,invalidate
        bne        1b
#endif
        tst        r2, #VM_EXEC
        mcrne        p15, 0, ip, c7, c5, 0                @ invalidate I cache
        mcrne        p15, 0, ip, c7, c10, 4                @ drain WB
        mov        pc, lr

上面就是清空Dcache和Icache的程序,在这里有一点我不理解?
        mov        r2, #VM_EXEC
...
        tst        r2, #VM_EXEC
这两句话的作用,百思不得其解!

论坛徽章:
0
发表于 2011-09-14 10:27 |显示全部楼层
这个可能和下面的代码有关

ENTRY(arm926_flush_kern_cache_all)
        mov        r2, #VM_EXEC
        mov        ip, #0
__flush_whole_cache:#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
        mcr        p15, 0, ip, c7, c6, 0                @ invalidate D cache
#else
1:        mrc        p15, 0, r15, c7, c14, 3         @ test,clean,invalidate
        bne        1b
#endif
        tst        r2, #VM_EXEC
        mcrne        p15, 0, ip, c7, c5, 0                @ invalidate I cache
        mcrne        p15, 0, ip, c7, c10, 4                @ drain WB
        mov        pc, lr

/*
*        flush_user_cache_range(start, end, flags)
*
*        Clean and invalidate a range of cache entries in the
*        specified address range.
*
*        - start        - start address (inclusive)
*        - end        - end address (exclusive)
*        - flags        - vm_flags describing address space */
ENTRY(arm926_flush_user_cache_range)
        mov        ip, #0
        sub        r3, r1, r0                        @ calculate total size
        cmp        r3, #CACHE_DLIMIT
        bgt        __flush_whole_cache

arm926_flush_user_cache_range  中的第3个参数是flag, 就是R2, 当bgt  __flush_whole_cache
是这个tst r2 就有用了,
但对arm926_flush_kern_cache_all ,mov r2, tst r2 就是保证本身不边

论坛徽章:
0
发表于 2011-09-14 10:45 |显示全部楼层
非常感谢楼上,不过你说的对arm926_flush_kern_cache_all ,mov r2, tst r2 就是保证本身不变。我还是不太理解,因为在这段程序内不会对r2有所改变的操作,又何必检测r2的值不变呢?

论坛徽章:
0
发表于 2011-09-14 11:00 |显示全部楼层
如果纯对 arm926_flush_kern_cache_all  来讲mov r2,tst r2 可以拿掉,
但是 arm926_flush_user_cache_range  跳转 __flush_whole_cache 来讲,下面要判断tst r2,
如果不加个mov r2 ,exec 那么 flush cache all 就不能执行到flush icache 了

论坛徽章:
0
发表于 2011-09-14 13:14 |显示全部楼层
楼上的,你说的没错。太感动了。谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP