summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2017-08-31 14:48:55 -0400
committerPeter Jones <pjones@redhat.com>2017-08-31 15:13:34 -0400
commit78f6b007e7138df347cb9c527f1ebe01a32cfe3d (patch)
tree0e22138044dd4baddf9b683afed94685e966b9c3
parent5202f80c32bdcab0469785e953bf9fa8dd4eaaa1 (diff)
downloadefi-boot-shim-78f6b007e7138df347cb9c527f1ebe01a32cfe3d.tar.gz
efi-boot-shim-78f6b007e7138df347cb9c527f1ebe01a32cfe3d.zip
Make msleep() be a thing
Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--include/console.h2
-rw-r--r--lib/console.c6
-rw-r--r--replacements.c13
-rw-r--r--shim.c18
4 files changed, 22 insertions, 17 deletions
diff --git a/include/console.h b/include/console.h
index d59e3b4f..9d39841c 100644
--- a/include/console.h
+++ b/include/console.h
@@ -88,4 +88,6 @@ extern UINT8 verbose;
__dprinta_ret; \
})
+extern VOID msleep(unsigned long msecs);
+
#endif /* _SHIM_LIB_CONSOLE_H */
diff --git a/lib/console.c b/lib/console.c
index 3fee403e..31ac110d 100644
--- a/lib/console.c
+++ b/lib/console.c
@@ -459,3 +459,9 @@ VOID setup_console (int text)
uefi_call_wrapper(concon->SetMode, 2, concon, new_mode);
}
+
+VOID
+msleep(unsigned long msecs)
+{
+ uefi_call_wrapper(BS->Stall, 1, msecs);
+}
diff --git a/replacements.c b/replacements.c
index 01eda0e3..898b42b1 100644
--- a/replacements.c
+++ b/replacements.c
@@ -52,11 +52,8 @@
#include <efilib.h>
#include "shim.h"
#include "replacements.h"
-
-/* oh for fuck's sakes.*/
-#ifndef EFI_SECURITY_VIOLATION
-#define EFI_SECURITY_VIOLATION 26
-#endif
+#include "console.h"
+#include "errors.h"
static EFI_SYSTEM_TABLE *systab;
@@ -129,7 +126,7 @@ start_image(EFI_HANDLE image_handle, UINTN *exit_data_size, CHAR16 **exit_data)
Print(L"Something has gone seriously wrong: %d\n",
status2);
Print(L"shim cannot continue, sorry.\n");
- systab->BootServices->Stall(5000000);
+ msleep(5000000);
systab->RuntimeServices->ResetSystem(
EfiResetShutdown,
EFI_SECURITY_VIOLATION, 0, NULL);
@@ -155,7 +152,7 @@ exit_boot_services(EFI_HANDLE image_key, UINTN map_key)
Print(L"Bootloader has not verified loaded image.\n");
Print(L"System is compromised. halting.\n");
- systab->BootServices->Stall(5000000);
+ msleep(5000000);
systab->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION, 0, NULL);
return EFI_SECURITY_VIOLATION;
}
@@ -177,7 +174,7 @@ do_exit(EFI_HANDLE ImageHandle, EFI_STATUS ExitStatus,
Print(L"Something has gone seriously wrong: %r\n",
status2);
Print(L"shim cannot continue, sorry.\n");
- systab->BootServices->Stall(5000000);
+ msleep(5000000);
systab->RuntimeServices->ResetSystem(
EfiResetShutdown,
EFI_SECURITY_VIOLATION, 0, NULL);
diff --git a/shim.c b/shim.c
index bd314b31..d6ff38c4 100644
--- a/shim.c
+++ b/shim.c
@@ -1900,7 +1900,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
efi_status = start_image(image_handle, MOK_MANAGER);
if (efi_status != EFI_SUCCESS) {
Print(L"start_image() returned %r\n", efi_status);
- uefi_call_wrapper(BS->Stall, 1, 2000000);
+ msleep(2000000);
return efi_status;
}
@@ -1910,7 +1910,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
if (efi_status != EFI_SUCCESS) {
Print(L"start_image() returned %r\n", efi_status);
- uefi_call_wrapper(BS->Stall, 1, 2000000);
+ msleep(2000000);
}
return efi_status;
@@ -2751,7 +2751,7 @@ debug_hook(void)
#else
if (x > 12000)
break;
- uefi_call_wrapper(BS->Stall, 1, 5000);
+ msleep(5000);
#endif
}
x = 1;
@@ -2798,10 +2798,10 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
if (efi_status != EFI_SUCCESS && efi_status != EFI_NOT_FOUND) {
Print(L"Something has gone seriously wrong: %r\n", efi_status);
Print(L"Shim was unable to measure state into the TPM\n");
- systab->BootServices->Stall(5000000);
- systab->RuntimeServices->ResetSystem(EfiResetShutdown,
- EFI_SECURITY_VIOLATION,
- 0, NULL);
+ msleep(5000000);
+ uefi_call_wrapper(systab->RuntimeServices->ResetSystem, 4,
+ EfiResetShutdown, EFI_SECURITY_VIOLATION,
+ 0, NULL);
}
/*
@@ -2814,7 +2814,7 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
if (EFI_ERROR(efi_status)) {
Print(L"Something has gone seriously wrong: %r\n", efi_status);
Print(L"shim cannot continue, sorry.\n");
- uefi_call_wrapper(BS->Stall, 1, 5000000);
+ msleep(5000000);
uefi_call_wrapper(systab->RuntimeServices->ResetSystem, 4,
EfiResetShutdown, EFI_SECURITY_VIOLATION,
0, NULL);
@@ -2825,7 +2825,7 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
*/
if (user_insecure_mode) {
Print(L"Booting in insecure mode\n");
- uefi_call_wrapper(BS->Stall, 1, 2000000);
+ msleep(2000000);
}
/*