WATCHDOG驱动框架

看门狗的框架涉及到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调用



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值