当前位置: 技术问答>linux和unix
关于ioremap
来源: 互联网 发布时间:2016-02-03
本文导语: 我在驱动里 #define PHY_ADDR (0x1e700000) virt_from_phy = ioremap(PHY_ADDR, 1); 返回错误为 unable to handle kernel NULL pointer dereference at virtual address 00000000 而 virt_from_phy = ioremap(PHY_ADDR, 8); 就能够成功 请问是什么原因,能解...
我在驱动里
#define PHY_ADDR (0x1e700000)
virt_from_phy = ioremap(PHY_ADDR, 1);
返回错误为
unable to handle kernel NULL pointer dereference at virtual address 00000000
而
virt_from_phy = ioremap(PHY_ADDR, 8);
就能够成功
请问是什么原因,能解释解释么?
#define PHY_ADDR (0x1e700000)
virt_from_phy = ioremap(PHY_ADDR, 1);
返回错误为
unable to handle kernel NULL pointer dereference at virtual address 00000000
而
virt_from_phy = ioremap(PHY_ADDR, 8);
就能够成功
请问是什么原因,能解释解释么?
|
/*
* Remap an arbitrary physical address space into the kernel virtual
* address space. Needed when the kernel wants to access high addresses
* directly.
*
* NOTE! We need to allow non-page-aligned mappings too: we will obviously
* have to convert them into an offset in a page-aligned mapping, but the
* caller shouldn't need to know that small detail.
*
* 'flags' are the extra L_PTE_ flags that you want to specify for this
* mapping. See include/asm-arm/proc-armv/pgtable.h for more information.
*/
void * __ioremap(unsigned long phys_addr, size_t size, unsigned long flags)
{
void * addr;
struct vm_struct * area;
unsigned long offset, last_addr;
/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
if (!size || last_addr addr;
if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
vfree(addr);
return NULL;
}
return (void *) (offset + (char *)addr);
}
其中的remap_area_pages可以查看http://blog.chinaunix.net/u1/38994/showart_327363.html
* Remap an arbitrary physical address space into the kernel virtual
* address space. Needed when the kernel wants to access high addresses
* directly.
*
* NOTE! We need to allow non-page-aligned mappings too: we will obviously
* have to convert them into an offset in a page-aligned mapping, but the
* caller shouldn't need to know that small detail.
*
* 'flags' are the extra L_PTE_ flags that you want to specify for this
* mapping. See include/asm-arm/proc-armv/pgtable.h for more information.
*/
void * __ioremap(unsigned long phys_addr, size_t size, unsigned long flags)
{
void * addr;
struct vm_struct * area;
unsigned long offset, last_addr;
/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
if (!size || last_addr addr;
if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
vfree(addr);
return NULL;
}
return (void *) (offset + (char *)addr);
}
其中的remap_area_pages可以查看http://blog.chinaunix.net/u1/38994/showart_327363.html
|
如果指定的地址已经被分配的话,总是返回0
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。