mmu_context.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #ifndef __PARISC_MMU_CONTEXT_H
  2. #define __PARISC_MMU_CONTEXT_H
  3. static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk, unsigned cpu)
  4. {
  5. }
  6. /* on PA-RISC, we actually have enough contexts to justify an allocator
  7.  * for them.  prumpf */
  8. extern unsigned long alloc_sid(void);
  9. extern void free_sid(unsigned long);
  10. static inline int
  11. init_new_context(struct task_struct *tsk, struct mm_struct *mm)
  12. {
  13. /*
  14.  * Init_new_context can be called for a cloned mm, so we
  15.  * only allocate a space id if one hasn't been allocated
  16.  * yet AND mm != &init_mm (cloned kernel thread which
  17.  * will run in the kernel space with spaceid 0).
  18.  */
  19. if ((mm != &init_mm) && (mm->context == 0)) {
  20. mm->context = alloc_sid();
  21. }
  22. return 0;
  23. }
  24. static inline void
  25. destroy_context(struct mm_struct *mm)
  26. {
  27. free_sid(mm->context);
  28. mm->context = 0;
  29. }
  30. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
  31. {
  32. if (prev != next) {
  33. /* Re-load page tables */
  34. tsk->thread.pg_tables = __pa(next->pgd);
  35. mtctl(tsk->thread.pg_tables, 25);
  36. mtsp(next->context,3);
  37. }
  38. }
  39. static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
  40. {
  41. /*
  42.  * Activate_mm is our one chance to allocate a space id
  43.  * for a new mm created in the exec path. There's also
  44.  * some lazy tlb stuff, which is currently dead code, but
  45.  * we only allocate a space id if one hasn't been allocated
  46.  * already, so we should be OK.
  47.  */
  48. if (next == &init_mm) BUG(); /* Should never happen */
  49. if (next->context == 0)
  50.     next->context = alloc_sid();
  51. switch_mm(prev,next,current,0);
  52. }
  53. #endif