1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2007 Atmel Corporation
5 #include <linux/delay.h>
6 #include <linux/kdebug.h>
7 #include <linux/notifier.h>
8 #include <linux/sched.h>
9 #include <linux/sched/debug.h>
10 #include <linux/hardirq.h>
13 NMI_SHOW_STATE = 1 << 0,
14 NMI_SHOW_REGS = 1 << 1,
16 NMI_DEBOUNCE = 1 << 3,
19 static unsigned long nmi_actions;
21 static int nmi_debug_notify(struct notifier_block *self,
22 unsigned long val, void *data)
24 struct die_args *args = data;
26 if (likely(val != DIE_NMI))
29 if (nmi_actions & NMI_SHOW_STATE)
31 if (nmi_actions & NMI_SHOW_REGS)
32 show_regs(args->regs);
33 if (nmi_actions & NMI_DEBOUNCE)
35 if (nmi_actions & NMI_DIE)
41 static struct notifier_block nmi_debug_nb = {
42 .notifier_call = nmi_debug_notify,
45 static int __init nmi_debug_setup(char *str)
49 register_die_notifier(&nmi_debug_nb);
54 for (p = str + 1; *p; p = sep + 1) {
58 if (strcmp(p, "state") == 0)
59 nmi_actions |= NMI_SHOW_STATE;
60 else if (strcmp(p, "regs") == 0)
61 nmi_actions |= NMI_SHOW_REGS;
62 else if (strcmp(p, "debounce") == 0)
63 nmi_actions |= NMI_DEBOUNCE;
64 else if (strcmp(p, "die") == 0)
65 nmi_actions |= NMI_DIE;
67 printk(KERN_WARNING "NMI: Unrecognized action `%s'\n",
75 __setup("nmi_debug", nmi_debug_setup);