home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / linux / atari / source / source.lzh / atari-linux-0.01pl3 / include / asm / segment.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  3.0 KB  |  125 lines

  1. /*
  2.  *  linux/include/asm/segment.h
  3.  *
  4.  *  Copyright (C) 1991, 1992  Linus Torvalds
  5.  *
  6.  * This file is subject to the terms and conditions of the GNU General Public
  7.  * License.  See the file README.legal in the main directory of this archive
  8.  * for more details.
  9.  */
  10.  
  11. /*
  12.  * 680x0 support added by Hamish Macdonald
  13.  */
  14.  
  15. #ifndef _ASM_SEGMENT_H
  16. #define _ASM_SEGMENT_H
  17.  
  18. static inline unsigned char get_user_byte(const char * addr)
  19. {
  20.     register unsigned char _v;
  21.  
  22.     __asm__ __volatile__ ("movesb %1,%0":"=r" (_v):"m" (*addr));
  23.     return _v;
  24. }
  25.  
  26. #define get_fs_byte(addr) get_user_byte((char *)(addr))
  27.  
  28. static inline unsigned short get_user_word(const short *addr)
  29. {
  30.     unsigned short _v;
  31.  
  32.     __asm__ __volatile__ ("movesw %1,%0":"=r" (_v):"m" (*addr));
  33.     return _v;
  34. }
  35.  
  36. #define get_fs_word(addr) get_user_word((short *)(addr))
  37.  
  38. static inline unsigned long get_user_long(const int *addr)
  39. {
  40.     unsigned long _v;
  41.  
  42.     __asm__ __volatile__ ("movesl %1,%0":"=r" (_v):"m" (*addr)); \
  43.     return _v;
  44. }
  45.  
  46. #define get_fs_long(addr) get_user_long((int *)(addr))
  47.  
  48. static inline void put_user_byte(char val,char *addr)
  49. {
  50.     __asm__ __volatile__ ("movesb %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory");
  51. }
  52.  
  53. #define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
  54.  
  55. static inline void put_user_word(short val,short * addr)
  56. {
  57.     __asm__ __volatile__ ("movesw %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory");
  58. }
  59.  
  60. #define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
  61.  
  62. static inline void put_user_long(unsigned long val,int * addr)
  63. {
  64.     __asm__ __volatile__ ("movesl %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory");
  65. }
  66.  
  67. #define put_fs_long(x,addr) put_user_long((x),(int *)(addr))
  68.  
  69. static inline void memcpy_tofs(void * to, const void * from, unsigned long n)
  70. {
  71.     if (n == 0) return;
  72.     __asm__ __volatile__ ("movel %1,a0\n\t"
  73.                   "movel %2,a1\n\t"
  74.                   "1:\n\t"
  75.                   "moveb a0@+,d0\n\t"
  76.                   "movesb d0,a1@+\n\t"
  77.                   "dbra %0,1b\n\t"
  78.                   "subl #65536,%0\n\t"
  79.                   "bccs 1b"
  80.                   : "=d" (n) : "g" (from), "g" (to), "0" (n-1)
  81.                   : "d0", "a0", "a1", "memory");
  82. }
  83.  
  84. static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
  85. {
  86.     if (n == 0) return;
  87.     __asm__ __volatile__ ("movel %1,a0\n\t"
  88.                   "movel %2,a1\n\t"
  89.                   "1:\n\t"
  90.                   "movesb a0@+,d0\n\t"
  91.                   "moveb d0,a1@+\n\t"
  92.                   "dbra %0,1b\n\t"
  93.                   "subl #65536,%0\n\t"
  94.                   "bccs 1b"
  95.                   : "=d" (n) : "g" (from), "g" (to), "0" (n-1)
  96.                   : "d0", "a0", "a1", "memory");
  97. }
  98.  
  99. /*
  100.  * Get/set the SFC/DFC registers for MOVES instructions
  101.  */
  102.  
  103. static inline unsigned long get_fs(void)
  104. {
  105.     unsigned long _v;
  106.     __asm__ ("movec dfc,%0":"=r" (_v):);
  107.  
  108.     return _v;
  109. }
  110.  
  111. static inline unsigned long get_ds(void)
  112. {
  113.     /* return the supervisor data space code */
  114.     return 0x5;
  115. }
  116.  
  117. static inline void set_fs(unsigned long val)
  118. {
  119.     __asm__ __volatile__ ("movec %0,sfc\n\t"
  120.                   "movec %0,dfc\n\t"
  121.                   : /* no outputs */ : "r" (val), "r" (val) : "memory");
  122. }
  123.  
  124. #endif /* _ASM_SEGMENT_H */
  125.