diff --git a/sys/alpha/include/cpufunc.h b/sys/alpha/include/cpufunc.h index cabfe0fa88a8..d47652cd16f7 100644 --- a/sys/alpha/include/cpufunc.h +++ b/sys/alpha/include/cpufunc.h @@ -45,29 +45,14 @@ breakpoint(void) #endif -/* - * Bogus interrupt manipulation - */ -static __inline void -disable_intr(void) +static __inline critical_t +critical_enter(void) { - alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH); + return (alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH)); } static __inline void -enable_intr(void) -{ - alpha_pal_swpipl(ALPHA_PSL_IPL_0); -} - -static __inline u_int -save_intr(void) -{ - return alpha_pal_rdps() & ALPHA_PSL_IPL_MASK; -} - -static __inline void -restore_intr(u_int ipl) +critical_exit(critical_t ipl) { alpha_pal_swpipl(ipl); } diff --git a/sys/alpha/include/types.h b/sys/alpha/include/types.h index 8ca3c6b8560c..2a4c3254b91d 100644 --- a/sys/alpha/include/types.h +++ b/sys/alpha/include/types.h @@ -64,6 +64,9 @@ typedef long intfptr_t; typedef unsigned long uintfptr_t; #endif +/* Critical section value */ +typedef register_t critical_t; + /* Interrupt mask (spl, xxx_imask, etc) */ typedef __uint32_t intrmask_t; diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 8941ba141ee7..7f0804f8d70b 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -90,21 +90,6 @@ enable_intr(void) __asm __volatile("sti"); } -static __inline u_int -save_intr(void) -{ - u_int ef; - - __asm __volatile("pushfl; popl %0" : "=r" (ef)); - return (ef); -} - -static __inline void -restore_intr(u_int ef) -{ - __asm __volatile("pushl %0; popfl" : : "r" (ef) : "memory" ); -} - #define HAVE_INLINE_FFS static __inline int @@ -495,6 +480,22 @@ rdr7(void) return (data); } +static __inline critical_t +critical_enter(void) +{ + critical_t eflags; + + eflags = read_eflags(); + disable_intr(); + return (eflags); +} + +static __inline void +critical_exit(critical_t eflags) +{ + write_eflags(eflags); +} + #else /* !__GNUC__ */ int breakpoint __P((void)); @@ -529,6 +530,8 @@ u_int rfs __P((void)); u_int rgs __P((void)); void load_fs __P((u_int sel)); void load_gs __P((u_int sel)); +critical_t critical_enter __P((void)); +void critical_exit __P((critical_t eflags)); #endif /* __GNUC__ */ diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 8941ba141ee7..7f0804f8d70b 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -90,21 +90,6 @@ enable_intr(void) __asm __volatile("sti"); } -static __inline u_int -save_intr(void) -{ - u_int ef; - - __asm __volatile("pushfl; popl %0" : "=r" (ef)); - return (ef); -} - -static __inline void -restore_intr(u_int ef) -{ - __asm __volatile("pushl %0; popfl" : : "r" (ef) : "memory" ); -} - #define HAVE_INLINE_FFS static __inline int @@ -495,6 +480,22 @@ rdr7(void) return (data); } +static __inline critical_t +critical_enter(void) +{ + critical_t eflags; + + eflags = read_eflags(); + disable_intr(); + return (eflags); +} + +static __inline void +critical_exit(critical_t eflags) +{ + write_eflags(eflags); +} + #else /* !__GNUC__ */ int breakpoint __P((void)); @@ -529,6 +530,8 @@ u_int rfs __P((void)); u_int rgs __P((void)); void load_fs __P((u_int sel)); void load_gs __P((u_int sel)); +critical_t critical_enter __P((void)); +void critical_exit __P((critical_t eflags)); #endif /* __GNUC__ */ diff --git a/sys/i386/include/types.h b/sys/i386/include/types.h index 7063a04428f6..66e95ec5403b 100644 --- a/sys/i386/include/types.h +++ b/sys/i386/include/types.h @@ -60,6 +60,9 @@ typedef int intfptr_t; typedef unsigned int uintfptr_t; #endif +/* Critical section value */ +typedef register_t critical_t; + /* Interrupt mask (spl, xxx_imask, etc) */ typedef __uint32_t intrmask_t; diff --git a/sys/ia64/include/cpufunc.h b/sys/ia64/include/cpufunc.h index 3128f7090f6d..b3ff55c20770 100644 --- a/sys/ia64/include/cpufunc.h +++ b/sys/ia64/include/cpufunc.h @@ -163,9 +163,6 @@ writel(u_int addr, u_int32_t data) return; /* TODO: implement this */ } -/* - * Bogus interrupt manipulation - */ static __inline void disable_intr(void) { @@ -178,16 +175,18 @@ enable_intr(void) __asm __volatile (";; ssm psr.i;; srlz.d"); } -static __inline u_int -save_intr(void) +static __inline critical_t +critical_enter(void) { - u_int psr; + critical_t psr; + __asm __volatile ("mov %0=psr;;" : "=r" (psr)); - return psr; + disable_intr(); + return (psr); } static __inline void -restore_intr(u_int psr) +critical_exit(critical_t psr) { __asm __volatile ("mov psr.l=%0;; srlz.d" :: "r" (psr)); } diff --git a/sys/ia64/include/types.h b/sys/ia64/include/types.h index f8235a284ecf..86ece498a2bf 100644 --- a/sys/ia64/include/types.h +++ b/sys/ia64/include/types.h @@ -64,8 +64,11 @@ typedef long intfptr_t; typedef unsigned long uintfptr_t; #endif +/* Critical section value */ +typedef register_t critical_t; + /* Interrupt mask (spl, xxx_imask, etc) */ -typedef __uint32_t intrmask_t; +typedef __uint64_t intrmask_t; /* Interrupt handler function type */ typedef void inthand2_t(void *);