hi,
i am newbies for mips. i want to mmap the kernel space address
0x1f00,0000 to user mode space for MIPS32 CPU? how to write the mmap file mothod?
0x1f00,0000 to user mode space for MIPS32 CPU? how to write the mmap file mothod?
here is my code, is it right? Would you like to give me some advise?
Thanks!
Thanks!
static int test_reg_mmap(struct file * file, struct vm_area_struct * vma)
{
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long size = vma->vm_end-vma->vm_start;
unsigned int *pfn;
unsigned int __iomem *buf;
#if 0
offset += 0xbf000000;
#else
buf = (unsigned int * )ioremap_nocache(0x1f000000, size);
pfn = vmalloc_to_pfn((void *)buf);
offset += pfn;
#endif
if ((offset>__pa(high_memory)) || (file->f_flags & O_SYNC)) {
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
}
{
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long size = vma->vm_end-vma->vm_start;
unsigned int *pfn;
unsigned int __iomem *buf;
#if 0
offset += 0xbf000000;
#else
buf = (unsigned int * )ioremap_nocache(0x1f000000, size);
pfn = vmalloc_to_pfn((void *)buf);
offset += pfn;
#endif
if ((offset>__pa(high_memory)) || (file->f_flags & O_SYNC)) {
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
}
/* Don't try to swap out physical pages.. */
vma->vm_flags |= VM_RESERVED;
/* Don't dump addresses that are not real memory to a core file.*/
if (offset >= __pa(high_memory) || (file->f_flags & O_SYNC))
vma->vm_flags |= VM_IO;
if (remap_pfn_range(vma, vma->vm_start, offset, vma->vm_end-vma->vm_start,
vma->vm_page_prot))
return 0;
}
vma->vm_flags |= VM_RESERVED;
/* Don't dump addresses that are not real memory to a core file.*/
if (offset >= __pa(high_memory) || (file->f_flags & O_SYNC))
vma->vm_flags |= VM_IO;
if (remap_pfn_range(vma, vma->vm_start, offset, vma->vm_end-vma->vm_start,
vma->vm_page_prot))
return 0;
}
Best,
Figo.zhang