This source file includes following definitions.
- get_user_byte
- get_user_word
- get_user_long
- put_user_byte
- put_user_word
- put_user_long
- memcpy_tofs
- memcpy_fromfs
- get_fs
- get_ds
- set_fs
1 #ifndef _ASM_SEGMENT_H
2 #define _ASM_SEGMENT_H
3
4 static inline unsigned char get_user_byte(const char * addr)
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)
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)
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)
35 {
36 __asm__ ("movb %0,%%fs:%1": :"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)
42 {
43 __asm__ ("movw %0,%%fs:%1": :"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)
49 {
50 __asm__ ("movl %0,%%fs:%1": :"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)
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 :
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)
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 :
87 :"c" (n),"D" ((long) to),"S" ((long) from)
88 :"cx","di","si");
89 }
90
91
92
93
94
95
96
97
98 static inline unsigned long get_fs(void)
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)
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)
113 {
114 __asm__ __volatile__("mov %w0,%%fs": :"r" (val));
115 }
116
117 #endif