]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Rename
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Feb 2008 02:32:49 +0000 (02:32 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Feb 2008 02:32:49 +0000 (02:32 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4720 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/SnpDxe/Get_status.c [new file with mode: 0644]

diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Get_status.c b/MdeModulePkg/Universal/Network/SnpDxe/Get_status.c
new file mode 100644 (file)
index 0000000..d1fa262
--- /dev/null
@@ -0,0 +1,190 @@
+/** @file\r
+Copyright (c) 2004 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which 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
+\r
+Module name:\r
+  get_status.c\r
+\r
+Abstract:\r
+\r
+Revision history:\r
+  2000-Feb-03 M(f)J   Genesis.\r
+\r
+**/\r
+\r
+#include "Snp.h"\r
+\r
+STATIC\r
+/**\r
+  this routine calls undi to get the status of the interrupts, get the list of\r
+  transmit buffers that completed transmitting!\r
+\r
+  @param  snp                     pointer to snp driver structure\r
+  @param  InterruptStatusPtr      a non null pointer gets the interrupt status\r
+  @param  TransmitBufferListPtrs  a non null ointer gets the list of pointers of\r
+                                  previously  transmitted buffers whose\r
+                                  transmission was completed  asynchrnously.\r
+\r
+\r
+**/\r
+EFI_STATUS\r
+pxe_getstatus (\r
+  SNP_DRIVER *snp,\r
+  UINT32     *InterruptStatusPtr,\r
+  VOID       **TransmitBufferListPtr\r
+  )\r
+{\r
+  PXE_DB_GET_STATUS *db;\r
+  UINT16            InterruptFlags;\r
+\r
+  db                = snp->db;\r
+  snp->cdb.OpCode   = PXE_OPCODE_GET_STATUS;\r
+\r
+  snp->cdb.OpFlags  = 0;\r
+\r
+  if (TransmitBufferListPtr != NULL) {\r
+    snp->cdb.OpFlags |= PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS;\r
+  }\r
+\r
+  if (InterruptStatusPtr != NULL) {\r
+    snp->cdb.OpFlags |= PXE_OPFLAGS_GET_INTERRUPT_STATUS;\r
+  }\r
+\r
+  snp->cdb.CPBsize  = PXE_CPBSIZE_NOT_USED;\r
+  snp->cdb.CPBaddr  = PXE_CPBADDR_NOT_USED;\r
+\r
+  //\r
+  // size DB for return of one buffer\r
+  //\r
+  snp->cdb.DBsize = (UINT16) (((UINT16) (sizeof (PXE_DB_GET_STATUS)) - (UINT16) (sizeof db->TxBuffer)) + (UINT16) (sizeof db->TxBuffer[0]));\r
+\r
+  snp->cdb.DBaddr     = (UINT64)(UINTN) db;\r
+\r
+  snp->cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
+  snp->cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
+  snp->cdb.IFnum      = snp->if_num;\r
+  snp->cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+\r
+  //\r
+  // Issue UNDI command and check result.\r
+  //\r
+  DEBUG ((EFI_D_NET, "\nsnp->undi.get_status()  "));\r
+\r
+  (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
+\r
+  if (snp->cdb.StatCode != EFI_SUCCESS) {\r
+    DEBUG (\r
+      (EFI_D_NET,\r
+      "\nsnp->undi.get_status()  %xh:%xh\n",\r
+      snp->cdb.StatFlags,\r
+      snp->cdb.StatFlags)\r
+      );\r
+\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // report the values back..\r
+  //\r
+  if (InterruptStatusPtr != NULL) {\r
+    InterruptFlags      = (UINT16) (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK);\r
+\r
+    *InterruptStatusPtr = 0;\r
+\r
+    if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_RECEIVE) {\r
+      *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;\r
+    }\r
+\r
+    if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_TRANSMIT) {\r
+      *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r
+    }\r
+\r
+    if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_COMMAND) {\r
+      *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;\r
+    }\r
+\r
+    if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_SOFTWARE) {\r
+      *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;\r
+    }\r
+\r
+  }\r
+\r
+  if (TransmitBufferListPtr != NULL) {\r
+    *TransmitBufferListPtr =\r
+      (\r
+        (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN) ||\r
+        (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY)\r
+      ) ? 0 : (VOID *) (UINTN) db->TxBuffer[0];\r
+\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  This is the SNP interface routine for getting the status\r
+  This routine basically retrieves snp structure, checks the SNP state and\r
+  calls the pxe_getstatus routine to actually get the undi status\r
+\r
+  @param  this                    context pointer\r
+  @param  InterruptStatusPtr      a non null pointer gets the interrupt status\r
+  @param  TransmitBufferListPtrs  a non null ointer gets the list of pointers of\r
+                                  previously  transmitted buffers whose\r
+                                  transmission was completed  asynchrnously.\r
+\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+snp_undi32_get_status (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r
+  OUT UINT32                     *InterruptStatusPtr OPTIONAL,\r
+  OUT VOID                       **TransmitBufferListPtr OPTIONAL\r
+  )\r
+{\r
+  SNP_DRIVER  *snp;\r
+  EFI_TPL     OldTpl;\r
+  EFI_STATUS  Status;\r
+\r
+  if (this == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (InterruptStatusPtr == NULL && TransmitBufferListPtr == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  if (snp == NULL) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  switch (snp->mode.State) {\r
+  case EfiSimpleNetworkInitialized:\r
+    break;\r
+\r
+  case EfiSimpleNetworkStopped:\r
+    Status = EFI_NOT_STARTED;\r
+    goto ON_EXIT;\r
+\r
+  default:\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto ON_EXIT;\r
+  }\r
+\r
+  Status = pxe_getstatus (snp, InterruptStatusPtr, TransmitBufferListPtr);\r
+\r
+ON_EXIT:\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
+  return Status;\r
+}\r