mirror of
https://github.com/ipxe/ipxe
synced 2026-01-29 12:29:13 +03:00
[efi] Allow for custom methods for disconnecting existing drivers
Allow for greater control over the process used to disconnect existing drivers from a device handle, by converting the "exclude" field from a simple protocol GUID to a per-driver method. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -448,7 +448,7 @@ void efi_driver_uninstall ( void ) {
|
||||
* @v protocol Protocol GUID
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
|
||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
|
||||
@@ -479,6 +479,8 @@ static int efi_driver_exclude ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
}
|
||||
|
||||
/* Try to disconnect driver */
|
||||
DBGC ( device, "EFIDRV %s disconnecting %s drivers\n",
|
||||
efi_handle_name ( device ), efi_guid_ntoa ( protocol ) );
|
||||
if ( driver ) {
|
||||
DBGC ( device, "EFIDRV %s disconnecting %s driver ",
|
||||
efi_handle_name ( device ), efi_guid_ntoa ( protocol ) );
|
||||
@@ -514,7 +516,6 @@ static int efi_driver_connect ( EFI_HANDLE device ) {
|
||||
EFI_HANDLE drivers[2] =
|
||||
{ efi_driver_binding.DriverBindingHandle, NULL };
|
||||
struct efi_driver *efidrv;
|
||||
EFI_GUID *exclude;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
@@ -533,17 +534,14 @@ static int efi_driver_connect ( EFI_HANDLE device ) {
|
||||
efi_handle_name ( device ) );
|
||||
efi_driver_disconnecting = 1;
|
||||
for_each_table_entry_reverse ( efidrv, EFI_DRIVERS ) {
|
||||
exclude = efidrv->exclude;
|
||||
if ( ! exclude )
|
||||
if ( ! efidrv->exclude )
|
||||
continue;
|
||||
if ( ( rc = efidrv->supported ( device ) ) != 0 )
|
||||
continue;
|
||||
DBGC ( device, "EFIDRV %s disconnecting %s drivers\n",
|
||||
efi_handle_name ( device ), efi_guid_ntoa ( exclude ) );
|
||||
if ( ( rc = efi_driver_exclude ( device, exclude ) ) != 0 ) {
|
||||
DBGC ( device, "EFIDRV %s could not disconnect %s "
|
||||
if ( ( rc = efidrv->exclude ( device ) ) != 0 ) {
|
||||
DBGC ( device, "EFIDRV %s could not disconnect "
|
||||
"drivers: %s\n", efi_handle_name ( device ),
|
||||
efi_guid_ntoa ( exclude ), strerror ( rc ) );
|
||||
strerror ( rc ) );
|
||||
/* Ignore the error and attempt to connect anyway */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,6 +829,26 @@ static int efipci_supported ( EFI_HANDLE device ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude existing drivers
|
||||
*
|
||||
* @v device EFI device handle
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int efipci_exclude ( EFI_HANDLE device ) {
|
||||
EFI_GUID *protocol = &efi_pci_io_protocol_guid;
|
||||
int rc;
|
||||
|
||||
/* Exclude existing PCI I/O protocol drivers */
|
||||
if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) {
|
||||
DBGC ( device, "EFIPCI %s could not exclude drivers: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach driver to device
|
||||
*
|
||||
@@ -916,8 +936,8 @@ static void efipci_stop ( struct efi_device *efidev ) {
|
||||
/** EFI PCI driver */
|
||||
struct efi_driver efipci_driver __efi_driver ( EFI_DRIVER_HARDWARE ) = {
|
||||
.name = "PCI",
|
||||
.exclude = &efi_pci_io_protocol_guid,
|
||||
.supported = efipci_supported,
|
||||
.exclude = efipci_exclude,
|
||||
.start = efipci_start,
|
||||
.stop = efipci_stop,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user