comparison vd_watchdog/vd_watchdog.c @ 0:71475f5afa92

Watchdog for Vortex86 6071 on FreeBSD
author Thinker K.F. Li <thinker@branda.to>
date Tue, 08 Jul 2008 09:57:54 +0800
parents
children 0b9854adb86c
comparison
equal deleted inserted replaced
-1:000000000000 0:71475f5afa92
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <fcntl.h>
5 #include <sys/ioctl.h>
6 #include "vordog.h"
7
8 #define DEVNAME "/dev/vordog0"
9 #define PROG "vd_watchdog"
10
11 static void
12 watchdog(int min) {
13 struct vordog_cfg cfg;
14 int intval;
15 int r;
16 int fd;
17
18 fd = open(DEVNAME, O_RDWR);
19 if(fd == -1) {
20 perror(PROG);
21 exit(1);
22 }
23 cfg.init_val = min;
24 cfg.unit = VDT_1M;
25 r = ioctl(fd, VDCTL_ENABLE, &cfg);
26 if(r == -1) {
27 perror(PROG);
28 exit(1);
29 }
30
31 intval = min * 60 * 3 / 4;
32 while(1) {
33 sleep(intval);
34 r = ioctl(fd, VDCTL_RESET);
35 if(r == -1) {
36 perror(PROG);
37 exit(1);
38 }
39 printf("reset\n");
40 }
41 }
42
43
44 int
45 main(int argc, const char *argv[]) {
46 watchdog(1);
47 return 0;
48 }