亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rtc.c

?? powerpc內核mpc8241linux系統下char驅動程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* *	Real Time Clock interface for Linux	 * *	Copyright (C) 1996 Paul Gortmaker * *	This driver allows use of the real time clock (built into *	nearly all computers) from user space. It exports the /dev/rtc *	interface supporting various ioctl() and also the /proc/rtc *	pseudo-file for status information. * *	The ioctls can be used to set the interrupt behaviour and *	generation rate from the RTC via IRQ 8. Then the /dev/rtc *	interface can be used to make use of these timer interrupts, *	be they interval or alarm based. * *	The /dev/rtc interface will block on reads until an interrupt *	has been received. If a RTC interrupt has already happened, *	it will output an unsigned long and then block. The output value *	contains the interrupt status in the low byte and the number of *	interrupts since the last read in the remaining high bytes. The  *	/dev/rtc interface can also be used with the select(2) call. * *	This program is free software; you can redistribute it and/or *	modify it under the terms of the GNU General Public License *	as published by the Free Software Foundation; either version *	2 of the License, or (at your option) any later version. * *	Based on other minimal char device drivers, like Alan's *	watchdog, Ted's random, etc. etc. * *	1.07	Paul Gortmaker. *	1.08	Miquel van Smoorenburg: disallow certain things on the *		DEC Alpha as the CMOS clock is also used for other things. *	1.09	Nikita Schmidt: epoch support and some Alpha cleanup. * */#define RTC_VERSION		"1.09"#define RTC_IRQ 	8	/* Can't see this changing soon.	*/#define RTC_IO_EXTENT	0x10	/* Only really two ports, but...	*//* *	Note that *all* calls to CMOS_READ and CMOS_WRITE are done with *	interrupts disabled. Due to the index-port/data-port (0x70/0x71) *	design of the RTC, we don't want two different things trying to *	get to it at once. (e.g. the periodic 11 min sync from time.c vs. *	this driver.) */#include <linux/types.h>#include <linux/errno.h>#include <linux/miscdevice.h>#include <linux/malloc.h>#include <linux/ioport.h>#include <linux/fcntl.h>#include <linux/mc146818rtc.h>#include <linux/init.h>#include <linux/poll.h>#include <asm/io.h>#include <asm/uaccess.h>#include <asm/system.h>/* *	We sponge a minor off of the misc major. No need slurping *	up another valuable major dev number for this. If you add *	an ioctl, make sure you don't conflict with SPARC's RTC *	ioctls. */static struct wait_queue *rtc_wait;static struct timer_list rtc_irq_timer;static long long rtc_llseek(struct file *file, loff_t offset, int origin);static ssize_t rtc_read(struct file *file, char *buf,			size_t count, loff_t *ppos);static int rtc_ioctl(struct inode *inode, struct file *file,		     unsigned int cmd, unsigned long arg);static unsigned int rtc_poll(struct file *file, poll_table *wait);void get_rtc_time (struct rtc_time *rtc_tm);void get_rtc_alm_time (struct rtc_time *alm_tm);void rtc_dropped_irq(unsigned long data);void set_rtc_irq_bit(unsigned char bit);void mask_rtc_irq_bit(unsigned char bit);static inline unsigned char rtc_is_updating(void);/* *	Bits in rtc_status. (6 bits of room for future expansion) */#define RTC_IS_OPEN		0x01	/* means /dev/rtc is in use	*/#define RTC_TIMER_ON		0x02	/* missed irq timer active	*/unsigned char rtc_status = 0;		/* bitmapped status byte.	*/unsigned long rtc_freq = 0;		/* Current periodic IRQ rate	*/unsigned long rtc_irq_data = 0;		/* our output to the world	*//* *	If this driver ever becomes modularised, it will be really nice *	to make the epoch retain its value across module reload... */static unsigned long epoch = 1900;	/* year corresponding to 0x00	*/unsigned char days_in_mo[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};/* *	A very tiny interrupt handler. It runs with SA_INTERRUPT set, *	so that there is no possibility of conflicting with the *	set_rtc_mmss() call that happens during some timer interrupts. *	(See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.) */static void rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs){	/*	 *	Can be an alarm interrupt, update complete interrupt,	 *	or a periodic interrupt. We store the status in the	 *	low byte and the number of interrupts received since	 *	the last read in the remainder of rtc_irq_data.	 */	rtc_irq_data += 0x100;	rtc_irq_data &= ~0xff;	rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);	wake_up_interruptible(&rtc_wait);		if (rtc_status & RTC_TIMER_ON)		mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);}/* *	Now all the various file operations that we export. */static long long rtc_llseek(struct file *file, loff_t offset, int origin){	return -ESPIPE;}static ssize_t rtc_read(struct file *file, char *buf,			size_t count, loff_t *ppos){	struct wait_queue wait = { current, NULL };	unsigned long data;	ssize_t retval;		if (count < sizeof(unsigned long))		return -EINVAL;	add_wait_queue(&rtc_wait, &wait);	current->state = TASK_INTERRUPTIBLE;			while ((data = xchg(&rtc_irq_data, 0)) == 0) {		if (file->f_flags & O_NONBLOCK) {			retval = -EAGAIN;			goto out;		}		if (signal_pending(current)) {			retval = -ERESTARTSYS;			goto out;		}		schedule();	}	retval = put_user(data, (unsigned long *)buf); 	if (!retval)		retval = sizeof(unsigned long);  out:	current->state = TASK_RUNNING;	remove_wait_queue(&rtc_wait, &wait);	return retval;}static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,		     unsigned long arg){	unsigned long flags;	struct rtc_time wtime; 	switch (cmd) {	case RTC_AIE_OFF:	/* Mask alarm int. enab. bit	*/	{		mask_rtc_irq_bit(RTC_AIE);		return 0;	}	case RTC_AIE_ON:	/* Allow alarm interrupts.	*/	{		set_rtc_irq_bit(RTC_AIE);		return 0;	}	case RTC_PIE_OFF:	/* Mask periodic int. enab. bit	*/	{		mask_rtc_irq_bit(RTC_PIE);		if (rtc_status & RTC_TIMER_ON) {			del_timer(&rtc_irq_timer);			rtc_status &= ~RTC_TIMER_ON;		}		return 0;	}	case RTC_PIE_ON:	/* Allow periodic ints		*/	{		/*		 * We don't really want Joe User enabling more		 * than 64Hz of interrupts on a multi-user machine.		 */		if ((rtc_freq > 64) && (!capable(CAP_SYS_RESOURCE)))			return -EACCES;		if (!(rtc_status & RTC_TIMER_ON)) {			rtc_status |= RTC_TIMER_ON;			rtc_irq_timer.expires = jiffies + HZ/rtc_freq + 2*HZ/100;			add_timer(&rtc_irq_timer);		}		set_rtc_irq_bit(RTC_PIE);		return 0;	}	case RTC_UIE_OFF:	/* Mask ints from RTC updates.	*/	{		mask_rtc_irq_bit(RTC_UIE);		return 0;	}	case RTC_UIE_ON:	/* Allow ints for RTC updates.	*/	{		set_rtc_irq_bit(RTC_UIE);		return 0;	}	case RTC_ALM_READ:	/* Read the present alarm time */	{		/*		 * This returns a struct rtc_time. Reading >= 0xc0		 * means "don't care" or "match all". Only the tm_hour,		 * tm_min, and tm_sec values are filled in.		 */		get_rtc_alm_time(&wtime);		break; 	}	case RTC_ALM_SET:	/* Store a time into the alarm */	{		/*		 * This expects a struct rtc_time. Writing 0xff means		 * "don't care" or "match all". Only the tm_hour,		 * tm_min and tm_sec are used.		 */		unsigned char hrs, min, sec;		struct rtc_time alm_tm;		if (copy_from_user(&alm_tm, (struct rtc_time*)arg,				   sizeof(struct rtc_time)))			return -EFAULT;		hrs = alm_tm.tm_hour;		min = alm_tm.tm_min;		sec = alm_tm.tm_sec;		if (hrs >= 24)			hrs = 0xff;		if (min >= 60)			min = 0xff;		if (sec >= 60)			sec = 0xff;		save_flags(flags);		cli();		if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||		    RTC_ALWAYS_BCD)		{			BIN_TO_BCD(sec);			BIN_TO_BCD(min);			BIN_TO_BCD(hrs);		}		CMOS_WRITE(hrs, RTC_HOURS_ALARM);		CMOS_WRITE(min, RTC_MINUTES_ALARM);		CMOS_WRITE(sec, RTC_SECONDS_ALARM);		restore_flags(flags);		return 0;	}	case RTC_RD_TIME:	/* Read the time/date from RTC	*/	{		get_rtc_time(&wtime);		break;	}	case RTC_SET_TIME:	/* Set the RTC */	{		struct rtc_time rtc_tm;		unsigned char mon, day, hrs, min, sec, leap_yr;		unsigned char save_control, save_freq_select;		unsigned int yrs;		unsigned long flags;					if (!capable(CAP_SYS_TIME))			return -EACCES;		if (copy_from_user(&rtc_tm, (struct rtc_time*)arg,				   sizeof(struct rtc_time)))			return -EFAULT;		yrs = rtc_tm.tm_year + 1900;		mon = rtc_tm.tm_mon + 1;   /* tm_mon starts at zero */		day = rtc_tm.tm_mday;		hrs = rtc_tm.tm_hour;		min = rtc_tm.tm_min;		sec = rtc_tm.tm_sec;		if (yrs < 1970)			return -EINVAL;		leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400));		if ((mon > 12) || (day == 0))			return -EINVAL;		if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr)))			return -EINVAL;					if ((hrs >= 24) || (min >= 60) || (sec >= 60))			return -EINVAL;		if ((yrs -= epoch) > 255)    /* They are unsigned */			return -EINVAL;		save_flags(flags);		cli();		if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)		    || RTC_ALWAYS_BCD) {			if (yrs > 169) {				restore_flags(flags);				return -EINVAL;			}			if (yrs >= 100)				yrs -= 100;			BIN_TO_BCD(sec);			BIN_TO_BCD(min);			BIN_TO_BCD(hrs);			BIN_TO_BCD(day);			BIN_TO_BCD(mon);			BIN_TO_BCD(yrs);		}		save_control = CMOS_READ(RTC_CONTROL);		CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);		save_freq_select = CMOS_READ(RTC_FREQ_SELECT);		CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);		CMOS_WRITE(yrs, RTC_YEAR);		CMOS_WRITE(mon, RTC_MONTH);		CMOS_WRITE(day, RTC_DAY_OF_MONTH);		CMOS_WRITE(hrs, RTC_HOURS);		CMOS_WRITE(min, RTC_MINUTES);		CMOS_WRITE(sec, RTC_SECONDS);		CMOS_WRITE(save_control, RTC_CONTROL);		CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);		restore_flags(flags);		return 0;	}	case RTC_IRQP_READ:	/* Read the periodic IRQ rate.	*/	{		return put_user(rtc_freq, (unsigned long *)arg);	}	case RTC_IRQP_SET:	/* Set periodic IRQ rate.	*/	{		int tmp = 0;		unsigned char val;		/* 		 * The max we can do is 8192Hz.		 */		if ((arg < 2) || (arg > 8192))			return -EINVAL;		/*		 * We don't really want Joe User generating more		 * than 64Hz of interrupts on a multi-user machine.		 */		if ((arg > 64) && (!capable(CAP_SYS_RESOURCE)))			return -EACCES;		while (arg > (1<<tmp))			tmp++;		/*		 * Check that the input was really a power of 2.		 */		if (arg != (1<<tmp))			return -EINVAL;		rtc_freq = arg;		save_flags(flags);		cli();		val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;		val |= (16 - tmp);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频中午一区| 国产精品乱码一区二三区小蝌蚪| 日韩欧美资源站| 国产欧美一区二区三区沐欲| 亚洲精品国久久99热| 午夜欧美电影在线观看| 国产久卡久卡久卡久卡视频精品| 成人黄色777网| 欧美精选一区二区| 久久久久九九视频| 亚洲一区二区三区自拍| 激情都市一区二区| 91传媒视频在线播放| 日韩欧美高清dvd碟片| 国产精品伦理在线| 人人爽香蕉精品| eeuss影院一区二区三区| 欧美精品免费视频| 亚洲欧美在线观看| 蜜臀av国产精品久久久久| 99久久777色| 欧美v日韩v国产v| 亚洲精品成人a在线观看| 久久国产精品免费| 欧美在线短视频| 国产精品日产欧美久久久久| 日韩中文字幕1| 成人网在线免费视频| 欧美一卡2卡三卡4卡5免费| 国产精品福利av| 久久国产精品色婷婷| 在线观看av一区| 国产精品三级在线观看| 人人精品人人爱| 欧美性xxxxxx少妇| 国产精品免费aⅴ片在线观看| 免费久久99精品国产| 欧美主播一区二区三区美女| 国产精品久久夜| 国产美女一区二区| 欧美久久久一区| 一区二区在线观看不卡| 国产传媒一区在线| 欧美mv日韩mv国产网站app| 亚洲二区视频在线| 色婷婷综合久色| 国产精品欧美久久久久无广告| 精东粉嫩av免费一区二区三区| 欧美挠脚心视频网站| 亚洲精品视频免费看| 99视频一区二区| 国产精品美女一区二区| 国产精品77777| 久久综合色播五月| 美女视频第一区二区三区免费观看网站| 日本精品免费观看高清观看| 国产精品久久久久精k8| 国产不卡视频在线播放| 久久综合色一综合色88| 国内一区二区在线| 欧美精品一区二区不卡| 久久精品国产精品青草| 日韩一区二区精品葵司在线| 日韩 欧美一区二区三区| 88在线观看91蜜桃国自产| 亚洲综合免费观看高清完整版| 91小视频在线| 一个色在线综合| 日本韩国一区二区三区| 一区二区不卡在线播放 | 久久综合九色综合97婷婷女人| 视频一区二区三区入口| 欧美精品久久一区| 日韩av中文字幕一区二区三区| 8v天堂国产在线一区二区| 午夜精品一区二区三区电影天堂 | 亚洲综合在线五月| 91高清视频在线| 亚洲亚洲精品在线观看| 欧美三级在线视频| 五月综合激情婷婷六月色窝| 欧美日韩一区二区三区不卡| 婷婷中文字幕一区三区| 日韩欧美激情在线| 国产在线不卡一区| 日本一区二区免费在线观看视频 | 亚洲欧美日韩电影| 在线观看视频欧美| 日本不卡视频在线| 精品美女一区二区三区| 国产成人av电影在线| 国产精品久久久久久久久久免费看| 成人高清免费在线播放| 亚洲乱码中文字幕| 欧美日韩精品系列| 精品一区二区三区在线观看国产| 久久女同精品一区二区| av亚洲精华国产精华精| 亚洲国产精品久久一线不卡| 欧美一级日韩一级| 国产成人综合视频| 亚洲卡通欧美制服中文| 337p亚洲精品色噜噜噜| 国产精品一区二区果冻传媒| 国产精品成人在线观看| 欧美日韩国产首页| 国产在线播放一区三区四| 18成人在线视频| 91精品国产综合久久久久久 | 国产婷婷色一区二区三区| 99v久久综合狠狠综合久久| 亚洲成人精品一区二区| 精品国产麻豆免费人成网站| 99久久免费国产| 日产国产欧美视频一区精品| 久久精品人人爽人人爽| 欧美日韩在线播放一区| 国内久久婷婷综合| 亚洲小说欧美激情另类| 久久久一区二区三区| 在线视频国内一区二区| 国产主播一区二区三区| 依依成人综合视频| 国产亚洲欧洲997久久综合| 欧美主播一区二区三区| 国产成人精品影院| 视频一区免费在线观看| 国产精品久久久久7777按摩| 91精品国产综合久久久蜜臀图片| 北岛玲一区二区三区四区| 秋霞成人午夜伦在线观看| 成人欧美一区二区三区小说 | 国产在线精品不卡| 亚洲一区二区视频在线| 国产欧美精品区一区二区三区 | 久久国产精品一区二区| 亚洲欧美另类久久久精品2019| 日韩精品中文字幕一区| 一本大道av伊人久久综合| 韩国毛片一区二区三区| 亚洲国产精品视频| 综合色中文字幕| 久久久天堂av| 日韩欧美中文字幕精品| 欧美怡红院视频| 成人性生交大片免费看视频在线| 日本最新不卡在线| 亚洲午夜一区二区| 亚洲欧美日韩中文播放| 欧美国产精品劲爆| 精品久久久久久无| 制服丝袜av成人在线看| 日本高清不卡在线观看| 成人永久看片免费视频天堂| 久久国产精品无码网站| 国产亚洲综合在线| 精品国产三级电影在线观看| 51精品久久久久久久蜜臀| 色婷婷综合久久久久中文一区二区| 国产成人午夜片在线观看高清观看| 免费成人小视频| 日韩黄色免费网站| 亚洲香蕉伊在人在线观| 亚洲狼人国产精品| 亚洲你懂的在线视频| 中文字幕一区二区三区在线播放| www国产亚洲精品久久麻豆| 欧美xfplay| 91精品国产91综合久久蜜臀| 欧美午夜影院一区| 欧洲在线/亚洲| 欧美在线视频全部完| 99久久综合精品| 成+人+亚洲+综合天堂| 高清视频一区二区| 国产成人免费高清| 国产传媒欧美日韩成人| 国产不卡高清在线观看视频| 国产69精品久久777的优势| 国产成人av一区二区| 国产白丝网站精品污在线入口 | 中文字幕欧美区| 国产欧美日韩麻豆91| 中文字幕精品综合| 国产精品九色蝌蚪自拍| 中文字幕一区二区三区不卡| 中文字幕亚洲一区二区av在线| 国产精品久久免费看| 日韩理论片网站| 一区二区视频在线看| 亚洲午夜久久久久久久久电影院 | 91国内精品野花午夜精品| 色88888久久久久久影院按摩| 色噜噜狠狠一区二区三区果冻| 欧美在线免费观看视频| 在线观看91av| 久久久影院官网| 中文字幕视频一区| 亚洲综合色网站| 免费观看成人鲁鲁鲁鲁鲁视频|