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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Sep  8 17:12:21 2014 +0200

cobalt/posix/memory: do not duplicate base heap information

Now that we have a single contiguous storage area with no embedded
meta-data attached to the base heap, we may retrieve the size and base
memory information directly from it.

---

 include/cobalt/kernel/ppd.h  |    2 --
 kernel/cobalt/posix/memory.c |   10 ++++------
 kernel/cobalt/posix/memory.h |    2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/include/cobalt/kernel/ppd.h b/include/cobalt/kernel/ppd.h
index a4b2d4b..e76350c 100644
--- a/include/cobalt/kernel/ppd.h
+++ b/include/cobalt/kernel/ppd.h
@@ -26,8 +26,6 @@
 
 struct cobalt_umm {
        struct xnheap heap;
-       u32 size;
-       void *basemem;
        atomic_t refcount;
        void (*release)(struct cobalt_umm *umm);
 };
diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c
index c9735ac..d3cce34 100644
--- a/kernel/cobalt/posix/memory.c
+++ b/kernel/cobalt/posix/memory.c
@@ -89,7 +89,7 @@ static int umm_mmap(struct rtdm_fd *fd, struct vm_area_struct 
*vma)
                return -ENODEV;
 
        len = vma->vm_end - vma->vm_start;
-       if (len != umm->size)
+       if (len != xnheap_get_size(&umm->heap))
                return -EINVAL;
 
        vma->vm_private_data = umm;
@@ -97,7 +97,7 @@ static int umm_mmap(struct rtdm_fd *fd, struct vm_area_struct 
*vma)
        if (xnarch_cache_aliasing())
                vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-       ret = rtdm_mmap_vmem(vma, umm->basemem);
+       ret = rtdm_mmap_vmem(vma, xnheap_get_membase(&umm->heap));
        if (ret)
                return ret;
 
@@ -118,7 +118,7 @@ static int stat_umm(struct rtdm_fd *fd,
                return -ENODEV;
 
        xnlock_get_irqsave(&umm->heap.lock, s);
-       stat.size = umm->size;
+       stat.size = xnheap_get_size(&umm->heap);
        stat.free = xnheap_get_free(&umm->heap);
        xnlock_put_irqrestore(&umm->heap.lock, s);
 
@@ -340,8 +340,6 @@ int cobalt_umm_init(struct cobalt_umm *umm, u32 size,
                return ret;
        }
 
-       umm->basemem = basemem;
-       umm->size = size;
        umm->release = release;
        atomic_set(&umm->refcount, 1);
        smp_mb();
@@ -355,7 +353,7 @@ void cobalt_umm_destroy(struct cobalt_umm *umm)
 
        if (atomic_dec_and_test(&umm->refcount)) {
                xnheap_destroy(&umm->heap, NULL, NULL);
-               vfree(umm->basemem);
+               vfree(xnheap_get_membase(&umm->heap));
                if (umm->release)
                        umm->release(umm);
        }
diff --git a/kernel/cobalt/posix/memory.h b/kernel/cobalt/posix/memory.h
index 702bb67..83b499d 100644
--- a/kernel/cobalt/posix/memory.h
+++ b/kernel/cobalt/posix/memory.h
@@ -40,7 +40,7 @@ void cobalt_umm_free(struct cobalt_umm *umm, void *p)
 static inline
 __u32 cobalt_umm_offset(struct cobalt_umm *umm, void *p)
 {
-       return p - umm->basemem;
+       return p - xnheap_get_membase(&umm->heap);
 }
 
 int cobalt_memdev_init(void);


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

Reply via email to