staticbool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
/* * ali_start - start watchdog countdown * * Starts the timer running providing the timer has a counter * configuration set.
*/
staticvoid ali_start(void)
{
u32 val;
spin_lock(&ali_lock);
pci_read_config_dword(ali_pci, 0xCC, &val);
val &= ~0x3F; /* Mask count */
val |= (1 << 25) | ali_timeout_bits;
pci_write_config_dword(ali_pci, 0xCC, val);
spin_unlock(&ali_lock);
}
/* * ali_stop - stop the timer countdown * * Stop the ALi watchdog countdown
*/
staticvoid ali_stop(void)
{
u32 val;
spin_lock(&ali_lock);
pci_read_config_dword(ali_pci, 0xCC, &val);
val &= ~0x3F; /* Mask count to zero (disabled) */
val &= ~(1 << 25); /* and for safety mask the reset enable */
pci_write_config_dword(ali_pci, 0xCC, val);
spin_unlock(&ali_lock);
}
/* * ali_keepalive - send a keepalive to the watchdog * * Send a keepalive to the timer (actually we restart the timer).
*/
staticvoid ali_keepalive(void)
{
ali_start();
}
/* * ali_settimer - compute the timer reload value * @t: time in seconds * * Computes the timeout values needed
*/
/* * ali_write - writes to ALi watchdog * @file: file from VFS * @data: user address of data * @len: length of data * @ppos: pointer to the file offset * * Handle a write to the ALi watchdog. Writing to the file pings * the watchdog and resets it. Writing the magic 'V' sequence allows * the next close to turn off the watchdog.
*/
static ssize_t ali_write(struct file *file, constchar __user *data,
size_t len, loff_t *ppos)
{ /* See if we got the magic character 'V' and reload the timer */ if (len) { if (!nowayout) {
size_t i;
/* note: just in case someone wrote the
magic character five months ago... */
ali_expect_release = 0;
/* scan to see whether or not we got
the magic character */ for (i = 0; i != len; i++) { char c; if (get_user(c, data + i)) return -EFAULT; if (c == 'V')
ali_expect_release = 42;
}
}
/* someone wrote to us, we should reload the timer */
ali_start();
} return len;
}
/* * ali_ioctl - handle watchdog ioctls * @file: VFS file pointer * @cmd: ioctl number * @arg: arguments to the ioctl * * Handle the watchdog ioctls supported by the ALi driver. Really * we want an extension to enable irq ack monitoring and the like
*/
case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0, p); case WDIOC_SETOPTIONS:
{ int new_options, retval = -EINVAL;
if (get_user(new_options, p)) return -EFAULT; if (new_options & WDIOS_DISABLECARD) {
ali_stop();
retval = 0;
} if (new_options & WDIOS_ENABLECARD) {
ali_start();
retval = 0;
} return retval;
} case WDIOC_KEEPALIVE:
ali_keepalive(); return 0; case WDIOC_SETTIMEOUT:
{ int new_timeout; if (get_user(new_timeout, p)) return -EFAULT; if (ali_settimer(new_timeout)) return -EINVAL;
ali_keepalive();
}
fallthrough; case WDIOC_GETTIMEOUT: return put_user(timeout, p); default: return -ENOTTY;
}
}
/* * ali_open - handle open of ali watchdog * @inode: inode from VFS * @file: file from VFS * * Open the ALi watchdog device. Ensure only one person opens it * at a time. Also start the watchdog running.
*/
staticint ali_open(struct inode *inode, struct file *file)
{ /* /dev/watchdog can only be opened once */ if (test_and_set_bit(0, &ali_is_open)) return -EBUSY;
/* * ali_release - close an ALi watchdog * @inode: inode from VFS * @file: file from VFS * * Close the ALi watchdog device. Actual shutdown of the timer * only occurs if the magic sequence has been set.
*/
staticint ali_release(struct inode *inode, struct file *file)
{ /* * Shut off the timer.
*/ if (ali_expect_release == 42)
ali_stop(); else {
pr_crit("Unexpected close, not stopping watchdog!\n");
ali_keepalive();
}
clear_bit(0, &ali_is_open);
ali_expect_release = 0; return 0;
}
/* * ali_notify_sys - System down notifier * * Notifier for system down
*/
staticint ali_notify_sys(struct notifier_block *this, unsignedlong code, void *unused)
{ if (code == SYS_DOWN || code == SYS_HALT)
ali_stop(); /* Turn the WDT off */ return NOTIFY_DONE;
}
/* * Data for PCI driver interface * * This data only exists for exporting the supported * PCI ids via MODULE_DEVICE_TABLE. We do not actually * register a pci_driver, because someone else might one day * want to register another driver on the same PCI id.
*/
/* * ali_find_watchdog - find a 1535 and 7101 * * Scans the PCI hardware for a 1535 series bridge and matching 7101 * watchdog device. This may be overtight but it is better to be safe
*/
/* * watchdog_init - module initialiser * * Scan for a suitable watchdog and if so initialize it. Return an error * if we cannot, the error causes the module to unload
*/
staticint __init watchdog_init(void)
{ int ret;
/* Check whether or not the hardware watchdog is there */ if (ali_find_watchdog() != 0) return -ENODEV;
/* Check that the timeout value is within it's range;
if not reset to the default */ if (timeout < 1 || timeout >= 18000) {
timeout = WATCHDOG_TIMEOUT;
pr_info("timeout value must be 0 < timeout < 18000, using %d\n",
timeout);
}
/* Calculate the watchdog's timeout */
ali_settimer(timeout);
ret = register_reboot_notifier(&ali_notifier); if (ret != 0) {
pr_err("cannot register reboot notifier (err=%d)\n", ret); goto out;
}
ret = misc_register(&ali_miscdev); if (ret != 0) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret); goto unreg_reboot;
}
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.