Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.16 135 lines 3.8 kB view raw
1 Berkshire Products PC Watchdog Card 2 Support for ISA Cards Revision A and C 3 Documentation and Driver by Ken Hollis <kenji@bitgate.com> 4 5 The PC Watchdog is a card that offers the same type of functionality that 6 the WDT card does, only it doesn't require an IRQ to run. Furthermore, 7 the Revision C card allows you to monitor any IO Port to automatically 8 trigger the card into being reset. This way you can make the card 9 monitor hard drive status, or anything else you need. 10 11 The Watchdog Driver has one basic role: to talk to the card and send 12 signals to it so it doesn't reset your computer ... at least during 13 normal operation. 14 15 The Watchdog Driver will automatically find your watchdog card, and will 16 attach a running driver for use with that card. After the watchdog 17 drivers have initialized, you can then talk to the card using the PC 18 Watchdog program, available from http://ftp.bitgate.com/pcwd/. 19 20 I suggest putting a "watchdog -d" before the beginning of an fsck, and 21 a "watchdog -e -t 1" immediately after the end of an fsck. (Remember 22 to run the program with an "&" to run it in the background!) 23 24 If you want to write a program to be compatible with the PC Watchdog 25 driver, simply do the following: 26 27-- Snippet of code -- 28/* 29 * Watchdog Driver Test Program 30 */ 31 32#include <stdio.h> 33#include <stdlib.h> 34#include <string.h> 35#include <unistd.h> 36#include <fcntl.h> 37#include <sys/ioctl.h> 38#include <linux/types.h> 39#include <linux/watchdog.h> 40 41int fd; 42 43/* 44 * This function simply sends an IOCTL to the driver, which in turn ticks 45 * the PC Watchdog card to reset its internal timer so it doesn't trigger 46 * a computer reset. 47 */ 48void keep_alive(void) 49{ 50 int dummy; 51 52 ioctl(fd, WDIOC_KEEPALIVE, &dummy); 53} 54 55/* 56 * The main program. Run the program with "-d" to disable the card, 57 * or "-e" to enable the card. 58 */ 59int main(int argc, char *argv[]) 60{ 61 fd = open("/dev/watchdog", O_WRONLY); 62 63 if (fd == -1) { 64 fprintf(stderr, "Watchdog device not enabled.\n"); 65 fflush(stderr); 66 exit(-1); 67 } 68 69 if (argc > 1) { 70 if (!strncasecmp(argv[1], "-d", 2)) { 71 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_DISABLECARD); 72 fprintf(stderr, "Watchdog card disabled.\n"); 73 fflush(stderr); 74 exit(0); 75 } else if (!strncasecmp(argv[1], "-e", 2)) { 76 ioctl(fd, WDIOC_SETOPTIONS, WDIOS_ENABLECARD); 77 fprintf(stderr, "Watchdog card enabled.\n"); 78 fflush(stderr); 79 exit(0); 80 } else { 81 fprintf(stderr, "-d to disable, -e to enable.\n"); 82 fprintf(stderr, "run by itself to tick the card.\n"); 83 fflush(stderr); 84 exit(0); 85 } 86 } else { 87 fprintf(stderr, "Watchdog Ticking Away!\n"); 88 fflush(stderr); 89 } 90 91 while(1) { 92 keep_alive(); 93 sleep(1); 94 } 95} 96-- End snippet -- 97 98 Other IOCTL functions include: 99 100 WDIOC_GETSUPPORT 101 This returns the support of the card itself. This 102 returns in structure "PCWDS" which returns: 103 options = WDIOS_TEMPPANIC 104 (This card supports temperature) 105 firmware_version = xxxx 106 (Firmware version of the card) 107 108 WDIOC_GETSTATUS 109 This returns the status of the card, with the bits of 110 WDIOF_* bitwise-anded into the value. (The comments 111 are in linux/pcwd.h) 112 113 WDIOC_GETBOOTSTATUS 114 This returns the status of the card that was reported 115 at bootup. 116 117 WDIOC_GETTEMP 118 This returns the temperature of the card. (You can also 119 read /dev/watchdog, which gives a temperature update 120 every second.) 121 122 WDIOC_SETOPTIONS 123 This lets you set the options of the card. You can either 124 enable or disable the card this way. 125 126 WDIOC_KEEPALIVE 127 This pings the card to tell it not to reset your computer. 128 129 And that's all she wrote! 130 131 -- Ken Hollis 132 (kenji@bitgate.com) 133 134(This documentation may be out of date. Check 135 http://ftp.bitgate.com/pcwd/ for the absolute latest additions.)