mirror of https://github.com/acidanthera/audk.git
MdeModulePkg: Fix SNP.Initialize() spec conformance issue
v2: *Refine the coding style according edk2 community's feedback. Current SNP UNDI Initialize command does not follow the UEFI Spec to update the SNP MediaPresent field. The result for the Initialize command execution check should be: StatFlags: (1) Monitor the upper two bits (14 & 15) in the field to know whether the command has been executed by the UNDI (Not started, Queued, Error, Complete). (2) Check the other field to see if there is an active connection to this network device (used to update MediaPresent). StatCode: After command execution completes, either successfully or not, this field contains the result of the command execution (success or failure). This patch is used to fix it. NOTE: If any UNDI driver does not follow the UEFI Spec for the media status update, it may meet failure with this more conditions check (StatFlags). Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
This commit is contained in:
parent
c6ca1c011b
commit
43b9d23dd3
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Implementation of initializing a network adapter.
|
Implementation of initializing a network adapter.
|
||||||
|
|
||||||
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed
|
This program and the accompanying materials are licensed
|
||||||
and made available under the terms and conditions of the BSD License which
|
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
|
accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -37,6 +37,8 @@ PxeInit (
|
||||||
VOID *Addr;
|
VOID *Addr;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
Cpb = Snp->Cpb;
|
Cpb = Snp->Cpb;
|
||||||
if (Snp->TxRxBufferSize != 0) {
|
if (Snp->TxRxBufferSize != 0) {
|
||||||
Status = Snp->PciIo->AllocateBuffer (
|
Status = Snp->PciIo->AllocateBuffer (
|
||||||
|
@ -99,9 +101,29 @@ PxeInit (
|
||||||
|
|
||||||
(*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
|
(*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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Snp->Mode.State = EfiSimpleNetworkInitialized;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
DEBUG (
|
DEBUG (
|
||||||
|
@ -234,7 +256,6 @@ SnpUndi32Initialize (
|
||||||
//
|
//
|
||||||
if (Snp->CableDetectSupported) {
|
if (Snp->CableDetectSupported) {
|
||||||
if (PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {
|
if (PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {
|
||||||
Snp->Mode.MediaPresent = TRUE;
|
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue