]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Callback.c
Roll back the DEBUG mask change which cause SerialIo read_conf test item failure.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Callback.c
index 6dc9943cf60721727c9d6f2593d4d7d35db26862..c84b542203e3264cb1a9b96c0bd4704b85baad43 100644 (file)
@@ -3,7 +3,7 @@
   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, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation. <BR>\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
@@ -28,43 +28,40 @@ EFI_LOCK             mLock;
 //\r
 // End Global variables\r
 //\r
-extern EFI_PCI_IO_PROTOCOL  *mPciIoFncs;\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
-snp_undi32_callback_v2p_30 (\r
+SnpUndi32CallbackV2p30 (\r
   IN UINT64     CpuAddr,\r
   IN OUT UINT64 DeviceAddrPtr\r
   )\r
-/*++\r
-\r
-Routine Description:\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\r
- to 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 routine\r
- does not call the map routine itself, but it assumes that the mapping was done\r
- at the time of providing the address to UNDI. This routine just looks up the\r
- address in a map table (which is the v2p structure chain)\r
-\r
-Arguments:\r
- CpuAddr - virtual address of a buffer\r
- DeviceAddrPtr - pointer to the physical address\r
-\r
-Returns:\r
- void - The DeviceAddrPtr will contain 0 in case of any error\r
-\r
---*/\r
 {\r
-  struct s_v2p  *v2p;\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_ERROR, "\nv2p: Null virtual address or physical pointer.\n"));\r
+    DEBUG ((EFI_D_NET, "\nv2p: Null virtual address or physical pointer.\n"));\r
     return ;\r
   }\r
 \r
@@ -77,31 +74,26 @@ Returns:
   // 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 (find_v2p (&v2p, (VOID *) (UINTN) CpuAddr) != EFI_SUCCESS) {\r
+  if (FindV2p (&V2p, (VOID *) (UINTN) CpuAddr) != EFI_SUCCESS) {\r
     *(UINT64 *) (UINTN) DeviceAddrPtr = CpuAddr;\r
   } else {\r
-    *(UINT64 *) (UINTN) DeviceAddrPtr = v2p->paddr;\r
+    *(UINT64 *) (UINTN) DeviceAddrPtr = V2p->PhysicalAddress;\r
   }\r
 }\r
 \r
-VOID\r
-snp_undi32_callback_block_30 (\r
-  IN UINT32 Enable\r
-  )\r
-/*++\r
+/**\r
+  Acquire or release a lock of an exclusive access to a critical section of the\r
+  code/data. \r
 \r
-Routine Description:\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
+  This is a callback routine supplied to UNDI at undi_start time.\r
 \r
-Arguments:\r
- Enable - non-zero indicates acquire\r
-          zero indicates release\r
+  @param Enable   Non-zero indicates acquire; Zero indicates release.\r
 \r
-Returns:\r
- void\r
---*/\r
+**/\r
+VOID\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
@@ -119,59 +111,50 @@ Returns:
   }\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
-snp_undi32_callback_delay_30 (\r
+SnpUndi32CallbackDelay30 (\r
   IN UINT64 MicroSeconds\r
   )\r
-/*++\r
-\r
-Routine Description:\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
-Arguments:\r
- MicroSeconds - number of micro seconds to pause, ususlly multiple of 10\r
-\r
-Returns:\r
- void\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
-snp_undi32_callback_memio_30 (\r
+SnpUndi32CallbackMemio30 (\r
   IN UINT8      ReadOrWrite,\r
   IN UINT8      NumBytes,\r
   IN UINT64     Address,\r
   IN OUT UINT64 BufferAddr\r
   )\r
-/*++\r
-\r
-Routine Description:\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
-Arguments:\r
-  ReadOrWrite - indicates read or write, IO or Memory\r
-  NumBytes    - number of bytes to read or write\r
-  Address     - IO or memory address to read from or write to\r
-  BufferAddr  - memory location to read into or that contains the bytes\r
-                to write\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
   EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
 \r
@@ -194,150 +177,137 @@ Returns:
 \r
   switch (ReadOrWrite) {\r
   case PXE_IO_READ:\r
-    mPciIoFncs->Io.Read (\r
-                    mPciIoFncs,\r
-                    Width,\r
-                    1,    // BAR 1, IO base address\r
-                    Address,\r
-                    1,    // count\r
-                    (VOID *) (UINTN) BufferAddr\r
-                    );\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
-    mPciIoFncs->Io.Write (\r
-                    mPciIoFncs,\r
-                    Width,\r
-                    1,    // BAR 1, IO base address\r
-                    Address,\r
-                    1,    // count\r
-                    (VOID *) (UINTN) BufferAddr\r
-                    );\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
-    mPciIoFncs->Mem.Read (\r
-                      mPciIoFncs,\r
-                      Width,\r
-                      0,  // BAR 0, Memory base address\r
-                      Address,\r
-                      1,  // count\r
-                      (VOID *) (UINTN) BufferAddr\r
-                      );\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
-    mPciIoFncs->Mem.Write (\r
-                      mPciIoFncs,\r
-                      Width,\r
-                      0,  // BAR 0, Memory base address\r
-                      Address,\r
-                      1,  // count\r
-                      (VOID *) (UINTN) BufferAddr\r
-                      );\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
-// New callbacks for 3.1:\r
-// there won't be a virtual2physical callback for UNDI 3.1 because undi3.1 uses\r
-// the MemMap call to map the required address by itself!\r
-//\r
+\r
+/**\r
+  Acquire or release a lock of the exclusive access to a critical section of the \r
+  code/data. \r
+   \r
+  This is a callback routine supplied to UNDI3.1 at undi_start time.\r
+  New callbacks for 3.1: there won't be a virtual2physical callback for UNDI 3.1\r
+  because undi3.1 uses the MemMap call to map the required address by itself! \r
+\r
+  @param UniqueId  This was supplied to UNDI at Undi_Start, SNP uses this to \r
+                      store Undi interface context (Undi does not read or write\r
+                      this variable).\r
+  @param Enable    Non-zero indicates acquire; Zero indicates release. \r
+\r
+**/\r
 VOID\r
-snp_undi32_callback_block (\r
+SnpUndi32CallbackBlock (\r
   IN UINT64 UniqueId,\r
   IN UINT32 Enable\r
   )\r
-/*++\r
-\r
-Routine Description:\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
- section of the code/data\r
-\r
-Arguments:\r
- UniqueId - This was supplied to UNDI at Undi_Start, SNP uses this to store\r
-            Undi interface context (Undi does not read or write this variable)\r
- Enable   - non-zero indicates acquire\r
-            zero indicates release\r
-\r
-Returns:\r
- void\r
-\r
---*/\r
 {\r
-  SNP_DRIVER  *snp;\r
+  SNP_DRIVER  *Snp;\r
 \r
-  snp = (SNP_DRIVER *) (UINTN) UniqueId;\r
+  Snp = (SNP_DRIVER *) (UINTN) UniqueId;\r
   //\r
   // tcpip was calling snp at tpl_notify and when we acquire a lock that was\r
   // created at a lower level (TPL_CALLBACK) it gives an assert!\r
   //\r
   if (Enable != 0) {\r
-    EfiAcquireLock (&snp->lock);\r
+    EfiAcquireLock (&Snp->Lock);\r
   } else {\r
-    EfiReleaseLock (&snp->lock);\r
+    EfiReleaseLock (&Snp->Lock);\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 UniqueId      This was supplied to UNDI at Undi_Start, SNP uses this to\r
+                       store Undi interface context (Undi does not read or write\r
+                       this variable).\r
+  @param MicroSeconds  Number of micro seconds to pause, ususlly multiple of 10.  \r
+\r
+**/\r
 VOID\r
-snp_undi32_callback_delay (\r
+SnpUndi32CallbackDelay (\r
   IN UINT64 UniqueId,\r
   IN UINT64 MicroSeconds\r
   )\r
-/*++\r
-\r
-Routine Description:\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
-Arguments:\r
- MicroSeconds - number of micro seconds to pause, ususlly multiple of 10\r
-\r
-Returns:\r
- void\r
---*/\r
 {\r
   if (MicroSeconds != 0) {\r
     gBS->Stall ((UINTN) MicroSeconds);\r
   }\r
 }\r
 \r
-/*\r
- *  IO routine for UNDI start CPB.\r
- */\r
+/**\r
+  IO routine for UNDI3.1. \r
+   \r
+  This is a callback routine supplied to UNDI at undi_start time.\r
+   \r
+  @param UniqueId       This was supplied to UNDI at Undi_Start, SNP uses this \r
+                               to store Undi interface context (Undi does not read or\r
+                               write this variable).\r
+  @param ReadOrWrite    Indicates read or write, IO or Memory.\r
+  @param NumBytes       Number of bytes to read or write.\r
+  @param MemOrPortAddr  IO or memory address to read from or write to.\r
+  @param BufferPtr      Memory location to read into or that contains the bytes\r
+                               to write.\r
+\r
+**/\r
 VOID\r
-snp_undi32_callback_memio (\r
-  UINT64 UniqueId,\r
-  UINT8  ReadOrWrite,\r
-  UINT8  NumBytes,\r
-  UINT64 Address,\r
-  UINT64 BufferAddr\r
+SnpUndi32CallbackMemio (\r
+  IN UINT64     UniqueId,\r
+  IN UINT8      ReadOrWrite,\r
+  IN UINT8      NumBytes,\r
+  IN UINT64     MemOrPortAddr,\r
+  IN OUT UINT64 BufferPtr\r
   )\r
-/*++\r
-\r
-Routine Description:\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- This is the IO routine for UNDI3.1.\r
-\r
-Arguments:\r
-  ReadOrWrite - indicates read or write, IO or Memory\r
-  NumBytes    - number of bytes to read or write\r
-  Address     - IO or memory address to read from or write to\r
-  BufferAddr  - memory location to read into or that contains the bytes\r
-                to write\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
-  SNP_DRIVER                *snp;\r
+  SNP_DRIVER                *Snp;\r
   EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
 \r
-  snp   = (SNP_DRIVER *) (UINTN) UniqueId;\r
+  Snp   = (SNP_DRIVER *) (UINTN) UniqueId;\r
 \r
   Width = (EFI_PCI_IO_PROTOCOL_WIDTH) 0;\r
   switch (NumBytes) {\r
@@ -356,46 +326,46 @@ Returns:
 \r
   switch (ReadOrWrite) {\r
   case PXE_IO_READ:\r
-    snp->IoFncs->Io.Read (\r
-                      snp->IoFncs,\r
-                      Width,\r
-                      snp->IoBarIndex,      // BAR 1 (for 32bit regs), IO base address\r
-                      Address,\r
-                      1,                    // count\r
-                      (VOID *) (UINTN) BufferAddr\r
-                      );\r
+    Snp->PciIo->Io.Read (\r
+                     Snp->PciIo,\r
+                     Width,\r
+                     Snp->IoBarIndex,      // BAR 1 (for 32bit regs), IO base address\r
+                     MemOrPortAddr,\r
+                     1,                    // count\r
+                     (VOID *) (UINTN) BufferPtr\r
+                     );\r
     break;\r
 \r
   case PXE_IO_WRITE:\r
-    snp->IoFncs->Io.Write (\r
-                      snp->IoFncs,\r
-                      Width,\r
-                      snp->IoBarIndex,      // BAR 1 (for 32bit regs), IO base address\r
-                      Address,\r
-                      1,                    // count\r
-                      (VOID *) (UINTN) BufferAddr\r
-                      );\r
+    Snp->PciIo->Io.Write (\r
+                     Snp->PciIo,\r
+                     Width,\r
+                     Snp->IoBarIndex,      // BAR 1 (for 32bit regs), IO base address\r
+                     MemOrPortAddr,\r
+                     1,                    // count\r
+                     (VOID *) (UINTN) BufferPtr\r
+                     );\r
     break;\r
 \r
   case PXE_MEM_READ:\r
-    snp->IoFncs->Mem.Read (\r
-                      snp->IoFncs,\r
+    Snp->PciIo->Mem.Read (\r
+                      Snp->PciIo,\r
                       Width,\r
-                      snp->MemoryBarIndex,  // BAR 0, Memory base address\r
-                      Address,\r
+                      Snp->MemoryBarIndex,  // BAR 0, Memory base address\r
+                      MemOrPortAddr,\r
                       1,                    // count\r
-                      (VOID *) (UINTN) BufferAddr\r
+                      (VOID *) (UINTN) BufferPtr\r
                       );\r
     break;\r
 \r
   case PXE_MEM_WRITE:\r
-    snp->IoFncs->Mem.Write (\r
-                      snp->IoFncs,\r
+    Snp->PciIo->Mem.Write (\r
+                      Snp->PciIo,\r
                       Width,\r
-                      snp->MemoryBarIndex,  // BAR 0, Memory base address\r
-                      Address,\r
+                      Snp->MemoryBarIndex,  // BAR 0, Memory base address\r
+                      MemOrPortAddr,\r
                       1,                    // count\r
-                      (VOID *) (UINTN) BufferAddr\r
+                      (VOID *) (UINTN) BufferPtr\r
                       );\r
     break;\r
   }\r
@@ -403,44 +373,39 @@ Returns:
   return ;\r
 }\r
 \r
+/**\r
+  Map a CPU address to a device address. \r
+\r
+  This is a callback routine supplied to UNDI at undi_start time.\r
+\r
+  @param UniqueId      This was supplied to UNDI at Undi_Start, SNP uses this to\r
+                       store Undi interface context (Undi does not read or write\r
+                       this variable).\r
+  @param CpuAddr       Virtual address to be mapped.\r
+  @param NumBytes      Size of memory to be mapped.\r
+  @param Direction     Direction of data flow for this memory's usage:\r
+                       cpu->device, device->cpu or both ways.\r
+  @param DeviceAddrPtr Pointer to return the mapped device address.\r
+\r
+**/\r
 VOID\r
-snp_undi32_callback_map (\r
+SnpUndi32CallbackMap (\r
   IN UINT64     UniqueId,\r
   IN UINT64     CpuAddr,\r
   IN UINT32     NumBytes,\r
   IN UINT32     Direction,\r
   IN OUT UINT64 DeviceAddrPtr\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  This is a callback routine supplied to UNDI at undi_start time.\r
-  UNDI call this routine when it has to map a CPU address to a device\r
-  address.\r
-\r
-Arguments:\r
-  UniqueId      - This was supplied to UNDI at Undi_Start, SNP uses this to store\r
-                  Undi interface context (Undi does not read or write this variable)\r
-  CpuAddr       - Virtual address to be mapped!\r
-  NumBytes      - size of memory to be mapped\r
-  Direction     - direction of data flow for this memory's usage:\r
-                  cpu->device, device->cpu or both ways\r
-  DeviceAddrPtr - pointer to return the mapped device address\r
-\r
-Returns:\r
-  None\r
-\r
---*/\r
 {\r
   EFI_PHYSICAL_ADDRESS          *DevAddrPtr;\r
   EFI_PCI_IO_PROTOCOL_OPERATION DirectionFlag;\r
   UINTN                         BuffSize;\r
-  SNP_DRIVER                    *snp;\r
+  SNP_DRIVER                    *Snp;\r
   UINTN                         Index;\r
   EFI_STATUS                    Status;\r
 \r
   BuffSize    = (UINTN) NumBytes;\r
-  snp         = (SNP_DRIVER *) (UINTN) UniqueId;\r
+  Snp         = (SNP_DRIVER *) (UINTN) UniqueId;\r
   DevAddrPtr  = (EFI_PHYSICAL_ADDRESS *) (UINTN) DeviceAddrPtr;\r
 \r
   if (CpuAddr == 0) {\r
@@ -472,7 +437,7 @@ Returns:
   // find an unused map_list entry\r
   //\r
   for (Index = 0; Index < MAX_MAP_LENGTH; Index++) {\r
-    if (snp->map_list[Index].virt == 0) {\r
+    if (Snp->MapList[Index].VirtualAddress == 0) {\r
       break;\r
     }\r
   }\r
@@ -483,109 +448,100 @@ Returns:
     return ;\r
   }\r
 \r
-  snp->map_list[Index].virt = (EFI_PHYSICAL_ADDRESS) CpuAddr;\r
+  Snp->MapList[Index].VirtualAddress = (EFI_PHYSICAL_ADDRESS) CpuAddr;\r
 \r
-  Status = snp->IoFncs->Map (\r
-                          snp->IoFncs,\r
-                          DirectionFlag,\r
-                          (VOID *) (UINTN) CpuAddr,\r
-                          &BuffSize,\r
-                          DevAddrPtr,\r
-                          &(snp->map_list[Index].map_cookie)\r
-                          );\r
+  Status = Snp->PciIo->Map (\r
+                         Snp->PciIo,\r
+                         DirectionFlag,\r
+                         (VOID *) (UINTN) CpuAddr,\r
+                         &BuffSize,\r
+                         DevAddrPtr,\r
+                         &(Snp->MapList[Index].MapCookie)\r
+                         );\r
   if (Status != EFI_SUCCESS) {\r
-    *DevAddrPtr               = 0;\r
-    snp->map_list[Index].virt = 0;\r
+    *DevAddrPtr                        = 0;\r
+    Snp->MapList[Index].VirtualAddress = 0;\r
   }\r
 \r
   return ;\r
 }\r
 \r
+/**\r
+  Unmap an address that was previously mapped using map callback. \r
+   \r
+  This is a callback routine supplied to UNDI at undi_start time.\r
+\r
+  @param UniqueId    This was supplied to UNDI at Undi_Start, SNP uses this to \r
+                     store. Undi interface context (Undi does not read or write\r
+                     this variable).\r
+  @param CpuAddr     Virtual address that was mapped.\r
+  @param NumBytes    Size of memory mapped.\r
+  @param Direction   Direction of data flow for this memory's usage: \r
+                     cpu->device, device->cpu or both ways.\r
+  @param DeviceAddr  The mapped device address.\r
+\r
+**/\r
 VOID\r
-snp_undi32_callback_unmap (\r
+SnpUndi32CallbackUnmap (\r
   IN UINT64 UniqueId,\r
   IN UINT64 CpuAddr,\r
   IN UINT32 NumBytes,\r
   IN UINT32 Direction,\r
   IN UINT64 DeviceAddr\r
   )\r
-/*++\r
-\r
-Routine Description:\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- UNDI call this routine when it wants to unmap an address that was previously\r
- mapped using map callback\r
-\r
-Arguments:\r
- UniqueId - This was supplied to UNDI at Undi_Start, SNP uses this to store\r
-            Undi interface context (Undi does not read or write this variable)\r
- CpuAddr  - Virtual address that was mapped!\r
- NumBytes - size of memory mapped\r
- Direction- direction of data flow for this memory's usage:\r
-            cpu->device, device->cpu or both ways\r
- DeviceAddr - the mapped device address\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
-  SNP_DRIVER  *snp;\r
+  SNP_DRIVER  *Snp;\r
   UINT16      Index;\r
 \r
-  snp = (SNP_DRIVER *) (UINTN) UniqueId;\r
+  Snp = (SNP_DRIVER *) (UINTN) UniqueId;\r
 \r
   for (Index = 0; Index < MAX_MAP_LENGTH; Index++) {\r
-    if (snp->map_list[Index].virt == CpuAddr) {\r
+    if (Snp->MapList[Index].VirtualAddress == CpuAddr) {\r
       break;\r
     }\r
   }\r
 \r
-  if (Index >= MAX_MAP_LENGTH)\r
-  {\r
+  if (Index >= MAX_MAP_LENGTH) {\r
     DEBUG ((EFI_D_ERROR, "SNP could not find a mapping, failed to unmap.\n"));\r
     return ;\r
   }\r
 \r
-  snp->IoFncs->Unmap (snp->IoFncs, snp->map_list[Index].map_cookie);\r
-  snp->map_list[Index].virt       = 0;\r
-  snp->map_list[Index].map_cookie = NULL;\r
+  Snp->PciIo->Unmap (Snp->PciIo, Snp->MapList[Index].MapCookie);\r
+  Snp->MapList[Index].VirtualAddress = 0;\r
+  Snp->MapList[Index].MapCookie      = NULL;\r
   return ;\r
 }\r
 \r
+/** \r
+  Synchronize the virtual buffer contents with the mapped buffer contents. \r
+   \r
+  This is a callback routine supplied to UNDI at undi_start time. The virtual\r
+  and mapped buffers need not correspond to the same physical memory (especially \r
+  if the virtual address is > 4GB). Depending on the direction for which the \r
+  buffer is mapped, undi will need to synchronize their contents whenever it \r
+  writes to/reads from the buffer using either the cpu address or the device \r
+  address. \r
+  EFI does not provide a sync call since virt=physical, we should just do the \r
+  synchronization ourselves here. \r
+\r
+  @param UniqueId    This was supplied to UNDI at Undi_Start, SNP uses this to \r
+                     store Undi interface context (Undi does not read or write\r
+                     this variable).\r
+  @param CpuAddr     Virtual address that was mapped.\r
+  @param NumBytes    Size of memory mapped.\r
+  @param Direction   Direction of data flow for this memory's usage:\r
+                     cpu->device, device->cpu or both ways.\r
+  @param DeviceAddr  The mapped device address.\r
+\r
+**/\r
 VOID\r
-snp_undi32_callback_sync (\r
-  UINT64 UniqueId,\r
-  UINT64 CpuAddr,\r
-  UINT32 NumBytes,\r
-  UINT32 Direction,\r
-  UINT64 DeviceAddr\r
+SnpUndi32CallbackSync (\r
+  IN UINT64             UniqueId,\r
+  IN UINT64             CpuAddr,\r
+  IN UINT32             NumBytes,\r
+  IN UINT32             Direction,\r
+  IN UINT64             DeviceAddr\r
   )\r
-/*++\r
-\r
-Routine Description:\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- UNDI call this routine when it wants synchronize the virtual buffer contents\r
- with the mapped buffer contents. The virtual and mapped buffers need not\r
- correspond to the same physical memory (especially if the virtual address is\r
- > 4GB). Depending on the direction for which the buffer is mapped, undi will\r
- need to synchronize their contents whenever it writes to/reads from the buffer\r
- using either the cpu address or the device address.\r
-\r
- EFI does not provide a sync call, since virt=physical, we sould just do\r
- the synchronization ourself here!\r
-\r
-Arguments:\r
- UniqueId - This was supplied to UNDI at Undi_Start, SNP uses this to store\r
-            Undi interface context (Undi does not read or write this variable)\r
- CpuAddr  - Virtual address that was mapped!\r
- NumBytes - size of memory mapped\r
- Direction- direction of data flow for this memory's usage:\r
-            cpu->device, device->cpu or both ways\r
- DeviceAddr - the mapped device address\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
   if ((CpuAddr == 0) || (DeviceAddr == 0) || (NumBytes == 0)) {\r
     return ;\r