Rev 356 | Rev 359 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 356 | Rev 358 | ||
---|---|---|---|
Line 136... | Line 136... | ||
136 | * value of EFLAGS. |
136 | * value of EFLAGS. |
137 | */ |
137 | */ |
138 | static inline pri_t cpu_priority_low(void) { |
138 | static inline pri_t cpu_priority_low(void) { |
139 | pri_t v; |
139 | pri_t v; |
140 | __asm__ volatile ( |
140 | __asm__ volatile ( |
141 | "pushf\n" |
141 | "pushf\n\t" |
142 | "popl %0\n" |
142 | "popl %0\n\t" |
143 | "sti\n" |
143 | "sti\n" |
144 | : "=r" (v) |
144 | : "=r" (v) |
145 | ); |
145 | ); |
146 | return v; |
146 | return v; |
147 | } |
147 | } |
Line 152... | Line 152... | ||
152 | * value of EFLAGS. |
152 | * value of EFLAGS. |
153 | */ |
153 | */ |
154 | static inline pri_t cpu_priority_high(void) { |
154 | static inline pri_t cpu_priority_high(void) { |
155 | pri_t v; |
155 | pri_t v; |
156 | __asm__ volatile ( |
156 | __asm__ volatile ( |
157 | "pushf\n" |
157 | "pushf\n\t" |
158 | "popl %0\n" |
158 | "popl %0\n\t" |
159 | "cli\n" |
159 | "cli\n" |
160 | : "=r" (v) |
160 | : "=r" (v) |
161 | ); |
161 | ); |
162 | return v; |
162 | return v; |
163 | } |
163 | } |
Line 166... | Line 166... | ||
166 | * |
166 | * |
167 | * Restore EFLAGS. |
167 | * Restore EFLAGS. |
168 | */ |
168 | */ |
169 | static inline void cpu_priority_restore(pri_t pri) { |
169 | static inline void cpu_priority_restore(pri_t pri) { |
170 | __asm__ volatile ( |
170 | __asm__ volatile ( |
171 | "pushl %0\n" |
171 | "pushl %0\n\t" |
172 | "popf\n" |
172 | "popf\n" |
173 | : : "r" (pri) |
173 | : : "r" (pri) |
174 | ); |
174 | ); |
175 | } |
175 | } |
176 | 176 | ||
Line 179... | Line 179... | ||
179 | * Return EFLAFS. |
179 | * Return EFLAFS. |
180 | */ |
180 | */ |
181 | static inline pri_t cpu_priority_read(void) { |
181 | static inline pri_t cpu_priority_read(void) { |
182 | pri_t v; |
182 | pri_t v; |
183 | __asm__ volatile ( |
183 | __asm__ volatile ( |
184 | "pushf\n" |
184 | "pushf\n\t" |
185 | "popl %0\n" |
185 | "popl %0\n" |
186 | : "=r" (v) |
186 | : "=r" (v) |
187 | ); |
187 | ); |
188 | return v; |
188 | return v; |
189 | } |
189 | } |
Line 210... | Line 210... | ||
210 | __asm__ volatile("rdtsc\n" : "=A" (v)); |
210 | __asm__ volatile("rdtsc\n" : "=A" (v)); |
211 | 211 | ||
212 | return v; |
212 | return v; |
213 | } |
213 | } |
214 | 214 | ||
- | 215 | /** Copy memory |
|
- | 216 | * |
|
- | 217 | * Copy a given number of bytes (3rd argument) |
|
- | 218 | * from the memory location defined by 2nd argument |
|
- | 219 | * to the memory location defined by 1st argument. |
|
- | 220 | * The memory areas cannot overlap. |
|
- | 221 | * |
|
- | 222 | * @param destination |
|
- | 223 | * @param source |
|
- | 224 | * @param number of bytes |
|
- | 225 | * @return destination |
|
- | 226 | */ |
|
- | 227 | static inline void * memcpy(void * dst, const void * src, size_t cnt) |
|
- | 228 | { |
|
- | 229 | __u32 d0, d1, d2; |
|
- | 230 | ||
- | 231 | __asm__ __volatile__( |
|
- | 232 | "rep movsl\n\t" |
|
- | 233 | "movl %4, %%ecx\n\t" |
|
- | 234 | "andl $3, %%ecx\n\t" |
|
- | 235 | "jz 1f\n\t" |
|
- | 236 | "rep movsb\n\t" |
|
- | 237 | "1:\n" |
|
- | 238 | : "=&c" (d0), "=&D" (d1), "=&S" (d2) |
|
- | 239 | : "0" (cnt / 4), "g" (cnt), "1" ((__u32) dst), "2" ((__u32) src) |
|
- | 240 | : "memory"); |
|
- | 241 | ||
- | 242 | return dst; |
|
- | 243 | } |
|
- | 244 | ||
215 | 245 | ||
216 | #endif |
246 | #endif |