]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Use the PciIo->GetBarAttributes to find the logical bar index of the memory mapped...
authorFu, Siyuan <siyuan.fu@intel.com>
Mon, 15 Sep 2014 03:37:58 +0000 (03:37 +0000)
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 15 Sep 2014 03:37:58 +0000 (03:37 +0000)
2. Remove unused code for undi 3.0.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu, Siyuan <siyuan.fu@intel.com>
Reviewed-By: Ye, Ting (ting.ye@intel.com)
Reviewed-By: Ni, Ruiyu <ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16104 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/SnpDxe/Callback.c
MdeModulePkg/Universal/Network/SnpDxe/Snp.c
MdeModulePkg/Universal/Network/SnpDxe/Snp.h

index 5ee191aeea35e63fb502cd62233f42f5a3a6d9bb..7f35642937dbf65d5143afe19f4dfa7b5280b9db 100644 (file)
@@ -1,9 +1,9 @@
 /** @file\r
 /** @file\r
-  This file contains two sets of callback routines for undi3.0 and undi3.1.\r
+  This file contains the callback routines for undi3.1.\r
   the callback routines for Undi3.1 have an extra parameter UniqueId which\r
   stores the interface context for the NIC that snp is trying to talk.\r
 \r
   the callback routines for Undi3.1 have an extra parameter UniqueId which\r
   stores the interface context for the NIC that snp is trying to talk.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
 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
 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
@@ -16,218 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "Snp.h"\r
 \r
 \r
 #include "Snp.h"\r
 \r
-//\r
-// Global variables\r
-// these 2 global variables are used only for 3.0 undi. we could not place\r
-// them in the snp structure because we will not know which snp structure\r
-// in the callback context!\r
-//\r
-BOOLEAN              mInitializeLock = TRUE;\r
-EFI_LOCK             mLock;\r
-\r
-//\r
-// End Global variables\r
-//\r
-extern EFI_PCI_IO_PROTOCOL  *mPciIo;\r
-\r
-/**\r
-  Convert a virtual or CPU address provided by SNP to a physical or device\r
-  address.\r
-\r
-  This is a callback routine supplied to UNDI at undi_start time. Since EFI uses\r
-  the identical mapping, this routine returns the physical address same as the\r
-  virtual address for most of the addresses. an address above 4GB cannot\r
-  generally be used as a device address, it needs to be mapped to a lower\r
-  physical address. This routine does not call the map routine itself, but it\r
-  assumes that the mapping was done at the time of providing the address to\r
-  UNDI. This routine just looks up the address in a map table (which is the v2p\r
-  structure chain).\r
-\r
-  @param  CpuAddr        Virtual address.\r
-  @param  DeviceAddrPtr  Pointer to the physical address, or 0 in case of any\r
-                         error.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackV2p30 (\r
-  IN UINT64     CpuAddr,\r
-  IN OUT UINT64 DeviceAddrPtr\r
-  )\r
-{\r
-  V2P  *V2p;\r
-  //\r
-  // Do nothing if virtual address is zero or physical pointer is NULL.\r
-  // No need to map if the virtual address is within 4GB limit since\r
-  // EFI uses identical mapping\r
-  //\r
-  if ((CpuAddr == 0) || (DeviceAddrPtr == 0)) {\r
-    DEBUG ((EFI_D_NET, "\nv2p: Null virtual address or physical pointer.\n"));\r
-    return ;\r
-  }\r
-\r
-  if (CpuAddr < FOUR_GIGABYTES) {\r
-    *(UINT64 *) (UINTN) DeviceAddrPtr = CpuAddr;\r
-    return ;\r
-  }\r
-  //\r
-  // SNP creates a vaddr tp paddr mapping at the time of calling undi with any\r
-  // big address, this callback routine just looks up in the v2p list and\r
-  // returns the physical address for any given virtual address.\r
-  //\r
-  if (FindV2p (&V2p, (VOID *) (UINTN) CpuAddr) != EFI_SUCCESS) {\r
-    *(UINT64 *) (UINTN) DeviceAddrPtr = CpuAddr;\r
-  } else {\r
-    *(UINT64 *) (UINTN) DeviceAddrPtr = V2p->PhysicalAddress;\r
-  }\r
-}\r
-\r
-/**\r
-  Acquire or release a lock of an exclusive access to a critical section of the\r
-  code/data.\r
-\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-\r
-  @param Enable   Non-zero indicates acquire; Zero indicates release.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackBlock30 (\r
-  IN UINT32 Enable\r
-  )\r
-{\r
-  //\r
-  // tcpip was calling snp at tpl_notify and if we acquire a lock that was\r
-  // created at a lower level (TPL_CALLBACK) it gives an assert!\r
-  //\r
-  if (mInitializeLock) {\r
-    EfiInitializeLock (&mLock, TPL_NOTIFY);\r
-    mInitializeLock = FALSE;\r
-  }\r
-\r
-  if (Enable != 0) {\r
-    EfiAcquireLock (&mLock);\r
-  } else {\r
-    EfiReleaseLock (&mLock);\r
-  }\r
-}\r
-\r
-/**\r
-  Delay MicroSeconds of micro seconds.\r
-\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-\r
-  @param MicroSeconds  Number of micro seconds to pause, ususlly multiple of 10.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackDelay30 (\r
-  IN UINT64 MicroSeconds\r
-  )\r
-{\r
-  if (MicroSeconds != 0) {\r
-    gBS->Stall ((UINTN) MicroSeconds);\r
-  }\r
-}\r
-\r
-/**\r
-  IO routine for UNDI.\r
-\r
-  This is a callback routine supplied to UNDI at undi_start time. This is not\r
-  currently being used by UNDI3.0 because Undi3.0 uses io/mem offsets relative\r
-  to the beginning of the device io/mem address and so it needs to use the\r
-  PCI_IO_FUNCTION that abstracts the start of the device's io/mem addresses.\r
-  Since SNP cannot retrive the context of the undi3.0 interface it cannot use\r
-  the PCI_IO_FUNCTION that specific for that NIC and uses one global IO\r
-  functions structure, this does not work. This however works fine for EFI1.0\r
-  Undis because they use absolute addresses for io/mem access.\r
-\r
-  @param ReadOrWrite  Indicates read or write, IO or Memory.\r
-  @param NumBytes     Number of bytes to read or write.\r
-  @param Address      IO or memory address to read from or write to.\r
-  @param BufferAddr   Memory location to read into or that contains the bytes to\r
-                      write.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackMemio30 (\r
-  IN UINT8      ReadOrWrite,\r
-  IN UINT8      NumBytes,\r
-  IN UINT64     Address,\r
-  IN OUT UINT64 BufferAddr\r
-  )\r
-{\r
-  EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
-\r
-  switch (NumBytes) {\r
-  case 2:\r
-    Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 1;\r
-    break;\r
-\r
-  case 4:\r
-    Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 2;\r
-    break;\r
-\r
-  case 8:\r
-    Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 3;\r
-    break;\r
-\r
-  default:\r
-    Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 0;\r
-  }\r
-\r
-  switch (ReadOrWrite) {\r
-  case PXE_IO_READ:\r
-    mPciIo->Io.Read (\r
-                 mPciIo,\r
-                 Width,\r
-                 1,    // BAR 1, IO base address\r
-                 Address,\r
-                 1,    // count\r
-                 (VOID *) (UINTN) BufferAddr\r
-                 );\r
-    break;\r
-\r
-  case PXE_IO_WRITE:\r
-    mPciIo->Io.Write (\r
-                 mPciIo,\r
-                 Width,\r
-                 1,    // BAR 1, IO base address\r
-                 Address,\r
-                 1,    // count\r
-                 (VOID *) (UINTN) BufferAddr\r
-                 );\r
-    break;\r
-\r
-  case PXE_MEM_READ:\r
-    mPciIo->Mem.Read (\r
-                  mPciIo,\r
-                  Width,\r
-                  0,  // BAR 0, Memory base address\r
-                  Address,\r
-                  1,  // count\r
-                  (VOID *) (UINTN) BufferAddr\r
-                  );\r
-    break;\r
-\r
-  case PXE_MEM_WRITE:\r
-    mPciIo->Mem.Write (\r
-                  mPciIo,\r
-                  Width,\r
-                  0,  // BAR 0, Memory base address\r
-                  Address,\r
-                  1,  // count\r
-                  (VOID *) (UINTN) BufferAddr\r
-                  );\r
-    break;\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
 /**\r
   Acquire or release a lock of the exclusive access to a critical section of the\r
   code/data.\r
 /**\r
   Acquire or release a lock of the exclusive access to a critical section of the\r
   code/data.\r
index 6aa207a48d243ef564b2c7bd91076b643ea009bd..aa5926a6a521321d9d864917267870d75210a4ef 100644 (file)
@@ -14,14 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "Snp.h"\r
 \r
 \r
 #include "Snp.h"\r
 \r
-//\r
-//  Module global variables needed to support undi 3.0 interface\r
-//\r
-EFI_PCI_IO_PROTOCOL         *mPciIo;\r
-V2P                         *mV2p = NULL; // undi3.0 map_list head\r
-// End Global variables\r
-//\r
-\r
 /**\r
   One notified function to stop UNDI device when gBS->ExitBootServices() called.\r
 \r
 /**\r
   One notified function to stop UNDI device when gBS->ExitBootServices() called.\r
 \r
@@ -277,12 +269,11 @@ SimpleNetworkDriverStart (
   SNP_DRIVER                                *Snp;\r
   VOID                                      *Address;\r
   EFI_HANDLE                                Handle;\r
   SNP_DRIVER                                *Snp;\r
   VOID                                      *Address;\r
   EFI_HANDLE                                Handle;\r
-  PXE_PCI_CONFIG_INFO                       ConfigInfo;\r
-  PCI_TYPE00                                *ConfigHeader;\r
-  UINT32                                    *TempBar;\r
   UINT8                                     BarIndex;\r
   PXE_STATFLAGS                             InitStatFlags;\r
   UINT8                                     BarIndex;\r
   PXE_STATFLAGS                             InitStatFlags;\r
-\r
+  EFI_PCI_IO_PROTOCOL                       *PciIo;\r
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR         *BarDesc;\r
+  \r
   DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));\r
 \r
   Status = gBS->OpenProtocol (\r
   DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier()  "));\r
 \r
   Status = gBS->OpenProtocol (\r
@@ -311,7 +302,7 @@ SimpleNetworkDriverStart (
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiPciIoProtocolGuid,\r
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &mPciIo,\r
+                  (VOID **) &PciIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
@@ -367,14 +358,14 @@ SimpleNetworkDriverStart (
   // OK, we like this UNDI, and we know snp is not already there on this handle\r
   // Allocate and initialize a new simple network protocol structure.\r
   //\r
   // OK, we like this UNDI, and we know snp is not already there on this handle\r
   // Allocate and initialize a new simple network protocol structure.\r
   //\r
-  Status = mPciIo->AllocateBuffer (\r
-                        mPciIo,\r
-                        AllocateAnyPages,\r
-                        EfiBootServicesData,\r
-                        SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
-                        &Address,\r
-                        0\r
-                        );\r
+  Status = PciIo->AllocateBuffer (\r
+                    PciIo,\r
+                    AllocateAnyPages,\r
+                    EfiBootServicesData,\r
+                    SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
+                    &Address,\r
+                    0\r
+                    );\r
 \r
   if (Status != EFI_SUCCESS) {\r
     DEBUG ((EFI_D_NET, "\nCould not allocate SNP_DRIVER structure.\n"));\r
 \r
   if (Status != EFI_SUCCESS) {\r
     DEBUG ((EFI_D_NET, "\nCould not allocate SNP_DRIVER structure.\n"));\r
@@ -385,7 +376,7 @@ SimpleNetworkDriverStart (
 \r
   ZeroMem (Snp, sizeof (SNP_DRIVER));\r
 \r
 \r
   ZeroMem (Snp, sizeof (SNP_DRIVER));\r
 \r
-  Snp->PciIo      = mPciIo;\r
+  Snp->PciIo      = PciIo;\r
   Snp->Signature  = SNP_DRIVER_SIGNATURE;\r
 \r
   EfiInitializeLock (&Snp->Lock, TPL_NOTIFY);\r
   Snp->Signature  = SNP_DRIVER_SIGNATURE;\r
 \r
   EfiInitializeLock (&Snp->Lock, TPL_NOTIFY);\r
@@ -446,14 +437,14 @@ SimpleNetworkDriverStart (
   // -it is OK to allocate one global set of CPB, DB pair for each UNDI\r
   // interface as EFI does not multi-task and so SNP will not be re-entered!\r
   //\r
   // -it is OK to allocate one global set of CPB, DB pair for each UNDI\r
   // interface as EFI does not multi-task and so SNP will not be re-entered!\r
   //\r
-  Status = mPciIo->AllocateBuffer (\r
-                        mPciIo,\r
-                        AllocateAnyPages,\r
-                        EfiBootServicesData,\r
-                        SNP_MEM_PAGES (4096),\r
-                        &Address,\r
-                        0\r
-                        );\r
+  Status = PciIo->AllocateBuffer (\r
+                    PciIo,\r
+                    AllocateAnyPages,\r
+                    EfiBootServicesData,\r
+                    SNP_MEM_PAGES (4096),\r
+                    &Address,\r
+                    0\r
+                    );\r
 \r
   if (Status != EFI_SUCCESS) {\r
     DEBUG ((EFI_D_NET, "\nCould not allocate CPB and DB structures.\n"));\r
 \r
   if (Status != EFI_SUCCESS) {\r
     DEBUG ((EFI_D_NET, "\nCould not allocate CPB and DB structures.\n"));\r
@@ -464,19 +455,35 @@ SimpleNetworkDriverStart (
   Snp->Db   = (VOID *) ((UINTN) Address + 2048);\r
 \r
   //\r
   Snp->Db   = (VOID *) ((UINTN) Address + 2048);\r
 \r
   //\r
-  // PxeStart call is going to give the callback functions to UNDI, these callback\r
-  // functions use the BarIndex values from the snp structure, so these must be initialized\r
-  // with default values before doing a PxeStart. The correct values can be obtained after\r
-  // getting the config information from UNDI\r
-  //\r
-  Snp->MemoryBarIndex = 0;\r
-  Snp->IoBarIndex     = 1;\r
+  // Find the correct memory and io bar.\r
+  //\r
+  Snp->MemoryBarIndex = PCI_MAX_BAR;\r
+  Snp->IoBarIndex     = PCI_MAX_BAR;\r
+  for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {\r
+    Status = PciIo->GetBarAttributes (\r
+                      PciIo,\r
+                      BarIndex,\r
+                      NULL,\r
+                      (VOID**) &BarDesc\r
+                      );\r
+    if (Status == EFI_UNSUPPORTED) {\r
+      continue;\r
+    } else if (EFI_ERROR (Status)) {\r
+      goto Error_DeleteSNP;\r
+    }\r
+\r
+    if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {\r
+      Snp->MemoryBarIndex = BarIndex;\r
+    } else if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {\r
+      Snp->IoBarIndex = BarIndex;\r
+    }\r
+\r
+    FreePool (BarDesc);\r
+  }\r
+  if ((Snp->MemoryBarIndex == PCI_MAX_BAR) || (Snp->IoBarIndex == PCI_MAX_BAR)) {\r
+    goto Error_DeleteSNP;\r
+  }\r
 \r
 \r
-  //\r
-  // we need the undi init information many times in this snp code, just get it\r
-  // once here and store it in the snp driver structure. to get Init Info\r
-  // from UNDI we have to start undi first.\r
-  //\r
   Status = PxeStart (Snp);\r
 \r
   if (Status != EFI_SUCCESS) {\r
   Status = PxeStart (Snp);\r
 \r
   if (Status != EFI_SUCCESS) {\r
@@ -513,57 +520,6 @@ SimpleNetworkDriverStart (
     goto Error_DeleteSNP;\r
   }\r
 \r
     goto Error_DeleteSNP;\r
   }\r
 \r
-  Snp->Cdb.OpCode     = PXE_OPCODE_GET_CONFIG_INFO;\r
-  Snp->Cdb.OpFlags    = PXE_OPFLAGS_NOT_USED;\r
-\r
-  Snp->Cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
-  Snp->Cdb.CPBaddr    = PXE_DBADDR_NOT_USED;\r
-\r
-  Snp->Cdb.DBsize     = (UINT16) sizeof (ConfigInfo);\r
-  Snp->Cdb.DBaddr     = (UINT64)(UINTN) &ConfigInfo;\r
-\r
-  Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
-  Snp->Cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
-\r
-  Snp->Cdb.IFnum      = Snp->IfNum;\r
-  Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
-\r
-  DEBUG ((EFI_D_NET, "\nSnp->undi.get_config_info()  "));\r
-\r
-  (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
-\r
-  if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
-    DEBUG ((EFI_D_NET, "\nSnp->undi.config_info()  %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
-    PxeStop (Snp);\r
-    goto Error_DeleteSNP;\r
-  }\r
-  //\r
-  // Find the correct BAR to do IO.\r
-  //\r
-  //\r
-  // Enumerate through the PCI BARs for the device to determine which one is\r
-  // the IO BAR.  Save the index of the BAR into the adapter info structure.\r
-  // for  regular 32bit BARs, 0 is memory mapped, 1 is io mapped\r
-  //\r
-  ConfigHeader  = (PCI_TYPE00 *) ConfigInfo.Config.Byte;\r
-  TempBar       = (UINT32 *) ConfigHeader->Device.Bar;\r
-  for (BarIndex = 0; BarIndex <= 5; BarIndex++) {\r
-    if ((*TempBar & PCI_BAR_MEM_MASK) == PCI_BAR_MEM_64BIT) {\r
-      //\r
-      // This is a 64-bit memory bar, skip this and the\r
-      // next bar as well.\r
-      //\r
-      TempBar++;\r
-    }\r
-\r
-    if ((*TempBar & PCI_BAR_IO_MASK) == PCI_BAR_IO_MODE) {\r
-      Snp->IoBarIndex = BarIndex;\r
-      break;\r
-    }\r
-\r
-    TempBar++;\r
-  }\r
-\r
   //\r
   //  Initialize simple network protocol mode structure\r
   //\r
   //\r
   //  Initialize simple network protocol mode structure\r
   //\r
@@ -703,19 +659,19 @@ SimpleNetworkDriverStart (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
-  mPciIo->FreeBuffer (\r
-            mPciIo,\r
-            SNP_MEM_PAGES (4096),\r
-            Snp->Cpb\r
-            );\r
+  PciIo->FreeBuffer (\r
+           PciIo,\r
+           SNP_MEM_PAGES (4096),\r
+           Snp->Cpb\r
+           );\r
 \r
 Error_DeleteSNP:\r
 \r
 \r
 Error_DeleteSNP:\r
 \r
-  mPciIo->FreeBuffer (\r
-                mPciIo,\r
-                SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
-                Snp\r
-                );\r
+  PciIo->FreeBuffer (\r
+           PciIo,\r
+           SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
+           Snp\r
+           );\r
 NiiError:\r
   gBS->CloseProtocol (\r
         Controller,\r
 NiiError:\r
   gBS->CloseProtocol (\r
         Controller,\r
@@ -771,6 +727,7 @@ SimpleNetworkDriverStop (
   EFI_STATUS                  Status;\r
   EFI_SIMPLE_NETWORK_PROTOCOL *SnpProtocol;\r
   SNP_DRIVER                  *Snp;\r
   EFI_STATUS                  Status;\r
   EFI_SIMPLE_NETWORK_PROTOCOL *SnpProtocol;\r
   SNP_DRIVER                  *Snp;\r
+  EFI_PCI_IO_PROTOCOL         *PciIo;\r
 \r
   //\r
   // Get our context back.\r
 \r
   //\r
   // Get our context back.\r
@@ -822,17 +779,18 @@ SimpleNetworkDriverStop (
   PxeShutdown (Snp);\r
   PxeStop (Snp);\r
 \r
   PxeShutdown (Snp);\r
   PxeStop (Snp);\r
 \r
-  mPciIo->FreeBuffer (\r
-                mPciIo,\r
-                SNP_MEM_PAGES (4096),\r
-                Snp->Cpb\r
-                );\r
+  PciIo = Snp->PciIo;\r
+  PciIo->FreeBuffer (\r
+           PciIo,\r
+           SNP_MEM_PAGES (4096),\r
+           Snp->Cpb\r
+           );\r
 \r
 \r
-  mPciIo->FreeBuffer (\r
-                mPciIo,\r
-                SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
-                Snp\r
-                );\r
+  PciIo->FreeBuffer (\r
+           PciIo,\r
+           SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
+           Snp\r
+           );\r
 \r
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
@@ -849,159 +807,6 @@ EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding = {
   NULL\r
 };\r
 \r
   NULL\r
 };\r
 \r
-\r
-/**\r
-  This routine maps the given CPU address to a Device address. It creates a\r
-  an entry in the map list with the virtual and physical addresses and the\r
-  un map cookie.\r
-\r
-  @param  V2p                  pointer to return a map list node pointer.\r
-  @param  Type                 the direction in which the data flows from the given\r
-                               virtual address device->cpu or cpu->device or both\r
-                               ways.\r
-  @param  VirtualAddress       virtual address (or CPU address) to be mapped.\r
-  @param  BufferSize           size of the buffer to be mapped.\r
-\r
-  @retval EFI_SUCEESS           routine has completed the mapping.\r
-  @retval EFI_INVALID_PARAMETER invalid parameter.\r
-  @retval EFI_OUT_OF_RESOURCES  out of resource.\r
-  @retval other                 error as indicated.\r
-\r
-**/\r
-EFI_STATUS\r
-AddV2P (\r
-  IN OUT V2P                    **V2p,\r
-  EFI_PCI_IO_PROTOCOL_OPERATION Type,\r
-  VOID                          *VirtualAddress,\r
-  UINTN                         BufferSize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if ((V2p == NULL) || (VirtualAddress == NULL) || (BufferSize == 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *V2p = AllocatePool (sizeof (V2P));\r
-  if (*V2p == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Status = mPciIo->Map (\r
-                     mPciIo,\r
-                     Type,\r
-                     VirtualAddress,\r
-                     &BufferSize,\r
-                     &(*V2p)->PhysicalAddress,\r
-                     &(*V2p)->Unmap\r
-                     );\r
-  if (Status != EFI_SUCCESS) {\r
-    FreePool (*V2p);\r
-    return Status;\r
-  }\r
-  (*V2p)->VirtualAddress = VirtualAddress;\r
-  (*V2p)->BufferSize     = BufferSize;\r
-  (*V2p)->Next           = mV2p;\r
-  mV2p                   = *V2p;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  This routine searches the linked list of mapped address nodes (for undi3.0\r
-  interface) to find the node that corresponds to the given virtual address and\r
-  returns a pointer to that node.\r
-\r
-  @param  V2p                  pointer to return a map list node pointer.\r
-  @param  VirtualAddr          virtual address (or CPU address) to be searched in\r
-                               the map list\r
-\r
-  @retval EFI_SUCEESS          A match was found.\r
-  @retval Other                A match cannot be found.\r
-\r
-**/\r
-EFI_STATUS\r
-FindV2p (\r
-  V2P          **V2p,\r
-  VOID         *VirtualAddr\r
-  )\r
-{\r
-  V2P    *Ptr;\r
-\r
-  if (V2p == NULL || VirtualAddr == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  for (Ptr = mV2p; Ptr != NULL; Ptr = Ptr->Next) {\r
-    if (Ptr->VirtualAddress == VirtualAddr) {\r
-      *V2p = Ptr;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
-  Unmap the given virtual address and free the memory allocated for the map list\r
-  node corresponding to that address.\r
-\r
-  @param  VirtualAddress       virtual address (or CPU address) to be unmapped.\r
-\r
-  @retval EFI_SUCEESS          Successfully unmapped.\r
-  @retval Other                Other errors as indicated.\r
-\r
-**/\r
-EFI_STATUS\r
-DelV2p (\r
-  VOID *VirtualAddress\r
-  )\r
-{\r
-  V2P           *Current;\r
-  V2P           *Next;\r
-  EFI_STATUS    Status;\r
-\r
-  if (VirtualAddress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (mV2p == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Is our node at the head of the list??\r
-  //\r
-  if ((Current = mV2p)->VirtualAddress == VirtualAddress) {\r
-    mV2p    = mV2p->Next;\r
-\r
-    Status  = mPciIo->Unmap (mPciIo, Current->Unmap);\r
-\r
-    FreePool (Current);\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "Unmap failed with status = %r\n", Status));\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  for (; Current->Next != NULL; Current = Next) {\r
-    if ((Next = Current->Next)->VirtualAddress == VirtualAddress) {\r
-      Current->Next = Next->Next;\r
-      Status  = mPciIo->Unmap (mPciIo, Next->Unmap);\r
-      FreePool (Next);\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "Unmap failed with status = %r\n", Status));\r
-      }\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
 /**\r
   The SNP driver entry point.\r
 \r
 /**\r
   The SNP driver entry point.\r
 \r
index 4211b4dfc7771a4055f874f5dfaeb383c8099c34..f1d0ab36dbcfa79c73a997e3f1dcafe3a29550a3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
     Declaration of strctures and functions for SnpDxe driver.\r
 \r
 /** @file\r
     Declaration of strctures and functions for SnpDxe driver.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2014, 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
 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
@@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PrintLib.h>\r
 \r
 #include <IndustryStandard/Pci.h>\r
 #include <Library/PrintLib.h>\r
 \r
 #include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/Acpi.h>\r
 \r
 #define FOUR_GIGABYTES  (UINT64) 0x100000000ULL\r
 \r
 \r
 #define FOUR_GIGABYTES  (UINT64) 0x100000000ULL\r
 \r
@@ -140,62 +141,6 @@ extern EFI_DRIVER_BINDING_PROTOCOL    gSimpleNetworkDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL    gSimpleNetworkComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL   gSimpleNetworkComponentName2;\r
 \r
 extern EFI_COMPONENT_NAME_PROTOCOL    gSimpleNetworkComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL   gSimpleNetworkComponentName2;\r
 \r
-//\r
-//  Virtual to physical mapping for all UNDI 3.0s.\r
-//\r
-typedef struct _V2P V2P;\r
-\r
-struct _V2P {\r
-  V2P                   *Next;\r
-  VOID                  *VirtualAddress;\r
-  UINTN                 BufferSize;\r
-  EFI_PHYSICAL_ADDRESS  PhysicalAddress;\r
-  VOID                  *Unmap;\r
-};\r
-\r
-/**\r
-  This routine maps the given CPU address to a Device address. It creates a\r
-  an entry in the map list with the virtual and physical addresses and the\r
-  un map cookie.\r
-\r
-  @param  V2p                  pointer to return a map list node pointer.\r
-  @param  Type                 the direction in which the data flows from the given\r
-                               virtual address device->cpu or cpu->device or both\r
-                               ways.\r
-  @param  VirtualAddress       virtual address (or CPU address) to be mapped.\r
-  @param  BufferSize           size of the buffer to be mapped.\r
-\r
-  @retval EFI_SUCEESS          routine has completed the mapping.\r
-  @retval other                error as indicated.\r
-\r
-**/\r
-EFI_STATUS\r
-AddV2p (\r
-  V2P                           **V2p,\r
-  EFI_PCI_IO_PROTOCOL_OPERATION Type,\r
-  VOID                          *VirtualAddress,\r
-  UINTN                         BufferSize\r
-  );\r
-\r
-/**\r
-  This routine searches the linked list of mapped address nodes (for undi3.0\r
-  interface) to find the node that corresponds to the given virtual address and\r
-  returns a pointer to that node.\r
-\r
-  @param  V2p                  pointer to return a map list node pointer.\r
-  @param  VirtualAddress                virtual address (or CPU address) to be searched in\r
-                               the map list\r
-\r
-  @retval EFI_SUCEESS          if a match found!\r
-  @retval Other                match not found\r
-\r
-**/\r
-EFI_STATUS\r
-FindV2p (\r
-  V2P          **V2p,\r
-  VOID         *VirtualAddress\r
-  );\r
-\r
 /**\r
   this routine calls undi to start the interface and changes the snp state.\r
 \r
 /**\r
   this routine calls undi to start the interface and changes the snp state.\r
 \r
@@ -272,100 +217,6 @@ PxeGetStnAddr (
   SNP_DRIVER *Snp\r
   );\r
 \r
   SNP_DRIVER *Snp\r
   );\r
 \r
-/**\r
-  This routine unmaps the given virtual address and frees the memory allocated\r
-  for the map list node corresponding to that address.\r
-\r
-  @param  VirtualAddress       virtual address (or CPU address) to be unmapped\r
-\r
-  @retval EFI_SUCEESS          if successfully unmapped\r
-  @retval Other                as indicated by the error\r
-\r
-**/\r
-EFI_STATUS\r
-DelV2p (\r
-  VOID *VirtualAddress\r
-  );\r
-\r
-/**\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-  UNDI call this routine when it wants to have exclusive access to a critical\r
-  section of the code/data.\r
-\r
-  @param Enable   non-zero indicates acquire\r
-                  zero indicates release\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackBlock30 (\r
-  IN UINT32 Enable\r
-  );\r
-\r
-/**\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-  UNDI call this routine with the number of micro seconds when it wants to\r
-  pause.\r
-\r
-  @param MicroSeconds  number of micro seconds to pause, ususlly multiple of 10.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackDelay30 (\r
-  IN UINT64 MicroSeconds\r
-  );\r
-\r
-/**\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-  This is the IO routine for UNDI. This is not currently being used by UNDI3.0\r
-  because Undi3.0 uses io/mem offsets relative to the beginning of the device\r
-  io/mem address and so it needs to use the PCI_IO_FUNCTION that abstracts the\r
-  start of the device's io/mem addresses. Since SNP cannot retrive the context\r
-  of the undi3.0 interface it cannot use the PCI_IO_FUNCTION that specific for\r
-  that NIC and uses one global IO functions structure, this does not work.\r
-  This however works fine for EFI1.0 Undis because they use absolute addresses\r
-  for io/mem access.\r
-\r
-  @param ReadOrWrite  indicates read or write, IO or Memory\r
-  @param NumBytes     number of bytes to read or write\r
-  @param Address      IO or memory address to read from or write to\r
-  @param BufferAddr   memory location to read into or that contains the bytes to\r
-                      write\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackMemio30 (\r
-  IN UINT8      ReadOrWrite,\r
-  IN UINT8      NumBytes,\r
-  IN UINT64     Address,\r
-  IN OUT UINT64 BufferAddr\r
-  );\r
-\r
-/**\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-  UNDI call this routine with a virtual or CPU address that SNP provided to\r
-  convert it to a physical or device address. Since EFI uses the identical\r
-  mapping, this routine returns the physical address same as the virtual address\r
-  for most of the addresses. an address above 4GB cannot generally be used as a\r
-  device address, it needs to be mapped to a lower physical address. This\r
-  routine does not call the map routine itself, but it assumes that the mapping\r
-  was done at the time of providing the address to UNDI. This routine just\r
-  looks up the address in a map table (which is the v2p structure chain).\r
-\r
-  @param  CpuAddr        virtual address of a buffer.\r
-  @param  DeviceAddrPtr  pointer to the physical address.\r
-                         The DeviceAddrPtr will contain 0 in case of any error.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SnpUndi32CallbackV2p30 (\r
-  IN UINT64     CpuAddr,\r
-  IN OUT UINT64 DeviceAddrPtr\r
-  );\r
-\r
 /**\r
   This is a callback routine supplied to UNDI3.1 at undi_start time.\r
   UNDI call this routine when it wants to have exclusive access to a critical\r
 /**\r
   This is a callback routine supplied to UNDI3.1 at undi_start time.\r
   UNDI call this routine when it wants to have exclusive access to a critical\r