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
 	EFI_GUID guid;
59
 	EFI_GUID guid;
60
 	/** Variable containing pointer to protocol structure */
60
 	/** Variable containing pointer to protocol structure */
61
 	void **protocol;
61
 	void **protocol;
62
+	/** Protocol is required */
63
+	int required;
62
 };
64
 };
63
 
65
 
64
 /** EFI protocol table */
66
 /** EFI protocol table */
78
 		.protocol = ( ( void ** ) ( void * )			     \
80
 		.protocol = ( ( void ** ) ( void * )			     \
79
 			      ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
81
 			      ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
80
 				(_ptr) : (_ptr) ) ),			     \
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
 /** An EFI configuration table used by iPXE */
100
 /** An EFI configuration table used by iPXE */

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

187
 		} else {
187
 		} else {
188
 			DBGC ( systab, "EFI does not provide protocol %s\n",
188
 			DBGC ( systab, "EFI does not provide protocol %s\n",
189
 			       efi_guid_ntoa ( &prot->guid ) );
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