2 * Copyright (C) 2007 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #include <linux/delay.h>
9 #include <linux/kdebug.h>
10 #include <linux/notifier.h>
11 #include <linux/sched.h>
12 #include <linux/sched/debug.h>
17 NMI_SHOW_STATE = 1 << 0,
18 NMI_SHOW_REGS = 1 << 1,
20 NMI_DEBOUNCE = 1 << 3,
23 static unsigned long nmi_actions;
25 static int nmi_debug_notify(struct notifier_block *self,
26 unsigned long val, void *data)
28 struct die_args *args = data;
30 if (likely(val != DIE_NMI))
33 if (nmi_actions & NMI_SHOW_STATE)
35 if (nmi_actions & NMI_SHOW_REGS)
36 show_regs(args->regs);
37 if (nmi_actions & NMI_DEBOUNCE)
39 if (nmi_actions & NMI_DIE)
45 static struct notifier_block nmi_debug_nb = {
46 .notifier_call = nmi_debug_notify,
49 static int __init nmi_debug_setup(char *str)
53 register_die_notifier(&nmi_debug_nb);
55 printk(KERN_WARNING "Unable to enable NMI.\n");
62 for (p = str + 1; *p; p = sep + 1) {
66 if (strcmp(p, "state") == 0)
67 nmi_actions |= NMI_SHOW_STATE;
68 else if (strcmp(p, "regs") == 0)
69 nmi_actions |= NMI_SHOW_REGS;
70 else if (strcmp(p, "debounce") == 0)
71 nmi_actions |= NMI_DEBOUNCE;
72 else if (strcmp(p, "die") == 0)
73 nmi_actions |= NMI_DIE;
75 printk(KERN_WARNING "NMI: Unrecognized action `%s'\n",
83 __setup("nmi_debug", nmi_debug_setup);