Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1165978
  • 博文数量: 173
  • 博客积分: 4048
  • 博客等级:
  • 技术积分: 2679
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-12 18:53
文章分类

全部博文(173)

文章存档

2018年(1)

2016年(1)

2013年(1)

2012年(118)

2011年(52)

分类: 嵌入式

2012-03-29 14:50:01

如果板上nios使用的cache较大,则运行uclinux可能死机。需要修改arch/nios2/mm/memory.c文件中的icache_push函数为

点击(此处)折叠或打开

  1. void icache_push(unsigned long vaddr, int len)
  2. {
  3.         cache_invalidate_data(vaddr, len);
  4.         cache_invalidate_inst(vaddr, len);
  5. }
(Note that cache_invalidate_data() is a bit of a misnomer as it actually writes dirty cache lines to memory before invalidating them. Also, I'm using the 'test-nios2' branch of Thomas Chou's git repository.)

The reason this is needed is that load_flat_file() in fs/binfmt_flat.c (which is responsible for loading executables in FLAT or ZFLAT format) calls flush_icache_range() after loading the executable into memory. The NiosII implementation of flush_icache_range() in include/asm-nios2/cacheflush.h) just calls the icache_push() function described above. However, with the old version of icache_push() there may still be dirty data cache lines that have not yet been written to memory. If the CPU reads instructions from these memory addresses before the data cache lines have been flushed, it will be reading invalid (stale) instructions.


这是因为uclinux执行程序时,需要将可执行文件中的指令和数据载入内存,其中指令可能仍然在数据cache中,没有写入内存。这时cpu通过指令cache从内存读取指令时,就会读出无效指令,从而导致系统崩溃。因此修改上述文件,读入指令时,先将数据cache中数据写入内存。

flush_icache_range() is also called when loading kernel modules.


Presumably with an 8K or less data cache it's only been working by chance so far!
阅读(2159) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

macharith2013-11-28 13:02:46

学习了!以前真没注意!