mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
efi_loader: complete implementation of GetTime()
Implement the missing parts of the GetTime() runtime service. Fill seconds. Fill daylight saving time flag correctly. Provide dummy values for capabilities. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
committed by
Alexander Graf
parent
197005ae2a
commit
49de24559d
@@ -117,24 +117,41 @@ static void EFIAPI efi_reset_system_boottime(
|
|||||||
while (1) { }
|
while (1) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_get_time_boottime - get current time
|
||||||
|
*
|
||||||
|
* This function implements the GetTime runtime service.
|
||||||
|
* See the Unified Extensible Firmware Interface (UEFI) specification
|
||||||
|
* for details.
|
||||||
|
*
|
||||||
|
* @time: pointer to structure to receive current time
|
||||||
|
* @capabilities: pointer to structure to receive RTC properties
|
||||||
|
* Return Value: status code
|
||||||
|
*/
|
||||||
static efi_status_t EFIAPI efi_get_time_boottime(
|
static efi_status_t EFIAPI efi_get_time_boottime(
|
||||||
struct efi_time *time,
|
struct efi_time *time,
|
||||||
struct efi_time_cap *capabilities)
|
struct efi_time_cap *capabilities)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CMD_DATE) && defined(CONFIG_DM_RTC)
|
#ifdef CONFIG_DM_RTC
|
||||||
struct rtc_time tm;
|
efi_status_t ret = EFI_SUCCESS;
|
||||||
int r;
|
int r;
|
||||||
|
struct rtc_time tm;
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
|
|
||||||
EFI_ENTRY("%p %p", time, capabilities);
|
EFI_ENTRY("%p %p", time, capabilities);
|
||||||
|
|
||||||
r = uclass_get_device(UCLASS_RTC, 0, &dev);
|
if (!time) {
|
||||||
if (r)
|
ret = EFI_INVALID_PARAMETER;
|
||||||
return EFI_EXIT(EFI_DEVICE_ERROR);
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = uclass_get_device(UCLASS_RTC, 0, &dev);
|
||||||
|
if (!r)
|
||||||
r = dm_rtc_get(dev, &tm);
|
r = dm_rtc_get(dev, &tm);
|
||||||
if (r)
|
if (r) {
|
||||||
return EFI_EXIT(EFI_DEVICE_ERROR);
|
ret = EFI_DEVICE_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
memset(time, 0, sizeof(*time));
|
memset(time, 0, sizeof(*time));
|
||||||
time->year = tm.tm_year;
|
time->year = tm.tm_year;
|
||||||
@@ -142,11 +159,23 @@ static efi_status_t EFIAPI efi_get_time_boottime(
|
|||||||
time->day = tm.tm_mday;
|
time->day = tm.tm_mday;
|
||||||
time->hour = tm.tm_hour;
|
time->hour = tm.tm_hour;
|
||||||
time->minute = tm.tm_min;
|
time->minute = tm.tm_min;
|
||||||
time->daylight = tm.tm_isdst;
|
time->second = tm.tm_sec;
|
||||||
|
time->daylight = EFI_TIME_ADJUST_DAYLIGHT;
|
||||||
|
if (tm.tm_isdst > 0)
|
||||||
|
time->daylight |= EFI_TIME_IN_DAYLIGHT;
|
||||||
|
time->timezone = EFI_UNSPECIFIED_TIMEZONE;
|
||||||
|
|
||||||
return EFI_EXIT(EFI_SUCCESS);
|
if (capabilities) {
|
||||||
|
/* Set reasonable dummy values */
|
||||||
|
capabilities->resolution = 1; /* 1 Hz */
|
||||||
|
capabilities->accuracy = 100000000; /* 100 ppm */
|
||||||
|
capabilities->sets_to_zero = false;
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
return EFI_EXIT(ret);
|
||||||
#else
|
#else
|
||||||
return EFI_DEVICE_ERROR;
|
EFI_ENTRY("%p %p", time, capabilities);
|
||||||
|
return EFI_EXIT(EFI_DEVICE_ERROR);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user