]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/avr32/kernel/nmi_debug.c
sched/headers: Prepare for new header dependencies before moving code to <linux/sched...
[mirror_ubuntu-bionic-kernel.git] / arch / avr32 / kernel / nmi_debug.c
1 /*
2 * Copyright (C) 2007 Atmel Corporation
3 *
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.
7 */
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>
13
14 #include <asm/irq.h>
15
16 enum nmi_action {
17 NMI_SHOW_STATE = 1 << 0,
18 NMI_SHOW_REGS = 1 << 1,
19 NMI_DIE = 1 << 2,
20 NMI_DEBOUNCE = 1 << 3,
21 };
22
23 static unsigned long nmi_actions;
24
25 static int nmi_debug_notify(struct notifier_block *self,
26 unsigned long val, void *data)
27 {
28 struct die_args *args = data;
29
30 if (likely(val != DIE_NMI))
31 return NOTIFY_DONE;
32
33 if (nmi_actions & NMI_SHOW_STATE)
34 show_state();
35 if (nmi_actions & NMI_SHOW_REGS)
36 show_regs(args->regs);
37 if (nmi_actions & NMI_DEBOUNCE)
38 mdelay(10);
39 if (nmi_actions & NMI_DIE)
40 return NOTIFY_BAD;
41
42 return NOTIFY_OK;
43 }
44
45 static struct notifier_block nmi_debug_nb = {
46 .notifier_call = nmi_debug_notify,
47 };
48
49 static int __init nmi_debug_setup(char *str)
50 {
51 char *p, *sep;
52
53 register_die_notifier(&nmi_debug_nb);
54 if (nmi_enable()) {
55 printk(KERN_WARNING "Unable to enable NMI.\n");
56 return 0;
57 }
58
59 if (*str != '=')
60 return 0;
61
62 for (p = str + 1; *p; p = sep + 1) {
63 sep = strchr(p, ',');
64 if (sep)
65 *sep = 0;
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;
74 else
75 printk(KERN_WARNING "NMI: Unrecognized action `%s'\n",
76 p);
77 if (!sep)
78 break;
79 }
80
81 return 0;
82 }
83 __setup("nmi_debug", nmi_debug_setup);