]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/boot/efi/util.c
Merge pull request #21981 from medhefgo/boot-cleanup
[thirdparty/systemd.git] / src / boot / efi / util.c
index 76e4eef1eb5de2b425c5ddc3a3d6bd0f14725c7e..ab47e108989feb7efcc2f54ebd3d1024295a32f4 100644 (file)
@@ -436,7 +436,7 @@ CHAR8 *strchra(const CHAR8 *s, CHAR8 c) {
 }
 
 EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **ret, UINTN *ret_size) {
-        _cleanup_(FileHandleClosep) EFI_FILE_HANDLE handle = NULL;
+        _cleanup_(file_handle_closep) EFI_FILE_HANDLE handle = NULL;
         _cleanup_freepool_ CHAR8 *buf = NULL;
         EFI_STATUS err;
 
@@ -703,7 +703,7 @@ EFI_STATUS open_directory(
                 const CHAR16 *path,
                 EFI_FILE_HANDLE *ret) {
 
-        _cleanup_(FileHandleClosep) EFI_FILE_HANDLE dir = NULL;
+        _cleanup_(file_handle_closep) EFI_FILE_HANDLE dir = NULL;
         _cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
         EFI_STATUS err;
 
@@ -738,3 +738,20 @@ UINT64 get_os_indications_supported(void) {
 
         return osind;
 }
+
+#ifdef EFI_DEBUG
+__attribute__((noinline)) void debug_break(void) {
+        /* This is a poor programmer's breakpoint to wait until a debugger
+         * has attached to us. Just "set variable wait = 0" or "return" to continue. */
+        volatile BOOLEAN wait = TRUE;
+        while (wait)
+                /* Prefer asm based stalling so that gdb has a source location to present. */
+#if defined(__i386__) || defined(__x86_64__)
+                asm volatile("pause");
+#elif defined(__aarch64__)
+                asm volatile("wfi");
+#else
+                BS->Stall(5000);
+#endif
+}
+#endif