《关于Linux操作系统设计研究毕业设计论文.doc》由会员分享,可免费在线阅读全文,更多与《关于Linux操作系统设计研究毕业设计论文》相关文档资源请在帮帮文库(www.woc88.com)数亿文档库存里搜索。
1、frintf(stderr,quotAlarmtimenowsetto%d:%d:%d\nquot,rtc_tmtm_hour,rtc_tmtm_min,rtc_tmtm_sec);陈伟强:基于Linux操作系统下RTC驱动开发retval=ioctl(fd,RTC_AIE_ON,);if(retval==){error(quotRTC_AIE_ONioctlquot);exit(errno);}frintf(stderr,quotWaitingsecondsforalarmquot);fflush(stderr);retval=read(fd,amdata,sizeof(unsignedlong));if(retval==){error(quotreadquot);exit(errno);}irqcount++;frintf(std。
2、rr=EACCES;eak;}蚌埠学院本科毕业设计(论文)if(err)gotodone;switch(cmd){caseRTC_ALM_READ:mutex_unlock(amrtcgtos_lock);err=rtc_read_alarm(rtc,amalarm);if(erros_lock);if(coy_from_user(amalarmtime,uarg,sizeof(tm)))returnEFAULT;alarmenabled=;alarmending=;alarmtimetm_wday=;alarmtimetm_yday=;alarmtimetm_isdst=;{unsignedlongnow,then;err=rtc_read_time(rtc,amtm);if(errlt)returnerr;rtc_tm_to_ti。
3、rtc_tmtm_min++;}if(rtc_tmtm_min==){rtc_tmtm_min=;rtc_tmtm_hour++;}if(rtc_tmtm_hour==)rtc_tmtm_hour=;retval=ioctl(fd,RTC_ALM_SET,amrtc_tm);if(retval==){if(errno==ENOTTY){frintf(stderr,quot\nAlarmIRQsnotsuorted\nquot);gototest_PIE;}error(quotRTC_ALM_SETioctlquot);exit(errno);}retval=ioctl(fd,RTC_ALM_READ,amrtc_tm);if(retval==){error(quotRTC_ALM_READioctlquot);exit(errno);。
4、structrtc_wkalrmalarm;void__user*uarg=(void__user*)arg;err=mutex_lock_interrutible(amrtcgtos_lock);if(err)returnerr;switch(cmd){caseRTC_EPOCH_SET:caseRTC_SET_TIME:if(!caable(CAP_SYS_TIME))err=EACCES;eak;caseRTC_IRQP_SET:if(arggtrtcgtmax_user_freqamam!caable(CAP_SYS_RESOURCE))err=EACCES;eak;caseRTC_PIE_ON:if(rtcgtirq_freqgtrtcgtmax_user_freqamam!caable(CAP_SYS_RESOURCE))。
5、retval==){error(quotRTC_UIE_OFFioctlquot);exit(errno);}test_READ:retval=ioctl(fd,RTC_RD_TIME,amrtc_tm);if(retval==){error(quotRTC_RD_TIMEioctlquot);exit(errno);}frintf(stderr,quot\n\nCurrentRTCdatetimeis%d%d%d,%d:%d:%d\nquot,rtc_tmtm_mday,rtc_tmtm_mon+,rtc_tmtm_year+,rtc_tmtm_hour,rtc_tmtm_min,rtc_tmtm_sec);rtc_tmtm_sec+=;蚌埠学院本科毕业设计(论文)if(rtc_tmtm_secgt=){rtc_tmtm_sec%=。
6、e(amtm,amnow);alarmtimetm_mday=tmtm_mday;alarmtimetm_mon=tmtm_mon;alarmtimetm_year=tmtm_year;err=rtc_valid_tm(amalarmtime);陈伟强:基于Linux操作系统下RTC驱动开发if(erros_lock);err=rtc_read_time(rtc,amtm);if(erros_lock);if(coy_from_user(amtm,uarg,sizeof(tm)))returnEFAULT;returnrtc_set_time(rtc,amtm);caseRTC_PIE_ON:err=rtc_irq_set_state(rtc,NULL,);eak;caseRTC_PIE_OFF:err=rtc_irq_set_sta。
7、m)))returnEFAULT;returnrtc_set_alarm(rtc,amalarm);caseRTC_WKALM_RD:mutex_unlock(amrtcgtos_lock);err=rtc_read_alarm(rtc,amalarm(retval==)陈伟强:基于Linux操作系统下RTC驱动开发{error(quotselectquot);exit(errno);}retval=read(fd,amdata,sizeof(unsignedlong));if(retval==){error(quotreadquot);exit(errno);}frintf(stderr,quot%dquot,i);fflush(stderr);irqcount++;}retval=ioctl(fd,RTC_UIE_OFF,);if。
8、rr=EACCES;eak;}蚌埠学院本科毕业设计(论文)if(err)gotodone;switch(cmd){caseRTC_ALM_READ:mutex_unlock(amrtcgtos_lock);err=rtc_read_alarm(rtc,amalarm);if(erros_lock);if(coy_from_user(amalarmtime,uarg,sizeof(tm)))returnEFAULT;alarmenabled=;alarmending=;alarmtimetm_wday=;alarmtimetm_yday=;alarmtimetm_isdst=;{unsignedlongnow,then;err=rtc_read_time(rtc,amtm);if(errlt)returnerr;rtc_tm_to_ti。
9、e(rtc,NULL,);eak;蚌埠学院本科毕业设计(论文)caseRTC_AIE_ON:mutex_unlock(amrtcgtos_lock);returnrtc_alarm_irq_enable(rtc,);caseRTC_AIE_OFF:mutex_unlock(amrtcgtos_lock);returnrtc_alarm_irq_enable(rtc,);caseRTC_UIE_ON:mutex_unlock(amrtcgtos_lock);returnrtc_udate_irq_enable(rtc,);caseRTC_UIE_OFF:mutex_unlock(amrtcgtos_lock);returnrtc_udate_irq_enable(rtc,);caseRTC_IRQP_SET:err=rtc_irq_se。
10、_freq(rtc,NULL,arg);eak;caseRTC_IRQP_READ:err=ut_user(rtcgtirq_freq,(unsignedlong__user*)uarg);eak;ifcaseRTC_EPOCH_SET:ifndefrtc_eochif(arglt){err=EINVAL;eak;}rtc_eoch=arg;err=;endifeak;caseRTC_EPOCH_READ:err=ut_user(rtc_eoch,(unsignedlong__user*)uarg);陈伟强:基于Linux操作系统下RTC驱动开发eak;endifcaseRTC_WKALM_SET:mutex_unlock(amrtcgtos_lock);if(coy_from_user(amalarm,uarg,sizeof(ala。
11、ze_tret;if(count!=sizeof(unsignedint)amamcountirq_queue,amwait);do{__set_current_state(TASK_INTERRUPTIBLE);sin_lock_irq(amrtcgtirq_lock);data=rtcgtirq_data;rtcgtirq_data=;sin_unlock_irq(amrtcgtirq_lock);if(data!=){蚌埠学院本科毕业设计(论文)ret=;eak;}if(filegtf_flagsamO_NONBLOCK){ret=EAGAIN;eak;}if(signal_ending(current)){ret=ERESTARTSYS;eak;}schedule();}while();set_current_state(TA 。
12、SK_RUNNING);remove_wait_queue(amrtcgtirq_queue,amwait);if(ret==){if(rtcgtosgtread_callback)data=rtcgtosgtread_callback(rtcgtdevarent,data);if(sizeof(int)!=sizeof(long)amamcount==sizeof(unsignedint))ret=ut_user(data,(unsignedint__user*)buf)?:sizeof(unsignedint);elseret=ut_user(data,(unsignedlong__user*)buf)?:sizeof(unsignedlong);}returnret;}staticunsignedintrtc_dev_oll(s