aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2001-03-28 02:31:54 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2001-03-28 02:31:54 +0000
commit034dc442ad1898c8211261bb7596faa03eacff02 (patch)
tree7030ff568a7983ad4333c17850e6b70459545c35 /sys
parent646672fe820f93ddd9bc54959a53cd0c93591c26 (diff)
downloadsrc-034dc442ad1898c8211261bb7596faa03eacff02.tar.gz
src-034dc442ad1898c8211261bb7596faa03eacff02.zip
- Add the new critical_t type used to save state inside of critical
sections. - Add implementations of the critical_enter() and critical_exit() functions and remove restore_intr() and save_intr(). - Remove the somewhat bogus disable_intr() and enable_intr() functions on the alpha as the alpha actually uses a priority level and not simple bit flag on the CPU.
Notes
Notes: svn path=/head/; revision=74897
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/include/cpufunc.h23
-rw-r--r--sys/alpha/include/types.h3
-rw-r--r--sys/amd64/include/cpufunc.h33
-rw-r--r--sys/i386/include/cpufunc.h33
-rw-r--r--sys/i386/include/types.h3
-rw-r--r--sys/ia64/include/cpufunc.h15
-rw-r--r--sys/ia64/include/types.h5
7 files changed, 57 insertions, 58 deletions
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)
-{
- 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)
+static __inline critical_t
+critical_enter(void)
{
- return alpha_pal_rdps() & ALPHA_PSL_IPL_MASK;
+ return (alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH));
}
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 *);