diff options
Diffstat (limited to 'sys/boot/efi/libefi/time.c')
-rw-r--r-- | sys/boot/efi/libefi/time.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/sys/boot/efi/libefi/time.c b/sys/boot/efi/libefi/time.c index c862c4c..2f598f6 100644 --- a/sys/boot/efi/libefi/time.c +++ b/sys/boot/efi/libefi/time.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* * Copyright (c) 1999, 2000 * Intel Corporation. @@ -39,18 +38,23 @@ * */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + #include <efi.h> #include <efilib.h> #include <time.h> #include <sys/time.h> -// +/* // Accurate only for the past couple of centuries; // that will probably do. // // (#defines From FreeBSD 3.2 lib/libc/stdtime/tzfile.h) -// +*/ #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) #define SECSPERHOUR ( 60*60 ) @@ -59,11 +63,11 @@ time_t EfiTimeToUnixTime(EFI_TIME *ETime) { - // + /* // These arrays give the cumulative number of days up to the first of the // month number used as the index (1 -> 12) for regular and leap years. // The value at index 13 is for the whole year. - // + */ static time_t CumulativeDays[2][14] = { {0, 0, @@ -97,9 +101,9 @@ EfiTimeToUnixTime(EFI_TIME *ETime) time_t UTime; int Year; - // + /* // Do a santity check - // + */ if ( ETime->Year < 1998 || ETime->Year > 2099 || ETime->Month == 0 || ETime->Month > 12 || ETime->Day == 0 || ETime->Month > 31 || @@ -111,51 +115,51 @@ EfiTimeToUnixTime(EFI_TIME *ETime) return (0); } - // + /* // Years - // + */ UTime = 0; for (Year = 1970; Year != ETime->Year; ++Year) { UTime += (CumulativeDays[isleap(Year)][13] * SECSPERDAY); } - // + /* // UTime should now be set to 00:00:00 on Jan 1 of the file's year. - // - // Months // + // Months + */ UTime += (CumulativeDays[isleap(ETime->Year)][ETime->Month] * SECSPERDAY); - // + /* // UTime should now be set to 00:00:00 on the first of the file's month and year // // Days -- Don't count the file's day - // + */ UTime += (((ETime->Day > 0) ? ETime->Day-1:0) * SECSPERDAY); - // + /* // Hours - // + */ UTime += (ETime->Hour * SECSPERHOUR); - // + /* // Minutes - // + */ UTime += (ETime->Minute * 60); - // + /* // Seconds - // + */ UTime += ETime->Second; - // + /* // EFI time is repored in local time. Adjust for any time zone offset to // get true UT - // + */ if ( ETime->TimeZone != EFI_UNSPECIFIED_TIMEZONE ) { - // + /* // TimeZone is kept in minues... - // + */ UTime += (ETime->TimeZone * 60); } @@ -172,31 +176,31 @@ EFI_GetTimeOfDay( EFI_TIME_CAPABILITIES Capabilities; EFI_STATUS Status; - // + /* // Get time from EFI - // + */ Status = RS->GetTime( &EfiTime, &Capabilities ); if (EFI_ERROR(Status)) return (-1); - // + /* // Convert to UNIX time (ie seconds since the epoch - // + */ tp->tv_sec = EfiTimeToUnixTime( &EfiTime ); - tp->tv_usec = 0; // EfiTime.Nanosecond * 1000; + tp->tv_usec = 0; /* EfiTime.Nanosecond * 1000; */ - // + /* // Do something with the timezone if needed - // + */ if (tzp) { tzp->tz_minuteswest = EfiTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE ? 0 : EfiTime.TimeZone; - // + /* // This isn't quit right since it doesn't deal with EFI_TIME_IN_DAYLIGHT - // + */ tzp->tz_dsttime = EfiTime.Daylight & EFI_TIME_ADJUST_DAYLIGHT ? 1 : 0; } |