This source file includes following definitions.
- watchdog_fire
- softdog_open
- softdog_release
- softdog_write
- watchdog_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include <linux/types.h>
23 #include <linux/kernel.h>
24 #include <linux/fs.h>
25 #include <linux/mm.h>
26 #include <linux/mouse.h>
27 #define WATCHDOG_MINOR 130
28 #define TIMER_MARGIN (60*HZ)
29
30
31
32
33
34 struct timer_list watchdog_ticktock;
35 static int timer_alive = 0;
36
37
38
39
40
41
42 static void watchdog_fire(unsigned long data)
43 {
44 extern void hard_reset_now(void);
45 hard_reset_now();
46 printk("WATCHDOG: Reboot didn't ?????\n");
47 }
48
49
50
51
52
53 static int softdog_open(struct inode *inode, struct file *file)
54 {
55 if(timer_alive)
56 return -EBUSY;
57
58
59
60 watchdog_ticktock.expires=jiffies+TIMER_MARGIN;
61 add_timer(&watchdog_ticktock);
62 timer_alive++;
63 return 0;
64 }
65
66 static void softdog_release(struct inode *inode, struct file *file)
67 {
68
69
70
71 del_timer(&watchdog_ticktock);
72 timer_alive=0;
73 }
74
75 static int softdog_write(struct inode *inode, struct file *file, const char *data, int len)
76 {
77
78
79
80 del_timer(&watchdog_ticktock);
81 watchdog_ticktock.expires=jiffies+TIMER_MARGIN;
82 add_timer(&watchdog_ticktock);
83 return 1;
84 }
85
86
87
88
89
90 void watchdog_init(void)
91 {
92 static struct file_operations softdog_fops=
93 {
94 NULL,
95 NULL,
96 softdog_write,
97 NULL,
98 NULL,
99 NULL,
100 NULL,
101 softdog_open,
102 softdog_release,
103 NULL,
104 NULL
105 };
106 static struct mouse softdog_mouse={
107 WATCHDOG_MINOR,
108 "softdog",
109 &softdog_fops
110 };
111
112 mouse_register(&softdog_mouse);
113 init_timer(&watchdog_ticktock);
114 watchdog_ticktock.function=watchdog_fire;
115 printk("Software Watchdog Timer: 0.03\n");
116 }