linux-mips
[Top] [All Lists]

Re: how to mmap 0x1f000000 to user space?

To: figo zhang <figo1802@gmail.com>
Subject: Re: how to mmap 0x1f000000 to user space?
From: Markus Gothe <nietzsche@lysator.liu.se>
Date: Sat, 24 Oct 2009 18:27:39 +0200
Cc: linux-mips@linux-mips.org
In-reply-to: <c6ed1ac50910232228h4ca7d0b4safed0bc63a02868@mail.gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <c6ed1ac50910232228h4ca7d0b4safed0bc63a02868@mail.gmail.com>
Sender: linux-mips-bounce@linux-mips.org
What does the vendor UM say on the memory base?

//Markus

On 24 Oct 2009, at 07:28, figo zhang wrote:

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?
here is my code, is it right? Would you like to give me some advise?
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);
  }
       /* 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;
}



Best,
Figo.zhang

Attachment: PGP.sig
Description: This is a digitally signed message part

<Prev in Thread] Current Thread [Next in Thread>