⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watdog.c

📁 arm linux 平台下的watchdog程序,C语言代码
💻 C
字号:
/* * *watchdog.c * *  Copyright (C) 2006  ccb * *author: lichao *email:lichao@njupt.edu.cn *  May be freely distributed as part of Linux. */#include <linux/config.h>#include <linux/module.h>#include <linux/init.h>#include <linux/version.h>#include <asm-arm/uaccess.h>#include <linux/miscdevice.h>#include <linux/sched.h>#include <linux/delay.h>#include <linux/poll.h>#include <asm-arm/delay.h>#include <asm/hardware.h>#include <asm-arm/arch-s3c2410/S3C2410.h>//#include "weida_printer.h"#if CONFIG_MODVERSIONS==1#define MODVERSIONS#include <linux/modversions.h>#endif#define DEVICE_NAME	"watchdog"#define WATCHDOG_MAJOR 234//#define rWTCNT (*(volatile unsigned long*)0x53000008)//#define rWTCON (*(volatile unsigned long*)0x53000000)int WATCHDOG_DEV=0;static int watchdog_write(struct file * file, const char * buffer, size_t count, loff_t *ppos){	WTCNT=8448*2;	}static int watchdog_open(struct inode *inode,struct file *file){	printk("the watchdog device will be opened");	if(WATCHDOG_DEV) 		return -EBUSY;	WATCHDOG_DEV++;	//D_INC_USE_COUNT;	WTCNT=8448*2;  /*setup the initial value of the watchdog*/	WTCON=0xff39;	return 0;}static struct file_operations watchdog_fops = {	open:	watchdog_open,	write: 	watchdog_write,};static int __init watchdog_init(void){	int ret;  		ret = register_chrdev(WATCHDOG_MAJOR, DEVICE_NAME, &watchdog_fops);	if (ret < 0) {	  printk(DEVICE_NAME " Can't initial the watchdog device\n");	  return ret;	}		return 0;}static void __exit watchdog_exit(void){	unregister_chrdev(WATCHDOG_MAJOR, DEVICE_NAME);}module_init(watchdog_init);module_exit(watchdog_exit);MODULE_LICENSE("GPL");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -