Jan,

Why do you do this twice? You already detect this case during configure
time.

The runtime check ensures that the argument to BS->Stall() never overflows.
Having said that, perhaps this would be more fitting, and then forget about
the check at configure time:

+       const UINTN max_delay = ~ (UINTN) 0 / 1000 / 1000;
+       BS->Stall(1000 * 1000 *
+           (ENV_BOOT_DELAY < max_delay ? ENV_BOOT_DELAY : max_delay));

Earl

On 2024-02-16 07:54, Jan Kiszka wrote:
On 16.02.24 03:14, 'Earl Chew' via EFI Boot Guard wrote:
Support a configuration option to insert a delay before
starting the image to give the operator a chance to capture
diagnostic messages.

Signed-off-by: Earl Chew <earl_c...@yahoo.com>
---
  configure.ac | 17 +++++++++++++++++
  main.c       |  4 ++++
  2 files changed, 21 insertions(+)

diff --git a/configure.ac b/configure.ac
index b000603..de7ef3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,22 @@ AC_ARG_WITH([env-backend],
AC_SUBST([env_api_file], [${ENV_API_FILE}]) +AC_ARG_WITH([boot-delay],
+           AS_HELP_STRING([--with-boot-delay=INT],
+                          [specify the additional boot delay in seconds, 
defaults to 3]),
+           [
+               # Limit the boot delay to 1 hour to avoid overflowing
+               # BS->Stall() on 32 bit hosts.
+               ENV_BOOT_DELAY=${withval:-3}
+               AS_IF([test "${ENV_BOOT_DELAY}" -lt "0" -o "${ENV_BOOT_DELAY}" -gt 
"3600"],
+                     [
+                       AC_MSG_ERROR([Invalid boot delay.])
+                     ])
+           ],
+           [ ENV_BOOT_DELAY=0 ])
+
+AC_DEFINE_UNQUOTED([ENV_BOOT_DELAY], [${ENV_BOOT_DELAY}], [Additional boot 
delay])
+
  AC_ARG_WITH([num-config-parts],
            AS_HELP_STRING([--with-num-config-parts=INT],
                           [specify the number of used config partitions, 
defaults to 2]),
@@ -248,4 +264,5 @@ AC_MSG_RESULT([
        environment backend:     ${ENV_API_FILE}.c
        number of config parts:  ${ENV_NUM_CONFIG_PARTS}
        reserved for uservars:   ${ENV_MEM_USERVARS} bytes
+       boot delay:              ${ENV_BOOT_DELAY} seconds
  ])
diff --git a/main.c b/main.c
index 0ff121a..0da6a05 100644
--- a/main.c
+++ b/main.c
@@ -214,5 +214,9 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, 
EFI_SYSTEM_TABLE *system_table)
        INFO(L"Starting %s with watchdog set to %d seconds ...\n",
             bg_loader_params.payload_path, bg_loader_params.timeout);
+ const UINTN one_hour = 3600;
+       BS->Stall(1000 * 1000 *
+           (ENV_BOOT_DELAY < one_hour ? ENV_BOOT_DELAY : one_hour));

Why do you do this twice? You already detect this case during configure
time.

Jan

+
        return BS->StartImage(payload_handle, NULL, NULL);
  }


--
You received this message because you are subscribed to the Google Groups "EFI Boot 
Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to efibootguard-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/806d9194-4cfc-4b92-aa09-4622774b5e65%40yahoo.com.

Reply via email to