]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Get_status.c
Update SnpDxe to support dynamic media detect.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Get_status.c
index dc742081dadf1f32e216c79adaeaeeb4feac5099..cf738bd15f541049d34bd6bfaa95509ba9345a3e 100644 (file)
@@ -2,11 +2,11 @@
   Implementation of reading the current interrupt status and recycled transmit\r
   buffer status 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
-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
+Copyright (c) 2004 - 2010, Intel Corporation. <BR>\r
+All rights reserved. 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
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
@@ -16,18 +16,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Snp.h"\r
 \r
 /**\r
-  Call undi to get the status of the interrupts, get the list of transmit \r
-  buffers that completed transmitting. \r
+  Call undi to get the status of the interrupts, get the list of transmit\r
+  buffers that completed transmitting.\r
 \r
   @param  Snp                     Pointer to snp driver structure.\r
-  @param  InterruptStatusPtr      A non null pointer to contain the interrupt \r
+  @param  InterruptStatusPtr      A non null pointer to contain the interrupt\r
                                   status.\r
-  @param  TransmitBufferListPtrs  A non null pointer to contain the list of \r
+  @param  TransmitBufferListPtrs  A non null pointer to contain the list of\r
                                   pointers of previous transmitted buffers whose\r
                                   transmission was completed asynchrnously.\r
-   \r
+\r
   @retval EFI_SUCCESS         The status of the network interface was retrieved.\r
-  @retval EFI_DEVICE_ERROR    The command could not be sent to the network \r
+  @retval EFI_DEVICE_ERROR    The command could not be sent to the network\r
                               interface.\r
 \r
 **/\r
@@ -54,6 +54,10 @@ PxeGetStatus (
     Snp->Cdb.OpFlags |= PXE_OPFLAGS_GET_INTERRUPT_STATUS;\r
   }\r
 \r
+  if (Snp->MediaStatusSupported) {\r
+    Snp->Cdb.OpFlags |= PXE_OPFLAGS_GET_MEDIA_STATUS;\r
+  }\r
+\r
   Snp->Cdb.CPBsize  = PXE_CPBSIZE_NOT_USED;\r
   Snp->Cdb.CPBaddr  = PXE_CPBADDR_NOT_USED;\r
 \r
@@ -121,44 +125,53 @@ PxeGetStatus (
 \r
   }\r
 \r
+  //\r
+  // Update MediaPresent field of EFI_SIMPLE_NETWORK_MODE if the UNDI support\r
+  // returning media status from GET_STATUS command\r
+  //\r
+  if (Snp->MediaStatusSupported) {\r
+    Snp->Snp.Mode->MediaPresent =\r
+      (BOOLEAN) (((Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_MEDIA) != 0) ? FALSE : TRUE);\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
   Reads the current interrupt status and recycled transmit buffer status from a\r
   network interface.\r
-  \r
-  This function gets the current interrupt and recycled transmit buffer status \r
+\r
+  This function gets the current interrupt and recycled transmit buffer status\r
   from the network interface. The interrupt status is returned as a bit mask in\r
   InterruptStatus. If InterruptStatus is NULL, the interrupt status will not be\r
   read. If TxBuf is not NULL, a recycled transmit buffer address will be retrieved.\r
   If a recycled transmit buffer address is returned in TxBuf, then the buffer has\r
   been successfully transmitted, and the status for that buffer is cleared. If\r
-  the status of the network interface is successfully collected, EFI_SUCCESS \r
+  the status of the network interface is successfully collected, EFI_SUCCESS\r
   will be returned. If the driver has not been initialized, EFI_DEVICE_ERROR will\r
   be returned.\r
 \r
   @param This            A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
-  @param InterruptStatus A pointer to the bit mask of the currently active \r
+  @param InterruptStatus A pointer to the bit mask of the currently active\r
                          interrupts (see "Related Definitions"). If this is NULL,\r
                          the interrupt status will not be read from the device.\r
                          If this is not NULL, the interrupt status will be read\r
-                         from the device. When the interrupt status is read, it \r
-                         will also be cleared. Clearing the transmit interrupt does \r
+                         from the device. When the interrupt status is read, it\r
+                         will also be cleared. Clearing the transmit interrupt does\r
                          not empty the recycled transmit buffer array.\r
   @param TxBuf           Recycled transmit buffer address. The network interface\r
-                         will not transmit if its internal recycled transmit \r
+                         will not transmit if its internal recycled transmit\r
                          buffer array is full. Reading the transmit buffer does\r
                          not clear the transmit interrupt. If this is NULL, then\r
-                         the transmit buffer status will not be read. If there \r
-                         are no transmit buffers to recycle and TxBuf is not NULL, \r
+                         the transmit buffer status will not be read. If there\r
+                         are no transmit buffers to recycle and TxBuf is not NULL,\r
                          TxBuf will be set to NULL.\r
 \r
   @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
   @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid \r
+  @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r
                                 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network \r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network\r
                                 interface.\r
 \r
 **/\r