summaryrefslogtreecommitdiff
path: root/sys/arch/vax
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-06-02 17:40:00 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-06-02 17:40:00 +0000
commit966313e84db5a5cb446166cb326e852be8a6f905 (patch)
tree66494cabd8c3d7b21cb043d97a429b8c965edc32 /sys/arch/vax
parentda8ed29d45c3267fa10f5fd98b3acd64a3fae152 (diff)
Implement splassert() on vax.
Diffstat (limited to 'sys/arch/vax')
-rw-r--r--sys/arch/vax/include/intr.h23
-rw-r--r--sys/arch/vax/vax/machdep.c19
2 files changed, 37 insertions, 5 deletions
diff --git a/sys/arch/vax/include/intr.h b/sys/arch/vax/include/intr.h
index 34736bc40ae..6a7ce4d4094 100644
--- a/sys/arch/vax/include/intr.h
+++ b/sys/arch/vax/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.4 2006/06/01 06:01:28 miod Exp $ */
+/* $OpenBSD: intr.h,v 1.5 2006/06/02 17:39:58 miod Exp $ */
/* $NetBSD: intr.h,v 1.1 1998/08/18 23:55:00 matt Exp $ */
/*
@@ -55,9 +55,6 @@
#define IST_EDGE 2 /* edge-triggered */
#define IST_LEVEL 3 /* level-triggered */
-/* SPL asserts */
-#define splassert(wantipl) /* nothing */
-
#ifndef lint
#define splx(reg) \
({ \
@@ -100,4 +97,22 @@
#define spl6() _splraise(0x16)
#define spl7() _splraise(0x17)
+/* SPL asserts */
+#ifdef DIAGNOSTIC
+/*
+ * Although this function is implemented in MI code, it must be in this MD
+ * header because we don't want this header to include MI includes.
+ */
+void splassert_fail(int, int, const char *);
+extern int splassert_ctl;
+void splassert_check(int, const char *);
+#define splassert(__wantipl) do { \
+ if (__predict_false(splassert_ctl > 0)) { \
+ splassert_check(__wantipl, __func__); \
+ } \
+} while (0)
+#else
+#define splassert(wantipl) do { /* nothing */ } while (0)
+#endif
+
#endif /* _VAX_INTR_H */
diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c
index e0b3166b406..0d471a89bf5 100644
--- a/sys/arch/vax/vax/machdep.c
+++ b/sys/arch/vax/vax/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.78 2006/05/30 21:24:28 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.79 2006/06/02 17:39:59 miod Exp $ */
/* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */
/*
@@ -985,3 +985,20 @@ generic_reboot(int arg)
asm("halt");
}
+
+#ifdef DIAGNOSTIC
+void
+splassert_check(int wantipl, const char *func)
+{
+ int oldipl = mfpr(PR_IPL);
+
+ if (oldipl < wantipl) {
+ splassert_fail(wantipl, oldipl, func);
+ /*
+ * If the splassert_ctl is set to not panic, raise the ipl
+ * in a feeble attempt to reduce damage.
+ */
+ mtpr(wantipl, PR_IPL);
+ }
+}
+#endif