From: Rob Clark <robdclark@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] efi_loader: add back optional efi_handler::open()
Date: Mon, 24 Jul 2017 10:38:59 -0400 [thread overview]
Message-ID: <20170724143901.8888-1-robdclark@gmail.com> (raw)
In some cases it is useful to defer creation of the protocol interface
object. So add back an optional ->open() hook that is used if
protcol_interface is NULL.
I've slightly simplified the fxn ptr signature to remove unneeded args,
and so compiler will complain if patches that used the "old way" are,
and which do not need this extra complexity, are rebased.
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
include/efi_loader.h | 9 ++++++++-
lib/efi_loader/efi_boottime.c | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 90411cdbab..3da0477fdc 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -41,10 +41,17 @@ extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop;
/*
* When the UEFI payload wants to open a protocol on an object to get its
* interface (usually a struct with callback functions), this struct maps the
- * protocol GUID to the respective protocol interface */
+ * protocol GUID to the respective protocol interface.
+ *
+ * The optional ->open() fxn can be used for cases where the protocol
+ * interface is constructed on-demand, and is called if protocol_interface
+ * is NULL.
+ */
struct efi_handler {
const efi_guid_t *guid;
void *protocol_interface;
+ efi_status_t (EFIAPI *open)(void *handle, efi_guid_t *protocol,
+ void **protocol_interface);
};
/*
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 7d45c18ff7..21f41866d0 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1063,6 +1063,13 @@ static efi_status_t EFIAPI efi_open_protocol(
if (!guidcmp(hprotocol, protocol)) {
if (attributes !=
EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
+ if (!handler->protocol_interface) {
+ r = handler->open(efiobj->handle,
+ protocol,
+ &handler->protocol_interface);
+ if (r != EFI_SUCCESS)
+ goto out;
+ }
*protocol_interface =
handler->protocol_interface;
}
--
2.13.0
next reply other threads:[~2017-07-24 14:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 14:38 Rob Clark [this message]
2017-07-24 14:39 ` [U-Boot] [PATCH 1/2] efi_loader: add helper macro to construct protocol objects Rob Clark
2017-07-28 22:27 ` [U-Boot] [U-Boot, " Alexander Graf
2017-07-24 14:39 ` [U-Boot] [PATCH 2/2] efi_loader: expose protocols via GUID Rob Clark
2017-07-28 22:25 ` [U-Boot] [U-Boot,2/2] " Alexander Graf
2017-07-25 8:52 ` [U-Boot] [PATCH] efi_loader: add back optional efi_handler::open() Alexander Graf
-- strict thread matches above, loose matches on Subject: below --
2017-07-25 12:21 Rob Clark
2017-07-25 16:39 ` Heinrich Schuchardt
2017-07-25 17:20 ` Rob Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170724143901.8888-1-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox