From 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 Mon Sep 17 00:00:00 2001 From: Yunhong Jiang Date: Tue, 4 Aug 2015 12:17:53 -0700 Subject: Add the rt linux 4.1.3-rt3 as base Import the rt linux 4.1.3-rt3 as OPNFV kvm base. It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and the base is: commit 0917f823c59692d751951bf5ea699a2d1e2f26a2 Author: Sebastian Andrzej Siewior Date: Sat Jul 25 12:13:34 2015 +0200 Prepare v4.1.3-rt3 Signed-off-by: Sebastian Andrzej Siewior We lose all the git history this way and it's not good. We should apply another opnfv project repo in future. Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423 Signed-off-by: Yunhong Jiang --- kernel/Documentation/watchdog/src/.gitignore | 2 + kernel/Documentation/watchdog/src/Makefile | 5 ++ .../Documentation/watchdog/src/watchdog-simple.c | 24 ++++++ kernel/Documentation/watchdog/src/watchdog-test.c | 86 ++++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 kernel/Documentation/watchdog/src/.gitignore create mode 100644 kernel/Documentation/watchdog/src/Makefile create mode 100644 kernel/Documentation/watchdog/src/watchdog-simple.c create mode 100644 kernel/Documentation/watchdog/src/watchdog-test.c (limited to 'kernel/Documentation/watchdog/src') diff --git a/kernel/Documentation/watchdog/src/.gitignore b/kernel/Documentation/watchdog/src/.gitignore new file mode 100644 index 000000000..ac90997db --- /dev/null +++ b/kernel/Documentation/watchdog/src/.gitignore @@ -0,0 +1,2 @@ +watchdog-simple +watchdog-test diff --git a/kernel/Documentation/watchdog/src/Makefile b/kernel/Documentation/watchdog/src/Makefile new file mode 100644 index 000000000..4a892c304 --- /dev/null +++ b/kernel/Documentation/watchdog/src/Makefile @@ -0,0 +1,5 @@ +# List of programs to build +hostprogs-y := watchdog-simple watchdog-test + +# Tell kbuild to always build the programs +always := $(hostprogs-y) diff --git a/kernel/Documentation/watchdog/src/watchdog-simple.c b/kernel/Documentation/watchdog/src/watchdog-simple.c new file mode 100644 index 000000000..ba45803a2 --- /dev/null +++ b/kernel/Documentation/watchdog/src/watchdog-simple.c @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +int main(void) +{ + int fd = open("/dev/watchdog", O_WRONLY); + int ret = 0; + if (fd == -1) { + perror("watchdog"); + exit(EXIT_FAILURE); + } + while (1) { + ret = write(fd, "\0", 1); + if (ret != 1) { + ret = -1; + break; + } + sleep(10); + } + close(fd); + return ret; +} diff --git a/kernel/Documentation/watchdog/src/watchdog-test.c b/kernel/Documentation/watchdog/src/watchdog-test.c new file mode 100644 index 000000000..3da822967 --- /dev/null +++ b/kernel/Documentation/watchdog/src/watchdog-test.c @@ -0,0 +1,86 @@ +/* + * Watchdog Driver Test Program + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int fd; + +/* + * This function simply sends an IOCTL to the driver, which in turn ticks + * the PC Watchdog card to reset its internal timer so it doesn't trigger + * a computer reset. + */ +static void keep_alive(void) +{ + int dummy; + + ioctl(fd, WDIOC_KEEPALIVE, &dummy); +} + +/* + * The main program. Run the program with "-d" to disable the card, + * or "-e" to enable the card. + */ + +static void term(int sig) +{ + close(fd); + fprintf(stderr, "Stopping watchdog ticks...\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + int flags; + + fd = open("/dev/watchdog", O_WRONLY); + + if (fd == -1) { + fprintf(stderr, "Watchdog device not enabled.\n"); + fflush(stderr); + exit(-1); + } + + if (argc > 1) { + if (!strncasecmp(argv[1], "-d", 2)) { + flags = WDIOS_DISABLECARD; + ioctl(fd, WDIOC_SETOPTIONS, &flags); + fprintf(stderr, "Watchdog card disabled.\n"); + fflush(stderr); + goto end; + } else if (!strncasecmp(argv[1], "-e", 2)) { + flags = WDIOS_ENABLECARD; + ioctl(fd, WDIOC_SETOPTIONS, &flags); + fprintf(stderr, "Watchdog card enabled.\n"); + fflush(stderr); + goto end; + } else { + fprintf(stderr, "-d to disable, -e to enable.\n"); + fprintf(stderr, "run by itself to tick the card.\n"); + fflush(stderr); + goto end; + } + } else { + fprintf(stderr, "Watchdog Ticking Away!\n"); + fflush(stderr); + } + + signal(SIGINT, term); + + while(1) { + keep_alive(); + sleep(1); + } +end: + close(fd); + return 0; +} -- cgit 1.2.3-korg