This source file includes following definitions.
- get_fs_byte
- get_fs_byte
- get_fs_word
- get_fs_word
- get_fs_long
- get_fs_long
- get_fs_long
- get_fs_long
- put_fs_byte
- put_fs_byte
- put_fs_word
- put_fs_word
- put_fs_long
- put_fs_long
- put_fs_long
- put_fs_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_fs_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 static inline unsigned char get_fs_byte(const unsigned char * addr)
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)
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)
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)
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)
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)
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)
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)
69 {
70 __asm__ ("movb %0,%%fs:%1": :"iq" (val),"m" (*addr));
71 }
72
73 static inline void put_fs_byte(char val,unsigned char *addr)
74 {
75 __asm__ ("movb %0,%%fs:%1": :"iq" (val),"m" (*addr));
76 }
77
78 static inline void put_fs_word(short val,short * addr)
79 {
80 __asm__ ("movw %0,%%fs:%1": :"ir" (val),"m" (*addr));
81 }
82
83 static inline void put_fs_word(short val,unsigned short * addr)
84 {
85 __asm__ ("movw %0,%%fs:%1": :"ir" (val),"m" (*addr));
86 }
87
88 static inline void put_fs_long(unsigned long val,int * addr)
89 {
90 __asm__ ("movl %0,%%fs:%1": :"ir" (val),"m" (*addr));
91 }
92
93 static inline void put_fs_long(unsigned long val,unsigned int * addr)
94 {
95 __asm__ ("movl %0,%%fs:%1": :"ir" (val),"m" (*addr));
96 }
97
98 static inline void put_fs_long(unsigned long val,long * addr)
99 {
100 __asm__ ("movl %0,%%fs:%1": :"ir" (val),"m" (*addr));
101 }
102
103 static inline void put_fs_long(unsigned long val,unsigned long * addr)
104 {
105 __asm__ ("movl %0,%%fs:%1": :"ir" (val),"m" (*addr));
106 }
107
108 static inline void memcpy_tofs(void * to, const void * from, unsigned long n)
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 :
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)
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 :
140 :"c" (n),"D" ((long) to),"S" ((long) from)
141 :"cx","di","si");
142 }
143
144
145
146
147
148
149
150
151 static inline unsigned long get_fs(void)
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)
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)
166 {
167 __asm__ __volatile__("mov %w0,%%fs": :"r" (val));
168 }
169
170 #endif