📄 system.h
字号:
: "=r"(__r16), "=r"(__r17), "=r"(__r0) \ : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \ : "$1", "$22", "$23", "$24", "$25"); \ return __r0; \}__CALL_PAL_W1(cflush, unsigned long);__CALL_PAL_R0(rdmces, unsigned long);__CALL_PAL_R0(rdps, unsigned long);__CALL_PAL_R0(rdusp, unsigned long);__CALL_PAL_RW1(swpipl, unsigned long, unsigned long);__CALL_PAL_R0(whami, unsigned long);__CALL_PAL_W2(wrent, void*, unsigned long);__CALL_PAL_W1(wripir, unsigned long);__CALL_PAL_W1(wrkgp, unsigned long);__CALL_PAL_W1(wrmces, unsigned long);__CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long);__CALL_PAL_W1(wrusp, unsigned long);__CALL_PAL_W1(wrvptptr, unsigned long);#define IPL_MIN 0#define IPL_SW0 1#define IPL_SW1 2#define IPL_DEV0 3#define IPL_DEV1 4#define IPL_TIMER 5#define IPL_PERF 6#define IPL_POWERFAIL 6#define IPL_MCHECK 7#define IPL_MAX 7#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK#undef IPL_MIN#define IPL_MIN __min_iplextern int __min_ipl;#endif#define getipl() (rdps() & 7)#define setipl(ipl) ((void) swpipl(ipl))#define __cli() do { setipl(IPL_MAX); barrier(); } while(0)#define __sti() do { barrier(); setipl(IPL_MIN); } while(0)#define __save_flags(flags) ((flags) = rdps())#define __save_and_cli(flags) do { (flags) = swpipl(IPL_MAX); barrier(); } while(0)#define __restore_flags(flags) do { barrier(); setipl(flags); barrier(); } while(0)#define local_irq_save(flags) __save_and_cli(flags)#define local_irq_restore(flags) __restore_flags(flags)#define local_irq_disable() __cli()#define local_irq_enable() __sti()#ifdef CONFIG_SMPextern int global_irq_holder;#define save_and_cli(flags) (save_flags(flags), cli())extern void __global_cli(void);extern void __global_sti(void);extern unsigned long __global_save_flags(void);extern void __global_restore_flags(unsigned long flags);#define cli() __global_cli()#define sti() __global_sti()#define save_flags(flags) ((flags) = __global_save_flags())#define restore_flags(flags) __global_restore_flags(flags)#else /* CONFIG_SMP */#define cli() __cli()#define sti() __sti()#define save_flags(flags) __save_flags(flags)#define save_and_cli(flags) __save_and_cli(flags)#define restore_flags(flags) __restore_flags(flags)#endif /* CONFIG_SMP *//* * TB routines.. */#define __tbi(nr,arg,arg1...) \({ \ register unsigned long __r16 __asm__("$16") = (nr); \ register unsigned long __r17 __asm__("$17"); arg; \ __asm__ __volatile__( \ "call_pal %3 #__tbi" \ :"=r" (__r16),"=r" (__r17) \ :"0" (__r16),"i" (PAL_tbi) ,##arg1 \ :"$0", "$1", "$22", "$23", "$24", "$25"); \})#define tbi(x,y) __tbi(x,__r17=(y),"1" (__r17))#define tbisi(x) __tbi(1,__r17=(x),"1" (__r17))#define tbisd(x) __tbi(2,__r17=(x),"1" (__r17))#define tbis(x) __tbi(3,__r17=(x),"1" (__r17))#define tbiap() __tbi(-1, /* no second argument */)#define tbia() __tbi(-2, /* no second argument */)/* * Atomic exchange. * Since it can be used to implement critical sections * it must clobber "memory" (also for interrupts in UP). */extern __inline__ unsigned long__xchg_u32(volatile int *m, unsigned long val){ unsigned long dummy; __asm__ __volatile__( "1: ldl_l %0,%4\n" " bis $31,%3,%1\n" " stl_c %1,%2\n" " beq %1,2f\n"#ifdef CONFIG_SMP " mb\n"#endif ".subsection 2\n" "2: br 1b\n" ".previous" : "=&r" (val), "=&r" (dummy), "=m" (*m) : "rI" (val), "m" (*m) : "memory"); return val;}extern __inline__ unsigned long__xchg_u64(volatile long *m, unsigned long val){ unsigned long dummy; __asm__ __volatile__( "1: ldq_l %0,%4\n" " bis $31,%3,%1\n" " stq_c %1,%2\n" " beq %1,2f\n"#ifdef CONFIG_SMP " mb\n"#endif ".subsection 2\n" "2: br 1b\n" ".previous" : "=&r" (val), "=&r" (dummy), "=m" (*m) : "rI" (val), "m" (*m) : "memory"); return val;}/* This function doesn't exist, so you'll get a linker error if something tries to do an invalid xchg(). */extern void __xchg_called_with_bad_pointer(void);static __inline__ unsigned long__xchg(volatile void *ptr, unsigned long x, int size){ switch (size) { case 4: return __xchg_u32(ptr, x); case 8: return __xchg_u64(ptr, x); } __xchg_called_with_bad_pointer(); return x;}#define xchg(ptr,x) \ ({ \ __typeof__(*(ptr)) _x_ = (x); \ (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \ })#define tas(ptr) (xchg((ptr),1))/* * Atomic compare and exchange. Compare OLD with MEM, if identical, * store NEW in MEM. Return the initial value in MEM. Success is * indicated by comparing RETURN with OLD. * * The memory barrier should be placed in SMP only when we actually * make the change. If we don't change anything (so if the returned * prev is equal to old) then we aren't acquiring anything new and * we don't need any memory barrier as far I can tell. */#define __HAVE_ARCH_CMPXCHG 1extern __inline__ unsigned long__cmpxchg_u32(volatile int *m, int old, int new){ unsigned long prev, cmp; __asm__ __volatile__( "1: ldl_l %0,%5\n" " cmpeq %0,%3,%1\n" " beq %1,2f\n" " mov %4,%1\n" " stl_c %1,%2\n" " beq %1,3f\n"#ifdef CONFIG_SMP " mb\n"#endif "2:\n" ".subsection 2\n" "3: br 1b\n" ".previous" : "=&r"(prev), "=&r"(cmp), "=m"(*m) : "r"((long) old), "r"(new), "m"(*m) : "memory"); return prev;}extern __inline__ unsigned long__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new){ unsigned long prev, cmp; __asm__ __volatile__( "1: ldq_l %0,%5\n" " cmpeq %0,%3,%1\n" " beq %1,2f\n" " mov %4,%1\n" " stq_c %1,%2\n" " beq %1,3f\n"#ifdef CONFIG_SMP " mb\n"#endif "2:\n" ".subsection 2\n" "3: br 1b\n" ".previous" : "=&r"(prev), "=&r"(cmp), "=m"(*m) : "r"((long) old), "r"(new), "m"(*m) : "memory"); return prev;}/* This function doesn't exist, so you'll get a linker error if something tries to do an invalid cmpxchg(). */extern void __cmpxchg_called_with_bad_pointer(void);static __inline__ unsigned long__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size){ switch (size) { case 4: return __cmpxchg_u32(ptr, old, new); case 8: return __cmpxchg_u64(ptr, old, new); } __cmpxchg_called_with_bad_pointer(); return old;}#define cmpxchg(ptr,o,n) \ ({ \ __typeof__(*(ptr)) _o_ = (o); \ __typeof__(*(ptr)) _n_ = (n); \ (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ (unsigned long)_n_, sizeof(*(ptr))); \ })#endif /* __ASSEMBLY__ */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -