Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Feb 2003 22:21:53 +0100
From:      phk@phk.freebsd.dk
To:        current@freebsd.org
Cc:        soekris-tech@lists.soekris.com
Subject:   Re: cvs commit: src/sys/i386/i386 elan-mmcr.c 
Message-ID:  <10830.1046380913@critter.freebsd.dk>
In-Reply-To: Your message of "Thu, 27 Feb 2003 13:13:08 PST." <200302272113.h1RLD8CV051071@repoman.freebsd.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200302272113.h1RLD8CV051071@repoman.freebsd.org>, Poul-Henning Kamp
 writes:
>phk         2003/02/27 13:13:08 PST
>
>  Modified files:
>    sys/i386/i386        elan-mmcr.c 
>  Log:
>  Add support for the Elan CPU hardware watchdog used in "active" mode.

Now we can get the watchdog to kill the machine if it goes unresponsive.

(And no, I don't have an MFC plan, I don't have any Soekris' runing
-stable)

This is a small program which shows how to use the api.  See also
the comments in <sys/watchdog.h> (also new file).

------------------------------------------------------------------------
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/watchdog.h>

int
main(int argc, char **argv)
{
        int fd;
        int i, j;
        unsigned u;

        fd = open("/dev/elan-mmcr", O_RDWR);
        if (fd < 0)
                err(1, "/dev/elan-mmcr");

        /*
         * Set a two second timeout, but reset it after one second.
	 * Do this five times to see that it works as advertised.
         */
        for (j = 0; j < 5; j++) {
                u = WD_ACTIVE | WD_TO_2SEC;
                i = ioctl(fd, WDIOCPATPAT, &u);
                printf("2SEC %d %d\n", i, errno);
                sleep (1);
        }
        /*
         * Turn the watchdog off.
	 * Wait twice the previous timeout, we should survive.
         */
        u = 0;
        i = ioctl(fd, WDIOCPATPAT, &u);
        printf("OFF %d %d\n", i, errno);
        sleep (5);
        /*
         * Set a two second timeout, and let it, and us, expire.
         */
        u = WD_ACTIVE | WD_TO_2SEC;
        i = ioctl(fd, WDIOCPATPAT, &u);
        printf("2SEC %d %d\n", i, errno);
        sleep (5);

        /*
         * We shouldn't get here alive.
         */
        printf("Where's the kaboom ?\n");
        exit (0);
}
------------------------------------------------------------------------



-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?10830.1046380913>