diff options
| author | Simon Rettberg | 2026-01-28 12:53:53 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2026-01-28 12:53:53 +0100 |
| commit | 8e82785c584dc13e20f9229decb95bd17bbe9cd1 (patch) | |
| tree | a8b359e59196be5b2e3862bed189107f4bc9975f /src/interface/efi/efi_snp.c | |
| parent | Merge branch 'master' into openslx (diff) | |
| parent | [prefix] Make unlzma.S compatible with 386 class CPUs (diff) | |
| download | ipxe-openslx.tar.gz ipxe-openslx.tar.xz ipxe-openslx.zip | |
Merge branch 'master' into openslxopenslx
Diffstat (limited to 'src/interface/efi/efi_snp.c')
| -rw-r--r-- | src/interface/efi/efi_snp.c | 64 |
1 files changed, 25 insertions, 39 deletions
diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 8443be997..dad8b33df 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -18,6 +18,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER ); +FILE_SECBOOT ( PERMITTED ); #include <stdlib.h> #include <string.h> @@ -175,7 +176,7 @@ static void efi_snp_poll ( struct efi_snp_device *snpdev ) { while ( ( iobuf = netdev_rx_dequeue ( snpdev->netdev ) ) ) { list_add_tail ( &iobuf->list, &snpdev->rx ); snpdev->interrupts |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; - bs->SignalEvent ( &snpdev->snp.WaitForPacket ); + bs->SignalEvent ( snpdev->snp.WaitForPacket ); } } @@ -1792,14 +1793,6 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { EFI_STATUS efirc; int rc; - /* Find parent EFI device */ - efidev = efidev_parent ( netdev->dev ); - if ( ! efidev ) { - DBG ( "SNP skipping non-EFI device %s\n", netdev->name ); - rc = 0; - goto err_no_efidev; - } - /* Allocate the SNP device */ snpdev = zalloc ( sizeof ( *snpdev ) ); if ( ! snpdev ) { @@ -1807,9 +1800,13 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { goto err_alloc_snp; } snpdev->netdev = netdev_get ( netdev ); - snpdev->efidev = efidev; INIT_LIST_HEAD ( &snpdev->rx ); + /* Find parent EFI device, if any */ + efidev = efidev_parent ( netdev->dev ); + if ( efidev ) + snpdev->parent = efidev->device; + /* Sanity check */ if ( netdev->ll_protocol->ll_addr_len > sizeof ( EFI_MAC_ADDRESS ) ) { DBGC ( snpdev, "SNPDEV %p cannot support link-layer address " @@ -1916,29 +1913,25 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { * instances to prevent SnpDxe from attempting to bind to * them. */ - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii; } - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii31_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii31_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII31 protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii31; } - /* Add as child of EFI parent device */ - if ( ( rc = efi_child_add ( efidev->device, snpdev->handle ) ) != 0 ) { + /* Add as child of EFI parent device, if applicable */ + if ( snpdev->parent && + ( ( rc = efi_child_add ( snpdev->parent, + snpdev->handle ) ) != 0 ) ) { DBGC ( snpdev, "SNPDEV %p could not become child of %s: %s\n", snpdev, efi_handle_name ( efidev->device ), strerror ( rc ) ); @@ -1958,10 +1951,6 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { /* Add to list of SNP devices */ list_add ( &snpdev->list, &efi_snp_devices ); - /* Close device path */ - bs->CloseProtocol ( efidev->device, &efi_device_path_protocol_guid, - efi_image_handle, efidev->device ); - DBGC ( snpdev, "SNPDEV %p installed for %s as device %s\n", snpdev, netdev->name, efi_handle_name ( snpdev->handle ) ); return 0; @@ -1969,13 +1958,12 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { list_del ( &snpdev->list ); if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); - efi_child_del ( efidev->device, snpdev->handle ); + if ( snpdev->parent ) + efi_child_del ( snpdev->parent, snpdev->handle ); err_efi_child_add: - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); err_open_nii31: - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); err_open_nii: if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, @@ -2008,7 +1996,6 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { free ( snpdev ); } err_alloc_snp: - err_no_efidev: if ( leak ) DBGC ( snpdev, "SNPDEV %p nullified and leaked\n", snpdev ); return rc; @@ -2063,11 +2050,10 @@ static void efi_snp_remove ( struct net_device *netdev, void *priv __unused ) { list_del ( &snpdev->list ); if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); - efi_child_del ( snpdev->efidev->device, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + if ( snpdev->parent ) + efi_child_del ( snpdev->parent, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); if ( ( ! efi_shutdown_in_progress ) && ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, |
