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(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 return 0;
63 }
64
65 static void softdog_release(struct inode *inode, struct file *file)
66 {
67
68
69
70 del_timer(&watchdog_ticktock);
71 timer_alive=0;
72 }
73
74 static int softdog_write(struct inode *inode, struct file *file, const char *data, int len)
75 {
76
77
78
79 del_timer(&watchdog_ticktock);
80 watchdog_ticktock.expires=jiffies+TIMER_MARGIN;
81 add_timer(&watchdog_ticktock);
82 return 1;
83 }
84
85
86
87
88
89 void watchdog_init(void)
90 {
91 static struct file_operations softdog_fops=
92 {
93 NULL,
94 NULL,
95 softdog_write,
96 NULL,
97 NULL,
98 NULL,
99 NULL,
100 softdog_open,
101 softdog_release,
102 NULL,
103 NULL
104 };
105 static struct mouse softdog_mouse={
106 WATCHDOG_MINOR,
107 "softdog",
108 &softdog_fops
109 };
110
111 mouse_register(&softdog_mouse);
112 init_timer(&watchdog_ticktock);
113 watchdog_ticktock.function=watchdog_fire;
114 printk("Software Watchdog Timer: 0.02\n");
115 }