[U-Boot] [PATCH 1/1] efi_loader: allow return value in EFI_CALL

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Aug 15 19:42:45 UTC 2017


Macro EFI_CALL was introduced to call an UEFI function.
Unfortunately is did not support return values.
Most UEFI functions have a return value.

So let's rename EFI_CALL to EFI_CALL_VOID and introduce a
new EFI_CALL macro that supports return values.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 include/efi_loader.h          | 16 ++++++++++++++--
 lib/efi_loader/efi_boottime.c |  3 ++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 037cc7c543..1cee10ea0c 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -41,9 +41,21 @@ const char *__efi_nesting_dec(void);
 	})
 
 /*
- * Callback into UEFI world from u-boot:
+ * Call non-void UEFI function from u-boot and retrieve return value:
  */
-#define EFI_CALL(exp) do { \
+#define EFI_CALL(exp) ({ \
+	debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \
+	assert(__efi_exit_check()); \
+	typeof(exp) r = exp; \
+	assert(__efi_entry_check()); \
+	debug("%sEFI: Return From: %s\n", __efi_nesting_dec(), #exp); \
+	r; \
+})
+
+/*
+ * Call void UEFI function world from u-boot:
+ */
+#define EFI_CALL_VOID(exp) do { \
 	debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \
 	assert(__efi_exit_check()); \
 	exp; \
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 43f32385fa..6489a32505 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -158,7 +158,8 @@ void efi_signal_event(struct efi_event *event)
 		return;
 	event->signaled = 1;
 	if (event->type & EVT_NOTIFY_SIGNAL) {
-		EFI_CALL(event->notify_function(event, event->notify_context));
+		EFI_CALL_VOID(event->notify_function(event,
+						     event->notify_context));
 	}
 }
 
-- 
2.14.1



More information about the U-Boot mailing list