Linux驱动开发—看门狗(watchdog)设备框架

一、看门狗设备驱动框架简介

看门狗框架涉及drivers/watchdog/watchdog_dev.c 、drivers/watchdog/watchdog_core.c、drivers/watchdog/watchdog_pretimeout.c 这三个源文件,其本质是misc设备。

  • watchdog_dev.c作为上层,注册字符设备操作函数集file_operations结构体变量,与应用层对接。
  • watchdog_core.c:作为看门狗驱动框架核心层,提供看门狗设备的注册、卸载等相关API函数。
  • watchdog_pretimeout.c:主要涉及看门狗定时、预超时相关处理。

二、struct watchdog_device结构体(描述看门狗设备)

struct watchdog_device {
	int id;
	struct device *parent;
	const struct attribute_group **groups;
	const struct watchdog_info *info;
	const struct watchdog_ops *ops;
	const struct watchdog_governor *gov;
	unsigned int bootstatus;
	unsigned int timeout;
	unsigned int pretimeout;
	unsigned int min_timeout;
	unsigned int max_timeout;
	unsigned int min_hw_heartbeat_ms;
	unsigned int max_hw_heartbeat_ms;
	struct notifier_block reboot_nb;
	struct notifier_block restart_nb;
	void *driver_data;
	struct watchdog_core_data *wd_data;
	unsigned long status;
/* Bit numbers for status flags */
#define WDOG_ACTIVE		0	/* Is the watchdog running/active */
#define WDOG_NO_WAY_OUT		1	/* Is 'nowayout' feature set ? */
#define WDOG_STOP_ON_REBOOT	2	/* Should be stopped on reboot */
#define WDOG_HW_RUNNING		3	/* True if HW watchdog running */
#define WDOG_STOP_ON_UNREGISTER	4	/* Should be stopped on unregister */
	struct list_head deferred;
};
  • idid号,有watchdog_register_device函数注册时自动分配。
  • parent:父设备,可填充&p
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值