[U-Boot] [PATCH 3/3] efi_loader: indent entry/exit prints to show nesting level
Heinrich Schuchardt
xypron.glpk at gmx.de
Wed Jul 26 20:16:30 UTC 2017
On 07/26/2017 03:55 PM, Rob Clark wrote:
> 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 at gmail.com>
> ---
> include/efi_loader.h | 12 ++++++++----
> lib/efi_loader/efi_boottime.c | 28 ++++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 4b49fac84b..88091d4914 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -16,20 +16,24 @@
> #include <linux/list.h>
>
> int __efi_check_nesting(int delta);
> +const char *__efi_nesting_level(int delta);
> +
> /*
> * Enter the u-boot world from UEFI:
> */
> #define EFI_ENTRY(format, ...) do { \
> efi_restore_gd(); \
> + debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_level(1), \
> + __func__, ##__VA_ARGS__); \
> assert(__efi_check_nesting(+1)); \
> - debug("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
> } while(0)
>
> /*
> * Exit the u-boot world back to UEFI:
> */
> #define EFI_EXIT(ret) ({ \
> - debug("EFI: Exit: %s: %u\n", __func__, (u32)((ret) & ~EFI_ERROR_MASK)); \
> + debug("%sEFI: Exit: %s: %u\n", __efi_nesting_level(-1), \
> + __func__, (u32)((ret) & ~EFI_ERROR_MASK)); \
> assert(__efi_check_nesting(-1)); \
> efi_exit_func(ret); \
> })
> @@ -38,12 +42,12 @@ int __efi_check_nesting(int delta);
> * 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_level(1), #exp); \
> assert(__efi_check_nesting(-1)); \
> efi_exit_func(EFI_SUCCESS); \
> exp; \
> efi_restore_gd(); \
> - debug("EFI: Return From: %s\n", #exp); \
> + debug("%sEFI: Return From: %s\n", __efi_nesting_level(-1), #exp); \
> assert(__efi_check_nesting(+1)); \
> } while(0)
>
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index b21df7bd5d..f6c4c162cf 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -92,6 +92,34 @@ efi_status_t efi_exit_func(efi_status_t ret)
> return ret;
> }
>
> +/*
> + * Two spaces per indent level, maxing out at 10.. which ought to be
> + * enough for anyone ;-)
> + */
> +static const char *indent_string(int level)
> +{
> + static const char *indent = " ";
> + const int max = strlen(indent);
> + level = min(max, level * 2);
> + return &indent[max - level];
> +}
> +
> +const char *__efi_nesting_level(int delta)
> +{
> + static int nesting_level;
> + const char *s;
> + /* post-increment, pre-decrement */
> + if (delta > 0) {
> + s = indent_string(nesting_level);
> + nesting_level += delta;
> + } else {
> + nesting_level += delta;
> + s = indent_string(nesting_level);
> + assert(nesting_level >= 0);
> + }
> + return s;
> +}
> +
> /* Low 32 bit */
> #define EFI_LOW32(a) (a & 0xFFFFFFFFULL)
> /* High 32 bit */
>
Tested-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
More information about the U-Boot
mailing list