Loading ...
Sorry, an error occurred while loading the content.

mmap to kmalloc area - problem with mem_map_reserve

Expand Messages
  • lov2lin
    Hello, I am new to Linux device drivers. I am using Linux kernel version 2.6.8 I need to allocate some physical memory in the driver (kmalloc/get_free_pages)
    Message 1 of 1 , Jun 17, 2005
    • 0 Attachment
      Hello,

      I am new to Linux device drivers. I am using Linux kernel version
      2.6.8

      I need to allocate some physical memory in the driver
      (kmalloc/get_free_pages) and wants to mmap the same to the user
      space.

      There is some sample and description given at
      http://www.scs.ch/~frey/linux/memorymap.html for the same like the
      following

      Mapping addresses which are in the kernel virtual mapping into user
      space is straight foreward:
      · Implement a mmap method for your driver
      · set the VM_LOCKED flag on your memory area. This will
      prevent the swapper fromm swapping the pages out:
      vma->flags |= VM_LOCKED
      · Call remap_page_range() to map the physical address of your
      buffer to the user space address
      Example:
      vma->flags |= VM_LOCKED;
      if (remap_page_range(vma->vm_start,
      virt_to_phys((void*)((unsigned long)
      kmalloc_area)),
      size,
      PAGE_SHARED))
      {
      printk("remap page range failed\n");
      return -ENXIO;
      }

      But it needs to reserve the page with
      /* reserve all pages to make them remapable */
      mem_map_reserve(virt_to_page(kmalloc_area));


      I could not find the header file in my system for mem_map_reserve..
      /* this header files wraps some common module-space operations ...
      here we use mem_map_reserve() macro */
      #include <linux/wrapper.h>

      can anybody suggest how can I get it or any other alternatives with
      the new kernel versions.
      Thanks in advance.
    Your message has been successfully submitted and would be delivered to recipients shortly.