Source
status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft);
/*
* EFI Time Services Driver for Linux
*
* Copyright (C) 1999 Hewlett-Packard Co
* Copyright (C) 1999 Stephane Eranian <eranian@hpl.hp.com>
*
* Based on skeleton from the drivers/char/rtc.c driver by P. Gortmaker
*
* This code provides an architected & portable interface to the real time
* clock by using EFI instead of direct bit fiddling. The functionalities are
* quite different from the rtc.c driver. The only way to talk to the device
* is by using ioctl(). There is a /proc interface which provides the raw
* information.
*
* Please note that we have kept the API as close as possible to the
* legacy RTC. The standard /sbin/hwclock program should work normally
* when used to get/set the time.
*
* NOTES:
* - Locking is required for safe execution of EFI calls with regards
* to interrupts and SMP.
*
* TODO (December 1999):
* - provide the API to set/get the WakeUp Alarm (different from the
* rtc.c alarm).
* - SMP testing
* - Add module support
*/
/*
* EFI Epoch is 1/1/1998
*/
static DEFINE_SPINLOCK(efi_rtc_lock);
static long efi_rtc_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
static const unsigned short int __mon_yday[2][13] =
{
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
/* Leap years. */
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
/*
* returns day of the year [0-365]
*/
static inline int
compute_yday(efi_time_t *eft)
{
/* efi_time_t.month is in the [1-12] so, we need -1 */
return __mon_yday[is_leap(eft->year)][eft->month-1]+ eft->day -1;
}
/*
* returns day of the week [0-6] 0=Sunday
*
* Don't try to provide a year that's before 1998, please !
*/
static int
compute_wday(efi_time_t *eft)
{
int y;
int ndays = 0;
if ( eft->year < 1998 ) {
printk(KERN_ERR "efirtc: EFI year < 1998, invalid date\n");
return -1;
}
for(y=EFI_RTC_EPOCH; y < eft->year; y++ ) {
ndays += 365 + (is_leap(y) ? 1 : 0);
}