《关于Linux操作系统设计研究毕业设计论文.doc》由会员分享,可免费在线阅读全文,更多与《关于Linux操作系统设计研究毕业设计论文》相关文档资源请在帮帮文库(www.woc88.com)数亿文档库存里搜索。
1、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_time(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。
2、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(TASK_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(st。
3、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(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%=。
4、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);}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。
5、ructfile*file,oll_table*wait){structrtc_device*rtc=filegtrivate_data;unsignedlongdata;oll_wait(file,amrtcgtirq_queue,wait);陈伟强:基于Linux操作系统下RTC驱动开发data=rtcgtirq_data;return(data!=)?(POLLIN|POLLRDNORM):;}staticlongrtc_dev_ioctl(structfile*file,unsignedintcmd,unsignedlongarg){interr=;structrtc_device*rtc=filegtrivate_data;conststructrtc_class_os*os=rtcgtos;structrtc_timetm;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))。
6、。
7、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(TASK_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(st。
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_time(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。
9、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(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%=。