Module: xenomai-forge
Branch: next
Commit: e5615b65eb3f7c01a9820c11e4e7b83e62eacfcf
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e5615b65eb3f7c01a9820c11e4e7b83e62eacfcf

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Aug 15 12:08:23 2014 +0200

cobalt/rtdm: separate calls for logical vs purely virtual mappings

For the sake of clarity, introduce rtdm_mmap_vmem() for handling
purely virtual memory with no direct physical mapping.

---

 include/cobalt/kernel/rtdm/driver.h |    2 ++
 kernel/cobalt/rtdm/drvlib.c         |   51 ++++++++++++++++++++++++++++-------
 2 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 6fadac9..d95f86e 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -1152,6 +1152,8 @@ int rtdm_iomap_to_user(struct rtdm_fd *fd,
 
 int rtdm_mmap_kmem(struct vm_area_struct *vma, void *va);
 
+int rtdm_mmap_vmem(struct vm_area_struct *vma, void *va);
+
 int rtdm_mmap_iomem(struct vm_area_struct *vma, phys_addr_t pa);
 
 int rtdm_munmap(void *ptr, size_t len);
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index eb97a10..9e8535c 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -1804,20 +1804,21 @@ int rtdm_iomap_to_user(struct rtdm_fd *fd,
 EXPORT_SYMBOL_GPL(rtdm_iomap_to_user);
 
 /**
- * Map a kernel memory range to a virtual memory area.
+ * Map a kernel logical memory range to a virtual user area.
  *
  * This routine is commonly used from a ->mmap() handler of a RTDM
- * driver, for mapping a kernel memory area over the user address
- * space referred to by @a vma.
+ * driver, for mapping a virtual memory area with no direct physical
+ * mapping over the user address space referred to by @a vma.
  *
  * @param[in] vma The VMA descriptor to receive the mapping.
- * @param[in] va The kernel virtual address to be mapped.
+ * @param[in] va The kernel logical address to be mapped.
  *
  * @return 0 on success, otherwise a negated error code is returned.
  *
- * @note This service only works on memory regions allocated via
- * kmalloc() or vmalloc(). To map a chunk of physical I/O memory to a
- * VMA, call rtdm_mmap_iomem() instead.
+ * @note This service works on memory regions allocated via
+ * kmalloc(). To map a chunk of virtual space with no direct physical
+ * mapping, or a physical I/O memory to a VMA, call rtdm_mmap_vmem()
+ * or rtdm_mmap_iomem() respectively instead.
  *
  * @coretags{secondary-only}
  */
@@ -1828,7 +1829,36 @@ int rtdm_mmap_kmem(struct vm_area_struct *vma, void *va)
 EXPORT_SYMBOL_GPL(rtdm_mmap_kmem);
 
 /**
- * Map an I/O memory range to a virtual memory area.
+ * Map a virtual memory range to a virtual user area.
+ *
+ * This routine is commonly used from a ->mmap() handler of a RTDM
+ * driver, for mapping a purely virtual memory area over the user
+ * address space referred to by @a vma.
+ *
+ * @param[in] vma The VMA descriptor to receive the mapping.
+ * @param[in] va The virtual address to be mapped.
+ *
+ * @return 0 on success, otherwise a negated error code is returned.
+ *
+ * @note This service works on memory regions allocated via
+ * vmalloc(). To map a chunk of logical space obtained from kmalloc(),
+ * or a physical I/O memory to a VMA, call rtdm_mmap_kmem() or
+ * rtdm_mmap_iomem() respectively instead.
+ *
+ * @coretags{secondary-only}
+ */
+int rtdm_mmap_vmem(struct vm_area_struct *vma, void *va)
+{
+       /*
+        * Our helper handles both of directly mapped to physical and
+        * purely virtual memory ranges.
+        */
+       return mmap_kmem_helper(vma, va);
+}
+EXPORT_SYMBOL_GPL(rtdm_mmap_vmem);
+
+/**
+ * Map an I/O memory range to a virtual user area.
  *
  * This routine is commonly used from a ->mmap() handler of a RTDM
  * driver, for mapping an I/O memory area over the user address space
@@ -1839,8 +1869,9 @@ EXPORT_SYMBOL_GPL(rtdm_mmap_kmem);
  *
  * @return 0 on success, otherwise a negated error code is returned.
  *
- * @note To map a chunk of kernel virtual memory to a VMA, call
- * rtdm_mmap_kmem() instead.
+ * @note To map a chunk of logical space obtained from kmalloc(), or a
+ * purely virtual area with no direct physical mapping to a VMA, call
+ * rtdm_mmap_kmem() or rtdm_mmap_vmem() respectively instead.
  *
  * @coretags{secondary-only}
  */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to