]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/MnpDxe/MnpIo.c
For network dynamic media support:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpIo.c
index 65268a8d74202419a069b8463038ce0bb537d205..32cffd5730be524f1706e3eff1c8fa61dcf97aa0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of Managed Network Protocol I/O functions.\r
 \r
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
 of the BSD License which accompanies this distribution.  The full\r
@@ -210,6 +210,18 @@ MnpSyncSendPacket (
 \r
   HeaderSize    = Snp->Mode->MediaHeaderSize - TxData->HeaderLength;\r
 \r
+  //\r
+  // Check media status before transmit packet.\r
+  // Note: media status will be updated by periodic timer MediaDetectTimer.\r
+  //\r
+  if (!Snp->Mode->MediaPresent) {\r
+    //\r
+    // Media not present, skip packet transmit and report EFI_NO_MEDIA\r
+    //\r
+    Status = EFI_NO_MEDIA;\r
+    goto SIGNAL_TOKEN;\r
+  }\r
+\r
   //\r
   // Start the timeout event.\r
   //\r
@@ -998,9 +1010,8 @@ EXIT:
 /**\r
   Remove the received packets if timeout occurs.\r
 \r
-  @param[in]  Event             The event this notify function registered to.\r
-  @param[in]  Context           Pointer to the context data registered to the\r
-                                event.\r
+  @param[in]  Event        The event this notify function registered to.\r
+  @param[in]  Context      Pointer to the context data registered to the event.\r
 \r
 **/\r
 VOID\r
@@ -1065,19 +1076,50 @@ MnpCheckPacketTimeout (
   }\r
 }\r
 \r
+/**\r
+  Poll to update MediaPresent field in SNP ModeData by Snp->GetStatus().\r
+\r
+  @param[in]  Event        The event this notify function registered to.\r
+  @param[in]  Context      Pointer to the context data registered to the event.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+MnpCheckMediaStatus (\r
+  IN EFI_EVENT     Event,\r
+  IN VOID          *Context\r
+  )\r
+{\r
+  MNP_DEVICE_DATA             *MnpDeviceData;\r
+  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+  UINT32                      InterruptStatus;\r
+\r
+  MnpDeviceData = (MNP_DEVICE_DATA *) Context;\r
+  NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);\r
+\r
+  Snp = MnpDeviceData->Snp;\r
+  if (Snp->Mode->MediaPresentSupported) {\r
+    //\r
+    // Upon successful return of GetStatus(), the MediaPresent field of\r
+    // EFI_SIMPLE_NETWORK_MODE will be updated to reflect any change of media status\r
+    //\r
+    Snp->GetStatus (Snp, &InterruptStatus, NULL);\r
+  }\r
+}\r
+\r
 /**\r
   Poll to receive the packets from Snp. This function is either called by upperlayer\r
   protocols/applications or the system poll timer notify mechanism.\r
 \r
-  @param[in]       Event        The event this notify function registered to.\r
-  @param[in, out]  Context      Pointer to the context data registered to the event.\r
+  @param[in]  Event        The event this notify function registered to.\r
+  @param[in]  Context      Pointer to the context data registered to the event.\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 MnpSystemPoll (\r
-  IN     EFI_EVENT   Event,\r
-  IN OUT VOID        *Context\r
+  IN EFI_EVENT     Event,\r
+  IN VOID          *Context\r
   )\r
 {\r
   MNP_DEVICE_DATA  *MnpDeviceData;\r