efi_loader: Kconfig entries for GetTime(), SetTime()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 31 May 2019 20:56:02 +0000 (22:56 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 1 Jun 2019 02:53:13 +0000 (04:53 +0200)
The GetTime() and the SetTime() runtime services are not obligatory. So
let's make them customizable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/Kconfig
lib/efi_loader/efi_runtime.c
lib/efi_selftest/Makefile
lib/efi_selftest/efi_selftest_rtc.c

index fc04ea39d0ab3e5947f03ea4c835e32aa3fc78fb..cd5436c576b1bcbe62aff6607df0fa864c5783ae 100644 (file)
@@ -18,6 +18,22 @@ config EFI_LOADER
 
 if EFI_LOADER
 
+config EFI_GET_TIME
+       bool "GetTime() runtime service"
+       depends on DM_RTC
+       default y
+       help
+         Provide the GetTime() runtime service at boottime. This service
+         can be used by an EFI application to read the real time clock.
+
+config EFI_SET_TIME
+       bool "SetTime() runtime service"
+       depends on EFI_GET_TIME
+       default n
+       help
+         Provide the SetTime() runtime service at boottime. This service
+         can be used by an EFI application to adjust the real time clock.
+
 config EFI_DEVICE_PATH_TO_TEXT
        bool "Device path to text protocol"
        default y
index 98ab4de03daf131c60fd3624e0fab36fda4e138f..9c50955c9bd096d4dccdf2c08f8a702051612212 100644 (file)
@@ -167,7 +167,7 @@ static efi_status_t EFIAPI efi_get_time_boottime(
                        struct efi_time *time,
                        struct efi_time_cap *capabilities)
 {
-#ifdef CONFIG_DM_RTC
+#ifdef CONFIG_EFI_GET_TIME
        efi_status_t ret = EFI_SUCCESS;
        struct rtc_time tm;
        struct udevice *dev;
@@ -214,7 +214,7 @@ out:
 #endif
 }
 
-#ifdef CONFIG_DM_RTC
+#ifdef CONFIG_EFI_SET_TIME
 
 /**
  * efi_validate_time() - checks if timestamp is valid
@@ -252,7 +252,7 @@ static int efi_validate_time(struct efi_time *time)
  */
 static efi_status_t EFIAPI efi_set_time_boottime(struct efi_time *time)
 {
-#ifdef CONFIG_DM_RTC
+#ifdef CONFIG_EFI_SET_TIME
        efi_status_t ret = EFI_SUCCESS;
        struct rtc_time tm;
        struct udevice *dev;
index cfbb40c8910c2364295867bcc19ee8231ea33a17..b0321541476f8875fa82b531fb14313f4b132da3 100644 (file)
@@ -27,7 +27,6 @@ efi_selftest_loaded_image.o \
 efi_selftest_manageprotocols.o \
 efi_selftest_memory.o \
 efi_selftest_register_notify.o \
-efi_selftest_rtc.o \
 efi_selftest_snp.o \
 efi_selftest_textinput.o \
 efi_selftest_textinputex.o \
@@ -43,6 +42,7 @@ efi_selftest_unicode_collation.o
 
 obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o
 obj-$(CONFIG_EFI_LOADER_HII) += efi_selftest_hii.o
+obj-$(CONFIG_EFI_GET_TIME) += efi_selftest_rtc.o
 
 ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
 obj-y += efi_selftest_fdt.o
index 9eb29add3b0be35e920fac895fe4494c364bdb94..6f7035dee616968fc1a56e0cacec32af798d87a2 100644 (file)
@@ -40,7 +40,9 @@ static int setup(const efi_handle_t handle,
 static int execute(void)
 {
        efi_status_t ret;
-       struct efi_time tm, tm_old, tm_new = {
+       struct efi_time tm_old;
+#ifdef CONFIG_EFI_SET_TIME
+       struct efi_time tm, tm_new = {
                .year = 2017,
                .month = 5,
                .day = 19,
@@ -48,31 +50,23 @@ static int execute(void)
                .minute = 47,
                .second = 53,
        };
+#endif
 
        /* Display current time */
        ret = runtime->get_time(&tm_old, NULL);
        if (ret != EFI_SUCCESS) {
-#ifdef CONFIG_CMD_DATE
                efi_st_error(EFI_ST_NO_RTC);
                return EFI_ST_FAILURE;
-#else
-               efi_st_todo(EFI_ST_NO_RTC);
-               return EFI_ST_SUCCESS;
-#endif
        }
        efi_st_printf("Time according to real time clock: "
                      "%.4u-%.2u-%.2u %.2u:%.2u:%.2u\n",
                      tm_old.year, tm_old.month, tm_old.day,
                      tm_old.hour, tm_old.minute, tm_old.second);
+#ifdef CONFIG_EFI_SET_TIME
        ret = runtime->set_time(&tm_new);
        if (ret != EFI_SUCCESS) {
-#ifdef CONFIG_CMD_DATE
                efi_st_error(EFI_ST_NO_RTC_SET);
                return EFI_ST_FAILURE;
-#else
-               efi_st_todo(EFI_ST_NO_RTC_SET);
-               return EFI_ST_SUCCESS;
-#endif
        }
        ret = runtime->get_time(&tm, NULL);
        if (ret != EFI_SUCCESS) {
@@ -95,6 +89,7 @@ static int execute(void)
                efi_st_error(EFI_ST_NO_RTC_SET);
                return EFI_ST_FAILURE;
        }
+#endif
 
        return EFI_ST_SUCCESS;
 }