| 1 | #ifndef __ASM_SYSTEM_H |
|---|
| 2 | #define __ASM_SYSTEM_H |
|---|
| 3 | |
|---|
| 4 | #include <linux/kernel.h> |
|---|
| 5 | #include <asm/segment.h> |
|---|
| 6 | #include <asm/cpufeature.h> |
|---|
| 7 | #include <linux/bitops.h> /* for LOCK_PREFIX */ |
|---|
| 8 | #include <asm/synch_bitops.h> |
|---|
| 9 | #include <asm/hypervisor.h> |
|---|
| 10 | |
|---|
| 11 | #ifdef __KERNEL__ |
|---|
| 12 | |
|---|
| 13 | struct task_struct; /* one of the stranger aspects of C forward declarations.. */ |
|---|
| 14 | extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next)); |
|---|
| 15 | |
|---|
| 16 | /* |
|---|
| 17 | * Saving eflags is important. It switches not only IOPL between tasks, |
|---|
| 18 | * it also protects other tasks from NT leaking through sysenter etc. |
|---|
| 19 | */ |
|---|
| 20 | #define switch_to(prev,next,last) do { \ |
|---|
| 21 | unsigned long esi,edi; \ |
|---|
| 22 | asm volatile("pushfl\n\t" /* Save flags */ \ |
|---|
| 23 | "pushl %%ebp\n\t" \ |
|---|
| 24 | "movl %%esp,%0\n\t" /* save ESP */ \ |
|---|
| 25 | "movl %5,%%esp\n\t" /* restore ESP */ \ |
|---|
| 26 | "movl $1f,%1\n\t" /* save EIP */ \ |
|---|
| 27 | "pushl %6\n\t" /* restore EIP */ \ |
|---|
| 28 | "jmp __switch_to\n" \ |
|---|
| 29 | "1:\t" \ |
|---|
| 30 | "popl %%ebp\n\t" \ |
|---|
| 31 | "popfl" \ |
|---|
| 32 | :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \ |
|---|
| 33 | "=a" (last),"=S" (esi),"=D" (edi) \ |
|---|
| 34 | :"m" (next->thread.esp),"m" (next->thread.eip), \ |
|---|
| 35 | "2" (prev), "d" (next)); \ |
|---|
| 36 | } while (0) |
|---|
| 37 | |
|---|
| 38 | #define _set_base(addr,base) do { unsigned long __pr; \ |
|---|
| 39 | __asm__ __volatile__ ("movw %%dx,%1\n\t" \ |
|---|
| 40 | "rorl $16,%%edx\n\t" \ |
|---|
| 41 | "movb %%dl,%2\n\t" \ |
|---|
| 42 | "movb %%dh,%3" \ |
|---|
| 43 | :"=&d" (__pr) \ |
|---|
| 44 | :"m" (*((addr)+2)), \ |
|---|
| 45 | "m" (*((addr)+4)), \ |
|---|
| 46 | "m" (*((addr)+7)), \ |
|---|
| 47 | "0" (base) \ |
|---|
| 48 | ); } while(0) |
|---|
| 49 | |
|---|
| 50 | #define _set_limit(addr,limit) do { unsigned long __lr; \ |
|---|
| 51 | __asm__ __volatile__ ("movw %%dx,%1\n\t" \ |
|---|
| 52 | "rorl $16,%%edx\n\t" \ |
|---|
| 53 | "movb %2,%%dh\n\t" \ |
|---|
| 54 | "andb $0xf0,%%dh\n\t" \ |
|---|
| 55 | "orb %%dh,%%dl\n\t" \ |
|---|
| 56 | "movb %%dl,%2" \ |
|---|
| 57 | :"=&d" (__lr) \ |
|---|
| 58 | :"m" (*(addr)), \ |
|---|
| 59 | "m" (*((addr)+6)), \ |
|---|
| 60 | "0" (limit) \ |
|---|
| 61 | ); } while(0) |
|---|
| 62 | |
|---|
| 63 | #define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) ) |
|---|
| 64 | #define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1) ) |
|---|
| 65 | |
|---|
| 66 | /* |
|---|
| 67 | * Load a segment. Fall back on loading the zero |
|---|
| 68 | * segment if something goes wrong.. |
|---|
| 69 | */ |
|---|
| 70 | #define loadsegment(seg,value) \ |
|---|
| 71 | asm volatile("\n" \ |
|---|
| 72 | "1:\t" \ |
|---|
| 73 | "mov %0,%%" #seg "\n" \ |
|---|
| 74 | "2:\n" \ |
|---|
| 75 | ".section .fixup,\"ax\"\n" \ |
|---|
| 76 | "3:\t" \ |
|---|
| 77 | "pushl $0\n\t" \ |
|---|
| 78 | "popl %%" #seg "\n\t" \ |
|---|
| 79 | "jmp 2b\n" \ |
|---|
| 80 | ".previous\n" \ |
|---|
| 81 | ".section __ex_table,\"a\"\n\t" \ |
|---|
| 82 | ".align 4\n\t" \ |
|---|
| 83 | ".long 1b,3b\n" \ |
|---|
| 84 | ".previous" \ |
|---|
| 85 | : :"rm" (value)) |
|---|
| 86 | |
|---|
| 87 | /* |
|---|
| 88 | * Save a segment register away |
|---|
| 89 | */ |
|---|
| 90 | #define savesegment(seg, value) \ |
|---|
| 91 | asm volatile("mov %%" #seg ",%0":"=rm" (value)) |
|---|
| 92 | |
|---|
| 93 | #define read_cr0() ({ \ |
|---|
| 94 | unsigned int __dummy; \ |
|---|
| 95 | __asm__ __volatile__( \ |
|---|
| 96 | "movl %%cr0,%0\n\t" \ |
|---|
| 97 | :"=r" (__dummy)); \ |
|---|
| 98 | __dummy; \ |
|---|
| 99 | }) |
|---|
| 100 | #define write_cr0(x) \ |
|---|
| 101 | __asm__ __volatile__("movl %0,%%cr0": :"r" (x)) |
|---|
| 102 | |
|---|
| 103 | #define read_cr2() (current_vcpu_info()->arch.cr2) |
|---|
| 104 | #define write_cr2(x) \ |
|---|
| 105 | __asm__ __volatile__("movl %0,%%cr2": :"r" (x)) |
|---|
| 106 | |
|---|
| 107 | #define read_cr3() ({ \ |
|---|
| 108 | unsigned int __dummy; \ |
|---|
| 109 | __asm__ ( \ |
|---|
| 110 | "movl %%cr3,%0\n\t" \ |
|---|
| 111 | :"=r" (__dummy)); \ |
|---|
| 112 | __dummy = xen_cr3_to_pfn(__dummy); \ |
|---|
| 113 | mfn_to_pfn(__dummy) << PAGE_SHIFT; \ |
|---|
| 114 | }) |
|---|
| 115 | #define write_cr3(x) ({ \ |
|---|
| 116 | unsigned int __dummy = pfn_to_mfn((x) >> PAGE_SHIFT); \ |
|---|
| 117 | __dummy = xen_pfn_to_cr3(__dummy); \ |
|---|
| 118 | __asm__ __volatile__("movl %0,%%cr3": :"r" (__dummy)); \ |
|---|
| 119 | }) |
|---|
| 120 | #define read_cr4() ({ \ |
|---|
| 121 | unsigned int __dummy; \ |
|---|
| 122 | __asm__( \ |
|---|
| 123 | "movl %%cr4,%0\n\t" \ |
|---|
| 124 | :"=r" (__dummy)); \ |
|---|
| 125 | __dummy; \ |
|---|
| 126 | }) |
|---|
| 127 | #define read_cr4_safe() ({ \ |
|---|
| 128 | unsigned int __dummy; \ |
|---|
| 129 | /* This could fault if %cr4 does not exist */ \ |
|---|
| 130 | __asm__("1: movl %%cr4, %0 \n" \ |
|---|
| 131 | "2: \n" \ |
|---|
| 132 | ".section __ex_table,\"a\" \n" \ |
|---|
| 133 | ".long 1b,2b \n" \ |
|---|
| 134 | ".previous \n" \ |
|---|
| 135 | : "=r" (__dummy): "0" (0)); \ |
|---|
| 136 | __dummy; \ |
|---|
| 137 | }) |
|---|
| 138 | |
|---|
| 139 | #define write_cr4(x) \ |
|---|
| 140 | __asm__ __volatile__("movl %0,%%cr4": :"r" (x)) |
|---|
| 141 | |
|---|
| 142 | /* |
|---|
| 143 | * Clear and set 'TS' bit respectively |
|---|
| 144 | */ |
|---|
| 145 | #define clts() (HYPERVISOR_fpu_taskswitch(0)) |
|---|
| 146 | #define stts() (HYPERVISOR_fpu_taskswitch(1)) |
|---|
| 147 | |
|---|
| 148 | #endif /* __KERNEL__ */ |
|---|
| 149 | |
|---|
| 150 | #define wbinvd() \ |
|---|
| 151 | __asm__ __volatile__ ("wbinvd": : :"memory") |
|---|
| 152 | |
|---|
| 153 | static inline unsigned long get_limit(unsigned long segment) |
|---|
| 154 | { |
|---|
| 155 | unsigned long __limit; |
|---|
| 156 | __asm__("lsll %1,%0" |
|---|
| 157 | :"=r" (__limit):"r" (segment)); |
|---|
| 158 | return __limit+1; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | #define nop() __asm__ __volatile__ ("nop") |
|---|
| 162 | |
|---|
| 163 | #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) |
|---|
| 164 | |
|---|
| 165 | #define tas(ptr) (xchg((ptr),1)) |
|---|
| 166 | |
|---|
| 167 | struct __xchg_dummy { unsigned long a[100]; }; |
|---|
| 168 | #define __xg(x) ((struct __xchg_dummy *)(x)) |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | #ifdef CONFIG_X86_CMPXCHG64 |
|---|
| 172 | |
|---|
| 173 | /* |
|---|
| 174 | * The semantics of XCHGCMP8B are a bit strange, this is why |
|---|
| 175 | * there is a loop and the loading of %%eax and %%edx has to |
|---|
| 176 | * be inside. This inlines well in most cases, the cached |
|---|
| 177 | * cost is around ~38 cycles. (in the future we might want |
|---|
| 178 | * to do an SIMD/3DNOW!/MMX/FPU 64-bit store here, but that |
|---|
| 179 | * might have an implicit FPU-save as a cost, so it's not |
|---|
| 180 | * clear which path to go.) |
|---|
| 181 | * |
|---|
| 182 | * cmpxchg8b must be used with the lock prefix here to allow |
|---|
| 183 | * the instruction to be executed atomically, see page 3-102 |
|---|
| 184 | * of the instruction set reference 24319102.pdf. We need |
|---|
| 185 | * the reader side to see the coherent 64bit value. |
|---|
| 186 | */ |
|---|
| 187 | static inline void __set_64bit (unsigned long long * ptr, |
|---|
| 188 | unsigned int low, unsigned int high) |
|---|
| 189 | { |
|---|
| 190 | __asm__ __volatile__ ( |
|---|
| 191 | "\n1:\t" |
|---|
| 192 | "movl (%0), %%eax\n\t" |
|---|
| 193 | "movl 4(%0), %%edx\n\t" |
|---|
| 194 | "lock cmpxchg8b (%0)\n\t" |
|---|
| 195 | "jnz 1b" |
|---|
| 196 | : /* no outputs */ |
|---|
| 197 | : "D"(ptr), |
|---|
| 198 | "b"(low), |
|---|
| 199 | "c"(high) |
|---|
| 200 | : "ax","dx","memory"); |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | static inline void __set_64bit_constant (unsigned long long *ptr, |
|---|
| 204 | unsigned long long value) |
|---|
| 205 | { |
|---|
| 206 | __set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL)); |
|---|
| 207 | } |
|---|
| 208 | #define ll_low(x) *(((unsigned int*)&(x))+0) |
|---|
| 209 | #define ll_high(x) *(((unsigned int*)&(x))+1) |
|---|
| 210 | |
|---|
| 211 | static inline void __set_64bit_var (unsigned long long *ptr, |
|---|
| 212 | unsigned long long value) |
|---|
| 213 | { |
|---|
| 214 | __set_64bit(ptr,ll_low(value), ll_high(value)); |
|---|
| 215 | } |
|---|
| 216 | |
|---|
| 217 | #define set_64bit(ptr,value) \ |
|---|
| 218 | (__builtin_constant_p(value) ? \ |
|---|
| 219 | __set_64bit_constant(ptr, value) : \ |
|---|
| 220 | __set_64bit_var(ptr, value) ) |
|---|
| 221 | |
|---|
| 222 | #define _set_64bit(ptr,value) \ |
|---|
| 223 | (__builtin_constant_p(value) ? \ |
|---|
| 224 | __set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : \ |
|---|
| 225 | __set_64bit(ptr, ll_low(value), ll_high(value)) ) |
|---|
| 226 | |
|---|
| 227 | #endif |
|---|
| 228 | |
|---|
| 229 | /* |
|---|
| 230 | * Note: no "lock" prefix even on SMP: xchg always implies lock anyway |
|---|
| 231 | * Note 2: xchg has side effect, so that attribute volatile is necessary, |
|---|
| 232 | * but generally the primitive is invalid, *ptr is output argument. --ANK |
|---|
| 233 | */ |
|---|
| 234 | static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) |
|---|
| 235 | { |
|---|
| 236 | switch (size) { |
|---|
| 237 | case 1: |
|---|
| 238 | __asm__ __volatile__("xchgb %b0,%1" |
|---|
| 239 | :"=q" (x) |
|---|
| 240 | :"m" (*__xg(ptr)), "0" (x) |
|---|
| 241 | :"memory"); |
|---|
| 242 | break; |
|---|
| 243 | case 2: |
|---|
| 244 | __asm__ __volatile__("xchgw %w0,%1" |
|---|
| 245 | :"=r" (x) |
|---|
| 246 | :"m" (*__xg(ptr)), "0" (x) |
|---|
| 247 | :"memory"); |
|---|
| 248 | break; |
|---|
| 249 | case 4: |
|---|
| 250 | __asm__ __volatile__("xchgl %0,%1" |
|---|
| 251 | :"=r" (x) |
|---|
| 252 | :"m" (*__xg(ptr)), "0" (x) |
|---|
| 253 | :"memory"); |
|---|
| 254 | break; |
|---|
| 255 | } |
|---|
| 256 | return x; |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | /* |
|---|
| 260 | * Atomic compare and exchange. Compare OLD with MEM, if identical, |
|---|
| 261 | * store NEW in MEM. Return the initial value in MEM. Success is |
|---|
| 262 | * indicated by comparing RETURN with OLD. |
|---|
| 263 | */ |
|---|
| 264 | |
|---|
| 265 | #ifdef CONFIG_X86_CMPXCHG |
|---|
| 266 | #define __HAVE_ARCH_CMPXCHG 1 |
|---|
| 267 | #define cmpxchg(ptr,o,n)\ |
|---|
| 268 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ |
|---|
| 269 | (unsigned long)(n),sizeof(*(ptr)))) |
|---|
| 270 | #endif |
|---|
| 271 | |
|---|
| 272 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, |
|---|
| 273 | unsigned long new, int size) |
|---|
| 274 | { |
|---|
| 275 | unsigned long prev; |
|---|
| 276 | switch (size) { |
|---|
| 277 | case 1: |
|---|
| 278 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" |
|---|
| 279 | : "=a"(prev) |
|---|
| 280 | : "q"(new), "m"(*__xg(ptr)), "0"(old) |
|---|
| 281 | : "memory"); |
|---|
| 282 | return prev; |
|---|
| 283 | case 2: |
|---|
| 284 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" |
|---|
| 285 | : "=a"(prev) |
|---|
| 286 | : "r"(new), "m"(*__xg(ptr)), "0"(old) |
|---|
| 287 | : "memory"); |
|---|
| 288 | return prev; |
|---|
| 289 | case 4: |
|---|
| 290 | __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2" |
|---|
| 291 | : "=a"(prev) |
|---|
| 292 | : "r"(new), "m"(*__xg(ptr)), "0"(old) |
|---|
| 293 | : "memory"); |
|---|
| 294 | return prev; |
|---|
| 295 | } |
|---|
| 296 | return old; |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | #ifndef CONFIG_X86_CMPXCHG |
|---|
| 300 | /* |
|---|
| 301 | * Building a kernel capable running on 80386. It may be necessary to |
|---|
| 302 | * simulate the cmpxchg on the 80386 CPU. For that purpose we define |
|---|
| 303 | * a function for each of the sizes we support. |
|---|
| 304 | */ |
|---|
| 305 | |
|---|
| 306 | extern unsigned long cmpxchg_386_u8(volatile void *, u8, u8); |
|---|
| 307 | extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16); |
|---|
| 308 | extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32); |
|---|
| 309 | |
|---|
| 310 | static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old, |
|---|
| 311 | unsigned long new, int size) |
|---|
| 312 | { |
|---|
| 313 | switch (size) { |
|---|
| 314 | case 1: |
|---|
| 315 | return cmpxchg_386_u8(ptr, old, new); |
|---|
| 316 | case 2: |
|---|
| 317 | return cmpxchg_386_u16(ptr, old, new); |
|---|
| 318 | case 4: |
|---|
| 319 | return cmpxchg_386_u32(ptr, old, new); |
|---|
| 320 | } |
|---|
| 321 | return old; |
|---|
| 322 | } |
|---|
| 323 | |
|---|
| 324 | #define cmpxchg(ptr,o,n) \ |
|---|
| 325 | ({ \ |
|---|
| 326 | __typeof__(*(ptr)) __ret; \ |
|---|
| 327 | if (likely(boot_cpu_data.x86 > 3)) \ |
|---|
| 328 | __ret = __cmpxchg((ptr), (unsigned long)(o), \ |
|---|
| 329 | (unsigned long)(n), sizeof(*(ptr))); \ |
|---|
| 330 | else \ |
|---|
| 331 | __ret = cmpxchg_386((ptr), (unsigned long)(o), \ |
|---|
| 332 | (unsigned long)(n), sizeof(*(ptr))); \ |
|---|
| 333 | __ret; \ |
|---|
| 334 | }) |
|---|
| 335 | #endif |
|---|
| 336 | |
|---|
| 337 | #ifdef CONFIG_X86_CMPXCHG64 |
|---|
| 338 | |
|---|
| 339 | static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long long old, |
|---|
| 340 | unsigned long long new) |
|---|
| 341 | { |
|---|
| 342 | unsigned long long prev; |
|---|
| 343 | __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3" |
|---|
| 344 | : "=A"(prev) |
|---|
| 345 | : "b"((unsigned long)new), |
|---|
| 346 | "c"((unsigned long)(new >> 32)), |
|---|
| 347 | "m"(*__xg(ptr)), |
|---|
| 348 | "0"(old) |
|---|
| 349 | : "memory"); |
|---|
| 350 | return prev; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | #define cmpxchg64(ptr,o,n)\ |
|---|
| 354 | ((__typeof__(*(ptr)))__cmpxchg64((ptr),(unsigned long long)(o),\ |
|---|
| 355 | (unsigned long long)(n))) |
|---|
| 356 | |
|---|
| 357 | #endif |
|---|
| 358 | |
|---|
| 359 | /* |
|---|
| 360 | * Force strict CPU ordering. |
|---|
| 361 | * And yes, this is required on UP too when we're talking |
|---|
| 362 | * to devices. |
|---|
| 363 | * |
|---|
| 364 | * For now, "wmb()" doesn't actually do anything, as all |
|---|
| 365 | * Intel CPU's follow what Intel calls a *Processor Order*, |
|---|
| 366 | * in which all writes are seen in the program order even |
|---|
| 367 | * outside the CPU. |
|---|
| 368 | * |
|---|
| 369 | * I expect future Intel CPU's to have a weaker ordering, |
|---|
| 370 | * but I'd also expect them to finally get their act together |
|---|
| 371 | * and add some real memory barriers if so. |
|---|
| 372 | * |
|---|
| 373 | * Some non intel clones support out of order store. wmb() ceases to be a |
|---|
| 374 | * nop for these. |
|---|
| 375 | */ |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | /* |
|---|
| 379 | * Actually only lfence would be needed for mb() because all stores done |
|---|
| 380 | * by the kernel should be already ordered. But keep a full barrier for now. |
|---|
| 381 | */ |
|---|
| 382 | |
|---|
| 383 | #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) |
|---|
| 384 | #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) |
|---|
| 385 | |
|---|
| 386 | /** |
|---|
| 387 | * read_barrier_depends - Flush all pending reads that subsequents reads |
|---|
| 388 | * depend on. |
|---|
| 389 | * |
|---|
| 390 | * No data-dependent reads from memory-like regions are ever reordered |
|---|
| 391 | * over this barrier. All reads preceding this primitive are guaranteed |
|---|
| 392 | * to access memory (but not necessarily other CPUs' caches) before any |
|---|
| 393 | * reads following this primitive that depend on the data return by |
|---|
| 394 | * any of the preceding reads. This primitive is much lighter weight than |
|---|
| 395 | * rmb() on most CPUs, and is never heavier weight than is |
|---|
| 396 | * rmb(). |
|---|
| 397 | * |
|---|
| 398 | * These ordering constraints are respected by both the local CPU |
|---|
| 399 | * and the compiler. |
|---|
| 400 | * |
|---|
| 401 | * Ordering is not guaranteed by anything other than these primitives, |
|---|
| 402 | * not even by data dependencies. See the documentation for |
|---|
| 403 | * memory_barrier() for examples and URLs to more information. |
|---|
| 404 | * |
|---|
| 405 | * For example, the following code would force ordering (the initial |
|---|
| 406 | * value of "a" is zero, "b" is one, and "p" is "&a"): |
|---|
| 407 | * |
|---|
| 408 | * <programlisting> |
|---|
| 409 | * CPU 0 CPU 1 |
|---|
| 410 | * |
|---|
| 411 | * b = 2; |
|---|
| 412 | * memory_barrier(); |
|---|
| 413 | * p = &b; q = p; |
|---|
| 414 | * read_barrier_depends(); |
|---|
| 415 | * d = *q; |
|---|
| 416 | * </programlisting> |
|---|
| 417 | * |
|---|
| 418 | * because the read of "*q" depends on the read of "p" and these |
|---|
| 419 | * two reads are separated by a read_barrier_depends(). However, |
|---|
| 420 | * the following code, with the same initial values for "a" and "b": |
|---|
| 421 | * |
|---|
| 422 | * <programlisting> |
|---|
| 423 | * CPU 0 CPU 1 |
|---|
| 424 | * |
|---|
| 425 | * a = 2; |
|---|
| 426 | * memory_barrier(); |
|---|
| 427 | * b = 3; y = b; |
|---|
| 428 | * read_barrier_depends(); |
|---|
| 429 | * x = a; |
|---|
| 430 | * </programlisting> |
|---|
| 431 | * |
|---|
| 432 | * does not enforce ordering, since there is no data dependency between |
|---|
| 433 | * the read of "a" and the read of "b". Therefore, on some CPUs, such |
|---|
| 434 | * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() |
|---|
| 435 | * in cases like this where there are no data dependencies. |
|---|
| 436 | **/ |
|---|
| 437 | |
|---|
| 438 | #define read_barrier_depends() do { } while(0) |
|---|
| 439 | |
|---|
| 440 | #ifdef CONFIG_X86_OOSTORE |
|---|
| 441 | /* Actually there are no OOO store capable CPUs for now that do SSE, |
|---|
| 442 | but make it already an possibility. */ |
|---|
| 443 | #define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) |
|---|
| 444 | #else |
|---|
| 445 | #define wmb() __asm__ __volatile__ ("": : :"memory") |
|---|
| 446 | #endif |
|---|
| 447 | |
|---|
| 448 | #ifdef CONFIG_SMP |
|---|
| 449 | #define smp_mb() mb() |
|---|
| 450 | #define smp_rmb() rmb() |
|---|
| 451 | #define smp_wmb() wmb() |
|---|
| 452 | #define smp_read_barrier_depends() read_barrier_depends() |
|---|
| 453 | #define set_mb(var, value) do { (void) xchg(&var, value); } while (0) |
|---|
| 454 | #else |
|---|
| 455 | #define smp_mb() barrier() |
|---|
| 456 | #define smp_rmb() barrier() |
|---|
| 457 | #define smp_wmb() barrier() |
|---|
| 458 | #define smp_read_barrier_depends() do { } while(0) |
|---|
| 459 | #define set_mb(var, value) do { var = value; barrier(); } while (0) |
|---|
| 460 | #endif |
|---|
| 461 | |
|---|
| 462 | #include <linux/irqflags.h> |
|---|
| 463 | |
|---|
| 464 | /* |
|---|
| 465 | * disable hlt during certain critical i/o operations |
|---|
| 466 | */ |
|---|
| 467 | #define HAVE_DISABLE_HLT |
|---|
| 468 | void disable_hlt(void); |
|---|
| 469 | void enable_hlt(void); |
|---|
| 470 | |
|---|
| 471 | extern int es7000_plat; |
|---|
| 472 | void cpu_idle_wait(void); |
|---|
| 473 | |
|---|
| 474 | /* |
|---|
| 475 | * On SMP systems, when the scheduler does migration-cost autodetection, |
|---|
| 476 | * it needs a way to flush as much of the CPU's caches as possible: |
|---|
| 477 | */ |
|---|
| 478 | static inline void sched_cacheflush(void) |
|---|
| 479 | { |
|---|
| 480 | wbinvd(); |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | extern unsigned long arch_align_stack(unsigned long sp); |
|---|
| 484 | extern void free_init_pages(char *what, unsigned long begin, unsigned long end); |
|---|
| 485 | |
|---|
| 486 | void default_idle(void); |
|---|
| 487 | |
|---|
| 488 | #endif |
|---|