H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_NMI_H |
| 2 | #define _ASM_X86_NMI_H |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 3 | |
| 4 | #include <linux/pm.h> |
| 5 | #include <asm/irq.h> |
| 6 | #include <asm/io.h> |
| 7 | |
| 8 | #ifdef ARCH_HAS_NMI_WATCHDOG |
| 9 | |
| 10 | /** |
| 11 | * do_nmi_callback |
| 12 | * |
| 13 | * Check to see if a callback exists and execute it. Return 1 |
| 14 | * if the handler exists and was handled successfully. |
| 15 | */ |
| 16 | int do_nmi_callback(struct pt_regs *regs, int cpu); |
| 17 | |
Cyrill Gorcunov | ddca03c | 2008-05-24 19:36:31 +0400 | [diff] [blame] | 18 | extern void die_nmi(char *str, struct pt_regs *regs, int do_panic); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 19 | extern int check_nmi_watchdog(void); |
| 20 | extern int nmi_watchdog_enabled; |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 21 | extern int avail_to_resrv_perfctr_nmi_bit(unsigned int); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 22 | extern int reserve_perfctr_nmi(unsigned int); |
| 23 | extern void release_perfctr_nmi(unsigned int); |
| 24 | extern int reserve_evntsel_nmi(unsigned int); |
| 25 | extern void release_evntsel_nmi(unsigned int); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 26 | |
| 27 | extern void setup_apic_nmi_watchdog(void *); |
| 28 | extern void stop_apic_nmi_watchdog(void *); |
| 29 | extern void disable_timer_nmi_watchdog(void); |
| 30 | extern void enable_timer_nmi_watchdog(void); |
| 31 | extern int nmi_watchdog_tick(struct pt_regs *regs, unsigned reason); |
Aristeu Rozanski | b3e15bd | 2008-09-22 13:13:59 -0400 | [diff] [blame] | 32 | extern void cpu_nmi_set_wd_enabled(void); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 33 | |
| 34 | extern atomic_t nmi_active; |
| 35 | extern unsigned int nmi_watchdog; |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 36 | #define NMI_NONE 0 |
| 37 | #define NMI_IO_APIC 1 |
| 38 | #define NMI_LOCAL_APIC 2 |
| 39 | #define NMI_INVALID 3 |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 40 | |
| 41 | struct ctl_table; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 42 | extern int proc_nmi_enabled(struct ctl_table *, int , |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 43 | void __user *, size_t *, loff_t *); |
| 44 | extern int unknown_nmi_panic; |
| 45 | |
Ingo Molnar | 47cab6a | 2009-08-03 09:31:54 +0200 | [diff] [blame] | 46 | void arch_trigger_all_cpu_backtrace(void); |
| 47 | #define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 48 | |
Maciej W. Rozycki | 148b508 | 2008-06-06 03:27:41 +0100 | [diff] [blame] | 49 | static inline void localise_nmi_watchdog(void) |
| 50 | { |
| 51 | if (nmi_watchdog == NMI_IO_APIC) |
| 52 | nmi_watchdog = NMI_LOCAL_APIC; |
| 53 | } |
Cyrill Gorcunov | 4de0043 | 2008-06-24 22:52:06 +0200 | [diff] [blame] | 54 | |
| 55 | /* check if nmi_watchdog is active (ie was specified at boot) */ |
| 56 | static inline int nmi_watchdog_active(void) |
| 57 | { |
| 58 | /* |
| 59 | * actually it should be: |
| 60 | * return (nmi_watchdog == NMI_LOCAL_APIC || |
| 61 | * nmi_watchdog == NMI_IO_APIC) |
| 62 | * but since they are power of two we could use a |
| 63 | * cheaper way --cvg |
| 64 | */ |
Cyrill Gorcunov | a4046f8 | 2009-06-07 12:19:37 +0400 | [diff] [blame] | 65 | return nmi_watchdog & (NMI_LOCAL_APIC | NMI_IO_APIC); |
Cyrill Gorcunov | 4de0043 | 2008-06-24 22:52:06 +0200 | [diff] [blame] | 66 | } |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 67 | #endif |
| 68 | |
| 69 | void lapic_watchdog_stop(void); |
| 70 | int lapic_watchdog_init(unsigned nmi_hz); |
| 71 | int lapic_wd_event(unsigned nmi_hz); |
| 72 | unsigned lapic_adjust_nmi_hz(unsigned hz); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 73 | void disable_lapic_nmi_watchdog(void); |
| 74 | void enable_lapic_nmi_watchdog(void); |
| 75 | void stop_nmi(void); |
| 76 | void restart_nmi(void); |
| 77 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 78 | #endif /* _ASM_X86_NMI_H */ |