- 论坛徽章:
- 0
|
本帖最后由 vip-weiwei 于 2012-05-30 10:52 编辑
回复 3# embeddedlwp
谢谢两位,再问:
我在LDD3中看到这样的程序段:
struct page *scullp_vma_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
unsigned long offset;
struct scullp_dev *ptr, *dev = vma->vm_private_data;
struct page *page = NOPAGE_SIGBUS;
void *pageptr = NULL; /* default to "missing" */
down(&dev->sem);
offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
if (offset >= dev->size) goto out; /* out of range */
/*
* Now retrieve the scullp device from the list,then the page.
* If the device has holes, the process receives a SIGBUS when
* accessing the hole.
*/
offset >>= PAGE_SHIFT; /* offset is a number of pages */
for (ptr = dev; ptr && offset >= dev->qset {
ptr = ptr->next;
offset -= dev->qset;
}
......
为什么这个设备文件要从文件起始开始算内存映射?而不是把address - vma->vm_start当作内存映射的大小?文件起始至vma_pgoff这段的内容通常会是什么?不好意思刚接触这个问的问题可能比较那个:) |
|