]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
efi_loader: indent entry/exit prints to show nesting level
authorRob Clark <robdclark@gmail.com>
Thu, 27 Jul 2017 12:04:19 +0000 (08:04 -0400)
committerAlexander Graf <agraf@suse.de>
Fri, 28 Jul 2017 22:18:46 +0000 (00:18 +0200)
This should make it easier to see when a callback back to UEFI world
calls back in to the u-boot world, and generally match up EFI_ENTRY()
and EFI_EXIT() calls.

Signed-off-by: Rob Clark <robdclark@gmail.com>
[agraf: remove static from const var]
Signed-off-by: Alexander Graf <agraf@suse.de>
include/efi_loader.h
lib/efi_loader/efi_boottime.c

index 4262d0ac6b9c72dec45b6ed7629f1a6ad7ae172c..037cc7c543414682ebe05f11da5df17764a80a81 100644 (file)
 
 int __efi_entry_check(void);
 int __efi_exit_check(void);
+const char *__efi_nesting_inc(void);
+const char *__efi_nesting_dec(void);
 
 /*
  * Enter the u-boot world from UEFI:
  */
 #define EFI_ENTRY(format, ...) do { \
        assert(__efi_entry_check()); \
-       debug("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
+       debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \
+               __func__, ##__VA_ARGS__); \
        } while(0)
 
 /*
@@ -31,7 +34,8 @@ int __efi_exit_check(void);
  */
 #define EFI_EXIT(ret) ({ \
        efi_status_t _r = ret; \
-       debug("EFI: Exit: %s: %u\n", __func__, (u32)(_r & ~EFI_ERROR_MASK)); \
+       debug("%sEFI: Exit: %s: %u\n", __efi_nesting_dec(), \
+               __func__, (u32)(_r & ~EFI_ERROR_MASK)); \
        assert(__efi_exit_check()); \
        _r; \
        })
@@ -40,11 +44,11 @@ int __efi_exit_check(void);
  * Callback into UEFI world from u-boot:
  */
 #define EFI_CALL(exp) do { \
-       debug("EFI: Call: %s\n", #exp); \
+       debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \
        assert(__efi_exit_check()); \
        exp; \
        assert(__efi_entry_check()); \
-       debug("EFI: Return From: %s\n", #exp); \
+       debug("%sEFI: Return From: %s\n", __efi_nesting_dec(), #exp); \
        } while(0)
 
 extern struct efi_runtime_services efi_runtime_services;
index aa8d0d12d01dca439a7bb407ec5402dd8a98bb94..59479eddb9d877d8d27ca026262db725ff04229d 100644 (file)
@@ -50,6 +50,7 @@ static volatile void *efi_gd, *app_gd;
 #endif
 
 static int entry_count;
+static int nesting_level;
 
 /* Called on every callback entry */
 int __efi_entry_check(void)
@@ -96,6 +97,28 @@ void efi_restore_gd(void)
 #endif
 }
 
+/*
+ * Two spaces per indent level, maxing out at 10.. which ought to be
+ * enough for anyone ;-)
+ */
+static const char *indent_string(int level)
+{
+       const char *indent = "                    ";
+       const int max = strlen(indent);
+       level = min(max, level * 2);
+       return &indent[max - level];
+}
+
+const char *__efi_nesting_inc(void)
+{
+       return indent_string(nesting_level++);
+}
+
+const char *__efi_nesting_dec(void)
+{
+       return indent_string(--nesting_level);
+}
+
 /* Low 32 bit */
 #define EFI_LOW32(a) (a & 0xFFFFFFFFULL)
 /* High 32 bit */
@@ -748,9 +771,11 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
                return EFI_EXIT(info->exit_status);
        }
 
+       __efi_nesting_dec();
        __efi_exit_check();
        entry(image_handle, &systab);
        __efi_entry_check();
+       __efi_nesting_inc();
 
        /* Should usually never get here */
        return EFI_EXIT(EFI_SUCCESS);