segment.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _M68K_SEGMENT_H
  2. #define _M68K_SEGMENT_H
  3. /* define constants */
  4. /* Address spaces (FC0-FC2) */
  5. #define USER_DATA (1)
  6. #ifndef __USER_DS
  7. #define __USER_DS (USER_DATA)
  8. #endif
  9. #define USER_PROGRAM (2)
  10. #define SUPER_DATA (5)
  11. #ifndef __KERNEL_DS
  12. #define __KERNEL_DS (SUPER_DATA)
  13. #endif
  14. #define SUPER_PROGRAM (6)
  15. #define CPU_SPACE (7)
  16. #ifndef __ASSEMBLY__
  17. typedef struct {
  18. unsigned long seg;
  19. } mm_segment_t;
  20. #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
  21. #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES
  22. /*
  23. * Get/set the SFC/DFC registers for MOVES instructions
  24. */
  25. #define USER_DS MAKE_MM_SEG(__USER_DS)
  26. #define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
  27. static inline mm_segment_t get_fs(void)
  28. {
  29. mm_segment_t _v;
  30. __asm__ ("movec %/dfc,%0":"=r" (_v.seg):);
  31. return _v;
  32. }
  33. static inline void set_fs(mm_segment_t val)
  34. {
  35. __asm__ __volatile__ ("movec %0,%/sfc\n\t"
  36. "movec %0,%/dfc\n\t"
  37. : /* no outputs */ : "r" (val.seg) : "memory");
  38. }
  39. static inline mm_segment_t get_ds(void)
  40. {
  41. /* return the supervisor data space code */
  42. return KERNEL_DS;
  43. }
  44. #else
  45. #define USER_DS MAKE_MM_SEG(TASK_SIZE)
  46. #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
  47. #define get_ds() (KERNEL_DS)
  48. #define get_fs() (current_thread_info()->addr_limit)
  49. #define set_fs(x) (current_thread_info()->addr_limit = (x))
  50. #endif
  51. #define segment_eq(a, b) ((a).seg == (b).seg)
  52. #endif /* __ASSEMBLY__ */
  53. #endif /* _M68K_SEGMENT_H */