]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: add helper macro to construct protocol objects
authorRob Clark <robdclark@gmail.com>
Mon, 24 Jul 2017 14:39:00 +0000 (10:39 -0400)
committerAlexander Graf <agraf@suse.de>
Tue, 25 Jul 2017 08:55:51 +0000 (10:55 +0200)
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 <robdclark@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
include/efi_loader.h

index 40f6c89e656ab76d1d464f5a21ca99afbf4f3826..f384cbbe771b07f6ff684944fd4611e5cd081b0b 100644 (file)
@@ -66,6 +66,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
  *