summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/cpufunc.h
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-12-18 00:27:18 +0000
committerjhb <jhb@FreeBSD.org>2001-12-18 00:27:18 +0000
commita3b98398cbfb4b809f8577b6a95aabb2c30a1aeb (patch)
treebd1f842c61588e8478e798dece6dff8b2be41310 /sys/amd64/include/cpufunc.h
parent090c933e94e7345e9c9e9a9fbe29ea6c8397a662 (diff)
downloadFreeBSD-src-a3b98398cbfb4b809f8577b6a95aabb2c30a1aeb.zip
FreeBSD-src-a3b98398cbfb4b809f8577b6a95aabb2c30a1aeb.tar.gz
Modify the critical section API as follows:
- The MD functions critical_enter/exit are renamed to start with a cpu_ prefix. - MI wrapper functions critical_enter/exit maintain a per-thread nesting count and a per-thread critical section saved state set when entering a critical section while at nesting level 0 and restored when exiting to nesting level 0. This moves the saved state out of spin mutexes so that interlocking spin mutexes works properly. - Most low-level MD code that used critical_enter/exit now use cpu_critical_enter/exit. MI code such as device drivers and spin mutexes use the MI wrappers. Note that since the MI wrappers store the state in the current thread, they do not have any return values or arguments. - mtx_intr_enable() is replaced with a constant CRITICAL_FORK which is assigned to curthread->td_savecrit during fork_exit(). Tested on: i386, alpha
Diffstat (limited to 'sys/amd64/include/cpufunc.h')
-rw-r--r--sys/amd64/include/cpufunc.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 4a9300a..a4f57cb 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -41,6 +41,7 @@
#define _MACHINE_CPUFUNC_H_
#include <sys/cdefs.h>
+#include <machine/psl.h>
__BEGIN_DECLS
#define readb(va) (*(volatile u_int8_t *) (va))
@@ -51,6 +52,8 @@ __BEGIN_DECLS
#define writew(va, d) (*(volatile u_int16_t *) (va) = (d))
#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
+#define CRITICAL_FORK (read_eflags() | PSL_I)
+
#ifdef __GNUC__
#ifdef SWTCH_OPTIM_STATS
@@ -548,7 +551,7 @@ load_dr7(u_int sel)
}
static __inline critical_t
-critical_enter(void)
+cpu_critical_enter(void)
{
critical_t eflags;
@@ -558,7 +561,7 @@ critical_enter(void)
}
static __inline void
-critical_exit(critical_t eflags)
+cpu_critical_exit(critical_t eflags)
{
write_eflags(eflags);
}
@@ -597,8 +600,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));
+critical_t cpu_critical_enter __P((void));
+void cpu_critical_exit __P((critical_t eflags));
#endif /* __GNUC__ */
OpenPOWER on IntegriCloud