]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Receive.c
MdeModulePkg: Refine SNP driver's media status check logic.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Receive.c
index a37156aa0b1fa5c1ac6846ef4c8f89d27896f903..ace5630066c205b0cea3bf7ac94b506dbb9a18e0 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Implementation of receiving a packet from a network interface.\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials are licensed\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed\r
 and made available under the terms and conditions of the BSD License which\r
 accompanies this distribution. The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -68,10 +68,10 @@ PxeReceive (
   Snp->Cdb.OpCode     = PXE_OPCODE_RECEIVE;\r
   Snp->Cdb.OpFlags    = PXE_OPFLAGS_NOT_USED;\r
 \r
-  Snp->Cdb.CPBsize    = sizeof (PXE_CPB_RECEIVE);\r
+  Snp->Cdb.CPBsize    = (UINT16) sizeof (PXE_CPB_RECEIVE);\r
   Snp->Cdb.CPBaddr    = (UINT64)(UINTN) Cpb;\r
 \r
-  Snp->Cdb.DBsize     = sizeof (PXE_DB_RECEIVE);\r
+  Snp->Cdb.DBsize     = (UINT16) sizeof (PXE_DB_RECEIVE);\r
   Snp->Cdb.DBaddr     = (UINT64)(UINTN) Db;\r
 \r
   Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
@@ -132,6 +132,16 @@ PxeReceive (
     *Protocol = (UINT16) PXE_SWAP_UINT16 (Db->Protocol);\r
   }\r
 \r
+  //\r
+  // We have received a packet from network interface, which implies that the\r
+  // network cable should be present. While, some UNDI driver may not report\r
+  // correct media status during Snp->Initialize(). So, we need ensure\r
+  // MediaPresent in SNP mode data is set to correct value.\r
+  //\r
+  if (Snp->Mode.MediaPresentSupported && !Snp->Mode.MediaPresent) {\r
+    Snp->Mode.MediaPresent = TRUE;\r
+  }\r
+\r
   return (*BufferSize <= BuffSize) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;\r
 }\r
 \r