Module: xenomai-abe
Branch: analogy
Commit: 6fddc692587ab0338872ccc3fdbfcf57e5b7584b
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=6fddc692587ab0338872ccc3fdbfcf57e5b7584b

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Oct 24 16:11:38 2009 +0200

blackfin: introduce MPU support

---

 include/asm-blackfin/bits/pod.h |   57 +++++++++++++++++++++++++++++++++++++-
 include/asm-blackfin/system.h   |    3 ++
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/include/asm-blackfin/bits/pod.h b/include/asm-blackfin/bits/pod.h
index a8eecb4..a77ac7e 100644
--- a/include/asm-blackfin/bits/pod.h
+++ b/include/asm-blackfin/bits/pod.h
@@ -59,12 +59,65 @@ static inline void xnarch_enter_root(xnarchtcb_t * rootcb)
 {
 }
 
+#ifdef CONFIG_MPU
+
+static inline
+struct task_struct *mpu_get_prev(struct xnarchtcb *tcb)
+{
+       return tcb->active_task;
+}
+
+static inline
+void mpu_set_next(struct xnarchtcb *tcb,
+                 struct task_struct *next)
+{
+       tcb->active_task = next;
+}
+
+static inline void mpu_switch(struct task_struct *prev,
+                             struct task_struct *next)
+{
+       if (next && next != prev) {
+               struct mm_struct *oldmm = prev->active_mm;
+               switch_mm(oldmm, next->active_mm, next);
+       }
+}
+
+#else /* !CONFIG_MPU */
+
+static inline
+struct task_struct *mpu_get_prev(struct xnarchtcb *tcb)
+{
+       return NULL;
+}
+
+static inline
+void mpu_set_next(struct xnarchtcb *tcb,
+                 struct task_struct *next)
+{
+}
+
+static inline void mpu_switch(struct task_struct *prev,
+                             struct task_struct *next)
+{
+}
+
+#endif /* CONFIG_MPU */
+
 static inline void xnarch_switch_to(xnarchtcb_t * out_tcb, xnarchtcb_t * 
in_tcb)
 {
-       if (in_tcb->user_task)
+       struct task_struct *prev = mpu_get_prev(out_tcb);
+       struct task_struct *next = in_tcb->user_task;
+
+       if (likely(next != NULL)) {
+               mpu_set_next(in_tcb, next);
                rthal_clear_foreign_stack(&rthal_domain);
-       else
+       } else {
+               mpu_set_next(in_tcb, prev);
                rthal_set_foreign_stack(&rthal_domain);
+       }
+
+       mpu_switch(prev, next);
 
        rthal_thread_switch(out_tcb->tsp, in_tcb->tsp);
 }
diff --git a/include/asm-blackfin/system.h b/include/asm-blackfin/system.h
index 1f87c9b..f7a46b2 100644
--- a/include/asm-blackfin/system.h
+++ b/include/asm-blackfin/system.h
@@ -49,6 +49,9 @@ typedef struct xnarchtcb {    /* Per-thread arch-dependent 
block */
 
     struct thread_struct ts;   /* Holds kernel-based thread context. */
     struct task_struct *user_task; /* Shadowed user-space task */
+#ifdef CONFIG_MPU
+    struct task_struct *active_task;    /* Active user-space task */
+#endif
     struct thread_struct *tsp; /* Pointer to the active thread struct (&ts or 
&user->thread). */
 
     /* Init block */


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

Reply via email to