summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Aronowski <kamil.aronowski@yahoo.com>2023-04-12 18:50:12 +0200
committerPeter Jones <pjones@redhat.com>2023-06-21 14:19:51 -0400
commit549d34691d68518e55c2edd6e759b19de7f8ddef (patch)
tree84bfec1f3e6d73869daad14c7a4c01e1a8980848
parentf7a4338f1b5ef03dca83ce44075e9d6e5897e037 (diff)
downloadefi-boot-shim-549d34691d68518e55c2edd6e759b19de7f8ddef.tar.gz
efi-boot-shim-549d34691d68518e55c2edd6e759b19de7f8ddef.zip
Rename 'msecs' to 'usecs' to avoid potential confusion
The function msleep uses gBS->Stall which waits for a specified number of microseconds. Reference: https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/5_uefi_services/51_services_that_uefi_drivers_commonly_use/517_stall This reference even mentions an example sleeping for 10 microseconds: // Wait 10 uS. Notice the letter 'u'. Therefore it's a good idea to call the function 'usleep' rather than 'msleep', so no one confuses it with milliseconds, and to change the argument name to match as well. Signed-off-by: Kamil Aronowski <kamil.aronowski@yahoo.com>
-rw-r--r--fallback.c8
-rw-r--r--include/asm.h4
-rw-r--r--include/console.h2
-rw-r--r--lib/console.c4
-rw-r--r--model.c2
-rw-r--r--replacements.c6
-rw-r--r--shim.c12
7 files changed, 19 insertions, 19 deletions
diff --git a/fallback.c b/fallback.c
index da4b25cc..ad70ccf1 100644
--- a/fallback.c
+++ b/fallback.c
@@ -1013,7 +1013,7 @@ try_start_first_option(EFI_HANDLE parent_image_handle)
console_print(L"Verbose enabled, sleeping for %d mseconds... "
L"Press the Pause key now to hold for longer.\n",
fallback_verbose_wait);
- msleep(fallback_verbose_wait);
+ usleep(fallback_verbose_wait);
}
if (!first_new_option) {
@@ -1036,7 +1036,7 @@ try_start_first_option(EFI_HANDLE parent_image_handle)
}
console_print(L"\n");
- msleep(500000000);
+ usleep(500000000);
return efi_status;
}
@@ -1051,7 +1051,7 @@ try_start_first_option(EFI_HANDLE parent_image_handle)
efi_status = BS->StartImage(image_handle, NULL, NULL);
if (EFI_ERROR(efi_status)) {
console_print(L"StartImage failed: %r\n", efi_status);
- msleep(500000000);
+ usleep(500000000);
}
return efi_status;
}
@@ -1218,7 +1218,7 @@ reset:
console_print(L"Verbose enabled, sleeping for %d mseconds... "
L"Press the Pause key now to hold for longer.\n",
fallback_verbose_wait);
- msleep(fallback_verbose_wait);
+ usleep(fallback_verbose_wait);
}
RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
diff --git a/include/asm.h b/include/asm.h
index 03b06557..f5118b23 100644
--- a/include/asm.h
+++ b/include/asm.h
@@ -40,11 +40,11 @@ static inline void wait_for_debug(void)
{
uint64_t a, b;
int x;
- extern void msleep(unsigned long msecs);
+ extern void usleep(unsigned long usecs);
a = read_counter();
for (x = 0; x < 1000; x++) {
- msleep(1000);
+ usleep(1000);
b = read_counter();
if (a != b)
break;
diff --git a/include/console.h b/include/console.h
index 2a29c2dc..8eb4b47f 100644
--- a/include/console.h
+++ b/include/console.h
@@ -123,7 +123,7 @@ extern EFI_STATUS print_crypto_errors(EFI_STATUS rc, char *file, const char *fun
#define crypterr(rc) print_crypto_errors((rc), __FILE__, __func__, __LINE__)
#ifndef SHIM_UNIT_TEST
-extern VOID msleep(unsigned long msecs);
+extern VOID usleep(unsigned long usecs);
#endif
/* This is used in various things to determine if we should print to the
diff --git a/lib/console.c b/lib/console.c
index c7ca3bc2..a751f79d 100644
--- a/lib/console.c
+++ b/lib/console.c
@@ -745,9 +745,9 @@ setup_verbosity(VOID)
#ifndef SHIM_UNIT_TEST
VOID
-msleep(unsigned long msecs)
+usleep(unsigned long usecs)
{
- BS->Stall(msecs);
+ BS->Stall(usecs);
}
#endif
diff --git a/model.c b/model.c
index e122ba9c..6052ff50 100644
--- a/model.c
+++ b/model.c
@@ -54,7 +54,7 @@ gcm_gmult_4bit(u64 Xi[2], u128 Htable[16])
}
void
-msleep(int n)
+usleep(int n)
{
__coverity_sleep__();
}
diff --git a/replacements.c b/replacements.c
index 6066f9d6..469e73aa 100644
--- a/replacements.c
+++ b/replacements.c
@@ -109,7 +109,7 @@ replacement_start_image(EFI_HANDLE image_handle, UINTN *exit_data_size, CHAR16 *
console_print(L"Something has gone seriously wrong: %r\n",
efi_status2);
console_print(L"shim cannot continue, sorry.\n");
- msleep(5000000);
+ usleep(5000000);
RT->ResetSystem(EfiResetShutdown,
EFI_SECURITY_VIOLATION,
0, NULL);
@@ -137,7 +137,7 @@ exit_boot_services(EFI_HANDLE image_key, UINTN map_key)
console_print(L"Bootloader has not verified loaded image.\n");
console_print(L"System is compromised. halting.\n");
- msleep(5000000);
+ usleep(5000000);
RT->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION, 0, NULL);
return EFI_SECURITY_VIOLATION;
}
@@ -162,7 +162,7 @@ do_exit(EFI_HANDLE ImageHandle, EFI_STATUS ExitStatus,
console_print(L"Something has gone seriously wrong: %r\n",
efi_status2);
console_print(L"shim cannot continue, sorry.\n");
- msleep(5000000);
+ usleep(5000000);
RT->ResetSystem(EfiResetShutdown,
EFI_SECURITY_VIOLATION, 0, NULL);
}
diff --git a/shim.c b/shim.c
index c31e97fb..17afcabb 100644
--- a/shim.c
+++ b/shim.c
@@ -1207,7 +1207,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
efi_status = start_image(image_handle, MOK_MANAGER);
if (EFI_ERROR(efi_status)) {
console_print(L"start_image() returned %r\n", efi_status);
- msleep(2000000);
+ usleep(2000000);
return efi_status;
}
@@ -1222,7 +1222,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
console_print(
L"start_image() returned %r, falling back to default loader\n",
efi_status);
- msleep(2000000);
+ usleep(2000000);
load_options = NULL;
load_options_size = 0;
efi_status = start_image(image_handle, DEFAULT_LOADER);
@@ -1230,7 +1230,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
if (EFI_ERROR(efi_status)) {
console_print(L"start_image() returned %r\n", efi_status);
- msleep(2000000);
+ usleep(2000000);
}
return efi_status;
@@ -1642,7 +1642,7 @@ devel_egress(devel_egress_action action UNUSED)
console_print(L"Waiting to %a...", reasons[action]);
for (size_t sleepcount = 0; sleepcount < 10; sleepcount++) {
console_print(L"%d...", 10 - sleepcount);
- msleep(1000000);
+ usleep(1000000);
}
console_print(L"\ndoing %a\n", action);
@@ -1780,7 +1780,7 @@ die:
#if defined(ENABLE_SHIM_DEVEL)
devel_egress(COLD_RESET);
#else
- msleep(5000000);
+ usleep(5000000);
RT->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION,
0, NULL);
#endif
@@ -1803,7 +1803,7 @@ die:
*/
if (user_insecure_mode) {
console_print(L"Booting in insecure mode\n");
- msleep(2000000);
+ usleep(2000000);
}
/*