linux/drivers/char/efirtc.c
<<
.32<5" /spa >0 5" /form>0 5" a .32<5" href="../linux+v3.8.6/drivers/char/efirtc.c">.32<5" img src="../.static/gfx/right.png" alt=">>">.3 /spa >0.3 spa class="lxr_search">.32<.32<5" input typ hidden" nam navtarget" > "> ">.32<5" input typ text" nam search" id search">.32<5" butt 2typ submit">Search0 5" /form>0 /spa >0.3 spa class="lxr_prefs">0 5" a href="+prefs?return=drivers/char/efirtc.c".32<5" onclick="return ajax_prefs();">.32<5"Prefs0 5" /a>.3 /spa >02<5" " /div>02<5" " form ac ="ajax+*" method="post" onsubmit="return false;">.3 input typ hidden" nam ajax_lookup" id ajax_lookup" > "> ">.2<5" " /form>0.2<5" " div class="headingbott m">
02<5"
02<5" 5" " div id search_results" class="search_results"0 5>02<5" " /div>0 div id content">0 div id file_contents">
" "1
/a>
spa  class="comment">/*
/spa >0" "2
/a>
spa  class="comment"> * EFI Time Services Driver for Linux
/spa >0" "3
/a>
spa  class="comment"> *
/spa >0" "4
/a>
spa  class="comment"> * Copyright (C) 1999 Hewlett-Packard Co
/spa >0" "5
/a>
spa  class="comment"> * Copyright (C) 1999 Stephane Erania  <erania @hpl.hp.com>
/spa >0" "6
/a>
spa  class="comment"> *
/spa >0" "7
/a>
spa  class="comment"> * Based on skelet  2from the drivers/char/rtc.c driver by P. Gortmaker
/spa >0" "8
/a>
spa  class="comment"> *
/spa >0" "9
/a>
spa  class="comment"> * This code provides a  architected & portable interface to the real time
/spa >0" optia>
spa  class="comment"> * clock by using EFI instead of direct bit fiddling. The func	   alities are 
/spa >0" 11
/a>
spa  class="comment"> * quite different2from the rtc.c driver. The only way to talk to the device 
/spa >0" 12
/a>
spa  class="comment"> * is by using ioctl(). There is a /proc interface which provides the raw 
/spa >0" 13
/a>
spa  class="comment"> * informa	   .
/spa >0" 14
/a>
spa  class="comment"> *
/spa >0" 15
/a>
spa  class="comment"> * Please note that we have kept the API as close as possible to the
/spa >0" 16
/a>
spa  class="comment"> * legacy RTC. The standard /sbin/hwclock program should work normally 
/spa >0" 17
/a>
spa  class="comment"> * when used to get/set the time.
/spa >0" 18
/a>
spa  class="comment"> *
/spa >0" 19
/a>
spa  class="comment"> * NOTES:
/spa >0" 2ptia>
spa  class="comment"> *      - Locking is required for safe execu"	  2of EFI calls with regards
/spa >0" 21
/a>
spa  class="comment"> *        to interrupts a d SMP.
/spa >0" 22
/a>
spa  class="comment"> *
/spa >0" 23
/a>
spa  class="comment"> * TODO (December 1999):
/spa >0" 24
/a>
spa  class="comment"> *      - provide the API to set/get the WakeUp Alarm (different2from the
/spa >0" 25
/a>
spa  class="comment"> *        rtc.c alarm).
/spa >0" 26
/a>
spa  class="comment"> *      - SMP testing
/spa >0" 27
/a>
spa  class="comment"> *      - Add module support
/spa >0" 28
/a>
spa  class="comment"> */
/spa >0" 29
/a>0" 3ptia>#include <linux/typ
s.htia>>0" 31tia>#include <linux/errno.htia>>0" 32tia>#include <linux/miscdevice.htia>>0" 33tia>#include <linux/module.htia>>0" 34tia>#include <linux/init.htia>>0" 35tia>#include <linux/rtc.htia>>0" 36tia>#include <linux/proc_fs.htia>>0" 37tia>#include <linux/efi.htia>>0" 38tia>#include <linux/uaccess.htia>>0" 39
/a>0" 40
/a>0" 41tia>#define"
a href="+code=EFI_RTC_VERSION" class="sref">EFI_RTC_VERSIONtia>         
spa  class="string">"0.4"
/spa >0" 42
/a>0" 43tia>#define"
a href="+code=EFI_ISDST" class="sref">EFI_ISDSTtia> (
a href="+code=EFI_TIME_ADJUST_DAYLIGHT" class="sref">EFI_TIME_ADJUST_DAYLIGHTtia>|
a href="+code=EFI_TIME_IN_DAYLIGHT" class="sref">EFI_TIME_IN_DAYLIGHTtia>)0" 44
/a>
spa  class="comment">/*
/spa >0" 45
/a>
spa  class="comment"> * EFI Epoch is 1/1/1998
/spa >0" 46
/a>
spa  class="comment"> */
/spa >0" 47tia>#define"
a href="+code=EFI_RTC_EPOCH" class="sref">EFI_RTC_EPOCHtia>         " 19980" 48
/a>0" 49
/a>static"
a href="+code=DEFINE_SPINLOCK" class="sref">DEFINE_SPINLOCK
/a>(
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>);0" 50
/a>0" 51
/a>static"long"
a href="+code=efi_rtc_ioctl" class="sref">efi_rtc_ioctl
/a>(struct"
a href="+code=file" class="sref">filetia> *
a href="+code=file" class="sref">filetia>, unsigned int"
a href="+code=cmd" class="sref">cmdtia>,0" 52tia>         "                                              unsigned long"
a href="+code=arg" class="sref">argtia>);0" 53
/a>0" 54tia>#define"
a href="+code=is_leap" class="sref">is_leap
/a>(
a href="+code=year" class="sref">yeartia>) \0" 55tia>         "((
a href="+code=year" class="sref">yeartia>) % 4 == 0 && ((
a href="+code=year" class="sref">yeartia>) % 100 != 0 || (
a href="+code=year" class="sref">yeartia>) % 400 == 0))0" 56
/a>0" 57
/a>static"const unsigned short int"
a href="+code=__mon_yday" class="sref">__mon_yday
/a>[2][13] =0" 58
/a>{0" 59tia>        
spa  class="comment">/* Normal years.  */
/spa >0" 60tia>        { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },0" 61tia>        
spa  class="comment">/* Leap years.  */
/spa >.10" 62tia>        { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }0" 63
/a>};0" 64
/a>0" 65
/a>
spa  class="comment">/*
/spa >0" 66
/a>
spa  class="comment"> * returns day2of the year [0-365]
/spa >0" 67
/a>
spa  class="comment"> */
/spa >0" 68
/a>static"
a href="+code=inline" class="sref">inlinetia> int0" 69
/a>
a href="+code=compute_yday" class="sref">compute_yday
/a>(
a href="+code=efi_time_t" class="sref">efi_time_ttia> *
a href="+code=eft" class="sref">efttia>)0" 70
/a>{0" 71tia>        
spa  class="comment">/* efi_time_t.month is in the [1-12] so, we need -1 */
/spa >0" 72tia>        return "
a href="+code=__mon_yday" class="sref">__mon_yday
/a>[
a href="+code=is_leap" class="sref">is_leap
/a>(
a href="+code=eft" class="sref">efttia>->
a href="+code=year" class="sref">yeartia>)][
a href="+code=eft" class="sref">efttia>->
a href="+code=month" class="sref">monthtia>-1]+"
a href="+code=eft" class="sref">efttia>->
a href="+code=day" class="sref">day
/a> -1;0" 73
/a>}0" 74
/a>
spa  class="comment">/*
/spa >0" 75
/a>
spa  class="comment"> * returns day2of the week [0-6] 0=Sunday
/spa >0" 76
/a>
spa  class="comment"> *
/spa >0" 77
/a>
spa  class="comment"> * Don't try to provide a year that's before 1998, please !
/spa >0" 78
/a>
spa  class="comment"> */
/spa >0" 79
/a>static"int0" 80
/a>
a href="+code=compute_wday" class="sref">compute_wday
/a>(
a href="+code=efi_time_t" class="sref">efi_time_ttia> *
a href="+code=eft" class="sref">efttia>)0" 81
/a>{0" 82tia>        int"
a href="+code=y" class="sref">y
/a>;0" 83tia>        int"
a href="+code=ndays" class="sref">ndaystia> = 0;0" 84
/a>0" 85tia>        if ("
a href="+code=eft" class="sref">efttia>->
a href="+code=year" class="sref">yeartia> < 1998 ) {0" 86tia>         "      
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERRtia> 
spa  class="string">"efirtc: EFI year < 1998, invalid date\n"
/spa >);0" 87tia>         "      return -1;0" 88tia>        }0" 89
/a>0" 90tia>        for(
a href="+code=y" class="sref">y
/a>=
a href="+code=EFI_RTC_EPOCH" class="sref">EFI_RTC_EPOCHtia>;"
a href="+code=y" class="sref">y
/a> < 
a href="+code=eft" class="sref">efttia>->
a href="+code=year" class="sref">yeartia>;"
a href="+code=y" class="sref">y
/a>++ ) {0" 91tia>         "      
a href="+code=ndays" class="sref">ndaystia> += 365 + (
a href="+code=is_leap" class="sref">is_leap
/a>(
a href="+code=y" class="sref">y
/a>) ? 1 : 0);0" 92tia>        }0" 93tia>        
a href="+code=ndays" class="sref">ndaystia> += 
a href="+code=compute_yday" class="sref">compute_yday
/a>(
a href="+code=eft" class="sref">efttia>);0" 94
/a>0" 95tia>        
spa  class="comment">/*
/spa >0" 96
/a>
spa  class="comment">         * 4=1/1/1998 was a Thursday
/spa >0" 97
/a>
spa  class="comment">         */
/spa >0" 98tia>        return (
a href="+code=ndays" class="sref">ndaystia> + 4) % 7;0" 99
/a>}0"100
/a>0"101
/a>static"void0"102
/a>
a href="+code=convert_to_efi_time" class="sref">convert_to_efi_time
/a>(struct"
a href="+code=rtc_time" class="sref">rtc_timetia> *
a href="+code=wtime" class="sref">wtimetia>,"
a href="+code=efi_time_t" class="sref">efi_time_ttia> *
a href="+code=eft" class="sref">efttia>)0"103
/a>{0"104
/a>0"105tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=year" class="sref">yeartia>       = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_year" class="sref">tm_yeartia> + 1900;0"106tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=month" class="sref">monthtia>      = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_mon" class="sref">tm_montia> + 1;10"107tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=day" class="sref">day
/a>        = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_mday" class="sref">tm_mday
/a>;0"108tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=hour" class="sref">hourtia>       = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_hour" class="sref">tm_hour
/a>;0"109tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=minute" class="sref">minutetia>     = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_min" class="sref">tm_min
/a>;0"110tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=second" class="sref">secondtia>     = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_sec" class="sref">tm_sec
/a>;0"111tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=nanosecond" class="sref">nanosecondtia> = 0;10"112tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=daylight" class="sref">daylighttia>   = 
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_isdst" class="sref">tm_isdsttia> ?"
a href="+code=EFI_ISDST" class="sref">EFI_ISDSTtia>: 0;0"113tia>        
a href="+code=eft" class="sref">efttia>->
a href="+code=timezone" class="sref">timezonetia>   = 
a href="+code=EFI_UNSPECIFIED_TIMEZONE" class="sref">EFI_UNSPECIFIED_TIMEZONE
/a>;0"114
/a>}0"115
/a>0"116
/a>static"void0"117
/a>
a href="+code=convert_from_efi_time" class="sref">convert_from_efi_time
/a>(
a href="+code=efi_time_t" class="sref">efi_time_ttia> *
a href="+code=eft" class="sref">efttia>, struct"
a href="+code=rtc_time" class="sref">rtc_timetia> *
a href="+code=wtime" class="sref">wtimetia>)0"118
/a>{0"119tia>        
a href="+code=memset" class="sref">memset
/a>(
a href="+code=wtime" class="sref">wtimetia>,"0, sizeof(*
a href="+code=wtime" class="sref">wtimetia>));0"120tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_sec" class="sref">tm_sec
/a>  = 
a href="+code=eft" class="sref">efttia>->
a href="+code=second" class="sref">secondtia>;0"121tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_min" class="sref">tm_min
/a>  = 
a href="+code=eft" class="sref">efttia>->
a href="+code=minute" class="sref">minutetia>;0"122tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_hour" class="sref">tm_hour
/a> = 
a href="+code=eft" class="sref">efttia>->
a href="+code=hour" class="sref">hourtia>;0"123tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_mday" class="sref">tm_mday
/a> = 
a href="+code=eft" class="sref">efttia>->
a href="+code=day" class="sref">day
/a>;0"124
/a>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_mon" class="sref">tm_montia>  = 
a href="+code=eft" class="sref">efttia>->
a href="+code=month" class="sref">monthtia> - 1;0"125tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_year" class="sref">tm_yeartia> = 
a href="+code=eft" class="sref">efttia>->
a href="+code=year" class="sref">yeartia> - 1900;0"126
/a>0"127tia>        
spa  class="comment">/* day2of the week [0-6], Sunday=0 */
/spa >0"128tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_wday" class="sref">tm_wdaytia> = 
a href="+code=compute_wday" class="sref">compute_wday
/a>(
a href="+code=eft" class="sref">efttia>);0"129
/a>0"130tia>        
spa  class="comment">/* day2in the year [1-365]*/
/spa >0"131tia>        
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_yday" class="sref">tm_ydaytia> = 
a href="+code=compute_yday" class="sref">compute_yday
/a>(
a href="+code=eft" class="sref">efttia>);0"132
/a>0"133
/a>0"134
/a>        switch (
a href="+code=eft" class="sref">efttia>->
a href="+code=daylight" class="sref">daylighttia> & 
a href="+code=EFI_ISDST" class="sref">EFI_ISDSTtia>) {0"135tia>         """""""case 
a href="+code=EFI_ISDST" class="sref">EFI_ISDSTtia>:0"136tia>         "              
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_isdst" class="sref">tm_isdsttia> = 1;0"137tia>         "              break;0"138tia>         """""""case 
a href="+code=EFI_TIME_ADJUST_DAYLIGHT" class="sref">EFI_TIME_ADJUST_DAYLIGHTtia>:0"139tia>         "              
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_isdst" class="sref">tm_isdsttia> = 0;0"140tia>         "              break;0"141tia>         "      default:0"142tia>         "              
a href="+code=wtime" class="sref">wtimetia>->
a href="+code=tm_isdst" class="sref">tm_isdsttia> = -1;0"143tia>        }0"144
/a>}0"145
/a>0"146
/a>static"long"
a href="+code=efi_rtc_ioctl" class="sref">efi_rtc_ioctl
/a>(struct"
a href="+code=file" class="sref">filetia> *
a href="+code=file" class="sref">filetia>, unsigned int"
a href="+code=cmd" class="sref">cmdtia>,0"147tia>         "                                              unsigned long"
a href="+code=arg" class="sref">argtia>)0"148
/a>{0"149
/a>0"150tia>        
a href="+code=efi_status_t" class="sref">efi_status_ttia>    
a href="+code=status" class="sref">status
/a>;0"151tia>        unsigned long"  
a href="+code=flags" class="sref">flags
/a>;0"152tia>        
a href="+code=efi_time_t" class="sref">efi_time_ttia>      
a href="+code=eft" class="sref">efttia>;0"153tia>        
a href="+code=efi_time_cap_t" class="sref">efi_time_cap_ttia>  
a href="+code=cap" class="sref">cap
/a>;0"154
/a>        struct"
a href="+code=rtc_time" class="sref">rtc_timetia> 
a href="+code=wtime" class="sref">wtimetia>;0"155tia>        struct"
a href="+code=rtc_wkalrm" class="sref">rtc_wkalrmtia> 
a href="+code=__user" class="sref">__usertia> *
a href="+code=ewp" class="sref">ewptia>;0"156tia>        unsigned char   
a href="+code=enabled" class="sref">enabledtia>, 
a href="+code=pending" class="sref">pendingtia>;0"157
/a>0"158tia>        switch (
a href="+code=cmd" class="sref">cmdtia>) {0"159tia>         "      case 
a href="+code=RTC_UIE_ON" class="sref">RTC_UIE_ONtia>:0"160tia>         "      case 
a href="+code=RTC_UIE_OFF" class="sref">RTC_UIE_OFFtia>:0"161tia>         "      case 
a href="+code=RTC_PIE_ON" class="sref">RTC_PIE_ONtia>:0"162tia>         "      case 
a href="+code=RTC_PIE_OFF" class="sref">RTC_PIE_OFFtia>:0"163tia>         "      case 
a href="+code=RTC_AIE_ON" class="sref">RTC_AIE_ONtia>:0"164tia>         "      case 
a href="+code=RTC_AIE_OFF" class="sref">RTC_AIE_OFFtia>:0"165tia>         """""""case 
a href="+code=RTC_ALM_SET" class="sref">RTC_ALM_SETtia>:0"166tia>         "      case 
a href="+code=RTC_ALM_READ" class="sref">RTC_ALM_READtia>:0"167tia>         "      case 
a href="+code=RTC_IRQP_READ" class="sref">RTC_IRQP_READtia>:0"168tia>         """""""case 
a href="+code=RTC_IRQP_SET" class="sref">RTC_IRQP_SETtia>:0"169tia>         "      case 
a href="+code=RTC_EPOCH_READ" class="sref">RTC_EPOCH_READtia>:0"170tia>         "      case 
a href="+code=RTC_EPOCH_SET" class="sref">RTC_EPOCH_SETtia>:0"171tia>         "              return -
a href="+code=EINVAL" class="sref">EINVALtia>;0"172
/a>0"173tia>         "      case 
a href="+code=RTC_RD_TIME" class="sref">RTC_RD_TIMEtia>:0"174tia>         "              
a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>, 
a href="+code=flags" class="sref">flags
/a>);0"175
/a>0"176tia>         "              
a href="+code=status" class="sref">status
/a> = 
a href="+code=efi" class="sref">efi
/a>.
a href="+code=get_time" class="sref">get_time
/a>(&
a href="+code=eft" class="sref">efttia>, &
a href="+code=cap" class="sref">cap
/a>);0"177
/a>0"178tia>         """""""        
a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>,
a href="+code=flags" class="sref">flags
/a>);0"179
/a>0"180tia>         "              if (
a href="+code=status" class="sref">status
/a> != 
a href="+code=EFI_SUCCESS" class="sref">EFI_SUCCESStia>) {0"181tia>         "                      
spa  class="comment">/* should never happen */
/spa >0"182tia>         "                      
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERRtia> 
spa  class="string">"efitime: can't read time\n"
/spa >);0"183tia>         "                      return -
a href="+code=EINVAL" class="sref">EINVALtia>;0"184tia>         "              }0"185
/a>0"186tia>         "              
a href="+code=convert_from_efi_time" class="sref">convert_from_efi_time
/a>(&
a href="+code=eft" class="sref">efttia>, &
a href="+code=wtime" class="sref">wtimetia>);0"187
/a>0"188tia>         """""""        return 
a href="+code=copy_to_user" class="sref">copy_to_user
/a>((void 
a href="+code=__user" class="sref">__usertia> *)
a href="+code=arg" class="sref">argtia>, &
a href="+code=wtime" class="sref">wtimetia>,0"189tia>         "                                  sizeof (struct"
a href="+code=rtc_time" class="sref">rtc_timetia>)) ? - 
a href="+code=EFAULT" class="sref">EFAULTtia> : 0;0"190
/a>0"191tia>         "      case 
a href="+code=RTC_SET_TIME" class="sref">RTC_SET_TIMEtia>:0"192
/a>0"193tia>         "              if (!
a href="+code=capable" class="sref">capable
/a>(
a href="+code=CAP_SYS_TIME" class="sref">CAP_SYS_TIMEtia>)) return -
a href="+code=EACCES" class="sref">EACCEStia>;0"194
/a>0"195tia>         """""""        if (
a href="+code=copy_from_user" class="sref">copy_from_user
/a>(&
a href="+code=wtime" class="sref">wtimetia>,"(struct"
a href="+code=rtc_time" class="sref">rtc_timetia> 
a href="+code=__user" class="sref">__usertia> *)
a href="+code=arg" class="sref">argtia>,0"196tia>         "                                 sizeof(struct"
a href="+code=rtc_time" class="sref">rtc_timetia>)) )0"197tia>         "                      return -
a href="+code=EFAULT" class="sref">EFAULTtia>;0"198
/a>0"199tia>         "              
a href="+code=convert_to_efi_time" class="sref">convert_to_efi_time
/a>(&
a href="+code=wtime" class="sref">wtimetia>,"&
a href="+code=eft" class="sref">efttia>);0"200
/a>0"201tia>         "              
a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>, 
a href="+code=flags" class="sref">flags
/a>);0"202
/a>0"203tia>         "              
a href="+code=status" class="sref">status
/a> = 
a href="+code=efi" class="sref">efi
/a>.
a href="+code=set_time" class="sref">set_time
/a>(&
a href="+code=eft" class="sref">efttia>);0"204
/a>0"205tia>         """""""        
a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>,
a href="+code=flags" class="sref">flags
/a>);0"206
/a>0"207tia>         "              return 
a href="+code=status" class="sref">status
/a> == 
a href="+code=EFI_SUCCESS" class="sref">EFI_SUCCESStia> ? 0 : -
a href="+code=EINVAL" class="sref">EINVALtia>;0"208
/a>0"209tia>         "      case 
a href="+code=RTC_WKALM_SET" class="sref">RTC_WKALM_SETtia>:0"210
/a>0"211tia>         "              if (!
a href="+code=capable" class="sref">capable
/a>(
a href="+code=CAP_SYS_TIME" class="sref">CAP_SYS_TIMEtia>)) return -
a href="+code=EACCES" class="sref">EACCEStia>;0"212
/a>0"213tia>         "              
a href="+code=ewp" class="sref">ewptia> = (struct"
a href="+code=rtc_wkalrm" class="sref">rtc_wkalrmtia> 
a href="+code=__user" class="sref">__usertia> *)
a href="+code=arg" class="sref">argtia>;0"214
/a>0"215tia>         """""""        if (  
a href="+code=get_user" class="sref">get_user
/a>(
a href="+code=enabled" class="sref">enabledtia>, &
a href="+code=ewp" class="sref">ewptia>->
a href="+code=enabled" class="sref">enabledtia>)0"216tia>         "                 || 
a href="+code=copy_from_user" class="sref">copy_from_user
/a>(&
a href="+code=wtime" class="sref">wtimetia>,"&
a href="+code=ewp" class="sref">ewptia>->
a href="+code=time" class="sref">timetia>,"sizeof(struct"
a href="+code=rtc_time" class="sref">rtc_timetia>)) )0"217tia>         "                      return -
a href="+code=EFAULT" class="sref">EFAULTtia>;0"218
/a>0"219tia>         "              
a href="+code=convert_to_efi_time" class="sref">convert_to_efi_time
/a>(&
a href="+code=wtime" class="sref">wtimetia>,"&
a href="+code=eft" class="sref">efttia>);0"220
/a>0"221tia>         "              
a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>, 
a href="+code=flags" class="sref">flags
/a>);0"222tia>         "              
spa  class="comment">/*
/spa >0"223tia>
spa  class="comment">                         * XXX Fixme:
/spa >0"224
/a>
spa  class="comment">                         * As2of EFI 0.92 with the firmware I have on my
/spa >0"225
/a>
spa  class="comment">                         * machine this call does not seem to work quitetispa >0"226
/a>
spa  class="comment">                         * righttispa >0"227
/a>
spa  class="comment">                         */
/spa >0"228tia>         """""""        
a href="+code=status" class="sref">status
/a> = 
a href="+code=efi" class="sref">efi
/a>.
a href="+code=set_wakeup_time" class="sref">set_wakeup_time
/a>((
a href="+code=efi_bool_t" class="sref">efi_bool_t
/a>)
a href="+code=enabled" class="sref">enabledtia>, &
a href="+code=eft" class="sref">efttia>);0"229
/a>0"230tia>         "              
a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>,
a href="+code=flags" class="sref">flags
/a>);0"231tia>0"232tia>         "              return 
a href="+code=status" class="sref">status
/a> == 
a href="+code=EFI_SUCCESS" class="sref">EFI_SUCCESStia> ? 0 : -
a href="+code=EINVAL" class="sref">EINVALtia>;0"233
/a>0"234tia>         "      case 
a href="+code=RTC_WKALM_RD" class="sref">RTC_WKALM_RDtia>:0"235
/a>0"236tia>         "              
a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>, 
a href="+code=flags" class="sref">flags
/a>);0"237
/a>0"238tia>         """""""        
a href="+code=status" class="sref">status
/a> = 
a href="+code=efi" class="sref">efi
/a>.
a href="+code=get_wakeup_time" class="sref">get_wakeup_time
/a>((
a href="+code=efi_bool_t" class="sref">efi_bool_t
/a> *)&
a href="+code=enabled" class="sref">enabledtia>, (
a href="+code=efi_bool_t" class="sref">efi_bool_t
/a> *)&
a href="+code=pending" class="sref">pendingtia>, &
a href="+code=eft" class="sref">efttia>);0"239
/a>0"240tia>         "              
a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>,
a href="+code=flags" class="sref">flags
/a>);0"241tia>0"242tia>         "              if (
a href="+code=status" class="sref">status
/a> != 
a href="+code=EFI_SUCCESS" class="sref">EFI_SUCCESStia>) return -
a href="+code=EINVAL" class="sref">EINVALtia>;0"243
/a>0"244tia>         "              
a href="+code=ewp" class="sref">ewptia> = (struct"
a href="+code=rtc_wkalrm" class="sref">rtc_wkalrmtia> 
a href="+code=__user" class="sref">__usertia> *)
a href="+code=arg" class="sref">argtia>;0"245
/a>0"246tia>         "              if (  
a href="+code=put_user" class="sref">put_user
/a>(
a href="+code=enabled" class="sref">enabledtia>, &
a href="+code=ewp" class="sref">ewptia>->
a href="+code=enabled" class="sref">enabledtia>)0"247tia>         "                 || 
a href="+code=put_user" class="sref">put_user
/a>(
a href="+code=pending" class="sref">pendingtia>, &
a href="+code=ewp" class="sref">ewptia>->
a href="+code=pending" class="sref">pendingtia>)) return -
a href="+code=EFAULT" class="sref">EFAULTtia>;0"248
/a>0"249tia>         "              
a href="+code=convert_from_efi_time" class="sref">convert_from_efi_time
/a>(&
a href="+code=eft" class="sref">efttia>, &
a href="+code=wtime" class="sref">wtimetia>);0"250
/a>0"251tia>         "              return 
a href="+code=copy_to_user" class="sref">copy_to_user
/a>(&
a href="+code=ewp" class="sref">ewptia>->
a href="+code=time" class="sref">timetia>,"&
a href="+code=wtime" class="sref">wtimetia>,0"252tia>         "                                  sizeof(struct"
a href="+code=rtc_time" class="sref">rtc_timetia>)) ? -
a href="+code=EFAULT" class="sref">EFAULTtia> : 0;0"253tia>        }0"254
/a>        return -
a href="+code=ENOTTY" class="sref">ENOTTYtia>;0"255tia>}0"256
/a>0"257
/a>
spa  class="comment">/*
/spa >0"258
/a>
spa  class="comment"> *      We enforce only one user at a time here with the open/close.
/spa >0"259tia>
spa  class="comment"> *      Also clear the previous interrupt data on a  open, a d clean
/spa >0"260tia>
spa  class="comment"> *      up things on a close.
/spa >0"261tia>
spa  class="comment"> */
/spa >0"262
/a>0"263tia>static"int"
a href="+code=efi_rtc_open" class="sref">efi_rtc_open
/a>(struct"
a href="+code=inode" class="sref">inodetia> *
a href="+code=inode" class="sref">inodetia>, struct"
a href="+code=file" class="sref">filetia> *
a href="+code=file" class="sref">filetia>)0"264tia>{0"265tia>        
spa  class="comment">/*
/spa >0"266
/a>
spa  class="comment">         * nothing special to do here
/spa >0"267
/a>
spa  class="comment">         * We do accept multiple open files at the sam
 time as we
/spa >0"268
/a>
spa  class="comment">         * synchronize on the per call operation.
/spa >0"269tia>
spa  class="comment">         */
/spa >0"270tia>        return 0;0"271tia>}0"272
/a>0"273tia>static"int"
a href="+code=efi_rtc_close" class="sref">efi_rtc_close
/a>(struct"
a href="+code=inode" class="sref">inodetia> *
a href="+code=inode" class="sref">inodetia>, struct"
a href="+code=file" class="sref">filetia> *
a href="+code=file" class="sref">filetia>)0"274tia>{0"275tia>        return 0;0"276tia>}0"277
/a>0"278
/a>
spa  class="comment">/*
/spa >0"279tia>
spa  class="comment"> *      The various file operations we support.
/spa >0"280tia>
spa  class="comment"> */
/spa >0"281tia>0"282tia>static"const struct"
a href="+code=file_operations" class="sref">file_operationstia> 
a href="+code=efi_rtc_fops" class="sref">efi_rtc_fopstia> = {0"283tia>        .
a href="+code=owner" class="sref">ownertia>         "= 
a href="+code=THIS_MODULE" class="sref">THIS_MODULEtia>,0"284tia>        .
a href="+code=unlocked_ioctl" class="sref">unlocked_ioctl
/a> = 
a href="+code=efi_rtc_ioctl" class="sref">efi_rtc_ioctl
/a>,0"285tia>        .
a href="+code=open" class="sref">open
/a>          "= 
a href="+code=efi_rtc_open" class="sref">efi_rtc_open
/a>,0"286tia>        .
a href="+code=release" class="sref">releasetia>        = 
a href="+code=efi_rtc_close" class="sref">efi_rtc_close
/a>,0"287tia>        .
a href="+code=llseek" class="sref">llseek
/a>         = 
a href="+code=no_llseek" class="sref">no_llseek
/a>,0"288tia>};0"289
/a>0"290
/a>static"struct"
a href="+code=miscdevice" class="sref">miscdevicetia> 
a href="+code=efi_rtc_dev" class="sref">efi_rtc_devtia>= {0"291tia>        
a href="+code=EFI_RTC_MINOR" class="sref">EFI_RTC_MINOR
/a>,0"292tia>        
spa  class="string">"efirtc"
/spa >,0"293tia>        &
a href="+code=efi_rtc_fops" class="sref">efi_rtc_fopstia>0"294
/a>};0"295
/a>0"296
/a>
spa  class="comment">/*
/spa >0"297
/a>
spa  class="comment"> *      We export RAW EFI information to /proc/driver/efirtc
/spa >0"298
/a>
spa  class="comment"> */
/spa >0"299tia>static"int0"300
/a>
a href="+code=efi_rtc_get_status" class="sref">efi_rtc_get_status
/a>(char *
a href="+code=buf" class="sref">buftia>)0"301tia>{0"302tia>        
a href="+code=efi_time_t" class="sref">efi_time_ttia>      
a href="+code=eft" class="sref">efttia>, 
a href="+code=alm" class="sref">almtia>;0"303tia>        
a href="+code=efi_time_cap_t" class="sref">efi_time_cap_ttia>  
a href="+code=cap" class="sref">cap
/a>;0"304tia>        char            *
a href="+code=p" class="sref">ptia> = 
a href="+code=buf" class="sref">buftia>;0"305tia>        
a href="+code=efi_bool_t" class="sref">efi_bool_t
/a>      
a href="+code=enabled" class="sref">enabledtia>, 
a href="+code=pending" class="sref">pendingtia>;       0"306tia>        unsigned long"  
a href="+code=flags" class="sref">flags
/a>;0"307
/a>0"308tia>        
a href="+code=memset" class="sref">memset
/a>(&
a href="+code=eft" class="sref">efttia>, 0,"sizeof(
a href="+code=eft" class="sref">efttia>));0"309tia>        
a href="+code=memset" class="sref">memset
/a>(&
a href="+code=alm" class="sref">almtia>, 0,"sizeof(
a href="+code=alm" class="sref">almtia>));0"310tia>        
a href="+code=memset" class="sref">memset
/a>(&
a href="+code=cap" class="sref">cap
/a>, 0,"sizeof(
a href="+code=cap" class="sref">cap
/a>));0"311tia>0"312tia>        
a href="+code=spin_lock_irqsave" class="sref">spin_lock_irqsave
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>, 
a href="+code=flags" class="sref">flags
/a>);0"313
/a>0"314
/a>        
a href="+code=efi" class="sref">efi
/a>.
a href="+code=get_time" class="sref">get_time
/a>(&
a href="+code=eft" class="sref">efttia>, &
a href="+code=cap" class="sref">cap
/a>);0"315tia>        
a href="+code=efi" class="sref">efi
/a>.
a href="+code=get_wakeup_time" class="sref">get_wakeup_time
/a>(&
a href="+code=enabled" class="sref">enabledtia>, &
a href="+code=pending" class="sref">pendingtia>, &
a href="+code=alm" class="sref">almtia>);0"316
/a>0"317tia>        
a href="+code=spin_unlock_irqrestore" class="sref">spin_unlock_irqrestore
/a>(&
a href="+code=efi_rtc_lock" class="sref">efi_rtc_locktia>,
a href="+code=flags" class="sref">flags
/a>);0"318
/a>0"319tia>        
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>,0"320tia>         "           
spa  class="string">"Time           : %u:%u:%u.%09u\n"
/spa >0"321tia>         "           
spa  class="string">"Date           : %u-%u-%u\n"
/spa >0"322tia>         "           
spa  class="string">"Daylight       : %u\n"
/spa >,0"323tia>         "           
a href="+code=eft" class="sref">efttia>.
a href="+code=hour" class="sref">hourtia>, 
a href="+code=eft" class="sref">efttia>.
a href="+code=minute" class="sref">minutetia>, 
a href="+code=eft" class="sref">efttia>.
a href="+code=second" class="sref">secondtia>, 
a href="+code=eft" class="sref">efttia>.
a href="+code=nanosecond" class="sref">nanosecondtia>, 0"324tia>         "           
a href="+code=eft" class="sref">efttia>.
a href="+code=year" class="sref">yeartia>, 
a href="+code=eft" class="sref">efttia>.
a href="+code=month" class="sref">monthtia>, 
a href="+code=eft" class="sref">efttia>.
a href="+code=day" class="sref">daytia>,0"325tia>         """""""     
a href="+code=eft" class="sref">efttia>.
a href="+code=daylight" class="sref">daylighttia>);0"326
/a>0"327tia>        if (
a href="+code=eft" class="sref">efttia>.
a href="+code=timezone" class="sref">timezonetia> == 
a href="+code=EFI_UNSPECIFIED_TIMEZONE" class="sref">EFI_UNSPECIFIED_TIMEZONEtia>)0"328tia>         """""""
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>, 
spa  class="string">"Timezone       : unspecified\n"
/spa >);0"329tia>        else0"330tia>         "      
spa  class="comment">/* XXX fixme: convert to string? */
/spa >0"331tia>         "      
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>, 
spa  class="string">"Timezone       : %u\n"
/spa >, 
a href="+code=eft" class="sref">efttia>.
a href="+code=timezone" class="sref">timezonetia>);0"332tia>         "      0"333
/a>0"334
/a>        
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>,0"335tia>         """""""     
spa  class="string">"Alarm Time     : %u:%u:%u.%09u\n"
/spa >0"336tia>         "           
spa  class="string">"Alarm Date     : %u-%u-%u\n"
/spa >0"337tia>         "           
spa  class="string">"Alarm Daylight : %u\n"
/spa >0"338tia>         """""""     
spa  class="string">"Enabled"""     : %s\n"
/spa >0"339tia>         "           
spa  class="string">"Pending"""     : %s\n"
/spa >,0"340tia>         "           
a href="+code=alm" class="sref">almtia>.
a href="+code=hour" class="sref">hourtia>, 
a href="+code=alm" class="sref">almtia>.
a href="+code=minute" class="sref">minutetia>, 
a href="+code=alm" class="sref">almtia>.
a href="+code=second" class="sref">secondtia>, 
a href="+code=alm" class="sref">almtia>.
a href="+code=nanosecond" class="sref">nanosecondtia>, 0"341tia>         "           
a href="+code=alm" class="sref">almtia>.
a href="+code=year" class="sref">yeartia>, 
a href="+code=alm" class="sref">almtia>.
a href="+code=month" class="sref">monthtia>, 
a href="+code=alm" class="sref">almtia>.
a href="+code=day" class="sref">daytia>, 0"342tia>         "           
a href="+code=alm" class="sref">almtia>.
a href="+code=daylight" class="sref">daylighttia>,0"343tia>         "           
a href="+code=enabled" class="sref">enabledtia> == 1 ? 
spa  class="string">"yes"
/spa > : 
spa  class="string">"no"
/spa >,0"344tia>         "           
a href="+code=pending" class="sref">pendingtia> == 1 ? 
spa  class="string">"yes"
/spa > : 
spa  class="string">"no"
/spa >);0"345
/a>0"346tia>        if (
a href="+code=eft" class="sref">efttia>.
a href="+code=timezone" class="sref">timezonetia> == 
a href="+code=EFI_UNSPECIFIED_TIMEZONE" class="sref">EFI_UNSPECIFIED_TIMEZONEtia>)0"347tia>         "      
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>, 
spa  class="string">"Timezone       : unspecified\n"
/spa >);0"348tia>        else0"349tia>         "      
spa  class="comment">/* XXX fixme: convert to string? */
/spa >0"350tia>         "      
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>, 
spa  class="string">"Timezone       : %u\n"
/spa >, 
a href="+code=alm" class="sref">almtia>.
a href="+code=timezone" class="sref">timezonetia>);0"351tia>0"352tia>        
spa  class="comment">/*
/spa >0"353tia>
spa  class="comment">         * now prints the capabilities
/spa >0"354
/a>
spa  class="comment">         */
/spa >0"355tia>        
a href="+code=p" class="sref">ptia> += 
a href="+code=sprintf" class="sref">sprintf
/a>(
a href="+code=p" class="sref">ptia>,0"356tia>         "           
spa  class="string">"Resolution     : %u\n"
/spa >0"357tia>         "           
spa  class="string">"Accuracy       : %u\n"
/spa >0"358tia>         """""""     
spa  class="string">"SetstoZero     : %u\n"
/spa >,0"359tia>         "            
a href="+code=cap" class="sref">cap
/a>.
a href="+code=resolution" class="sref">resolutiontia>, 
a href="+code=cap" class="sref">cap
/a>.
a href="+code=accuracy" class="sref">accuracytia>, 
a href="+code=cap" class="sref">cap
/a>.
a href="+code=sets_to_zero" class="sref">sets_to_zerotia>);0"360
/a>0"361tia>        return  
a href="+code=p" class="sref">ptia> - 
a href="+code=buf" class="sref">buftia>;0"362
/a>}0"363
/a>0"364tia>static"int0"365tia>
a href="+code=efi_rtc_read_proc" class="sref">efi_rtc_read_proc
/a>(char *
a href="+code=page" class="sref">pagetia>, char **
a href="+code=start" class="sref">starttia>, 
a href="+code=off_t" class="sref">off_ttia> 
a href="+code=off" class="sref">offtia>,0"366tia>         "                       int"
a href="+code=count" class="sref">counttia>, int"*
a href="+code=eof" class="sref">eoftia>, void *
a href="+code=data" class="sref">datatia>)0"367
/a>{0"368tia>        int"
a href="+code=len" class="sref">len
/a> = 
a href="+code=efi_rtc_get_status" class="sref">efi_rtc_get_status
/a>(
a href="+code=page" class="sref">pagetia>);0"369tia>        if (
a href="+code=len" class="sref">len
/a> <= 
a href="+code=off" class="sref">offtia>+
a href="+code=count" class="sref">counttia>)"*
a href="+code=eof" class="sref">eoftia> = 1;0"370tia>        *
a href="+code=start" class="sref">starttia> = 
a href="+code=page" class="sref">pagetia> + 
a href="+code=off" class="sref">offtia>;0"371tia>        
a href="+code=len" class="sref">len
/a> -= 
a href="+code=off" class="sref">offtia>;0"372tia>        if (
a href="+code=len" class="sref">len
/a>>
a href="+code=count" class="sref">counttia>)"
a href="+code=len" class="sref">len
/a> = 
a href="+code=count" class="sref">counttia>;0"373tia>        if (
a href="+code=len" class="sref">len
/a><0)"
a href="+code=len" class="sref">len
/a> = 0;0"374
/a>        return 
a href="+code=len" class="sref">len
/a>;0"375tia>}0"376
/a>0"377
/a>static"int"
a href="+code=__init" class="sref">__init
/a> 0"378
/a>
a href="+code=efi_rtc_init" class="sref">efi_rtc_init
/a>(void)0"379tia>{0"380tia>        int"
a href="+code=ret" class="sref">rettia>;0"381tia>        struct"
a href="+code=proc_dir_entry" class="sref">proc_dir_entrytia> *
a href="+code=dir" class="sref">dirtia>;0"382
/a>0"383tia>        
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_INFO" class="sref">KERN_INFOtia> 
spa  class="string">"EFI Time Services Driver v%s\n"
/spa >, 
a href="+code=EFI_RTC_VERSION" class="sref">EFI_RTC_VERSIONtia>);0"384
/a>0"385tia>        
a href="+code=ret" class="sref">rettia> = 
a href="+code=misc_register" class="sref">misc_register
/a>(&
a href="+code=efi_rtc_dev" class="sref">efi_rtc_devtia>);0"386tia>        if (
a href="+code=ret" class="sref">rettia>) {0"387tia>         "      
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERRtia> 
spa  class="string">"efirtc: can't misc_register on minor=%d\n"
/spa >,0"388tia>         """""""         "      
a href="+code=EFI_RTC_MINOR" class="sref">EFI_RTC_MINOR
/a>);0"389tia>         "      return 
a href="+code=ret" class="sref">rettia>;0"390tia>        }0"391tia>0"392tia>        
a href="+code=dir" class="sref">dirtia> = 
a href="+code=create_proc_read_entry" class="sref">create_proc_read_entrytia> (
spa  class="string">"driver/efirtc"
/spa >, 0, 
a href="+code=NULL" class="sref">NULLtia>,0"393tia>         "           "         "      
a href="+code=efi_rtc_read_proc" class="sref">efi_rtc_read_proc
/a>, 
a href="+code=NULL" class="sref">NULLtia>);0"394tia>        if (
a href="+code=dir" class="sref">dirtia> == 
a href="+code=NULL" class="sref">NULLtia>) {0"395tia>         """""""
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERRtia> 
spa  class="string">"efirtc: can't create /proc/driver/efirtc.\n"
/spa >);0"396tia>         "      
a href="+code=misc_deregister" class="sref">misc_deregister
/a>(&
a href="+code=efi_rtc_dev" class="sref">efi_rtc_devtia>);0"397tia>         "      return -1;0"398tia>        }0"399tia>        return 0;0"400
/a>}0"401tia>0"402tia>static"void 
a href="+code=__exit" class="sref">__exittia>0"403tia>
a href="+code=efi_rtc_exit" class="sref">efi_rtc_exit
/a>(void)0"404tia>{0"405tia>        
spa  class="comment">/* not yet used */
/spa >0"406tia>}0"407
/a>0"408
/a>
a href="+code=module_init" class="sref">module_init
/a>(
a href="+code=efi_rtc_init" class="sref">efi_rtc_init
/a>);0"409tia>
a href="+code=module_exit" class="sref">module_exit
/a>(
a href="+code=efi_rtc_exit" class="sref">efi_rtc_exit
/a>);0"410
/a>0"411tia>
a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE
/a>(
spa  class="string">"GPL"
/spa >);0"412tia>
lxr.linux.no kindly hosted by Redpill Linpro AStia>, provider of Linux"consulting a d operations services since 1995.