From owner-freebsd-current Thu Feb 27 13:21:58 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 593E937B401 for ; Thu, 27 Feb 2003 13:21:56 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5421943FA3 for ; Thu, 27 Feb 2003 13:21:55 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id h1RLLraa010831; Thu, 27 Feb 2003 22:21:53 +0100 (CET) (envelope-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 From: phk@phk.freebsd.dk In-Reply-To: Your message of "Thu, 27 Feb 2003 13:13:08 PST." <200302272113.h1RLD8CV051071@repoman.freebsd.org> Date: Thu, 27 Feb 2003 22:21:53 +0100 Message-ID: <10830.1046380913@critter.freebsd.dk> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 (also new file). ------------------------------------------------------------------------ #include #include #include #include #include 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