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_word
  3. get_fs_long
  4. put_fs_byte
  5. put_fs_word
  6. put_fs_long
  7. memcpy_tofs
  8. memcpy_fromfs
  9. get_fs
  10. get_ds
  11. set_fs

   1 static inline unsigned char get_fs_byte(const char * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
   2 {
   3         register unsigned char _v;
   4 
   5         __asm__ ("movb %%fs:%1,%0":"=q" (_v):"m" (*addr));
   6         return _v;
   7 }
   8 
   9 static inline unsigned short get_fs_word(const unsigned short *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  10 {
  11         unsigned short _v;
  12 
  13         __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr));
  14         return _v;
  15 }
  16 
  17 static inline unsigned long get_fs_long(const unsigned long *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  18 {
  19         unsigned long _v;
  20 
  21         __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \
  22         return _v;
  23 }
  24 
  25 static inline void put_fs_byte(char val,char *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27 __asm__ ("movb %0,%%fs:%1"::"q" (val),"m" (*addr));
  28 }
  29 
  30 static inline void put_fs_word(short val,short * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32 __asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr));
  33 }
  34 
  35 static inline void put_fs_long(unsigned long val,unsigned long * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  36 {
  37 __asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr));
  38 }
  39 
  40 static inline void memcpy_tofs(void * to, const void * from, unsigned long n)
     /* [previous][next][first][last][top][bottom][index][help] */
  41 {
  42 __asm__("cld\n\t"
  43         "push %%es\n\t"
  44         "push %%fs\n\t"
  45         "pop %%es\n\t"
  46         "testb $1,%%cl\n\t"
  47         "je 1f\n\t"
  48         "movsb\n"
  49         "1:\ttestb $2,%%cl\n\t"
  50         "je 2f\n\t"
  51         "movsw\n"
  52         "2:\tshrl $2,%%ecx\n\t"
  53         "rep ; movsl\n\t"
  54         "pop %%es"
  55         ::"c" (n),"D" ((long) to),"S" ((long) from)
  56         :"cx","di","si");
  57 }
  58 
  59 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61 __asm__("cld\n\t"
  62         "testb $1,%%cl\n\t"
  63         "je 1f\n\t"
  64         "fs ; movsb\n"
  65         "1:\ttestb $2,%%cl\n\t"
  66         "je 2f\n\t"
  67         "fs ; movsw\n"
  68         "2:\tshrl $2,%%ecx\n\t"
  69         "rep ; fs ; movsl"
  70         ::"c" (n),"D" ((long) to),"S" ((long) from)
  71         :"cx","di","si");
  72 }
  73 
  74 /*
  75  * Someone who knows GNU asm better than I should double check the followig.
  76  * It seems to work, but I don't know if I'm doing something subtly wrong.
  77  * --- TYT, 11/24/91
  78  * [ nothing wrong here, Linus: I just changed the ax to be any reg ]
  79  */
  80 
  81 static inline unsigned long get_fs(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  82 {
  83         unsigned short _v;
  84         __asm__("mov %%fs,%0":"=r" (_v):);
  85         return _v;
  86 }
  87 
  88 static inline unsigned long get_ds(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  89 {
  90         unsigned short _v;
  91         __asm__("mov %%ds,%0":"=r" (_v):);
  92         return _v;
  93 }
  94 
  95 static inline void set_fs(unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
  96 {
  97         __asm__ __volatile__("mov %0,%%fs"::"r" ((unsigned short) val));
  98 }
  99 

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