diff options
author | ps <ps@FreeBSD.org> | 2000-03-19 14:55:42 +0000 |
---|---|---|
committer | ps <ps@FreeBSD.org> | 2000-03-19 14:55:42 +0000 |
commit | 98dc3507a2094d6e5c76ad414570fa726e1ad895 (patch) | |
tree | 8ea07deda5714acb97e70e3a57a4f213c970b7fc /sys | |
parent | 7a6ba845319116578d4fd8a3551a85dbbf77dced (diff) | |
download | FreeBSD-src-98dc3507a2094d6e5c76ad414570fa726e1ad895.zip FreeBSD-src-98dc3507a2094d6e5c76ad414570fa726e1ad895.tar.gz |
Make SPLASSERT sysctl and boot time tunable with kern.splassertmode.
The following values are understood: 0 (ignore), 1 (log), and 2
(panic).
The default value is 1.
Reviewed by: peter
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/alpha/ipl_funcs.c | 36 | ||||
-rw-r--r-- | sys/i386/isa/ipl_funcs.c | 36 |
2 files changed, 70 insertions, 2 deletions
diff --git a/sys/alpha/alpha/ipl_funcs.c b/sys/alpha/alpha/ipl_funcs.c index ea4154a..fd6f86e 100644 --- a/sys/alpha/alpha/ipl_funcs.c +++ b/sys/alpha/alpha/ipl_funcs.c @@ -28,6 +28,8 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/sysctl.h> #include <sys/interrupt.h> #include <machine/ipl.h> #include <machine/cpu.h> @@ -166,6 +168,38 @@ GENSET(schedsoftvm, &idelayed, 1 << SWI_VM) GENSET(schedsoftclock, &idelayed, 1 << SWI_CLOCK) #ifdef INVARIANT_SUPPORT + +#define SPLASSERT_IGNORE 0 +#define SPLASSERT_LOG 1 +#define SPLASSERT_PANIC 2 + +static int splassertmode = SPLASSERT_LOG; +SYSCTL_INT(_kern, OID_AUTO, splassertmode, CTLFLAG_RW, + &splassertmode, 0, "Set the mode of SPLASSERT"); + +static void +init_splassertmode(void *ignored) +{ + TUNABLE_INT_FETCH("kern.splassertmode", 0, splassertmode); +} +SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_splassertmode, NULL); + +static void +splassertfail(char *str, const char *msg, char *name, int level) +{ + switch (splassertmode) { + case SPLASSERT_IGNORE: + break; + case SPLASSERT_LOG: + printf(str, msg, name, level); + printf("\n"); + break; + case SPLASSERT_PANIC: + panic(str, msg, name, level); + break; + } +} + #define GENSPLASSERT(name, pri) \ void \ name##assert(const char *msg) \ @@ -174,7 +208,7 @@ name##assert(const char *msg) \ \ cpl = getcpl(); \ if (cpl < ALPHA_PSL_IPL_##pri); \ - panic("%s: not %s, cpl == %#x", \ + splassertfail("%s: not %s, cpl == %#x", \ msg, __XSTRING(name) + 3, cpl); \ } #else diff --git a/sys/i386/isa/ipl_funcs.c b/sys/i386/isa/ipl_funcs.c index 13a0743..d7ba1c4 100644 --- a/sys/i386/isa/ipl_funcs.c +++ b/sys/i386/isa/ipl_funcs.c @@ -28,6 +28,8 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/sysctl.h> #include <machine/ipl.h> #include <machine/globals.h> #include <i386/isa/intr_machdep.h> @@ -66,12 +68,44 @@ softclockpending(void) } #ifdef INVARIANT_SUPPORT + +#define SPLASSERT_IGNORE 0 +#define SPLASSERT_LOG 1 +#define SPLASSERT_PANIC 2 + +static int splassertmode = SPLASSERT_LOG; +SYSCTL_INT(_kern, OID_AUTO, splassertmode, CTLFLAG_RW, + &splassertmode, 0, "Set the mode of SPLASSERT"); + +static void +init_splassertmode(void *ignored) +{ + TUNABLE_INT_FETCH("kern.splassertmode", 0, splassertmode); +} +SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_splassertmode, NULL); + +static void +splassertfail(char *str, const char *msg, char *name, int level) +{ + switch (splassertmode) { + case SPLASSERT_IGNORE: + break; + case SPLASSERT_LOG: + printf(str, msg, name, level); + printf("\n"); + break; + case SPLASSERT_PANIC: + panic(str, msg, name, level); + break; + } +} + #define GENSPLASSERT(NAME, MODIFIER) \ void \ NAME##assert(const char *msg) \ { \ if ((cpl & (MODIFIER)) != (MODIFIER)) \ - panic("%s: not %s, cpl == %#x", \ + splassertfail("%s: not %s, cpl == %#x", \ msg, __XSTRING(NAME) + 3, cpl); \ } #else |