30 #include <linux/types.h>
31 #include <linux/errno.h>
33 #include <linux/module.h>
35 #include <linux/rtc.h>
41 #define EFI_RTC_VERSION "0.4"
43 #define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT)
47 #define EFI_RTC_EPOCH 1998
51 static long efi_rtc_ioctl(
struct file *
file,
unsigned int cmd,
54 #define is_leap(year) \
55 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
57 static const unsigned short int __mon_yday[2][13] =
60 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
62 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
85 if ( eft->
year < 1998 ) {
91 ndays += 365 + (
is_leap(y) ? 1 : 0);
93 ndays += compute_yday(eft);
98 return (ndays + 4) % 7;
119 memset(wtime, 0,
sizeof(*wtime));
128 wtime->
tm_wday = compute_wday(eft);
131 wtime->
tm_yday = compute_yday(eft);
146 static long efi_rtc_ioctl(
struct file *
file,
unsigned int cmd,
178 spin_unlock_irqrestore(&efi_rtc_lock,flags);
186 convert_from_efi_time(&eft, &wtime);
199 convert_to_efi_time(&wtime, &eft);
205 spin_unlock_irqrestore(&efi_rtc_lock,flags);
219 convert_to_efi_time(&wtime, &eft);
230 spin_unlock_irqrestore(&efi_rtc_lock,flags);
240 spin_unlock_irqrestore(&efi_rtc_lock,flags);
249 convert_from_efi_time(&eft, &wtime);
263 static int efi_rtc_open(
struct inode *
inode,
struct file *file)
273 static int efi_rtc_close(
struct inode *
inode,
struct file *file)
284 .unlocked_ioctl = efi_rtc_ioctl,
285 .open = efi_rtc_open,
286 .release = efi_rtc_close,
300 efi_rtc_get_status(
char *
buf)
308 memset(&eft, 0,
sizeof(eft));
309 memset(&alm, 0,
sizeof(alm));
310 memset(&cap, 0,
sizeof(cap));
317 spin_unlock_irqrestore(&efi_rtc_lock,flags);
320 "Time : %u:%u:%u.%09u\n"
328 p +=
sprintf(p,
"Timezone : unspecified\n");
335 "Alarm Time : %u:%u:%u.%09u\n"
336 "Alarm Date : %u-%u-%u\n"
337 "Alarm Daylight : %u\n"
343 enabled == 1 ?
"yes" :
"no",
344 pending == 1 ?
"yes" :
"no");
347 p +=
sprintf(p,
"Timezone : unspecified\n");
368 int len = efi_rtc_get_status(page);
369 if (len <= off+count) *eof = 1;
372 if (len>count) len =
count;
392 dir = create_proc_read_entry (
"driver/efirtc", 0,
NULL,
393 efi_rtc_read_proc,
NULL);