Module: xenomai-head
Branch: master
Commit: 25d2d764887655c934781fa88024221fa851e939
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=25d2d764887655c934781fa88024221fa851e939

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Nov  2 12:22:35 2009 +0100

nucleus: fix shared heaps for MMU-less configs

nommu support requires the get_unmapped_area() handler to be available
from a character device fops, for getting a suggested address from
which to make the shared mapping.

This patch adds one to the shared heap management code.

---

 ksrc/nucleus/heap.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/ksrc/nucleus/heap.c b/ksrc/nucleus/heap.c
index c1eca3f..9040e85 100644
--- a/ksrc/nucleus/heap.c
+++ b/ksrc/nucleus/heap.c
@@ -1108,6 +1108,7 @@ static int xnheap_mmap(struct file *file, struct 
vm_area_struct *vma)
        vma->vm_ops = &xnheap_vmops;
        vma->vm_private_data = file->private_data;
 
+#ifdef CONFIG_MMU
        vaddr = (unsigned long)heap->archdep.heapbase + offset;
 
        err = -EAGAIN;
@@ -1132,6 +1133,12 @@ static int xnheap_mmap(struct file *file, struct 
vm_area_struct *vma)
                goto deref_out;
 
        xnarch_fault_range(vma);
+#else /* !CONFIG_MMU */
+       (void)vaddr;
+       if ((heap->archdep.kmflags & ~XNHEAP_GFP_NONCACHED) != 0 ||
+           heap->archdep.kmflags == XNHEAP_GFP_NONCACHED)
+               vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+#endif /* !CONFIG_MMU */
 
        return 0;
 
@@ -1140,6 +1147,42 @@ deref_out:
        return err;
 }
 
+#ifndef CONFIG_MMU
+static unsigned long xnheap_get_unmapped_area(struct file *file,
+                                             unsigned long addr,
+                                             unsigned long len,
+                                             unsigned long pgoff,
+                                             unsigned long flags)
+{
+       unsigned long uaddr, offset;
+       struct xnheap *heap;
+       int ret;
+
+       spin_lock(&kheapq_lock);
+
+       ret = -EINVAL;
+       heap = __validate_heap_addr(file->private_data);
+       if (heap == NULL)
+               goto fail;
+
+       offset = pgoff << PAGE_SHIFT;
+       if (offset + len > xnheap_extentsize(heap))
+               goto fail;
+
+       uaddr = (unsigned long)heap->archdep.heapbase + offset;
+
+       spin_unlock(&kheapq_lock);
+
+       return uaddr;
+fail:
+       spin_unlock(&kheapq_lock);
+
+       return (unsigned long)ret;
+}
+#else /* CONFIG_MMU */
+#define xnheap_get_unmapped_area  NULL
+#endif /* CONFIG_MMU */
+
 int xnheap_init_mapped(xnheap_t *heap, u_long heapsize, int memflags)
 {
        void *heapbase;
@@ -1222,9 +1265,10 @@ void xnheap_destroy_mapped(xnheap_t *heap,
 
 static struct file_operations xnheap_fops = {
        .owner = THIS_MODULE,
-       .open = &xnheap_open,
-       .ioctl = &xnheap_ioctl,
-       .mmap = &xnheap_mmap
+       .open = xnheap_open,
+       .ioctl = xnheap_ioctl,
+       .mmap = xnheap_mmap,
+       .get_unmapped_area = xnheap_get_unmapped_area
 };
 
 static struct miscdevice xnheap_dev = {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to