From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Clark Date: Mon, 24 Jul 2017 10:39:00 -0400 Subject: [U-Boot] [PATCH 1/2] efi_loader: add helper macro to construct protocol objects In-Reply-To: <20170724143901.8888-1-robdclark@gmail.com> References: <20170724143901.8888-1-robdclark@gmail.com> Message-ID: <20170724143901.8888-2-robdclark@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de There are a bunch of protocols which should be exposed by GUID but are not. Add a helper macro to create an efi_object, to avoid much typing. Note that using the pointer for efiobj->handle is semi-arbitrary. We just need a unique value to match the efiobj supporting the protocol with the handle that LocateHandle() returns.. See LibLocateProtocol() in gnu-efi. It does LocateHandle() to find all the handles, and then loops over them calling HandleProtocol() with the GUID of the protocol it is trying to find. Signed-off-by: Rob Clark --- include/efi_loader.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index 27c741ba0c..51fbf23864 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -63,6 +63,14 @@ struct efi_object { void *handle; }; +#define EFI_PROTOCOL_OBJECT(_guid, _protocol) (struct efi_object){ \ + .protocols = {{ \ + .guid = &(_guid), \ + .protocol_interface = (void *)(_protocol), \ + }}, \ + .handle = (void *)(_protocol), \ +} + /** * struct efi_event * -- 2.13.0