Unable to handle kernel paging request at virtual address 0x7e005070 解决办法

来源:互联网 发布:天下三捏脸数据 编辑:程序博客网 时间:2024/04/19 12:07

有点标题党的味道了~


 对于readl() 和 inl() 读取I/O端口报错的探究




给s3c6410的RTC写demo driver的时候遇到这个问题...

如图



          这是虚拟内存技术导致的问题,不能直接使用物理地址(不过这里有个疑问,我上次给PC写的CMOS driver貌似用的是物理地址,布吉岛为嘛)


           解决办法就是调用ioremap函数转换物理地址,重新映射IO端口到虚拟地址中


                Once equipped with ioremap (and iounmap), a device driver can access any I/O memory address, whether or not it is directly mapped to virtual address space. Remember, though, that the addresses returned from ioremap should not be dereferenced directly; instead, accessor functions provided by the kernel should be used. Before we get into those functions, we’d better review the ioremap prototypes and introduce a few details that we passed over in the previous chapter.


The functions are called according to the following definition:

#include <asm/io.h>void *ioremap(unsigned long phys_addr, unsigned long size);void *ioremap_nocache(unsigned long phys_addr, unsigned long size);void iounmap(void * addr);



                   First of all, you notice the new function ioremap_nocache. We didn’t cover it in Chapter 8, because its meaning is definitely hardware related. Quoting from one of the kernel headers: “It’s useful if some control registers are in such an area, and write combining or read caching is not desirable.” Actually, the function’s implementation
is identical to ioremap on most computer platforms: in situations where all of I/O memory is already visible through noncacheable addresses, there’s no reason to implement a separate, noncaching version of ioremap.


这里我重新改用了ioremap,everything work correctly...








0 0