summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-28 02:31:54 +0000
committerjhb <jhb@FreeBSD.org>2001-03-28 02:31:54 +0000
commit3e4166569d016eb336a76bfb079024dbfe30b695 (patch)
tree3c573685f1d602eaf162bbad2536ac337e2fd5a1
parent07d30bc01eb16ab706b0a136a5a9066b7b8dc322 (diff)
downloadFreeBSD-src-3e4166569d016eb336a76bfb079024dbfe30b695.zip
FreeBSD-src-3e4166569d016eb336a76bfb079024dbfe30b695.tar.gz
- 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.
-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 cabfe0f..d47652c 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 8ca3c6b..2a4c325 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 8941ba1..7f0804f 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 8941ba1..7f0804f 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 7063a04..66e95ec 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 3128f70..b3ff55c 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 f8235a2..86ece49 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 *);
OpenPOWER on IntegriCloud