当前位置:   article > 正文

WATCHDOG驱动框架

watchdog驱动框架

看门狗的框架涉及到drivers/watchdog/watchdog_dev.c、watchdog_dev.h、watchdog_core.c,include/linux/watchdog.h中

定义的结构体:

  1. struct watchdog_device {
  2. const struct watchdog_info *info;
  3. const struct watchdog_ops *ops;
  4. unsigned int bootstatus;
  5. unsigned int timeout;
  6. unsigned int min_timeout;
  7. unsigned int max_timeout;
  8. void *driver_data;
  9. unsigned long status;
  10. /* Bit numbers for status flags */
  11. #define WDOG_ACTIVE 0 /* Is the watchdog running/active */
  12. #define WDOG_DEV_OPEN 1 /* Opened via /dev/watchdog ? */
  13. #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
  14. #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
  15. };
  16. struct watchdog_ops {
  17. struct module *owner;
  18. /* mandatory operations */
  19. int (*start)(struct watchdog_device *);
  20. int (*stop)(struct watchdog_device *);
  21. /* optional operations */
  22. int (*ping)(struct watchdog_device *);
  23. unsigned int (*status)(struct watchdog_device *);
  24. int (*set_timeout)(struct watchdog_device *, unsigned int);
  25. unsigned int (*get_timeleft)(struct watchdog_device *);
  26. long (*ioctl)(struct watchdog_device *, unsigned int, unsigned long);
  27. };
  28. struct watchdog_info {
  29. __u32 options; /* Options the card/driver supports */
  30. __u32 firmware_version; /* Firmware version of the card */
  31. __u8 identity[32]; /* Identity of the board */
  32. };
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调用



本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/713119
推荐阅读
相关标签
  

闽ICP备14008679号