#define WATCHDOG_TIMEOUT 30/* 30 sec default timeout */ /* in seconds, will be multiplied by HZ to get seconds to wait for a ping */ staticint timeout = WATCHDOG_TIMEOUT;
module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1 <= timeout <= 3600, default="
__MODULE_STRING(WATCHDOG_TIMEOUT) ")");
staticbool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
/* *AMDElanSC520-WatchdogTimerRegisters
*/ #define MMCR_BASE 0xfffef000 /* The default base address */ #define OFFS_WDTMRCTL 0xCB0 /* Watchdog Timer Control Register */
staticvoid wdt_timer_ping(struct timer_list *unused)
{ /* If we got a heartbeat pulse within the WDT_US_INTERVAL *weagreetopingtheWDT
*/ if (time_before(jiffies, next_heartbeat)) { /* Ping the WDT */
spin_lock(&wdt_spinlock);
writew(0xAAAA, wdtmrctl);
writew(0x5555, wdtmrctl);
spin_unlock(&wdt_spinlock);
/* Re-set the timer interval */
mod_timer(&timer, jiffies + WDT_INTERVAL);
} else
pr_warn("Heartbeat lost! Will not ping the watchdog\n");
}
static ssize_t fop_write(struct file *file, constchar __user *buf,
size_t count, loff_t *ppos)
{ /* See if we got the magic character 'V' and reload the timer */ if (count) { if (!nowayout) {
size_t ofs;
/* note: just in case someone wrote the magic character
* five months ago... */
wdt_expect_close = 0;
/* now scan */ for (ofs = 0; ofs != count; ofs++) { char c; if (get_user(c, buf + ofs)) return -EFAULT; if (c == 'V')
wdt_expect_close = 42;
}
}
/* Well, anyhow someone wrote to us, we should
return that favour */
wdt_keepalive();
} return count;
}
staticint fop_open(struct inode *inode, struct file *file)
{ /* Just in case we're already talking to someone... */ if (test_and_set_bit(0, &wdt_is_open)) return -EBUSY; if (nowayout)
__module_get(THIS_MODULE);
/* Good, fire up the show */
wdt_startup(); return stream_open(inode, file);
}
staticint __init sc520_wdt_init(void)
{ int rc = -EBUSY;
/* Check that the timeout value is within it's range ;
if not reset to the default */ if (wdt_set_heartbeat(timeout)) {
wdt_set_heartbeat(WATCHDOG_TIMEOUT);
pr_info("timeout value must be 1 <= timeout <= 3600, using %d\n",
WATCHDOG_TIMEOUT);
}
wdtmrctl = ioremap(MMCR_BASE + OFFS_WDTMRCTL, 2); if (!wdtmrctl) {
pr_err("Unable to remap memory\n");
rc = -ENOMEM; goto err_out_region2;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.