⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system.h

📁 讲述linux的初始化过程
💻 H
📖 第 1 页 / 共 2 页
字号:
#else /* !CONFIG_SMP */# define cli()			__cli()# define sti()			__sti()# define save_flags(flags)	__save_flags(flags)# define restore_flags(flags)	__restore_flags(flags)#endif /* !CONFIG_SMP *//* * Force an unresolved reference if someone tries to use * ia64_fetch_and_add() with a bad value. */extern unsigned long __bad_size_for_ia64_fetch_and_add (void);extern unsigned long __bad_increment_for_ia64_fetch_and_add (void);#define IA64_FETCHADD(tmp,v,n,sz)						\({										\	switch (sz) {								\	      case 4:								\		__asm__ __volatile__ (IA64_SEMFIX"fetchadd4.rel %0=[%1],%2"	\				      : "=r"(tmp) : "r"(v), "i"(n) : "memory");	\		break;								\										\	      case 8:								\		__asm__ __volatile__ (IA64_SEMFIX"fetchadd8.rel %0=[%1],%2"	\				      : "=r"(tmp) : "r"(v), "i"(n) : "memory");	\		break;								\										\	      default:								\		__bad_size_for_ia64_fetch_and_add();				\	}									\})#define ia64_fetch_and_add(i,v)							\({										\	__u64 _tmp;								\	volatile __typeof__(*(v)) *_v = (v);					\	switch (i) {								\	      case -16:	IA64_FETCHADD(_tmp, _v, -16, sizeof(*(v))); break;	\	      case  -8:	IA64_FETCHADD(_tmp, _v,  -8, sizeof(*(v))); break;	\	      case  -4:	IA64_FETCHADD(_tmp, _v,  -4, sizeof(*(v))); break;	\	      case  -1:	IA64_FETCHADD(_tmp, _v,  -1, sizeof(*(v))); break;	\	      case   1:	IA64_FETCHADD(_tmp, _v,   1, sizeof(*(v))); break;	\	      case   4:	IA64_FETCHADD(_tmp, _v,   4, sizeof(*(v))); break;	\	      case   8:	IA64_FETCHADD(_tmp, _v,   8, sizeof(*(v))); break;	\	      case  16:	IA64_FETCHADD(_tmp, _v,  16, sizeof(*(v))); break;	\	      default:								\		_tmp = __bad_increment_for_ia64_fetch_and_add();		\		break;								\	}									\	(__typeof__(*v)) (_tmp + (i));	/* return new value */			\})/* * 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 (unsigned long x, volatile void *ptr, int size){	unsigned long result;	switch (size) {	      case 1:		__asm__ __volatile (IA64_SEMFIX"xchg1 %0=[%1],%2" : "=r" (result)				    : "r" (ptr), "r" (x) : "memory");		return result;	      case 2:		__asm__ __volatile (IA64_SEMFIX"xchg2 %0=[%1],%2" : "=r" (result)				    : "r" (ptr), "r" (x) : "memory");		return result;	      case 4:		__asm__ __volatile (IA64_SEMFIX"xchg4 %0=[%1],%2" : "=r" (result)				    : "r" (ptr), "r" (x) : "memory");		return result;	      case 8:		__asm__ __volatile (IA64_SEMFIX"xchg8 %0=[%1],%2" : "=r" (result)				    : "r" (ptr), "r" (x) : "memory");		return result;	}	__xchg_called_with_bad_pointer();	return x;}#define xchg(ptr,x)							     \  ((__typeof__(*(ptr))) __xchg ((unsigned long) (x), (ptr), sizeof(*(ptr))))/*  * 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. */#define __HAVE_ARCH_CMPXCHG 1/* * This function doesn't exist, so you'll get a linker error * if something tries to do an invalid cmpxchg(). */extern long __cmpxchg_called_with_bad_pointer(void);#define ia64_cmpxchg(sem,ptr,old,new,size)						\({											\	__typeof__(ptr) _p_ = (ptr);							\	__typeof__(new) _n_ = (new);							\	__u64 _o_, _r_;									\											\	switch (size) {									\	      case 1: _o_ = (__u8 ) (long) (old); break;				\	      case 2: _o_ = (__u16) (long) (old); break;				\	      case 4: _o_ = (__u32) (long) (old); break;				\	      case 8: _o_ = (__u64) (long) (old); break;				\	      default:									\	}										\	 __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(_o_));				\	switch (size) {									\	      case 1:									\		__asm__ __volatile__ (IA64_SEMFIX"cmpxchg1."sem" %0=[%1],%2,ar.ccv"	\				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\		break;									\											\	      case 2:									\		__asm__ __volatile__ (IA64_SEMFIX"cmpxchg2."sem" %0=[%1],%2,ar.ccv"	\				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\		break;									\											\	      case 4:									\		__asm__ __volatile__ (IA64_SEMFIX"cmpxchg4."sem" %0=[%1],%2,ar.ccv"	\				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\		break;									\											\	      case 8:									\		__asm__ __volatile__ (IA64_SEMFIX"cmpxchg8."sem" %0=[%1],%2,ar.ccv"	\				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\		break;									\											\	      default:									\		_r_ = __cmpxchg_called_with_bad_pointer();				\		break;									\	}										\	(__typeof__(old)) _r_;								\})#define cmpxchg_acq(ptr,o,n)	ia64_cmpxchg("acq", (ptr), (o), (n), sizeof(*(ptr)))#define cmpxchg_rel(ptr,o,n)	ia64_cmpxchg("rel", (ptr), (o), (n), sizeof(*(ptr)))/* for compatibility with other platforms: */#define cmpxchg(ptr,o,n)	cmpxchg_acq(ptr,o,n)#ifdef CONFIG_IA64_DEBUG_CMPXCHG# define CMPXCHG_BUGCHECK_DECL	int _cmpxchg_bugcheck_count = 128;# define CMPXCHG_BUGCHECK(v)							\  do {										\	if (_cmpxchg_bugcheck_count-- <= 0) {					\		void *ip;							\		extern int printk(const char *fmt, ...);			\		asm ("mov %0=ip" : "=r"(ip));					\		printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v));	\		break;								\	}									\  } while (0)#else /* !CONFIG_IA64_DEBUG_CMPXCHG */# define CMPXCHG_BUGCHECK_DECL# define CMPXCHG_BUGCHECK(v)#endif /* !CONFIG_IA64_DEBUG_CMPXCHG */#ifdef __KERNEL__#define prepare_to_switch()    do { } while(0)#ifdef CONFIG_IA32_SUPPORT# define IS_IA32_PROCESS(regs)	(ia64_psr(regs)->is != 0)#else# define IS_IA32_PROCESS(regs)		0#endif/* * Context switch from one thread to another.  If the two threads have * different address spaces, schedule() has already taken care of * switching to the new address space by calling switch_mm(). * * Disabling access to the fph partition and the debug-register * context switch MUST be done before calling ia64_switch_to() since a * newly created thread returns directly to * ia64_ret_from_syscall_clear_r8. */extern struct task_struct *ia64_switch_to (void *next_task);extern void ia64_save_extra (struct task_struct *task);extern void ia64_load_extra (struct task_struct *task);#define __switch_to(prev,next,last) do {						\	if (((prev)->thread.flags & (IA64_THREAD_DBG_VALID|IA64_THREAD_PM_VALID))	\	    || IS_IA32_PROCESS(ia64_task_regs(prev)))					\		ia64_save_extra(prev);							\	if (((next)->thread.flags & (IA64_THREAD_DBG_VALID|IA64_THREAD_PM_VALID))	\	    || IS_IA32_PROCESS(ia64_task_regs(next)))					\		ia64_load_extra(next);							\	(last) = ia64_switch_to((next));						\} while (0)#ifdef CONFIG_SMP   /*   * In the SMP case, we save the fph state when context-switching   * away from a thread that modified fph.  This way, when the thread   * gets scheduled on another CPU, the CPU can pick up the state from   * task->thread.fph, avoiding the complication of having to fetch   * the latest fph state from another CPU.   */# define switch_to(prev,next,last) do {						\	if (ia64_psr(ia64_task_regs(prev))->mfh) {				\		ia64_psr(ia64_task_regs(prev))->mfh = 0;			\		(prev)->thread.flags |= IA64_THREAD_FPH_VALID;			\		__ia64_save_fpu((prev)->thread.fph);				\	}									\	ia64_psr(ia64_task_regs(prev))->dfh = 1;				\	__switch_to(prev,next,last);						\  } while (0)#else# define switch_to(prev,next,last) do {						\	ia64_psr(ia64_task_regs(next))->dfh = (ia64_get_fpu_owner() != (next));	\	__switch_to(prev,next,last);						\} while (0)#endif#endif /* __KERNEL__ */#endif /* __ASSEMBLY__ */#endif /* _ASM_IA64_SYSTEM_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -