From fd6c5e1749d9e997221b2b32bf460f1c958e8627 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 7 Jul 2014 13:39:57 -0400 Subject: [PATCH] Revert "[efi] Disable SNP devices when running iPXE as the application" This reverts commit f473b9c3f66a2166129e1f60774f56e673423c5a. --- src/arch/x86/prefix/efidrvprefix.c | 6 +- src/image/efi_image.c | 4 - src/include/ipxe/efi/efi_snp.h | 4 - src/interface/efi/efi_snp.c | 133 ++--------------------------- 4 files changed, 9 insertions(+), 138 deletions(-) diff --git a/src/arch/x86/prefix/efidrvprefix.c b/src/arch/x86/prefix/efidrvprefix.c index 280e3353..8a31df56 100644 --- a/src/arch/x86/prefix/efidrvprefix.c +++ b/src/arch/x86/prefix/efidrvprefix.c @@ -22,7 +22,6 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include -#include /** * EFI entry point @@ -43,8 +42,7 @@ EFI_STATUS EFIAPI _efidrv_start ( EFI_HANDLE image_handle, initialise(); startup(); - /* Release network devices for use via SNP */ - efi_snp_release(); - return 0; } + +REQUIRE_OBJECT ( efi_snp ); diff --git a/src/image/efi_image.c b/src/image/efi_image.c index e993ad5e..31be078b 100644 --- a/src/image/efi_image.c +++ b/src/image/efi_image.c @@ -244,9 +244,6 @@ static int efi_image_exec ( struct image *image ) { loaded.image->LoadOptionsSize = ( ( wcslen ( cmdline ) + 1 /* NUL */ ) * sizeof ( wchar_t ) ); - /* Release network devices for use via SNP */ - efi_snp_release(); - /* Start the image */ if ( ( efirc = bs->StartImage ( handle, NULL, NULL ) ) != 0 ) { rc = -EEFI_START ( efirc ); @@ -259,7 +256,6 @@ static int efi_image_exec ( struct image *image ) { rc = 0; err_start_image: - efi_snp_claim(); err_open_protocol: /* Unload the image. We can't leave it loaded, because we * have no "unload" operation. diff --git a/src/include/ipxe/efi/efi_snp.h b/src/include/ipxe/efi/efi_snp.h index a468165c..daa62775 100644 --- a/src/include/ipxe/efi/efi_snp.h +++ b/src/include/ipxe/efi/efi_snp.h @@ -32,8 +32,6 @@ struct efi_snp_device { EFI_SIMPLE_NETWORK_PROTOCOL snp; /** The SNP "mode" (parameters) */ EFI_SIMPLE_NETWORK_MODE mode; - /** Started flag */ - int started; /** Outstanding TX packet count (via "interrupt status") * * Used in order to generate TX completions. @@ -77,7 +75,5 @@ struct efi_snp_device { extern int efi_snp_hii_install ( struct efi_snp_device *snpdev ); extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev ); extern struct efi_snp_device * last_opened_snpdev ( void ); -extern void efi_snp_claim ( void ); -extern void efi_snp_release ( void ); #endif /* _IPXE_EFI_SNP_H */ diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 9e7b8dcd..b25fce7e 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -69,35 +69,6 @@ static EFI_GUID efi_load_file_protocol_guid /** List of SNP devices */ static LIST_HEAD ( efi_snp_devices ); -/** - * Set EFI SNP mode state - * - * @v snp SNP interface - */ -static void efi_snp_set_state ( struct efi_snp_device *snpdev ) { - struct net_device *netdev = snpdev->netdev; - EFI_SIMPLE_NETWORK_MODE *mode = &snpdev->mode; - - /* Calculate state */ - if ( ! snpdev->started ) { - /* Start() method not called; report as Stopped */ - mode->State = EfiSimpleNetworkStopped; - } else if ( ! netdev_is_open ( netdev ) ) { - /* Network device not opened; report as Started */ - mode->State = EfiSimpleNetworkStarted; - } else if ( ! netdev_rx_frozen ( netdev ) ) { - /* Network device opened but claimed for use by iPXE; report - * as Started to inhibit receive polling. - */ - mode->State = EfiSimpleNetworkStarted; - } else { - /* Network device opened and available for use via SNP; report - * as Initialized. - */ - mode->State = EfiSimpleNetworkInitialized; - } -} - /** * Set EFI SNP mode based on iPXE net device parameters * @@ -163,12 +134,7 @@ efi_snp_start ( EFI_SIMPLE_NETWORK_PROTOCOL *snp ) { DBGC2 ( snpdev, "SNPDEV %p START\n", snpdev ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - - snpdev->started = 1; - efi_snp_set_state ( snpdev ); + snpdev->mode.State = EfiSimpleNetworkStarted; return 0; } @@ -185,12 +151,7 @@ efi_snp_stop ( EFI_SIMPLE_NETWORK_PROTOCOL *snp ) { DBGC2 ( snpdev, "SNPDEV %p STOP\n", snpdev ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - - snpdev->started = 0; - efi_snp_set_state ( snpdev ); + snpdev->mode.State = EfiSimpleNetworkStopped; return 0; } @@ -213,17 +174,13 @@ efi_snp_initialize ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, snpdev, ( ( unsigned long ) extra_rx_bufsize ), ( ( unsigned long ) extra_tx_bufsize ) ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open %s: %s\n", snpdev, snpdev->netdev->name, strerror ( rc ) ); return EFIRC ( rc ); } - efi_snp_set_state ( snpdev ); + snpdev->mode.State = EfiSimpleNetworkInitialized; return 0; } @@ -243,20 +200,16 @@ efi_snp_reset ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ext_verify ) { DBGC2 ( snpdev, "SNPDEV %p RESET (%s extended verification)\n", snpdev, ( ext_verify ? "with" : "without" ) ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - netdev_close ( snpdev->netdev ); - efi_snp_set_state ( snpdev ); + snpdev->mode.State = EfiSimpleNetworkStarted; if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not reopen %s: %s\n", snpdev, snpdev->netdev->name, strerror ( rc ) ); return EFIRC ( rc ); } - efi_snp_set_state ( snpdev ); + snpdev->mode.State = EfiSimpleNetworkInitialized; return 0; } @@ -273,13 +226,8 @@ efi_snp_shutdown ( EFI_SIMPLE_NETWORK_PROTOCOL *snp ) { DBGC2 ( snpdev, "SNPDEV %p SHUTDOWN\n", snpdev ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - netdev_close ( snpdev->netdev ); - efi_snp_set_state ( snpdev ); - + snpdev->mode.State = EfiSimpleNetworkStarted; return 0; } @@ -310,10 +258,6 @@ efi_snp_receive_filters ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 enable, snpdev->netdev->ll_protocol->ll_addr_len ); } - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Lie through our teeth, otherwise MNP refuses to accept us */ return 0; } @@ -336,10 +280,6 @@ efi_snp_station_address ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, DBGC2 ( snpdev, "SNPDEV %p STATION_ADDRESS %s\n", snpdev, ( reset ? "reset" : ll_protocol->ntoa ( new ) ) ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Set the MAC address */ if ( reset ) new = &snpdev->mode.PermanentAddress; @@ -373,10 +313,6 @@ efi_snp_statistics ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset, DBGC2 ( snpdev, "SNPDEV %p STATISTICS%s", snpdev, ( reset ? " reset" : "" ) ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Gather statistics */ memset ( &stats_buf, 0, sizeof ( stats_buf ) ); stats_buf.TxGoodFrames = snpdev->netdev->tx_stats.good; @@ -425,10 +361,6 @@ efi_snp_mcast_ip_to_mac ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN ipv6, inet_ntoa ( *( ( struct in_addr * ) ip ) ) ); DBGC2 ( snpdev, "SNPDEV %p MCAST_IP_TO_MAC %s\n", snpdev, ip_str ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Try to hash the address */ if ( ( rc = ll_protocol->mc_hash ( ( ipv6 ? AF_INET6 : AF_INET ), ip, mac ) ) != 0 ) { @@ -462,10 +394,6 @@ efi_snp_nvdata ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN read, if ( ! read ) DBGC2_HDA ( snpdev, offset, data, len ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - return EFI_UNSUPPORTED; } @@ -485,10 +413,6 @@ efi_snp_get_status ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, DBGC2 ( snpdev, "SNPDEV %p GET_STATUS", snpdev ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Poll the network device */ efi_snp_poll ( snpdev ); @@ -584,10 +508,6 @@ efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, } DBGC2 ( snpdev, "\n" ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Sanity checks */ if ( ll_header_len ) { if ( ll_header_len != ll_protocol->ll_header_len ) { @@ -696,10 +616,6 @@ efi_snp_receive ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, DBGC2 ( snpdev, "SNPDEV %p RECEIVE %p(+%lx)", snpdev, data, ( ( unsigned long ) *len ) ); - /* Fail if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return EFI_NOT_READY; - /* Poll the network device */ efi_snp_poll ( snpdev ); @@ -739,7 +655,7 @@ efi_snp_receive ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, out_bad_ll_header: free_iob ( iobuf ); - out_no_packet: +out_no_packet: return EFIRC ( rc ); } @@ -760,10 +676,6 @@ static VOID EFIAPI efi_snp_wait_for_packet ( EFI_EVENT event, if ( ! netdev_is_open ( snpdev->netdev ) ) return; - /* Do nothing if net device is currently claimed for use by iPXE */ - if ( ! netdev_rx_frozen ( snpdev->netdev ) ) - return; - /* Poll the network device */ efi_snp_poll ( snpdev ); @@ -873,15 +785,9 @@ efi_snp_load_file ( EFI_LOAD_FILE_PROTOCOL *load_file, return EFI_UNSUPPORTED; } - /* Claim network devices for use by iPXE */ - efi_snp_claim(); - /* Boot from network device */ ipxe ( netdev ); - /* Release network devices for use via SNP */ - efi_snp_release(); - /* Assume boot process was aborted */ return EFI_ABORTED; } @@ -1106,9 +1012,6 @@ static void efi_snp_notify ( struct net_device *netdev ) { ( netdev_link_ok ( netdev ) ? TRUE : FALSE ); DBGC ( snpdev, "SNPDEV %p link is %s\n", snpdev, ( snpdev->mode.MediaPresent ? "up" : "down" ) ); - - /* Update mode state */ - efi_snp_set_state ( snpdev ); } /** @@ -1167,25 +1070,3 @@ struct efi_snp_device * last_opened_snpdev ( void ) { return efi_snp_demux ( netdev ); } - -/** - * Claim network devices for use by iPXE - * - */ -void efi_snp_claim ( void ) { - struct net_device *netdev; - - for_each_netdev ( netdev ) - netdev_rx_unfreeze ( netdev ); -} - -/** - * Release network devices for use via SNP - * - */ -void efi_snp_release ( void ) { - struct net_device *netdev; - - for_each_netdev ( netdev ) - netdev_rx_freeze ( netdev ); -}