xen-vtx-unstable

annotate linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/system.h @ 4684:a71203a12503

bitkeeper revision 1.1159.258.107 (4270fc89Gyl1f0UFludQff4kq09XvQ)

reboot.c, init.c, hypervisor.h, evtchn.h, tlbflush.h, pgtable-2level.h:
sync w/ unstable.
system.h:
Fix typo.
pgtable.h, fixup.c, irq.c, direct.c, timer_tsc.c, pci-dma.c, init.c, fault.c:
Cleanup whitespace.
page.h:
Turn __pte and __pgd into #define's like the original definitions.
Add casts to unsigned long for phys_to_machine_mapping and
machine_to_phys_mapping.
fixmap.h, Makefile:
gnttab is not used in 2.0.
.del-gnttab.c~4461d10e936c37ab:
Delete: linux-2.6.11-xen-sparse/arch/xen/kernel/gnttab.c
.del-gnttab.h~974eaf5d22418ecd:
Delete: linux-2.6.11-xen-sparse/include/asm-xen/gnttab.h
setup.c:
Add panic notification handler.
Change phys_to_machine_mapping from unsigned long * to unsigned int *.
Whitespace cleanups.
page.h:
Change phys_to_machine_mapping from unsigned long * to unsigned int *.
process.c:
UTSNAME -> system_utsname.release as in plain Linux.
Disable preemption before reading smp_processor_id.
head.S:
sync w/ unstable for maintenance -- backport SMP-guest support bits.
Break __xen_guest definition up in several lines.
ldt.c, desc.h, common.c:
Move queue flush into load_LDT().
common.c:
g/c unused code.
Kconfig:
Fix whitespace for microcode option.
author cl349@firebug.cl.cam.ac.uk
date Thu Apr 28 15:08:57 2005 +0000 (2005-04-28)
parents cff0d3baf599
children c9edf0896f07
rev   line source
cl349@4087 1 #ifndef __ASM_SYSTEM_H
cl349@4087 2 #define __ASM_SYSTEM_H
cl349@4087 3
cl349@4087 4 #include <linux/config.h>
cl349@4087 5 #include <linux/kernel.h>
cl349@4087 6 #include <linux/bitops.h>
cl349@4087 7 #include <asm/synch_bitops.h>
cl349@4087 8 #include <asm/segment.h>
cl349@4087 9 #include <asm/cpufeature.h>
cl349@4087 10 #include <asm-xen/hypervisor.h>
cl349@4087 11 #include <asm-xen/evtchn.h>
cl349@4087 12
cl349@4087 13 #ifdef __KERNEL__
cl349@4087 14
cl349@4087 15 struct task_struct; /* one of the stranger aspects of C forward declarations.. */
cl349@4087 16 extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
cl349@4087 17
cl349@4087 18 #define switch_to(prev,next,last) do { \
cl349@4087 19 unsigned long esi,edi; \
cl349@4087 20 asm volatile("pushfl\n\t" \
cl349@4087 21 "pushl %%ebp\n\t" \
cl349@4087 22 "movl %%esp,%0\n\t" /* save ESP */ \
cl349@4087 23 "movl %5,%%esp\n\t" /* restore ESP */ \
cl349@4087 24 "movl $1f,%1\n\t" /* save EIP */ \
cl349@4087 25 "pushl %6\n\t" /* restore EIP */ \
cl349@4087 26 "jmp __switch_to\n" \
cl349@4087 27 "1:\t" \
cl349@4087 28 "popl %%ebp\n\t" \
cl349@4087 29 "popfl" \
cl349@4087 30 :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \
cl349@4087 31 "=a" (last),"=S" (esi),"=D" (edi) \
cl349@4087 32 :"m" (next->thread.esp),"m" (next->thread.eip), \
cl349@4087 33 "2" (prev), "d" (next)); \
cl349@4087 34 } while (0)
cl349@4087 35
cl349@4087 36 #define _set_base(addr,base) do { unsigned long __pr; \
cl349@4087 37 __asm__ __volatile__ ("movw %%dx,%1\n\t" \
cl349@4087 38 "rorl $16,%%edx\n\t" \
cl349@4087 39 "movb %%dl,%2\n\t" \
cl349@4087 40 "movb %%dh,%3" \
cl349@4087 41 :"=&d" (__pr) \
cl349@4087 42 :"m" (*((addr)+2)), \
cl349@4087 43 "m" (*((addr)+4)), \
cl349@4087 44 "m" (*((addr)+7)), \
cl349@4087 45 "0" (base) \
cl349@4087 46 ); } while(0)
cl349@4087 47
cl349@4087 48 #define _set_limit(addr,limit) do { unsigned long __lr; \
cl349@4087 49 __asm__ __volatile__ ("movw %%dx,%1\n\t" \
cl349@4087 50 "rorl $16,%%edx\n\t" \
cl349@4087 51 "movb %2,%%dh\n\t" \
cl349@4087 52 "andb $0xf0,%%dh\n\t" \
cl349@4087 53 "orb %%dh,%%dl\n\t" \
cl349@4087 54 "movb %%dl,%2" \
cl349@4087 55 :"=&d" (__lr) \
cl349@4087 56 :"m" (*(addr)), \
cl349@4087 57 "m" (*((addr)+6)), \
cl349@4087 58 "0" (limit) \
cl349@4087 59 ); } while(0)
cl349@4087 60
cl349@4087 61 #define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) )
cl349@4087 62 #define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1)>>12 )
cl349@4087 63
cl349@4087 64 static inline unsigned long _get_base(char * addr)
cl349@4087 65 {
cl349@4087 66 unsigned long __base;
cl349@4087 67 __asm__("movb %3,%%dh\n\t"
cl349@4087 68 "movb %2,%%dl\n\t"
cl349@4087 69 "shll $16,%%edx\n\t"
cl349@4087 70 "movw %1,%%dx"
cl349@4087 71 :"=&d" (__base)
cl349@4087 72 :"m" (*((addr)+2)),
cl349@4087 73 "m" (*((addr)+4)),
cl349@4087 74 "m" (*((addr)+7)));
cl349@4087 75 return __base;
cl349@4087 76 }
cl349@4087 77
cl349@4087 78 #define get_base(ldt) _get_base( ((char *)&(ldt)) )
cl349@4087 79
cl349@4087 80 /*
cl349@4087 81 * Load a segment. Fall back on loading the zero
cl349@4087 82 * segment if something goes wrong..
cl349@4087 83 */
cl349@4087 84 #define loadsegment(seg,value) \
cl349@4087 85 asm volatile("\n" \
cl349@4087 86 "1:\t" \
cl349@4087 87 "movl %0,%%" #seg "\n" \
cl349@4087 88 "2:\n" \
cl349@4087 89 ".section .fixup,\"ax\"\n" \
cl349@4087 90 "3:\t" \
cl349@4087 91 "pushl $0\n\t" \
cl349@4087 92 "popl %%" #seg "\n\t" \
cl349@4087 93 "jmp 2b\n" \
cl349@4087 94 ".previous\n" \
cl349@4087 95 ".section __ex_table,\"a\"\n\t" \
cl349@4087 96 ".align 4\n\t" \
cl349@4087 97 ".long 1b,3b\n" \
cl349@4087 98 ".previous" \
cl349@4087 99 : :"m" (*(unsigned int *)&(value)))
cl349@4087 100
cl349@4087 101 /*
cl349@4087 102 * Save a segment register away
cl349@4087 103 */
cl349@4087 104 #define savesegment(seg, value) \
cl349@4087 105 asm volatile("movl %%" #seg ",%0":"=m" (*(int *)&(value)))
cl349@4087 106
cl349@4087 107 /*
cl349@4087 108 * Clear and set 'TS' bit respectively
cl349@4087 109 */
cl349@4087 110 /* NB. 'clts' is done for us by Xen during virtual trap. */
cl349@4087 111 #define clts() ((void)0)
cl349@4087 112 #define read_cr0() \
cl349@4087 113 BUG();
cl349@4087 114 #define write_cr0(x) \
cl349@4087 115 BUG();
cl349@4087 116
cl349@4087 117 #define read_cr4() \
cl349@4087 118 BUG();
cl349@4087 119 #define write_cr4(x) \
cl349@4087 120 BUG();
cl349@4087 121 #define stts() (HYPERVISOR_fpu_taskswitch())
cl349@4087 122
cl349@4087 123 #endif /* __KERNEL__ */
cl349@4087 124
cl349@4087 125 static inline void wbinvd(void)
cl349@4087 126 {
cl349@4087 127 mmu_update_t u;
cl349@4087 128 u.ptr = MMU_EXTENDED_COMMAND;
cl349@4087 129 u.val = MMUEXT_FLUSH_CACHE;
cl349@4087 130 (void)HYPERVISOR_mmu_update(&u, 1, NULL);
cl349@4087 131 }
cl349@4087 132
cl349@4087 133 static inline unsigned long get_limit(unsigned long segment)
cl349@4087 134 {
cl349@4087 135 unsigned long __limit;
cl349@4087 136 __asm__("lsll %1,%0"
cl349@4087 137 :"=r" (__limit):"r" (segment));
cl349@4087 138 return __limit+1;
cl349@4087 139 }
cl349@4087 140
cl349@4087 141 #define nop() __asm__ __volatile__ ("nop")
cl349@4087 142
cl349@4087 143 #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
cl349@4087 144
cl349@4087 145 #define tas(ptr) (xchg((ptr),1))
cl349@4087 146
cl349@4087 147 struct __xchg_dummy { unsigned long a[100]; };
cl349@4087 148 #define __xg(x) ((struct __xchg_dummy *)(x))
cl349@4087 149
cl349@4087 150
cl349@4087 151 /*
cl349@4087 152 * The semantics of XCHGCMP8B are a bit strange, this is why
cl349@4087 153 * there is a loop and the loading of %%eax and %%edx has to
cl349@4087 154 * be inside. This inlines well in most cases, the cached
cl349@4087 155 * cost is around ~38 cycles. (in the future we might want
cl349@4087 156 * to do an SIMD/3DNOW!/MMX/FPU 64-bit store here, but that
cl349@4087 157 * might have an implicit FPU-save as a cost, so it's not
cl349@4087 158 * clear which path to go.)
cl349@4087 159 *
cl349@4087 160 * cmpxchg8b must be used with the lock prefix here to allow
cl349@4087 161 * the instruction to be executed atomically, see page 3-102
cl349@4087 162 * of the instruction set reference 24319102.pdf. We need
cl349@4087 163 * the reader side to see the coherent 64bit value.
cl349@4087 164 */
cl349@4087 165 static inline void __set_64bit (unsigned long long * ptr,
cl349@4087 166 unsigned int low, unsigned int high)
cl349@4087 167 {
cl349@4087 168 __asm__ __volatile__ (
cl349@4087 169 "\n1:\t"
cl349@4087 170 "movl (%0), %%eax\n\t"
cl349@4087 171 "movl 4(%0), %%edx\n\t"
cl349@4087 172 "lock cmpxchg8b (%0)\n\t"
cl349@4087 173 "jnz 1b"
cl349@4087 174 : /* no outputs */
cl349@4087 175 : "D"(ptr),
cl349@4087 176 "b"(low),
cl349@4087 177 "c"(high)
cl349@4087 178 : "ax","dx","memory");
cl349@4087 179 }
cl349@4087 180
cl349@4087 181 static inline void __set_64bit_constant (unsigned long long *ptr,
cl349@4087 182 unsigned long long value)
cl349@4087 183 {
cl349@4087 184 __set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL));
cl349@4087 185 }
cl349@4087 186 #define ll_low(x) *(((unsigned int*)&(x))+0)
cl349@4087 187 #define ll_high(x) *(((unsigned int*)&(x))+1)
cl349@4087 188
cl349@4087 189 static inline void __set_64bit_var (unsigned long long *ptr,
cl349@4087 190 unsigned long long value)
cl349@4087 191 {
cl349@4087 192 __set_64bit(ptr,ll_low(value), ll_high(value));
cl349@4087 193 }
cl349@4087 194
cl349@4087 195 #define set_64bit(ptr,value) \
cl349@4087 196 (__builtin_constant_p(value) ? \
cl349@4087 197 __set_64bit_constant(ptr, value) : \
cl349@4087 198 __set_64bit_var(ptr, value) )
cl349@4087 199
cl349@4087 200 #define _set_64bit(ptr,value) \
cl349@4087 201 (__builtin_constant_p(value) ? \
cl349@4087 202 __set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : \
cl349@4087 203 __set_64bit(ptr, ll_low(value), ll_high(value)) )
cl349@4087 204
cl349@4087 205 /*
cl349@4087 206 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway
cl349@4087 207 * Note 2: xchg has side effect, so that attribute volatile is necessary,
cl349@4087 208 * but generally the primitive is invalid, *ptr is output argument. --ANK
cl349@4087 209 */
cl349@4087 210 static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
cl349@4087 211 {
cl349@4087 212 switch (size) {
cl349@4087 213 case 1:
cl349@4087 214 __asm__ __volatile__("xchgb %b0,%1"
cl349@4087 215 :"=q" (x)
cl349@4087 216 :"m" (*__xg(ptr)), "0" (x)
cl349@4087 217 :"memory");
cl349@4087 218 break;
cl349@4087 219 case 2:
cl349@4087 220 __asm__ __volatile__("xchgw %w0,%1"
cl349@4087 221 :"=r" (x)
cl349@4087 222 :"m" (*__xg(ptr)), "0" (x)
cl349@4087 223 :"memory");
cl349@4087 224 break;
cl349@4087 225 case 4:
cl349@4087 226 __asm__ __volatile__("xchgl %0,%1"
cl349@4087 227 :"=r" (x)
cl349@4087 228 :"m" (*__xg(ptr)), "0" (x)
cl349@4087 229 :"memory");
cl349@4087 230 break;
cl349@4087 231 }
cl349@4087 232 return x;
cl349@4087 233 }
cl349@4087 234
cl349@4087 235 /*
cl349@4087 236 * Atomic compare and exchange. Compare OLD with MEM, if identical,
cl349@4087 237 * store NEW in MEM. Return the initial value in MEM. Success is
cl349@4087 238 * indicated by comparing RETURN with OLD.
cl349@4087 239 */
cl349@4087 240
cl349@4087 241 #ifdef CONFIG_X86_CMPXCHG
cl349@4087 242 #define __HAVE_ARCH_CMPXCHG 1
cl349@4087 243 #endif
cl349@4087 244
cl349@4087 245 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
cl349@4087 246 unsigned long new, int size)
cl349@4087 247 {
cl349@4087 248 unsigned long prev;
cl349@4087 249 switch (size) {
cl349@4087 250 case 1:
cl349@4087 251 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
cl349@4087 252 : "=a"(prev)
cl349@4087 253 : "q"(new), "m"(*__xg(ptr)), "0"(old)
cl349@4087 254 : "memory");
cl349@4087 255 return prev;
cl349@4087 256 case 2:
cl349@4087 257 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
cl349@4087 258 : "=a"(prev)
cl349@4087 259 : "q"(new), "m"(*__xg(ptr)), "0"(old)
cl349@4087 260 : "memory");
cl349@4087 261 return prev;
cl349@4087 262 case 4:
cl349@4087 263 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
cl349@4087 264 : "=a"(prev)
cl349@4087 265 : "q"(new), "m"(*__xg(ptr)), "0"(old)
cl349@4087 266 : "memory");
cl349@4087 267 return prev;
cl349@4087 268 }
cl349@4087 269 return old;
cl349@4087 270 }
cl349@4087 271
cl349@4087 272 #define cmpxchg(ptr,o,n)\
cl349@4087 273 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
cl349@4087 274 (unsigned long)(n),sizeof(*(ptr))))
cl349@4087 275
cl349@4087 276 #ifdef __KERNEL__
cl349@4087 277 struct alt_instr {
cl349@4087 278 __u8 *instr; /* original instruction */
cl349@4087 279 __u8 *replacement;
cl349@4087 280 __u8 cpuid; /* cpuid bit set for replacement */
cl349@4087 281 __u8 instrlen; /* length of original instruction */
cl349@4087 282 __u8 replacementlen; /* length of new instruction, <= instrlen */
cl349@4087 283 __u8 pad;
cl349@4087 284 };
cl349@4087 285 #endif
cl349@4087 286
cl349@4087 287 /*
cl349@4087 288 * Alternative instructions for different CPU types or capabilities.
cl349@4087 289 *
cl349@4087 290 * This allows to use optimized instructions even on generic binary
cl349@4087 291 * kernels.
cl349@4087 292 *
cl349@4087 293 * length of oldinstr must be longer or equal the length of newinstr
cl349@4087 294 * It can be padded with nops as needed.
cl349@4087 295 *
cl349@4087 296 * For non barrier like inlines please define new variants
cl349@4087 297 * without volatile and memory clobber.
cl349@4087 298 */
cl349@4087 299 #define alternative(oldinstr, newinstr, feature) \
cl349@4087 300 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
cl349@4087 301 ".section .altinstructions,\"a\"\n" \
cl349@4087 302 " .align 4\n" \
cl349@4087 303 " .long 661b\n" /* label */ \
cl349@4087 304 " .long 663f\n" /* new instruction */ \
cl349@4087 305 " .byte %c0\n" /* feature bit */ \
cl349@4087 306 " .byte 662b-661b\n" /* sourcelen */ \
cl349@4087 307 " .byte 664f-663f\n" /* replacementlen */ \
cl349@4087 308 ".previous\n" \
cl349@4087 309 ".section .altinstr_replacement,\"ax\"\n" \
cl349@4087 310 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
cl349@4087 311 ".previous" :: "i" (feature) : "memory")
cl349@4087 312
cl349@4087 313 /*
cl349@4087 314 * Alternative inline assembly with input.
cl349@4087 315 *
cl349@4087 316 * Pecularities:
cl349@4087 317 * No memory clobber here.
cl349@4087 318 * Argument numbers start with 1.
cl349@4087 319 * Best is to use constraints that are fixed size (like (%1) ... "r")
cl349@4087 320 * If you use variable sized constraints like "m" or "g" in the
cl349@4087 321 * replacement maake sure to pad to the worst case length.
cl349@4087 322 */
cl349@4087 323 #define alternative_input(oldinstr, newinstr, feature, input...) \
cl349@4087 324 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
cl349@4087 325 ".section .altinstructions,\"a\"\n" \
cl349@4087 326 " .align 4\n" \
cl349@4087 327 " .long 661b\n" /* label */ \
cl349@4087 328 " .long 663f\n" /* new instruction */ \
cl349@4087 329 " .byte %c0\n" /* feature bit */ \
cl349@4087 330 " .byte 662b-661b\n" /* sourcelen */ \
cl349@4087 331 " .byte 664f-663f\n" /* replacementlen */ \
cl349@4087 332 ".previous\n" \
cl349@4087 333 ".section .altinstr_replacement,\"ax\"\n" \
cl349@4087 334 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
cl349@4087 335 ".previous" :: "i" (feature), ##input)
cl349@4087 336
cl349@4087 337 /*
cl349@4087 338 * Force strict CPU ordering.
cl349@4087 339 * And yes, this is required on UP too when we're talking
cl349@4087 340 * to devices.
cl349@4087 341 *
cl349@4087 342 * For now, "wmb()" doesn't actually do anything, as all
cl349@4087 343 * Intel CPU's follow what Intel calls a *Processor Order*,
cl349@4087 344 * in which all writes are seen in the program order even
cl349@4087 345 * outside the CPU.
cl349@4087 346 *
cl349@4087 347 * I expect future Intel CPU's to have a weaker ordering,
cl349@4087 348 * but I'd also expect them to finally get their act together
cl349@4087 349 * and add some real memory barriers if so.
cl349@4087 350 *
cl349@4087 351 * Some non intel clones support out of order store. wmb() ceases to be a
cl349@4087 352 * nop for these.
cl349@4087 353 */
cl349@4087 354
cl349@4087 355
cl349@4087 356 /*
cl349@4087 357 * Actually only lfence would be needed for mb() because all stores done
cl349@4087 358 * by the kernel should be already ordered. But keep a full barrier for now.
cl349@4087 359 */
cl349@4087 360
cl349@4087 361 #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
cl349@4087 362 #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
cl349@4087 363
cl349@4087 364 /**
cl349@4087 365 * read_barrier_depends - Flush all pending reads that subsequents reads
cl349@4087 366 * depend on.
cl349@4087 367 *
cl349@4087 368 * No data-dependent reads from memory-like regions are ever reordered
cl349@4087 369 * over this barrier. All reads preceding this primitive are guaranteed
cl349@4087 370 * to access memory (but not necessarily other CPUs' caches) before any
cl349@4087 371 * reads following this primitive that depend on the data return by
cl349@4087 372 * any of the preceding reads. This primitive is much lighter weight than
cl349@4087 373 * rmb() on most CPUs, and is never heavier weight than is
cl349@4087 374 * rmb().
cl349@4087 375 *
cl349@4087 376 * These ordering constraints are respected by both the local CPU
cl349@4087 377 * and the compiler.
cl349@4087 378 *
cl349@4087 379 * Ordering is not guaranteed by anything other than these primitives,
cl349@4087 380 * not even by data dependencies. See the documentation for
cl349@4087 381 * memory_barrier() for examples and URLs to more information.
cl349@4087 382 *
cl349@4087 383 * For example, the following code would force ordering (the initial
cl349@4087 384 * value of "a" is zero, "b" is one, and "p" is "&a"):
cl349@4087 385 *
cl349@4087 386 * <programlisting>
cl349@4087 387 * CPU 0 CPU 1
cl349@4087 388 *
cl349@4087 389 * b = 2;
cl349@4087 390 * memory_barrier();
cl349@4087 391 * p = &b; q = p;
cl349@4087 392 * read_barrier_depends();
cl349@4087 393 * d = *q;
cl349@4087 394 * </programlisting>
cl349@4087 395 *
cl349@4087 396 * because the read of "*q" depends on the read of "p" and these
cl349@4087 397 * two reads are separated by a read_barrier_depends(). However,
cl349@4087 398 * the following code, with the same initial values for "a" and "b":
cl349@4087 399 *
cl349@4087 400 * <programlisting>
cl349@4087 401 * CPU 0 CPU 1
cl349@4087 402 *
cl349@4087 403 * a = 2;
cl349@4087 404 * memory_barrier();
cl349@4087 405 * b = 3; y = b;
cl349@4087 406 * read_barrier_depends();
cl349@4087 407 * x = a;
cl349@4087 408 * </programlisting>
cl349@4087 409 *
cl349@4087 410 * does not enforce ordering, since there is no data dependency between
cl349@4087 411 * the read of "a" and the read of "b". Therefore, on some CPUs, such
cl349@4087 412 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
cl349@4087 413 * in cases like thiswhere there are no data dependencies.
cl349@4087 414 **/
cl349@4087 415
cl349@4087 416 #define read_barrier_depends() do { } while(0)
cl349@4087 417
cl349@4087 418 #ifdef CONFIG_X86_OOSTORE
cl349@4087 419 /* Actually there are no OOO store capable CPUs for now that do SSE,
cl349@4087 420 but make it already an possibility. */
cl349@4087 421 #define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
cl349@4087 422 #else
cl349@4087 423 #define wmb() __asm__ __volatile__ ("": : :"memory")
cl349@4087 424 #endif
cl349@4087 425
cl349@4087 426 #ifdef CONFIG_SMP
cl349@4087 427 #define smp_mb() mb()
cl349@4087 428 #define smp_rmb() rmb()
cl349@4087 429 #define smp_wmb() wmb()
cl349@4087 430 #define smp_read_barrier_depends() read_barrier_depends()
cl349@4087 431 #define set_mb(var, value) do { xchg(&var, value); } while (0)
cl349@4087 432 #else
cl349@4087 433 #define smp_mb() barrier()
cl349@4087 434 #define smp_rmb() barrier()
cl349@4087 435 #define smp_wmb() barrier()
cl349@4087 436 #define smp_read_barrier_depends() do { } while(0)
cl349@4087 437 #define set_mb(var, value) do { var = value; barrier(); } while (0)
cl349@4087 438 #endif
cl349@4087 439
cl349@4087 440 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
cl349@4087 441
cl349@4087 442 /* interrupt control.. */
cl349@4087 443
cl349@4087 444 /*
cl349@4087 445 * The use of 'barrier' in the following reflects their use as local-lock
cl349@4087 446 * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
cl349@4684 447 * critical operations are executed. All critical operations must complete
cl349@4087 448 * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also
cl349@4087 449 * includes these barriers, for example.
cl349@4087 450 */
cl349@4087 451
cl349@4087 452 #define __cli() \
cl349@4087 453 do { \
cl349@4087 454 HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask = 1; \
cl349@4087 455 barrier(); \
cl349@4087 456 } while (0)
cl349@4087 457
cl349@4087 458 #define __sti() \
cl349@4087 459 do { \
cl349@4087 460 shared_info_t *_shared = HYPERVISOR_shared_info; \
cl349@4087 461 barrier(); \
cl349@4087 462 _shared->vcpu_data[0].evtchn_upcall_mask = 0; \
cl349@4087 463 barrier(); /* unmask then check (avoid races) */ \
cl349@4087 464 if ( unlikely(_shared->vcpu_data[0].evtchn_upcall_pending) ) \
cl349@4087 465 force_evtchn_callback(); \
cl349@4087 466 } while (0)
cl349@4087 467
cl349@4087 468 #define __save_flags(x) \
cl349@4087 469 do { \
cl349@4087 470 (x) = HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask; \
cl349@4087 471 } while (0)
cl349@4087 472
cl349@4087 473 #define __restore_flags(x) \
cl349@4087 474 do { \
cl349@4087 475 shared_info_t *_shared = HYPERVISOR_shared_info; \
cl349@4087 476 barrier(); \
cl349@4087 477 if ( (_shared->vcpu_data[0].evtchn_upcall_mask = (x)) == 0 ) { \
cl349@4087 478 barrier(); /* unmask then check (avoid races) */ \
cl349@4087 479 if ( unlikely(_shared->vcpu_data[0].evtchn_upcall_pending) ) \
cl349@4087 480 force_evtchn_callback(); \
cl349@4087 481 } \
cl349@4087 482 } while (0)
cl349@4087 483
cl349@4087 484 #define safe_halt() ((void)0)
cl349@4087 485
cl349@4087 486 #define __save_and_cli(x) \
cl349@4087 487 do { \
cl349@4087 488 (x) = HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask; \
cl349@4087 489 HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask = 1; \
cl349@4087 490 barrier(); \
cl349@4087 491 } while (0)
cl349@4087 492
cl349@4087 493 #define __save_and_sti(x) \
cl349@4087 494 do { \
cl349@4087 495 shared_info_t *_shared = HYPERVISOR_shared_info; \
cl349@4087 496 barrier(); \
cl349@4087 497 (x) = _shared->vcpu_data[0].evtchn_upcall_mask; \
cl349@4087 498 _shared->vcpu_data[0].evtchn_upcall_mask = 0; \
cl349@4087 499 barrier(); /* unmask then check (avoid races) */ \
cl349@4087 500 if ( unlikely(_shared->vcpu_data[0].evtchn_upcall_pending) ) \
cl349@4087 501 force_evtchn_callback(); \
cl349@4087 502 } while (0)
cl349@4087 503
cl349@4087 504 #define local_irq_save(x) __save_and_cli(x)
cl349@4087 505 #define local_irq_restore(x) __restore_flags(x)
cl349@4087 506 #define local_save_flags(x) __save_flags(x)
cl349@4087 507 #define local_irq_disable() __cli()
cl349@4087 508 #define local_irq_enable() __sti()
cl349@4087 509
cl349@4087 510 #define irqs_disabled() HYPERVISOR_shared_info->vcpu_data[0].evtchn_upcall_mask
cl349@4087 511
cl349@4087 512 /*
cl349@4087 513 * disable hlt during certain critical i/o operations
cl349@4087 514 */
cl349@4087 515 #define HAVE_DISABLE_HLT
cl349@4087 516 void disable_hlt(void);
cl349@4087 517 void enable_hlt(void);
cl349@4087 518
cl349@4087 519 extern int es7000_plat;
cl349@4087 520 void cpu_idle_wait(void);
cl349@4087 521
cl349@4087 522 #endif