X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FSnpDxe%2FInitialize.c;h=4d33154241361f52ada732829f125d59b5ace469;hp=21513752de05645b874fae98211abe2c78987c81;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hpb=128946c9c38977ac2047c86d4143db2a172fc2f6
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Initialize.c b/MdeModulePkg/Universal/Network/SnpDxe/Initialize.c
index 21513752de..4d33154241 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Initialize.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Initialize.c
@@ -1,14 +1,8 @@
/** @file
- Implementation of initializing a network adapter.
+ Implementation of initializing a network adapter.
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
-This program and the accompanying materials are licensed
-and made available under the terms and conditions of the BSD License which
-accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -19,9 +13,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Call UNDI to initialize the interface.
@param Snp Pointer to snp driver structure.
- @param CableDetectFlag Do/don't detect the cable (depending on what
+ @param CableDetectFlag Do/don't detect the cable (depending on what
undi supports).
-
+
@retval EFI_SUCCESS UNDI is initialized successfully.
@retval EFI_DEVICE_ERROR UNDI could not be initialized.
@retval Other Other errors as indicated.
@@ -37,6 +31,8 @@ PxeInit (
VOID *Addr;
EFI_STATUS Status;
+ Status = EFI_SUCCESS;
+
Cpb = Snp->Cpb;
if (Snp->TxRxBufferSize != 0) {
Status = Snp->PciIo->AllocateBuffer (
@@ -99,10 +95,30 @@ PxeInit (
(*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
- if (Snp->Cdb.StatCode == PXE_STATCODE_SUCCESS) {
- Snp->Mode.State = EfiSimpleNetworkInitialized;
+ //
+ // There are two fields need to be checked here:
+ // First is the upper two bits (14 & 15) in the CDB.StatFlags field. Until these bits change to report
+ // PXE_STATFLAGS_COMMAND_COMPLETE or PXE_STATFLAGS_COMMAND_FAILED, the command has not been executed by the UNDI.
+ // Second is the CDB.StatCode field. After command execution completes, either successfully or not,
+ // the CDB.StatCode field contains the result of the command execution.
+ //
+ if ((((Snp->Cdb.StatFlags) & PXE_STATFLAGS_STATUS_MASK) == PXE_STATFLAGS_COMMAND_COMPLETE) &&
+ (Snp->Cdb.StatCode == PXE_STATCODE_SUCCESS)) {
+ //
+ // If cable detect feature is enabled in CDB.OpFlags, check the CDB.StatFlags to see if there is an
+ // active connection to this network device. If the no media StatFlag is set, the UNDI and network
+ // device are still initialized.
+ //
+ if (CableDetectFlag == PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) {
+ if(((Snp->Cdb.StatFlags) & PXE_STATFLAGS_INITIALIZED_NO_MEDIA) != PXE_STATFLAGS_INITIALIZED_NO_MEDIA) {
+ Snp->Mode.MediaPresent = TRUE;
+ } else {
+ Snp->Mode.MediaPresent = FALSE;
+ }
+ }
- Status = EFI_SUCCESS;
+ Snp->Mode.State = EfiSimpleNetworkInitialized;
+ Status = EFI_SUCCESS;
} else {
DEBUG (
(EFI_D_WARN,
@@ -129,8 +145,8 @@ PxeInit (
/**
- Resets a network adapter and allocates the transmit and receive buffers
- required by the network interface; optionally, also requests allocation of
+ Resets a network adapter and allocates the transmit and receive buffers
+ required by the network interface; optionally, also requests allocation of
additional transmit and receive buffers.
This function allocates the transmit and receive buffers required by the network
@@ -142,8 +158,8 @@ PxeInit (
@param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
that the driver should allocate for the network interface.
- Some network interfaces will not be able to use the
- extra buffer, and the caller will not know if it is
+ Some network interfaces will not be able to use the
+ extra buffer, and the caller will not know if it is
actually being used.
@param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
that the driver should allocate for the network interface.
@@ -234,7 +250,6 @@ SnpUndi32Initialize (
//
if (Snp->CableDetectSupported) {
if (PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {
- Snp->Mode.MediaPresent = TRUE;
goto ON_EXIT;
}
}