diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-11-21 21:01:53 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-11-21 21:01:53 +0000 |
commit | 1fbb7c0b61aa61b569862ceca6d8800158617ea1 (patch) | |
tree | 1ac9616b4483accaa0512afb77bb6ba65fe21384 | |
parent | 482e8846fa64d561078abdc100e76868d995c857 (diff) |
splassert support.
-rw-r--r-- | sys/arch/landisk/include/intr.h | 18 | ||||
-rw-r--r-- | sys/arch/landisk/landisk/intr.c | 23 |
2 files changed, 39 insertions, 2 deletions
diff --git a/sys/arch/landisk/include/intr.h b/sys/arch/landisk/include/intr.h index 2db2eded584..e59441fd09f 100644 --- a/sys/arch/landisk/include/intr.h +++ b/sys/arch/landisk/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.3 2006/11/21 21:01:35 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.4 2006/11/21 21:01:51 miod Exp $ */ /* $NetBSD: intr.h,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /*- @@ -67,7 +67,23 @@ #define spl0() _cpu_intr_resume(IPL_NONE << 4) #define splx(x) _cpu_intr_resume(x) +#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 yet */ } while (0) +#endif void intr_init(void); void *extintr_establish(int, int, int (*)(void *), void *, const char *); diff --git a/sys/arch/landisk/landisk/intr.c b/sys/arch/landisk/landisk/intr.c index c5e89a099ef..68103d663ea 100644 --- a/sys/arch/landisk/landisk/intr.c +++ b/sys/arch/landisk/landisk/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.3 2006/11/21 21:00:57 miod Exp $ */ +/* $OpenBSD: intr.c,v 1.4 2006/11/21 21:01:52 miod Exp $ */ /* $NetBSD: intr.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /*- @@ -368,3 +368,24 @@ extintr_intr_handler(void *arg) } return 0; } + +#ifdef DIAGNOSTIC +void +splassert_check(int wantipl, const char *func) +{ + register_t sr; + int oldipl; + + __asm__ __volatile__ ("stc sr,%0" : "=r" (sr)); + + oldipl = (sr & 0xf0) >> 4; + 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. + */ + _cpu_intr_raise(wantipl << 4); + } +} +#endif |