Browse Source

[efi] Allow for optional protocols

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
95cff6a4d8
2 changed files with 20 additions and 2 deletions
  1. 17
    0
      src/include/ipxe/efi/efi.h
  2. 3
    2
      src/interface/efi/efi_init.c

+ 17
- 0
src/include/ipxe/efi/efi.h View File

@@ -59,6 +59,8 @@ struct efi_protocol {
59 59
 	EFI_GUID guid;
60 60
 	/** Variable containing pointer to protocol structure */
61 61
 	void **protocol;
62
+	/** Protocol is required */
63
+	int required;
62 64
 };
63 65
 
64 66
 /** EFI protocol table */
@@ -78,6 +80,21 @@ struct efi_protocol {
78 80
 		.protocol = ( ( void ** ) ( void * )			     \
79 81
 			      ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
80 82
 				(_ptr) : (_ptr) ) ),			     \
83
+		.required = 1,						     \
84
+	}
85
+
86
+/** Declare an EFI protocol to be requested by iPXE
87
+ *
88
+ * @v _protocol		EFI protocol name
89
+ * @v _ptr		Pointer to protocol instance
90
+ */
91
+#define EFI_REQUEST_PROTOCOL( _protocol, _ptr )				     \
92
+	struct efi_protocol __ ## _protocol __efi_protocol = {		     \
93
+		.guid = _protocol ## _GUID,				     \
94
+		.protocol = ( ( void ** ) ( void * )			     \
95
+			      ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
96
+				(_ptr) : (_ptr) ) ),			     \
97
+		.required = 0,						     \
81 98
 	}
82 99
 
83 100
 /** An EFI configuration table used by iPXE */

+ 3
- 2
src/interface/efi/efi_init.c View File

@@ -187,8 +187,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
187 187
 		} else {
188 188
 			DBGC ( systab, "EFI does not provide protocol %s\n",
189 189
 			       efi_guid_ntoa ( &prot->guid ) );
190
-			/* All protocols are required */
191
-			return efirc;
190
+			/* Fail if protocol is required */
191
+			if ( prot->required )
192
+				return efirc;
192 193
 		}
193 194
 	}
194 195
 

Loading…
Cancel
Save