root/include/asm/segment.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_fs_byte
  2. get_fs_byte
  3. get_fs_word
  4. get_fs_word
  5. get_fs_long
  6. get_fs_long
  7. get_fs_long
  8. get_fs_long
  9. put_fs_byte
  10. put_fs_byte
  11. put_fs_word
  12. put_fs_word
  13. put_fs_long
  14. put_fs_long
  15. put_fs_long
  16. put_fs_long
  17. memcpy_tofs
  18. memcpy_fromfs
  19. get_fs
  20. get_ds
  21. set_fs

   1 #ifndef _ASM_SEGMENT_H
   2 #define _ASM_SEGMENT_H
   3 
   4 static inline unsigned char get_fs_byte(const char * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
   5 {
   6         register unsigned char _v;
   7 
   8         __asm__ ("movb %%fs:%1,%0":"=q" (_v):"m" (*addr));
   9         return _v;
  10 }
  11 
  12 static inline unsigned char get_fs_byte(const unsigned char * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  13 {
  14         register unsigned char _v;
  15 
  16         __asm__ ("movb %%fs:%1,%0":"=q" (_v):"m" (*addr));
  17         return _v;
  18 }
  19 
  20 static inline unsigned short get_fs_word(const short *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22         unsigned short _v;
  23 
  24         __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
  25         return _v;
  26 }
  27 
  28 static inline unsigned short get_fs_word(const unsigned short *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30         unsigned short _v;
  31 
  32         __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
  33         return _v;
  34 }
  35 
  36 static inline unsigned long get_fs_long(const int *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38         unsigned long _v;
  39 
  40         __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
  41         return _v;
  42 }
  43 
  44 static inline unsigned long get_fs_long(const unsigned int *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46         unsigned long _v;
  47 
  48         __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
  49         return _v;
  50 }
  51 
  52 static inline unsigned long get_fs_long(const long *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54         unsigned long _v;
  55 
  56         __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
  57         return _v;
  58 }
  59 
  60 static inline unsigned long get_fs_long(const unsigned long *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  61 {
  62         unsigned long _v;
  63 
  64         __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
  65         return _v;
  66 }
  67 
  68 static inline void put_fs_byte(char val,char *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  69 {
  70 __asm__ ("movb %0,%%fs:%1": /* no outputs */ :"iq" (val),"m" (*addr));
  71 }
  72 
  73 static inline void put_fs_byte(char val,unsigned char *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  74 {
  75 __asm__ ("movb %0,%%fs:%1": /* no outputs */ :"iq" (val),"m" (*addr));
  76 }
  77 
  78 static inline void put_fs_word(short val,short * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  79 {
  80 __asm__ ("movw %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr));
  81 }
  82 
  83 static inline void put_fs_word(short val,unsigned short * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  84 {
  85 __asm__ ("movw %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr));
  86 }
  87 
  88 static inline void put_fs_long(unsigned long val,int * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  89 {
  90 __asm__ ("movl %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr));
  91 }
  92 
  93 static inline void put_fs_long(unsigned long val,unsigned int * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  94 {
  95 __asm__ ("movl %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr));
  96 }
  97 
  98 static inline void put_fs_long(unsigned long val,long * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  99 {
 100 __asm__ ("movl %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr));
 101 }
 102 
 103 static inline void put_fs_long(unsigned long val,unsigned long * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 104 {
 105 __asm__ ("movl %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr));
 106 }
 107 
 108 static inline void memcpy_tofs(void * to, const void * from, unsigned long n)
     /* [previous][next][first][last][top][bottom][index][help] */
 109 {
 110 __asm__("cld\n\t"
 111         "push %%es\n\t"
 112         "push %%fs\n\t"
 113         "pop %%es\n\t"
 114         "testb $1,%%cl\n\t"
 115         "je 1f\n\t"
 116         "movsb\n"
 117         "1:\ttestb $2,%%cl\n\t"
 118         "je 2f\n\t"
 119         "movsw\n"
 120         "2:\tshrl $2,%%ecx\n\t"
 121         "rep ; movsl\n\t"
 122         "pop %%es"
 123         : /* no outputs */
 124         :"c" (n),"D" ((long) to),"S" ((long) from)
 125         :"cx","di","si");
 126 }
 127 
 128 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
     /* [previous][next][first][last][top][bottom][index][help] */
 129 {
 130 __asm__("cld\n\t"
 131         "testb $1,%%cl\n\t"
 132         "je 1f\n\t"
 133         "fs ; movsb\n"
 134         "1:\ttestb $2,%%cl\n\t"
 135         "je 2f\n\t"
 136         "fs ; movsw\n"
 137         "2:\tshrl $2,%%ecx\n\t"
 138         "rep ; fs ; movsl"
 139         : /* no outputs */
 140         :"c" (n),"D" ((long) to),"S" ((long) from)
 141         :"cx","di","si");
 142 }
 143 
 144 /*
 145  * Someone who knows GNU asm better than I should double check the followig.
 146  * It seems to work, but I don't know if I'm doing something subtly wrong.
 147  * --- TYT, 11/24/91
 148  * [ nothing wrong here, Linus: I just changed the ax to be any reg ]
 149  */
 150 
 151 static inline unsigned long get_fs(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 152 {
 153         unsigned long _v;
 154         __asm__("mov %%fs,%w0":"=r" (_v):"0" (0));
 155         return _v;
 156 }
 157 
 158 static inline unsigned long get_ds(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 159 {
 160         unsigned long _v;
 161         __asm__("mov %%ds,%w0":"=r" (_v):"0" (0));
 162         return _v;
 163 }
 164 
 165 static inline void set_fs(unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
 166 {
 167         __asm__ __volatile__("mov %w0,%%fs": /* no output */ :"r" (val));
 168 }
 169 
 170 #endif /* _ASM_SEGMENT_H */

/* [previous][next][first][last][top][bottom][index][help] */