赞
踩
看门狗的框架涉及到drivers/watchdog/watchdog_dev.c、watchdog_dev.h、watchdog_core.c,include/linux/watchdog.h中
定义的结构体:
- struct watchdog_device {
- const struct watchdog_info *info;
- const struct watchdog_ops *ops;
- unsigned int bootstatus;
- unsigned int timeout;
- unsigned int min_timeout;
- unsigned int max_timeout;
- void *driver_data;
- unsigned long status;
- /* Bit numbers for status flags */
- #define WDOG_ACTIVE 0 /* Is the watchdog running/active */
- #define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */
- #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
- #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
- };
- struct watchdog_ops {
- struct module *owner;
- /* mandatory operations */
- int (*start)(struct watchdog_device *);
- int (*stop)(struct watchdog_device *);
- /* optional operations */
- int (*ping)(struct watchdog_device *);
- unsigned int (*status)(struct watchdog_device *);
- int (*set_timeout)(struct watchdog_device *, unsigned int);
- unsigned int (*get_timeleft)(struct watchdog_device *);
- long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long);
- };
- struct watchdog_info {
- __u32 options; /* Options the card/driver supports */
- __u32 firmware_version; /* Firmware version of the card */
- __u8 identity[32]; /* Identity of the board */
- };

watchdog.h涉及到的API:
设置watchdog为nowayout
void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
设置私有结构体
void watchdog_set_drvdata(struct watchdog_device *wdd, void *data)
获取私有结构体
void *watchdog_get_drvdata(struct watchdog_device *wdd)
注册watchdog_device结构体
int watchdog_register_device(struct watchdog_device *)
卸载watchdog_device结构体
void watchdog_unregister_device(struct watchdog_device *)
watchdog_core.c涉及到的API实现:
int watchdog_register_device(struct watchdog_device *wdd)
void watchdog_unregister_device(struct watchdog_device *wdd)
watchdog_dev.c涉及到的API:
static int watchdog_ping(struct watchdog_device *wddev)
static int watchdog_start(struct watchdog_device *wddev)
static int watchdog_stop(struct watchdog_device *wddev)
static ssize_t watchdog_write(struct file *file, const char __user *data,size_t len, loff_t *ppos)
static long watchdog_ioctl(struct file *file, unsigned int cmd,unsigned long arg)
static int watchdog_open(struct inode *inode, struct file *file)
static int watchdog_release(struct inode *inode, struct file *file)
int watchdog_dev_register(struct watchdog_device *watchdog) //被watchdog_register_device调用
int watchdog_dev_unregister(struct watchdog_device *watchdog) //被watchdog_unregister_device调用
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。