]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Allow for optional protocols
authorMichael Brown <mcb30@ipxe.org>
Mon, 19 May 2014 19:23:31 +0000 (20:23 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 19 May 2014 19:23:31 +0000 (20:23 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/efi/efi.h
src/interface/efi/efi_init.c

index a98b5588d4d3161055ddec3683e7c380940a149b..05576f9da0832e4fe66f5176c1c1f9d487809978 100644 (file)
@@ -59,6 +59,8 @@ struct efi_protocol {
        EFI_GUID guid;
        /** Variable containing pointer to protocol structure */
        void **protocol;
+       /** Protocol is required */
+       int required;
 };
 
 /** EFI protocol table */
@@ -78,6 +80,21 @@ struct efi_protocol {
                .protocol = ( ( void ** ) ( void * )                         \
                              ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
                                (_ptr) : (_ptr) ) ),                         \
+               .required = 1,                                               \
+       }
+
+/** Declare an EFI protocol to be requested by iPXE
+ *
+ * @v _protocol                EFI protocol name
+ * @v _ptr             Pointer to protocol instance
+ */
+#define EFI_REQUEST_PROTOCOL( _protocol, _ptr )                                     \
+       struct efi_protocol __ ## _protocol __efi_protocol = {               \
+               .guid = _protocol ## _GUID,                                  \
+               .protocol = ( ( void ** ) ( void * )                         \
+                             ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
+                               (_ptr) : (_ptr) ) ),                         \
+               .required = 0,                                               \
        }
 
 /** An EFI configuration table used by iPXE */
index b4ed5c1475a8ee9215d7e6eb0004375dd644854e..e6ef3d054111dee88e43e9608cc45c79ca758423 100644 (file)
@@ -187,8 +187,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
                } else {
                        DBGC ( systab, "EFI does not provide protocol %s\n",
                               efi_guid_ntoa ( &prot->guid ) );
-                       /* All protocols are required */
-                       return efirc;
+                       /* Fail if protocol is required */
+                       if ( prot->required )
+                               return efirc;
                }
        }