您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CMOS_READ函数代码示例

51自学网 2021-06-01 20:02:48
  C++
这篇教程C++ CMOS_READ函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CMOS_READ函数的典型用法代码示例。如果您正苦于以下问题:C++ CMOS_READ函数的具体用法?C++ CMOS_READ怎么用?C++ CMOS_READ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CMOS_READ函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dec_timer_state

static int dec_timer_state(void){	return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0;}
开发者ID:12019,项目名称:hg556a_source,代码行数:4,


示例2: cmos_read_alarm

static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t){	struct cmos_rtc	*cmos = dev_get_drvdata(dev);	unsigned char	rtc_control;	if (!is_valid_irq(cmos->irq))		return -EIO;	/* Basic alarms only support hour, minute, and seconds fields.	 * Some also support day and month, for alarms up to a year in	 * the future.	 */	t->time.tm_mday = -1;	t->time.tm_mon = -1;	spin_lock_irq(&rtc_lock);	t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);	t->time.tm_min = CMOS_READ(RTC_MINUTES_ALARM);	t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);	if (cmos->day_alrm) {		/* ignore upper bits on readback per ACPI spec */		t->time.tm_mday = CMOS_READ(cmos->day_alrm) & 0x3f;		if (!t->time.tm_mday)			t->time.tm_mday = -1;		if (cmos->mon_alrm) {			t->time.tm_mon = CMOS_READ(cmos->mon_alrm);			if (!t->time.tm_mon)				t->time.tm_mon = -1;		}	}	rtc_control = CMOS_READ(RTC_CONTROL);	spin_unlock_irq(&rtc_lock);	/* REVISIT this assumes PC style usage:  always BCD */	if (((unsigned)t->time.tm_sec) < 0x60)		t->time.tm_sec = bcd2bin(t->time.tm_sec);	else		t->time.tm_sec = -1;	if (((unsigned)t->time.tm_min) < 0x60)		t->time.tm_min = bcd2bin(t->time.tm_min);	else		t->time.tm_min = -1;	if (((unsigned)t->time.tm_hour) < 0x24)		t->time.tm_hour = bcd2bin(t->time.tm_hour);	else		t->time.tm_hour = -1;	if (cmos->day_alrm) {		if (((unsigned)t->time.tm_mday) <= 0x31)			t->time.tm_mday = bcd2bin(t->time.tm_mday);		else			t->time.tm_mday = -1;		if (cmos->mon_alrm) {			if (((unsigned)t->time.tm_mon) <= 0x12)				t->time.tm_mon = bcd2bin(t->time.tm_mon) - 1;			else				t->time.tm_mon = -1;		}	}	t->time.tm_year = -1;	t->enabled = !!(rtc_control & RTC_AIE);	t->pending = 0;	return 0;}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:70,


示例3: get_isa_cmos_time

static unsigned long __init get_isa_cmos_time(void){	unsigned int year, mon, day, hour, min, sec;	int i;	// check to see if the RTC makes sense.....	if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)		return mktime(1970, 1, 1, 0, 0, 0);	/* The Linux interpretation of the CMOS clock register contents:	 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the	 * RTC registers show the second which has precisely just started.	 * Let's hope other operating systems interpret the RTC the same way.	 */	/* read RTC exactly on falling edge of update flag */	for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */		if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)			break;	for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */		if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))			break;	do { /* Isn't this overkill ? UIP above should guarantee consistency */		sec  = CMOS_READ(RTC_SECONDS);		min  = CMOS_READ(RTC_MINUTES);		hour = CMOS_READ(RTC_HOURS);		day  = CMOS_READ(RTC_DAY_OF_MONTH);		mon  = CMOS_READ(RTC_MONTH);		year = CMOS_READ(RTC_YEAR);	} while (sec != CMOS_READ(RTC_SECONDS));	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		BCD_TO_BIN(sec);		BCD_TO_BIN(min);		BCD_TO_BIN(hour);		BCD_TO_BIN(day);		BCD_TO_BIN(mon);		BCD_TO_BIN(year);	}	if ((year += 1900) < 1970)		year += 100;	return mktime(year, mon, day, hour, min, sec);}
开发者ID:12019,项目名称:hg556a_source,代码行数:44,


示例4: sm_osl_proc_read_alarm

static intsm_osl_proc_read_alarm (	char                    *page,	char                    **start,	off_t                   off,	int                     count,	int                     *eof,	void                    *context){	char *str = page;	int len;	u32 sec,min,hr;	u32 day,mo,yr;	if (off != 0) goto out;	spin_lock(&rtc_lock);	sec = CMOS_READ(RTC_SECONDS_ALARM);	min = CMOS_READ(RTC_MINUTES_ALARM);	hr = CMOS_READ(RTC_HOURS_ALARM);#if 0	/* if I ever get an FACP with proper values, maybe I'll enable this code */	if (acpi_gbl_FADT->day_alrm)		day = CMOS_READ(acpi_gbl_FADT->day_alrm);	else		day =  CMOS_READ(RTC_DAY_OF_MONTH);	if (acpi_gbl_FADT->mon_alrm)		mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);	else		mo = CMOS_READ(RTC_MONTH);;	if (acpi_gbl_FADT->century)		yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR);	else		yr = CMOS_READ(RTC_YEAR);#else	day = CMOS_READ(RTC_DAY_OF_MONTH);	mo = CMOS_READ(RTC_MONTH);	yr = CMOS_READ(RTC_YEAR);#endif	spin_unlock(&rtc_lock);	BCD_TO_BIN(sec);	BCD_TO_BIN(min);	BCD_TO_BIN(hr);	BCD_TO_BIN(day);	BCD_TO_BIN(mo);	BCD_TO_BIN(yr);	str += sprintf(str,"%4.4u-",yr);	str += (mo > 12) ?		sprintf(str,"**-") :		sprintf(str,"%2.2u-",mo);	str += (day > 31) ?		sprintf(str,"** ") :		sprintf(str,"%2.2u ",day);	str += (hr > 23) ?		sprintf(str,"**:") :		sprintf(str,"%2.2u:",hr);	str += (min > 59) ?		sprintf(str,"**:") :		sprintf(str,"%2.2u:",min);	str += (sec > 59) ?		sprintf(str,"**/n") :		sprintf(str,"%2.2u/n",sec); out:	len = str - page;	if (len < count) *eof = 1;	else if (len > count) len = count;	if (len < 0) len = 0;	*start = page;	return len;}
开发者ID:huangyukun2012,项目名称:linux-2.4.21,代码行数:83,


示例5: rtc_ioctl

//.........这里部分代码省略.........		return 0;	}#endif	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.		 */		memset(&wtime, 0, sizeof(struct rtc_time));		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;		spin_lock_irq(&rtc_lock);		if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||		    RTC_ALWAYS_BCD)		{			if (sec < 60) BIN_TO_BCD(sec);			else sec = 0xff;			if (min < 60) BIN_TO_BCD(min);			else min = 0xff;			if (hrs < 24) BIN_TO_BCD(hrs);			else hrs = 0xff;		}		CMOS_WRITE(hrs, RTC_HOURS_ALARM);		CMOS_WRITE(min, RTC_MINUTES_ALARM);		CMOS_WRITE(sec, RTC_SECONDS_ALARM);		spin_unlock_irq(&rtc_lock);		return 0;	}	case RTC_RD_TIME:	/* Read the time/date from RTC	*/	{		memset(&wtime, 0, sizeof(struct rtc_time));		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;#ifdef CONFIG_DECSTATION		unsigned int real_yrs;
开发者ID:iPodLinux,项目名称:linux-2.4.24-ipod,代码行数:67,


示例6: rtc_proc_output

static int rtc_proc_output (char *buf){#define YN(bit) ((ctrl & bit) ? "yes" : "no")#define NY(bit) ((ctrl & bit) ? "no" : "yes")	char *p;	struct rtc_time tm;	unsigned char batt, ctrl;	unsigned long freq;	spin_lock_irq(&rtc_lock);	batt = CMOS_READ(RTC_VALID) & RTC_VRT;	ctrl = CMOS_READ(RTC_CONTROL);	freq = rtc_freq;	spin_unlock_irq(&rtc_lock);	p = buf;	get_rtc_time(&tm);	/*	 * There is no way to tell if the luser has the RTC set for local	 * time or for Universal Standard Time (GMT). Probably local though.	 */	p += sprintf(p,		     "rtc_time/t: %02d:%02d:%02d/n"		     "rtc_date/t: %04d-%02d-%02d/n"	 	     "rtc_epoch/t: %04lu/n",		     tm.tm_hour, tm.tm_min, tm.tm_sec,		     tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch);	get_rtc_alm_time(&tm);	/*	 * We implicitly assume 24hr mode here. Alarm values >= 0xc0 will	 * match any value for that particular field. Values that are	 * greater than a valid time, but less than 0xc0 shouldn't appear.	 */	p += sprintf(p, "alarm/t/t: ");	if (tm.tm_hour <= 24)		p += sprintf(p, "%02d:", tm.tm_hour);	else		p += sprintf(p, "**:");	if (tm.tm_min <= 59)		p += sprintf(p, "%02d:", tm.tm_min);	else		p += sprintf(p, "**:");	if (tm.tm_sec <= 59)		p += sprintf(p, "%02d/n", tm.tm_sec);	else		p += sprintf(p, "**/n");	p += sprintf(p,		     "DST_enable/t: %s/n"		     "BCD/t/t: %s/n"		     "24hr/t/t: %s/n"		     "square_wave/t: %s/n"		     "alarm_IRQ/t: %s/n"		     "update_IRQ/t: %s/n"		     "periodic_IRQ/t: %s/n"		     "periodic_freq/t: %ld/n"		     "batt_status/t: %s/n",		     YN(RTC_DST_EN),		     NY(RTC_DM_BINARY),		     YN(RTC_24H),		     YN(RTC_SQWE),		     YN(RTC_AIE),		     YN(RTC_UIE),		     YN(RTC_PIE),		     freq,		     batt ? "okay" : "dead");	return  p - buf;#undef YN#undef NY}
开发者ID:iPodLinux,项目名称:linux-2.4.24-ipod,代码行数:77,


示例7: acpi_system_alarm_seq_show

static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset){	u32			sec, min, hr;	u32			day, mo, yr;	ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");	spin_lock(&rtc_lock);	sec = CMOS_READ(RTC_SECONDS_ALARM);	min = CMOS_READ(RTC_MINUTES_ALARM);	hr = CMOS_READ(RTC_HOURS_ALARM);#if 0	/* If we ever get an FACP with proper values... */	if (acpi_gbl_FADT->day_alrm)		day = CMOS_READ(acpi_gbl_FADT->day_alrm);	else		day =  CMOS_READ(RTC_DAY_OF_MONTH);	if (acpi_gbl_FADT->mon_alrm)		mo = CMOS_READ(acpi_gbl_FADT->mon_alrm);	else		mo = CMOS_READ(RTC_MONTH);	if (acpi_gbl_FADT->century)		yr = CMOS_READ(acpi_gbl_FADT->century) * 100 + CMOS_READ(RTC_YEAR);	else		yr = CMOS_READ(RTC_YEAR);#else	day = CMOS_READ(RTC_DAY_OF_MONTH);	mo = CMOS_READ(RTC_MONTH);	yr = CMOS_READ(RTC_YEAR);#endif	spin_unlock(&rtc_lock);	BCD_TO_BIN(sec);	BCD_TO_BIN(min);	BCD_TO_BIN(hr);	BCD_TO_BIN(day);	BCD_TO_BIN(mo);	BCD_TO_BIN(yr);#if 0	/* we're trusting the FADT (see above)*/#else	/* If we're not trusting the FADT, we should at least make it	 * right for _this_ century... ehm, what is _this_ century?	 *	 * TBD:	 *  ASAP: find piece of code in the kernel, e.g. star tracker driver,	 *        which we can trust to determine the century correctly. Atom	 *        watch driver would be nice, too...	 *	 *  if that has not happened, change for first release in 2050: 	 *        if (yr<50)	 *                yr += 2100;	 *        else	 *                yr += 2000;   // current line of code	 *	 *  if that has not happened either, please do on 2099/12/31:23:59:59	 *        s/2000/2100	 *	 */	yr += 2000;#endif	seq_printf(seq,"%4.4u-", yr);	(mo > 12)  ? seq_puts(seq, "**-")  : seq_printf(seq, "%2.2u-", mo);	(day > 31) ? seq_puts(seq, "** ")  : seq_printf(seq, "%2.2u ", day);	(hr > 23)  ? seq_puts(seq, "**:")  : seq_printf(seq, "%2.2u:", hr);	(min > 59) ? seq_puts(seq, "**:")  : seq_printf(seq, "%2.2u:", min);	(sec > 59) ? seq_puts(seq, "**/n") : seq_printf(seq, "%2.2u/n", sec);	return 0;}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:74,


示例8: hd_init

static int __init hd_init(void){	int drive;	if (register_blkdev(MAJOR_NR,"hd"))		return -1;	hd_queue = blk_init_queue(do_hd_request, &hd_lock);	if (!hd_queue) {		unregister_blkdev(MAJOR_NR,"hd");		return -ENOMEM;	}	blk_queue_max_sectors(hd_queue, 255);	init_timer(&device_timer);	device_timer.function = hd_times_out;	blk_queue_hardsect_size(hd_queue, 512);#ifdef __i386__	if (!NR_HD) {		extern struct drive_info drive_info;		unsigned char *BIOS = (unsigned char *) &drive_info;		unsigned long flags;		int cmos_disks;		for (drive=0 ; drive<2 ; drive++) {			hd_info[drive].cyl = *(unsigned short *) BIOS;			hd_info[drive].head = *(2+BIOS);			hd_info[drive].wpcom = *(unsigned short *) (5+BIOS);			hd_info[drive].ctl = *(8+BIOS);			hd_info[drive].lzone = *(unsigned short *) (12+BIOS);			hd_info[drive].sect = *(14+BIOS);#ifdef does_not_work_for_everybody_with_scsi_but_helps_ibm_vp			if (hd_info[drive].cyl && NR_HD == drive)				NR_HD++;#endif			BIOS += 16;		}	/*		We query CMOS about hard disks : it could be that 		we have a SCSI/ESDI/etc controller that is BIOS		compatible with ST-506, and thus showing up in our		BIOS table, but not register compatible, and therefore		not present in CMOS.		Furthermore, we will assume that our ST-506 drives		<if any> are the primary drives in the system, and 		the ones reflected as drive 1 or 2.		The first drive is stored in the high nibble of CMOS		byte 0x12, the second in the low nibble.  This will be		either a 4 bit drive type or 0xf indicating use byte 0x19 		for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS.		Needless to say, a non-zero value means we have 		an AT controller hard disk for that drive.		Currently the rtc_lock is a bit academic since this		driver is non-modular, but someday... ?         Paul G.	*/		spin_lock_irqsave(&rtc_lock, flags);		cmos_disks = CMOS_READ(0x12);		spin_unlock_irqrestore(&rtc_lock, flags);		if (cmos_disks & 0xf0) {			if (cmos_disks & 0x0f)				NR_HD = 2;			else				NR_HD = 1;		}	}#endif /* __i386__ */#ifdef __arm__	if (!NR_HD) {		/* We don't know anything about the drive.  This means		 * that you *MUST* specify the drive parameters to the		 * kernel yourself.		 */		printk("hd: no drives specified - use hd=cyl,head,sectors"			" on kernel command line/n");	}#endif	if (!NR_HD)		goto out;	for (drive=0 ; drive < NR_HD ; drive++) {		struct gendisk *disk = alloc_disk(64);		struct hd_i_struct *p = &hd_info[drive];		if (!disk)			goto Enomem;		disk->major = MAJOR_NR;		disk->first_minor = drive << 6;		disk->fops = &hd_fops;		sprintf(disk->disk_name, "hd%c", 'a'+drive);		disk->private_data = p;		set_capacity(disk, p->head * p->sect * p->cyl);		disk->queue = hd_queue;		p->unit = drive;//.........这里部分代码省略.........
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:101,


示例9: date

void date(){	int year=2012;	printf("/n %d - %s - %d/n",CMOS_READ(7),month[CMOS_READ(8)-1],year);      }
开发者ID:BlueEarth,项目名称:Coldwave-OS,代码行数:6,


示例10: ds1287_timer_state

int ds1287_timer_state(void){	return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:4,


示例11: dayOfWeek

void dayOfWeek() {      printf("/n %s /n", day[CMOS_READ(6)-1]); 		        } 
开发者ID:BlueEarth,项目名称:Coldwave-OS,代码行数:5,


示例12: dec_rtc_get_time

static unsigned long dec_rtc_get_time(void){	unsigned int year, mon, day, hour, min, sec, real_year;	int i;	/* The Linux interpretation of the DS1287 clock register contents:	 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the	 * RTC registers show the second which has precisely just started.	 * Let's hope other operating systems interpret the RTC the same way.	 */	/* read RTC exactly on falling edge of update flag */	for (i = 0; i < 1000000; i++)	/* may take up to 1 second... */		if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)			break;	for (i = 0; i < 1000000; i++)	/* must try at least 2.228 ms */		if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))			break;	/* Isn't this overkill?  UIP above should guarantee consistency */	do {		sec = CMOS_READ(RTC_SECONDS);		min = CMOS_READ(RTC_MINUTES);		hour = CMOS_READ(RTC_HOURS);		day = CMOS_READ(RTC_DAY_OF_MONTH);		mon = CMOS_READ(RTC_MONTH);		year = CMOS_READ(RTC_YEAR);	} while (sec != CMOS_READ(RTC_SECONDS));	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		sec = BCD2BIN(sec);		min = BCD2BIN(min);		hour = BCD2BIN(hour);		day = BCD2BIN(day);		mon = BCD2BIN(mon);		year = BCD2BIN(year);	}	/*	 * The PROM will reset the year to either '72 or '73.	 * Therefore we store the real year separately, in one	 * of unused BBU RAM locations.	 */	real_year = CMOS_READ(RTC_DEC_YEAR);	year += real_year - 72 + 2000;	return mktime(year, mon, day, hour, min, sec);}
开发者ID:12019,项目名称:hg556a_source,代码行数:44,


示例13: dec_timer_ack

static void dec_timer_ack(void){	CMOS_READ(RTC_REG_C);			/* Ack the RTC interrupt.  */}
开发者ID:12019,项目名称:hg556a_source,代码行数:4,


示例14: acpi_system_write_alarm

static intacpi_system_write_alarm (	struct file		*file,	const char		*buffer,	unsigned long		count,	void			*data){	int			result = 0;	char			alarm_string[30] = {'/0'};	char			*p = alarm_string;	u32			sec, min, hr, day, mo, yr;	int			adjust = 0;	unsigned char		rtc_control = 0;	ACPI_FUNCTION_TRACE("acpi_system_write_alarm");	if (count > sizeof(alarm_string) - 1)		return_VALUE(-EINVAL);		if (copy_from_user(alarm_string, buffer, count))		return_VALUE(-EFAULT);	alarm_string[count] = '/0';	/* check for time adjustment */	if (alarm_string[0] == '+') {		p++;		adjust = 1;	}	if ((result = get_date_field(&p, &yr)))		goto end;	if ((result = get_date_field(&p, &mo)))		goto end;	if ((result = get_date_field(&p, &day)))		goto end;	if ((result = get_date_field(&p, &hr)))		goto end;	if ((result = get_date_field(&p, &min)))		goto end;	if ((result = get_date_field(&p, &sec)))		goto end;	if (sec > 59) {		min += 1;		sec -= 60;	}	if (min > 59) {		hr += 1;		min -= 60;	}	if (hr > 23) {		day += 1;		hr -= 24;	}	if (day > 31) {		mo += 1;		day -= 31;	}	if (mo > 12) {		yr += 1;		mo -= 12;	}	spin_lock_irq(&rtc_lock);	rtc_control = CMOS_READ(RTC_CONTROL);	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		BIN_TO_BCD(yr);		BIN_TO_BCD(mo);		BIN_TO_BCD(day);		BIN_TO_BCD(hr);		BIN_TO_BCD(min);		BIN_TO_BCD(sec);	}	if (adjust) {		yr  += CMOS_READ(RTC_YEAR);		mo  += CMOS_READ(RTC_MONTH);		day += CMOS_READ(RTC_DAY_OF_MONTH);		hr  += CMOS_READ(RTC_HOURS);		min += CMOS_READ(RTC_MINUTES);		sec += CMOS_READ(RTC_SECONDS);	}	spin_unlock_irq(&rtc_lock);	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		BCD_TO_BIN(yr);		BCD_TO_BIN(mo);		BCD_TO_BIN(day);		BCD_TO_BIN(hr);		BCD_TO_BIN(min);		BCD_TO_BIN(sec);	}	if (sec > 59) {		min++;		sec -= 60;	}//.........这里部分代码省略.........
开发者ID:NieHao,项目名称:Tomato-RAF,代码行数:101,


示例15: cmos_do_probe

static int INITSECTIONcmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq){	struct cmos_rtc_board_info	*info = dev->platform_data;	int				retval = 0;	unsigned char			rtc_control;	/* there can be only one ... */	if (cmos_rtc.dev)		return -EBUSY;	if (!ports)		return -ENODEV;	cmos_rtc.irq = rtc_irq;	cmos_rtc.iomem = ports;	/* For ACPI systems extension info comes from the FADT.  On others,	 * board specific setup provides it as appropriate.  Systems where	 * the alarm IRQ isn't automatically a wakeup IRQ (like ACPI, and	 * some almost-clones) can provide hooks to make that behave.	 */	if (info) {		cmos_rtc.day_alrm = info->rtc_day_alarm;		cmos_rtc.mon_alrm = info->rtc_mon_alarm;		cmos_rtc.century = info->rtc_century;		if (info->wake_on && info->wake_off) {			cmos_rtc.wake_on = info->wake_on;			cmos_rtc.wake_off = info->wake_off;		}	}	cmos_rtc.rtc = rtc_device_register(driver_name, dev,				&cmos_rtc_ops, THIS_MODULE);	if (IS_ERR(cmos_rtc.rtc))		return PTR_ERR(cmos_rtc.rtc);	cmos_rtc.dev = dev;	dev_set_drvdata(dev, &cmos_rtc);	/* platform and pnp busses handle resources incompatibly.	 *	 * REVISIT for non-x86 systems we may need to handle io memory	 * resources: ioremap them, and request_mem_region().	 */	if (is_pnp()) {		retval = request_resource(&ioport_resource, ports);		if (retval < 0) {			dev_dbg(dev, "i/o registers already in use/n");			goto cleanup0;		}	}	rename_region(ports, cmos_rtc.rtc->dev.bus_id);#ifdef CONFIG_ARCH_GEN3        /* MOSAIC WORKAROUND         * some of our boxes shipped with unexpected CMOS RTC mode bits         * if this is detected, reset the RTC to a known point         */	spin_lock_irq(&rtc_lock);	rtc_control = CMOS_READ(RTC_CONTROL);        if (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY))) {                struct rtc_time t;                printk(KERN_INFO "Fixing bogus CMOS RTC mode/n");                rtc_control |= RTC_24H;                rtc_control &= ~RTC_DM_BINARY;                CMOS_WRITE(rtc_control, RTC_CONTROL);                memset(&t, 0, sizeof(t));                t.tm_mday = 1;                t.tm_year = 109;                spin_unlock_irq(&rtc_lock);                set_rtc_time(&t);        } else {                spin_unlock_irq(&rtc_lock);        }#endif	spin_lock_irq(&rtc_lock);	/* force periodic irq to CMOS reset default of 1024Hz;	 *	 * REVISIT it's been reported that at least one x86_64 ALI mobo	 * doesn't use 32KHz here ... for portability we might need to	 * do something about other clock frequencies.	 */	CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);	cmos_rtc.rtc->irq_freq = 1024;	/* disable irqs.	 *	 * NOTE after changing RTC_xIE bits we always read INTR_FLAGS;	 * allegedly some older rtcs need that to handle irqs properly	 */	rtc_control = CMOS_READ(RTC_CONTROL);	rtc_control &= ~(RTC_PIE | RTC_AIE | RTC_UIE);	CMOS_WRITE(rtc_control, RTC_CONTROL);	CMOS_READ(RTC_INTR_FLAGS);//.........这里部分代码省略.........
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:101,


示例16: get_rtc_time

static void get_rtc_time(struct rtc_time *rtc_tm){	unsigned long uip_watchdog = jiffies;	unsigned char ctrl;#ifdef CONFIG_DECSTATION	unsigned int real_year;#endif	/*	 * read RTC once any update in progress is done. The update	 * can take just over 2ms. We wait 10 to 20ms. There is no need to	 * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.	 * If you need to know *exactly* when a second has started, enable	 * periodic update complete interrupts, (via ioctl) and then 	 * immediately read /dev/rtc which will block until you get the IRQ.	 * Once the read clears, read the RTC time (again via ioctl). Easy.	 */	if (rtc_is_updating() != 0)		while (jiffies - uip_watchdog < 2*HZ/100) {			barrier();			cpu_relax();		}	/*	 * Only the values that we read from the RTC are set. We leave	 * tm_wday, tm_yday and tm_isdst untouched. Even though the	 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated	 * by the RTC when initially set to a non-zero value.	 */	spin_lock_irq(&rtc_lock);	rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);	rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);	rtc_tm->tm_hour = CMOS_READ(RTC_HOURS);	rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);	rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);	rtc_tm->tm_year = CMOS_READ(RTC_YEAR);#ifdef CONFIG_DECSTATION	real_year = CMOS_READ(RTC_DEC_YEAR);#endif	ctrl = CMOS_READ(RTC_CONTROL);	spin_unlock_irq(&rtc_lock);	if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)	{		BCD_TO_BIN(rtc_tm->tm_sec);		BCD_TO_BIN(rtc_tm->tm_min);		BCD_TO_BIN(rtc_tm->tm_hour);		BCD_TO_BIN(rtc_tm->tm_mday);		BCD_TO_BIN(rtc_tm->tm_mon);		BCD_TO_BIN(rtc_tm->tm_year);	}#ifdef CONFIG_DECSTATION	rtc_tm->tm_year += real_year - 72;#endif	/*	 * Account for differences between how the RTC uses the values	 * and how they are defined in a struct rtc_time;	 */	if ((rtc_tm->tm_year += (epoch - 1900)) <= 69)		rtc_tm->tm_year += 100;	rtc_tm->tm_mon--;}
开发者ID:iPodLinux,项目名称:linux-2.4.24-ipod,代码行数:66,


示例17: mach_set_rtc_mmss

/* * In order to set the CMOS clock precisely, set_rtc_mmss has to be * called 500 ms after the second nowtime has started, because when * nowtime is written into the registers of the CMOS clock, it will * jump to the next second precisely 500 ms later. Check the Motorola * MC146818A or Dallas DS12887 data sheet for details. * * BUG: This routine does not handle hour overflow properly; it just *      sets the minutes. Usually you'll only notice that after reboot! */int mach_set_rtc_mmss(unsigned long nowtime){	int real_seconds, real_minutes, cmos_minutes;	unsigned char save_control, save_freq_select;	unsigned long flags;	int retval = 0;	spin_lock_irqsave(&rtc_lock, flags);	 /* tell the clock it's being set */	save_control = CMOS_READ(RTC_CONTROL);	CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);	/* stop and reset prescaler */	save_freq_select = CMOS_READ(RTC_FREQ_SELECT);	CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);	cmos_minutes = CMOS_READ(RTC_MINUTES);	if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)		cmos_minutes = bcd2bin(cmos_minutes);	/*	 * since we're only adjusting minutes and seconds,	 * don't interfere with hour overflow. This avoids	 * messing with unknown time zones but requires your	 * RTC not to be off by more than 15 minutes	 */	real_seconds = nowtime % 60;	real_minutes = nowtime / 60;	/* correct for half hour time zone */	if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)		real_minutes += 30;	real_minutes %= 60;	if (abs(real_minutes - cmos_minutes) < 30) {		if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {			real_seconds = bin2bcd(real_seconds);			real_minutes = bin2bcd(real_minutes);		}		CMOS_WRITE(real_seconds, RTC_SECONDS);		CMOS_WRITE(real_minutes, RTC_MINUTES);	} else {		printk_once(KERN_NOTICE		       "set_rtc_mmss: can't update from %d to %d/n",		       cmos_minutes, real_minutes);		retval = -1;	}	/* The following flags have to be released exactly in this order,	 * otherwise the DS12887 (popular MC146818A clone with integrated	 * battery and quartz) will not reset the oscillator and will not	 * update precisely 500 ms later. You won't find this mentioned in	 * the Dallas Semiconductor data sheets, but who believes data	 * sheets anyway ...                           -- Markus Kuhn	 */	CMOS_WRITE(save_control, RTC_CONTROL);	CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);	spin_unlock_irqrestore(&rtc_lock, flags);	return retval;}
开发者ID:AiWinters,项目名称:linux,代码行数:72,


示例18: rtc_init

static int __init rtc_init(void){#if defined(__alpha__) || defined(__mips__)	unsigned int year, ctrl;	unsigned long uip_watchdog;	char *guess = NULL;#endif#ifdef __sparc__	struct linux_ebus *ebus;	struct linux_ebus_device *edev;#ifdef __sparc_v9__	struct isa_bridge *isa_br;	struct isa_device *isa_dev;#endif#endif#ifdef __sparc__	for_each_ebus(ebus) {		for_each_ebusdev(edev, ebus) {			if(strcmp(edev->prom_name, "rtc") == 0) {				rtc_port = edev->resource[0].start;				rtc_irq = edev->irqs[0];				goto found;			}		}	}#ifdef __sparc_v9__	for_each_isa(isa_br) {		for_each_isadev(isa_dev, isa_br) {			if (strcmp(isa_dev->prom_name, "rtc") == 0) {				rtc_port = isa_dev->resource.start;				rtc_irq = isa_dev->irq;				goto found;			}		}	}#endif	printk(KERN_ERR "rtc_init: no PC rtc found/n");	return -EIO;found:	if (rtc_irq == PCI_IRQ_NONE) {		rtc_has_irq = 0;		goto no_irq;	}	/*	 * XXX Interrupt pin #7 in Espresso is shared between RTC and	 * PCI Slot 2 INTA# (and some INTx# in Slot 1). SA_INTERRUPT here	 * is asking for trouble with add-on boards. Change to SA_SHIRQ.	 */	if (request_irq(rtc_irq, rtc_interrupt, SA_INTERRUPT, "rtc", (void *)&rtc_port)) {		/*		 * Standard way for sparc to print irq's is to use		 * __irq_itoa(). I think for EBus it's ok to use %d.		 */		printk(KERN_ERR "rtc: cannot register IRQ %d/n", rtc_irq);		return -EIO;	}no_irq:#else	if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"))	{		printk(KERN_ERR "rtc: I/O port %d is not free./n", RTC_PORT (0));		return -EIO;	}#if RTC_IRQ	if(request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL))	{		/* Yeah right, seeing as irq 8 doesn't even hit the bus. */		printk(KERN_ERR "rtc: IRQ %d is not free./n", RTC_IRQ);		release_region(RTC_PORT(0), RTC_IO_EXTENT);		return -EIO;	}#endif#endif /* __sparc__ vs. others */	misc_register(&rtc_dev);	create_proc_read_entry ("driver/rtc", 0, 0, rtc_read_proc, NULL);#if defined(__alpha__) || defined(__mips__)	rtc_freq = HZ;		/* Each operating system on an Alpha uses its own epoch.	   Let's try to guess which one we are using now. */		uip_watchdog = jiffies;	if (rtc_is_updating() != 0)		while (jiffies - uip_watchdog < 2*HZ/100) { 			barrier();			cpu_relax();		}		spin_lock_irq(&rtc_lock);	year = CMOS_READ(RTC_YEAR);	ctrl = CMOS_READ(RTC_CONTROL);	spin_unlock_irq(&rtc_lock);	//.........这里部分代码省略.........
开发者ID:iPodLinux,项目名称:linux-2.4.24-ipod,代码行数:101,


示例19: cmos_set_alarm

static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t){	struct cmos_rtc	*cmos = dev_get_drvdata(dev);	unsigned char	mon, mday, hrs, min, sec;	unsigned char	rtc_control, rtc_intr;	if (!is_valid_irq(cmos->irq))		return -EIO;	/* REVISIT this assumes PC style usage:  always BCD */	/* Writing 0xff means "don't care" or "match all".  */	mon = t->time.tm_mon;	mon = (mon < 12) ? BIN2BCD(mon) : 0xff;	mon++;	mday = t->time.tm_mday;	mday = (mday >= 1 && mday <= 31) ? BIN2BCD(mday) : 0xff;	hrs = t->time.tm_hour;	hrs = (hrs < 24) ? BIN2BCD(hrs) : 0xff;	min = t->time.tm_min;	min = (min < 60) ? BIN2BCD(min) : 0xff;	sec = t->time.tm_sec;	sec = (sec < 60) ? BIN2BCD(sec) : 0xff;	spin_lock_irq(&rtc_lock);	/* next rtc irq must not be from previous alarm setting */	rtc_control = CMOS_READ(RTC_CONTROL);	rtc_control &= ~RTC_AIE;	CMOS_WRITE(rtc_control, RTC_CONTROL);	rtc_intr = CMOS_READ(RTC_INTR_FLAGS);	if (rtc_intr)		rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);	/* update alarm */	CMOS_WRITE(hrs, RTC_HOURS_ALARM);	CMOS_WRITE(min, RTC_MINUTES_ALARM);	CMOS_WRITE(sec, RTC_SECONDS_ALARM);	/* the system may support an "enhanced" alarm */	if (cmos->day_alrm) {		CMOS_WRITE(mday, cmos->day_alrm);		if (cmos->mon_alrm)			CMOS_WRITE(mon, cmos->mon_alrm);	}	if (t->enabled) {		rtc_control |= RTC_AIE;		CMOS_WRITE(rtc_control, RTC_CONTROL);		rtc_intr = CMOS_READ(RTC_INTR_FLAGS);		if (rtc_intr)			rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);	}	spin_unlock_irq(&rtc_lock);	return 0;}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:63,


示例20: footbridge_init_time

/* * Set up timer interrupt. */void __init footbridge_init_time(void){	if (machine_is_co285() ||	    machine_is_personal_server())		/*		 * Add-in 21285s shouldn't access the RTC		 */		rtc_base = 0;	else		rtc_base = 0x70;	if (rtc_base) {		int reg_d, reg_b;		/*		 * Probe for the RTC.		 */		reg_d = CMOS_READ(RTC_REG_D);		/*		 * make sure the divider is set		 */		CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);		/*		 * Set control reg B		 *   (24 hour mode, update enabled)		 */		reg_b = CMOS_READ(RTC_REG_B) & 0x7f;		reg_b |= 2;		CMOS_WRITE(reg_b, RTC_REG_B);		if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&		    CMOS_READ(RTC_REG_B) == reg_b) {			struct timespec tv;			/*			 * We have a RTC.  Check the battery			 */			if ((reg_d & 0x80) == 0)				printk(KERN_WARNING "RTC: *** warning: CMOS battery bad/n");			tv.tv_nsec = 0;			tv.tv_sec = get_isa_cmos_time();			do_settimeofday(&tv);			set_rtc = set_isa_cmos_time;		} else			rtc_base = 0;	}	if (machine_is_ebsa285() ||	    machine_is_co285() ||	    machine_is_personal_server()) {		gettimeoffset = timer1_gettimeoffset;		timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);		*CSR_TIMER1_CLR  = 0;		*CSR_TIMER1_LOAD = timer1_latch;		*CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;		footbridge_timer_irq.name = "Timer1 Timer Tick";		footbridge_timer_irq.handler = timer1_interrupt;				setup_irq(IRQ_TIMER1, &footbridge_timer_irq);	} else {		/* enable PIT timer */		/* set for periodic (4) and LSB/MSB write (0x30) */		outb(0x34, 0x43);		outb((mSEC_10_from_14/6) & 0xFF, 0x40);		outb((mSEC_10_from_14/6) >> 8, 0x40);		gettimeoffset = isa_gettimeoffset;		footbridge_timer_irq.name = "ISA Timer Tick";		footbridge_timer_irq.handler = isa_timer_interrupt;				setup_irq(IRQ_ISA_TIMER, &footbridge_timer_irq);	}}
开发者ID:12019,项目名称:hg556a_source,代码行数:84,


示例21: cmos_do_probe

static int INITSECTIONcmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq){	struct cmos_rtc_board_info	*info = dev->platform_data;	int				retval = 0;	unsigned char			rtc_control;	/* there can be only one ... */	if (cmos_rtc.dev)		return -EBUSY;	if (!ports)		return -ENODEV;	cmos_rtc.irq = rtc_irq;	cmos_rtc.iomem = ports;	/* For ACPI systems the info comes from the FADT.  On others,	 * board specific setup provides it as appropriate.	 */	if (info) {		cmos_rtc.day_alrm = info->rtc_day_alarm;		cmos_rtc.mon_alrm = info->rtc_mon_alarm;		cmos_rtc.century = info->rtc_century;	}	cmos_rtc.rtc = rtc_device_register(driver_name, dev,				&cmos_rtc_ops, THIS_MODULE);	if (IS_ERR(cmos_rtc.rtc))		return PTR_ERR(cmos_rtc.rtc);	cmos_rtc.dev = dev;	dev_set_drvdata(dev, &cmos_rtc);	/* platform and pnp busses handle resources incompatibly.	 *	 * REVISIT for non-x86 systems we may need to handle io memory	 * resources: ioremap them, and request_mem_region().	 */	if (is_pnpacpi()) {		retval = request_resource(&ioport_resource, ports);		if (retval < 0) {			dev_dbg(dev, "i/o registers already in use/n");			goto cleanup0;		}	}	rename_region(ports, cmos_rtc.rtc->class_dev.class_id);	spin_lock_irq(&rtc_lock);	/* force periodic irq to CMOS reset default of 1024Hz;	 *	 * REVISIT it's been reported that at least one x86_64 ALI mobo	 * doesn't use 32KHz here ... for portability we might need to	 * do something about other clock frequencies.	 */	CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);	cmos_rtc.rtc->irq_freq = 1024;	/* disable irqs.	 *	 * NOTE after changing RTC_xIE bits we always read INTR_FLAGS;	 * allegedly some older rtcs need that to handle irqs properly	 */	rtc_control = CMOS_READ(RTC_CONTROL);	rtc_control &= ~(RTC_PIE | RTC_AIE | RTC_UIE);	CMOS_WRITE(rtc_control, RTC_CONTROL);	CMOS_READ(RTC_INTR_FLAGS);	spin_unlock_irq(&rtc_lock);	/* FIXME teach the alarm code how to handle binary mode;	 * <asm-generic/rtc.h> doesn't know 12-hour mode either.	 */	if (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY))) {		dev_dbg(dev, "only 24-hr BCD mode supported/n");		retval = -ENXIO;		goto cleanup1;	}	if (is_valid_irq(rtc_irq))		retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,				cmos_rtc.rtc->class_dev.class_id,				&cmos_rtc.rtc->class_dev);	if (retval < 0) {		dev_dbg(dev, "IRQ %d is already in use/n", rtc_irq);		goto cleanup1;	}	/* REVISIT optionally make 50 or 114 bytes NVRAM available,	 * like rtc-ds1553, rtc-ds1742 ... this will often include	 * registers for century, and day/month alarm.	 */	pr_info("%s: alarms up to one %s%s/n",			cmos_rtc.rtc->class_dev.class_id,			is_valid_irq(rtc_irq)				?  (cmos_rtc.mon_alrm					? "year"					: (cmos_rtc.day_alrm//.........这里部分代码省略.........
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:101,


示例22: sys_setup

/* This may be used only once, enforced by 'static int callable' */int sys_setup(void * BIOS){	static int callable = 1;	int i,drive;	unsigned char cmos_disks;	struct partition *p;	struct buffer_head * bh;	if (!callable)		return -1;	callable = 0;#ifndef HD_TYPE	for (drive=0 ; drive<2 ; drive++) {		hd_info[drive].cyl = *(unsigned short *) BIOS;		hd_info[drive].head = *(unsigned char *) (2+BIOS);		hd_info[drive].wpcom = *(unsigned short *) (5+BIOS);		hd_info[drive].ctl = *(unsigned char *) (8+BIOS);		hd_info[drive].lzone = *(unsigned short *) (12+BIOS);		hd_info[drive].sect = *(unsigned char *) (14+BIOS);		BIOS += 16;	}	if (hd_info[1].cyl)		NR_HD=2;	else		NR_HD=1;#endif	for (i=0 ; i<NR_HD ; i++) {		hd[i*5].start_sect = 0;		hd[i*5].nr_sects = hd_info[i].head*				hd_info[i].sect*hd_info[i].cyl;	}	/*		We querry CMOS about hard disks : it could be that 		we have a SCSI/ESDI/etc controller that is BIOS		compatable with ST-506, and thus showing up in our		BIOS table, but not register compatable, and therefore		not present in CMOS.		Furthurmore, we will assume that our ST-506 drives		<if any> are the primary drives in the system, and 		the ones reflected as drive 1 or 2.		The first drive is stored in the high nibble of CMOS		byte 0x12, the second in the low nibble.  This will be		either a 4 bit drive type or 0xf indicating use byte 0x19 		for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS.		Needless to say, a non-zero value means we have 		an AT controller hard disk for that drive.			*/	if ((cmos_disks = CMOS_READ(0x12)) & 0xf0)		if (cmos_disks & 0x0f)			NR_HD = 2;		else			NR_HD = 1;	else		NR_HD = 0;	for (i = NR_HD ; i < 2 ; i++) {		hd[i*5].start_sect = 0;		hd[i*5].nr_sects = 0;	}	for (drive=0 ; drive<NR_HD ; drive++) {		if (!(bh = bread(0x300 + drive*5,0))) {			printk("Unable to read partition table of drive %d/n/r",				drive);			panic("");		}		if (bh->b_data[510] != 0x55 || (unsigned char)		    bh->b_data[511] != 0xAA) {			printk("Bad partition table on drive %d/n/r",drive);			panic("");		}		p = 0x1BE + (void *)bh->b_data;		for (i=1;i<5;i++,p++) {			hd[i+5*drive].start_sect = p->start_sect;			hd[i+5*drive].nr_sects = p->nr_sects;		}		brelse(bh);	}	if (NR_HD)		printk("Partition table%s ok./n/r",(NR_HD>1)?"s":"");	rd_load();	mount_root();	return (0);}
开发者ID:xh4n3,项目名称:study_kernel,代码行数:90,


示例23: rtc_ds1742_set_time

static intrtc_ds1742_set_time(unsigned long t){	struct rtc_time tm;	u8 year, month, day, hour, minute, second;	u8 cmos_year, cmos_month, cmos_day, cmos_hour, cmos_minute, cmos_second;	int cmos_century;	unsigned long flags;	spin_lock_irqsave(&rtc_lock, flags);	CMOS_WRITE(RTC_READ, RTC_CONTROL);	cmos_second = (u8)(CMOS_READ(RTC_SECONDS) & RTC_SECONDS_MASK);	cmos_minute = (u8)CMOS_READ(RTC_MINUTES);	cmos_hour = (u8)CMOS_READ(RTC_HOURS);	cmos_day = (u8)CMOS_READ(RTC_DATE);	cmos_month = (u8)CMOS_READ(RTC_MONTH);	cmos_year = (u8)CMOS_READ(RTC_YEAR);	cmos_century = CMOS_READ(RTC_CENTURY) & RTC_CENTURY_MASK;	CMOS_WRITE(RTC_WRITE, RTC_CONTROL);	/* convert */	to_tm(t, &tm);	/* check each field one by one */	year = BIN2BCD(tm.tm_year - EPOCH);	if (year != cmos_year) {		CMOS_WRITE(year,RTC_YEAR);	}	month = BIN2BCD(tm.tm_mon);	if (month != (cmos_month & 0x1f)) {		CMOS_WRITE((month & 0x1f) | (cmos_month & ~0x1f),RTC_MONTH);	}	day = BIN2BCD(tm.tm_mday);	if (day != cmos_day) {		CMOS_WRITE(day, RTC_DATE);	}	if (cmos_hour & 0x40) {		/* 12 hour format */		hour = 0x40;		if (tm.tm_hour > 12) {			hour |= 0x20 | (BIN2BCD(hour-12) & 0x1f);		} else {			hour |= BIN2BCD(tm.tm_hour);		}	} else {		/* 24 hour format */		hour = BIN2BCD(tm.tm_hour) & 0x3f;	}	if (hour != cmos_hour) CMOS_WRITE(hour, RTC_HOURS);	minute = BIN2BCD(tm.tm_min);	if (minute !=  cmos_minute) {		CMOS_WRITE(minute, RTC_MINUTES);	}	second = BIN2BCD(tm.tm_sec);	if (second !=  cmos_second) {		CMOS_WRITE(second & RTC_SECONDS_MASK,RTC_SECONDS);	}	/* RTC_CENTURY and RTC_CONTROL share same address... */	CMOS_WRITE(cmos_century, RTC_CONTROL);	spin_unlock_irqrestore(&rtc_lock, flags);	return 0;}
开发者ID:1x23,项目名称:unifi-gpl,代码行数:71,


示例24: sm_osl_proc_write_alarm

int sm_osl_proc_write_alarm (	struct file *file,	const char *buffer,	unsigned long count,	void *data){	char buf[30];	char *str = buf;	u32 sec,min,hr;	u32 day,mo,yr;	int adjust = 0;	unsigned char rtc_control;	int error = -EINVAL;	if (count > sizeof(buf) - 1) return -EINVAL;		if (copy_from_user(str,buffer,count)) return -EFAULT;	str[count] = '/0';	/* check for time adjustment */	if (str[0] == '+') {		str++;		adjust = 1;	}	if ((error = get_date_field(&str,&yr)))  goto out;	if ((error = get_date_field(&str,&mo)))  goto out;	if ((error = get_date_field(&str,&day))) goto out;	if ((error = get_date_field(&str,&hr)))  goto out;	if ((error = get_date_field(&str,&min))) goto out;	if ((error = get_date_field(&str,&sec))) goto out;	if (sec > 59) {		min += 1;		sec -= 60;	}	if (min > 59) {		hr += 1;		min -= 60;	} 	if (hr > 23) {		day += 1;		hr -= 24;	}	if (day > 31) { 		mo += 1;		day -= 31;	}	if (mo > 12) {		yr += 1;		mo -= 12;	}	spin_lock_irq(&rtc_lock);	rtc_control = CMOS_READ(RTC_CONTROL);	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		BIN_TO_BCD(yr);		BIN_TO_BCD(mo);		BIN_TO_BCD(day);		BIN_TO_BCD(hr);		BIN_TO_BCD(min);		BIN_TO_BCD(sec);	}	if (adjust) {		yr  += CMOS_READ(RTC_YEAR);		mo  += CMOS_READ(RTC_MONTH);		day += CMOS_READ(RTC_DAY_OF_MONTH);		hr  += CMOS_READ(RTC_HOURS);		min += CMOS_READ(RTC_MINUTES);		sec += CMOS_READ(RTC_SECONDS);	}	spin_unlock_irq(&rtc_lock);	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		BCD_TO_BIN(yr);		BCD_TO_BIN(mo);		BCD_TO_BIN(day);		BCD_TO_BIN(hr);		BCD_TO_BIN(min);		BCD_TO_BIN(sec);	}	if (sec > 59) {		min++;		sec -= 60;	}	if (min > 59) {		hr++;		min -= 60;	}	if (hr > 23) {		day++;		hr -= 24;	}	if (day > 31) {		mo++;		day -= 31;	}//.........这里部分代码省略.........
开发者ID:huangyukun2012,项目名称:linux-2.4.21,代码行数:101,


示例25: cmos_read_alarm

static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t){	struct cmos_rtc	*cmos = dev_get_drvdata(dev);	unsigned char	rtc_control;	if (!is_valid_irq(cmos->irq))		return -EIO;	t->time.tm_mday = -1;	t->time.tm_mon = -1;	spin_lock_irq(&rtc_lock);	t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);	t->time.tm_min = CMOS_READ(RTC_MINUTES_ALARM);	t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);	if (cmos->day_alrm) {				t->time.tm_mday = CMOS_READ(cmos->day_alrm) & 0x3f;		if (!t->time.tm_mday)			t->time.tm_mday = -1;		if (cmos->mon_alrm) {			t->time.tm_mon = CMOS_READ(cmos->mon_alrm);			if (!t->time.tm_mon)				t->time.tm_mon = -1;		}	}	rtc_control = CMOS_READ(RTC_CONTROL);	spin_unlock_irq(&rtc_lock);	if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {		if (((unsigned)t->time.tm_sec) < 0x60)			t->time.tm_sec = bcd2bin(t->time.tm_sec);		else			t->time.tm_sec = -1;		if (((unsigned)t->time.tm_min) < 0x60)			t->time.tm_min = bcd2bin(t->time.tm_min);		else			t->time.tm_min = -1;		if (((unsigned)t->time.tm_hour) < 0x24)			t->time.tm_hour = bcd2bin(t->time.tm_hour);		else			t->time.tm_hour = -1;		if (cmos->day_alrm) {			if (((unsigned)t->time.tm_mday) <= 0x31)				t->time.tm_mday = bcd2bin(t->time.tm_mday);			else				t->time.tm_mday = -1;			if (cmos->mon_alrm) {				if (((unsigned)t->time.tm_mon) <= 0x12)					t->time.tm_mon = bcd2bin(t->time.tm_mon)-1;				else					t->time.tm_mon = -1;			}		}	}	t->time.tm_year = -1;	t->enabled = !!(rtc_control & RTC_AIE);	t->pending = 0;	return 0;}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:67,


示例26: cmos_do_probe

static int INITSECTIONcmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq){	struct cmos_rtc_board_info	*info = dev->platform_data;	int				retval = 0;	unsigned char			rtc_control;	unsigned			address_space;	/* there can be only one ... */	if (cmos_rtc.dev)		return -EBUSY;	if (!ports)		return -ENODEV;	/* Claim I/O ports ASAP, minimizing conflict with legacy driver.	 *	 * REVISIT non-x86 systems may instead use memory space resources	 * (needing ioremap etc), not i/o space resources like this ...	 */	ports = request_region(ports->start,			ports->end + 1 - ports->start,			driver_name);	if (!ports) {		dev_dbg(dev, "i/o registers already in use/n");		return -EBUSY;	}	cmos_rtc.irq = rtc_irq;	cmos_rtc.iomem = ports;	/* Heuristic to deduce NVRAM size ... do what the legacy NVRAM	 * driver did, but don't reject unknown configs.   Old hardware	 * won't address 128 bytes.  Newer chips have multiple banks,	 * though they may not be listed in one I/O resource.	 */#if	defined(CONFIG_ATARI)	address_space = 64;#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__sparc__)	address_space = 128;#else#warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes.	address_space = 128;#endif	if (can_bank2 && ports->end > (ports->start + 1))		address_space = 256;	/* For ACPI systems extension info comes from the FADT.  On others,	 * board specific setup provides it as appropriate.  Systems where	 * the alarm IRQ isn't automatically a wakeup IRQ (like ACPI, and	 * some almost-clones) can provide hooks to make that behave.	 *	 * Note that ACPI doesn't preclude putting these registers into	 * "extended" areas of the chip, including some that we won't yet	 * expect CMOS_READ and friends to handle.	 */	if (info) {		if (info->rtc_day_alarm && info->rtc_day_alarm < 128)			cmos_rtc.day_alrm = info->rtc_day_alarm;		if (info->rtc_mon_alarm && info->rtc_mon_alarm < 128)			cmos_rtc.mon_alrm = info->rtc_mon_alarm;		if (info->rtc_century && info->rtc_century < 128)			cmos_rtc.century = info->rtc_century;		if (info->wake_on && info->wake_off) {			cmos_rtc.wake_on = info->wake_on;			cmos_rtc.wake_off = info->wake_off;		}	}	cmos_rtc.rtc = rtc_device_register(driver_name, dev,				&cmos_rtc_ops, THIS_MODULE);	if (IS_ERR(cmos_rtc.rtc)) {		retval = PTR_ERR(cmos_rtc.rtc);		goto cleanup0;	}	cmos_rtc.dev = dev;	dev_set_drvdata(dev, &cmos_rtc);	rename_region(ports, cmos_rtc.rtc->dev.bus_id);	spin_lock_irq(&rtc_lock);	/* force periodic irq to CMOS reset default of 1024Hz;	 *	 * REVISIT it's been reported that at least one x86_64 ALI mobo	 * doesn't use 32KHz here ... for portability we might need to	 * do something about other clock frequencies.	 */	cmos_rtc.rtc->irq_freq = 1024;	hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq);	CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);	/* disable irqs */	cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE);	rtc_control = CMOS_READ(RTC_CONTROL);	spin_unlock_irq(&rtc_lock);//.........这里部分代码省略.........
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:101,


示例27: cmos_do_probe

static int INITSECTIONcmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq){	struct cmos_rtc_board_info	*info = dev->platform_data;	int				retval = 0;	unsigned char			rtc_control;	unsigned			address_space;		if (cmos_rtc.dev)		return -EBUSY;	if (!ports)		return -ENODEV;	ports = request_region(ports->start,			resource_size(ports),			driver_name);	if (!ports) {		dev_dbg(dev, "i/o registers already in use/n");		return -EBUSY;	}	cmos_rtc.irq = rtc_irq;	cmos_rtc.iomem = ports;#if	defined(CONFIG_ATARI)	address_space = 64;#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /			|| defined(__sparc__) || defined(__mips__) /			|| defined(__powerpc__)	address_space = 128;#else#warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes.	address_space = 128;#endif	if (can_bank2 && ports->end > (ports->start + 1))		address_space = 256;	if (info) {		if (info->rtc_day_alarm && info->rtc_day_alarm < 128)			cmos_rtc.day_alrm = info->rtc_day_alarm;		if (info->rtc_mon_alarm && info->rtc_mon_alarm < 128)			cmos_rtc.mon_alrm = info->rtc_mon_alarm;		if (info->rtc_century && info->rtc_century < 128)			cmos_rtc.century = info->rtc_century;		if (info->wake_on && info->wake_off) {			cmos_rtc.wake_on = info->wake_on;			cmos_rtc.wake_off = info->wake_off;		}	}	cmos_rtc.dev = dev;	dev_set_drvdata(dev, &cmos_rtc);	cmos_rtc.rtc = rtc_device_register(driver_name, dev,				&cmos_rtc_ops, THIS_MODULE);	if (IS_ERR(cmos_rtc.rtc)) {		retval = PTR_ERR(cmos_rtc.rtc);		goto cleanup0;	}	rename_region(ports, dev_name(&cmos_rtc.rtc->dev));	spin_lock_irq(&rtc_lock);	cmos_rtc.rtc->irq_freq = 1024;	hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq);	CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);		cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE);	rtc_control = CMOS_READ(RTC_CONTROL);	spin_unlock_irq(&rtc_lock);       if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) {		dev_warn(dev, "only 24-hr supported/n");		retval = -ENXIO;		goto cleanup1;	}	if (is_valid_irq(rtc_irq)) {		irq_handler_t rtc_cmos_int_handler;		if (is_hpet_enabled()) {			int err;			rtc_cmos_int_handler = hpet_rtc_interrupt;			err = hpet_register_irq_handler(cmos_interrupt);			if (err != 0) {				printk(KERN_WARNING "hpet_register_irq_handler "						" failed in rtc_init().");				goto cleanup1;			}		} else			rtc_cmos_int_handler = cmos_interrupt;//.........这里部分代码省略.........
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:101,


示例28: mc146818_get_time

unsigned int mc146818_get_time(struct rtc_time *time){	unsigned char ctrl;	unsigned long flags;	unsigned char century = 0;#ifdef CONFIG_MACH_DECSTATION	unsigned int real_year;#endif	/*	 * read RTC once any update in progress is done. The update	 * can take just over 2ms. We wait 20ms. There is no need to	 * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.	 * If you need to know *exactly* when a second has started, enable	 * periodic update complete interrupts, (via ioctl) and then	 * immediately read /dev/rtc which will block until you get the IRQ.	 * Once the read clears, read the RTC time (again via ioctl). Easy.	 */	if (mc146818_is_updating())		mdelay(20);	/*	 * Only the values that we read from the RTC are set. We leave	 * tm_wday, tm_yday and tm_isdst untouched. Even though the	 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated	 * by the RTC when initially set to a non-zero value.	 */	spin_lock_irqsave(&rtc_lock, flags);	time->tm_sec = CMOS_READ(RTC_SECONDS);	time->tm_min = CMOS_READ(RTC_MINUTES);	time->tm_hour = CMOS_READ(RTC_HOURS);	time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);	time->tm_mon = CMOS_READ(RTC_MONTH);	time->tm_year = CMOS_READ(RTC_YEAR);#ifdef CONFIG_MACH_DECSTATION	real_year = CMOS_READ(RTC_DEC_YEAR);#endif#ifdef CONFIG_ACPI	if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&	    acpi_gbl_FADT.century)		century = CMOS_READ(acpi_gbl_FADT.century);#endif	ctrl = CMOS_READ(RTC_CONTROL);	spin_unlock_irqrestore(&rtc_lock, flags);	if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)	{		time->tm_sec = bcd2bin(time->tm_sec);		time->tm_min = bcd2bin(time->tm_min);		time->tm_hour = bcd2bin(time->tm_hour);		time->tm_mday = bcd2bin(time->tm_mday);		time->tm_mon = bcd2bin(time->tm_mon);		time->tm_year = bcd2bin(time->tm_year);		century = bcd2bin(century);	}#ifdef CONFIG_MACH_DECSTATION	time->tm_year += real_year - 72;#endif	if (century)		time->tm_year += (century - 19) * 100;	/*	 * Account for differences between how the RTC uses the values	 * and how they are defined in a struct rtc_time;	 */	if (time->tm_year <= 69)		time->tm_year += 100;	time->tm_mon--;	return RTC_24H;}
开发者ID:AK101111,项目名称:linux,代码行数:75,



注:本文中的CMOS_READ函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CMOS_WRITE函数代码示例
C++ CMNewObjectPath函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。