root/include/asm/segment.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_user_byte
  2. get_user_word
  3. get_user_long
  4. put_user_byte
  5. put_user_word
  6. put_user_long
  7. memcpy_tofs
  8. memcpy_fromfs
  9. get_fs
  10. get_ds
  11. set_fs

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

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