1 #ifndef __WATCHDOG_H__ 2 #define __WATCHDOG_H__ 3 4 #include "kernel/kernel.h" 5 #include "arch_watchdog.h" 6 7 extern int watchdog_enabled; /* if set to non-zero the watch dog is enabled */ 8 extern unsigned watchdog_local_timer_ticks; /* is timer still ticking? */ 9 10 /* 11 * as the implementation is not only architecture dependent but like in x86 case 12 * very much model specific, we need to keep a collection of methods that 13 * implement it in runtime after the correct arch/model was detected 14 */ 15 16 typedef void (* arch_watchdog_method_t)(const unsigned); 17 typedef int (* arch_watchdog_profile_init_t)(const unsigned); 18 19 struct arch_watchdog { 20 arch_watchdog_method_t init; /* initial setup */ 21 arch_watchdog_method_t reinit; /* reinit after a tick */ 22 arch_watchdog_profile_init_t profile_init; 23 u64_t resetval; 24 u64_t watchdog_resetval; 25 u64_t profile_resetval; 26 }; 27 28 extern struct arch_watchdog *watchdog; 29 30 /* let the arch code do whatever it needs to setup or quit the watchdog */ 31 int arch_watchdog_init(void); 32 void arch_watchdog_stop(void); 33 34 #ifdef __i386__ 35 /* if the watchdog detects lockup, let the arch code to handle it */ 36 void arch_watchdog_lockup(const struct nmi_frame * frame); 37 38 /* generic NMI handler. Takes one argument which points to where the arch 39 * specific low level handler dumped CPU information and can be inspected by the 40 * arch specific code of the watchdog implementation */ 41 void nmi_watchdog_handler(struct nmi_frame * frame); 42 #endif 43 44 /* 45 * start and stop profiling using the NMI watchdog 46 */ 47 int nmi_watchdog_start_profiling(const unsigned freq); 48 void nmi_watchdog_stop_profiling(void); 49 50 #endif /* __WATCHDOG_H__ */ 51