segment.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #define USER_DS MAKE_MM_SEG(__USER_DS)
  22. #define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
  23. /*
  24. * Get/set the SFC/DFC registers for MOVES instructions
  25. */
  26. static inline mm_segment_t get_fs(void)
  27. {
  28. #ifdef CONFIG_MMU
  29. mm_segment_t _v;
  30. __asm__ ("movec %/dfc,%0":"=r" (_v.seg):);
  31. return _v;
  32. #else
  33. return USER_DS;
  34. #endif
  35. }
  36. static inline mm_segment_t get_ds(void)
  37. {
  38. /* return the supervisor data space code */
  39. return KERNEL_DS;
  40. }
  41. static inline void set_fs(mm_segment_t val)
  42. {
  43. #ifdef CONFIG_MMU
  44. __asm__ __volatile__ ("movec %0,%/sfc\n\t"
  45. "movec %0,%/dfc\n\t"
  46. : /* no outputs */ : "r" (val.seg) : "memory");
  47. #endif
  48. }
  49. #define segment_eq(a,b) ((a).seg == (b).seg)
  50. #endif /* __ASSEMBLY__ */
  51. #endif /* _M68K_SEGMENT_H */