Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15357495
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2008-03-18 20:08:05

通过cp15协处理器flush dcache总线上的数据回DDR和SRAM

文章来源:http://gliethttp.cublog.cn

//gliethttp_20080318
以下dcahe回写代码摘自linux2.6.24内核arm930处理器的(Tavor)
/arch/arm/mm/proc-xsc3.S目录

实现:短暂的禁用dcache和MMU,所以bl flush_i_d_cache之后需要再打开一次MMU
    ;//gliethttp_20080318 add icache dcache off and both on function
    ALIGN 4
    EXPORT flush_i_d_cache
flush_i_d_cache
    stmfd {r0,lr}

      mov    r0, #0x1f00
    orr    r0, r0, #0x00e0
1    mcr    p15, 0, r0, c7, c14, 2        @ clean/invalidate L1 D line
    adds    r0, r0, #0x40000000
    bcc    1b
    subs r0, r0, #0x20
    bpl    1b
    mcr    p15, 0, ip, c7, c5, 0        @ invalidate L1 I cache and BTB
    mcr    p15, 0, ip, c7, c10, 4        @ data write barrier
    mcr    p15, 0, ip, c7, c5, 4        @ prefetch flush

    ;mcr p15, 0, r0, c7, c6, 0
    
    ldmfd {r0,pc}
    
    ALIGN 4
    EXPORT disable_i_d_cache
disable_i_d_cache
    stmfd sp!,{r0-r1,lr}

    bl flush_i_d_cache ;将dcache上的数据flush到DDR和SRAM上
    
    mov r1, #0x78
    orr r1, r1, #0x0001
    mcr p15, 0, r1, c1, c0, 0

    mrc p15, 0, r0, c2, c0, 0
    mov r0, r0
    sub pc, pc, #4
    
    ldmfd sp!,{r0-r1,pc}

    ALIGN 4
    EXPORT enable_i_d_cache
enable_i_d_cache
    stmfd sp!,{r0-r1,lr}
    
    mov r1, #0x78
    ;mrc p15, 0, r1, c2, c0, 0
    orr r1, r1, #0x0001
    orr r1, r1, #0x1000 @ Enable Icache
    orr r1, r1, #0x0004 @ Enable Dcache
    orr r1, r1, #0x0800 @ Enable BTB
    mcr p15, 0, r1, c1, c0, 0

    mrc p15, 0, r0, c2, c0, 0
    mov r0, r0
    sub pc, pc, #4
    
    ldmfd sp!,{r0-r1,pc

阅读(2571) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~