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

有点标题党的味道了~


 对于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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值