- 论坛徽章:
- 0
|
驱动里面
mmap函数:
volatile void *offset=(volatile void *)kmalloc(100,GFP_ATOMIC);
vma->vm_flags |= VM_RESERVED;
physical_addr=virt_to_phys(offset);
if (remap_page_range(vma->vm_start, physical_addr ,vma->vm_end-vma->vm_start, vma->vm_page_prot))
{
printk("remap error\n");
return -EAGAIN;
}
line_addr=offset;
应用程序里:
share_addr=mmap(0,100,PROT_READ|PROT_WRITE,MAP_FILE|MAP_SHARED,fd,0);
映射是成功了, 但是之后用户程序里,对share_addr写入,
memcpy(share_addr,"test",5);
printf("%s\n",share_addr); 正确
但是在内核里 printk("%s\n",line_addr); 就是不对。
请高手指教 |
|