Mercurial > vordog
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vd_watchdog/vd_watchdog.c Tue Jul 08 09:57:54 2008 +0800 @@ -0,0 +1,48 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include "vordog.h" + +#define DEVNAME "/dev/vordog0" +#define PROG "vd_watchdog" + +static void +watchdog(int min) { + struct vordog_cfg cfg; + int intval; + int r; + int fd; + + fd = open(DEVNAME, O_RDWR); + if(fd == -1) { + perror(PROG); + exit(1); + } + cfg.init_val = min; + cfg.unit = VDT_1M; + r = ioctl(fd, VDCTL_ENABLE, &cfg); + if(r == -1) { + perror(PROG); + exit(1); + } + + intval = min * 60 * 3 / 4; + while(1) { + sleep(intval); + r = ioctl(fd, VDCTL_RESET); + if(r == -1) { + perror(PROG); + exit(1); + } + printf("reset\n"); + } +} + + +int +main(int argc, const char *argv[]) { + watchdog(1); + return 0; +}