]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Callback.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Callback.c
index c246874917b10dabd7e7ad679e1a2d241b2aa17b..c4789ba11dc81be576666a40eb7e1bca2e180f9e 100644 (file)
@@ -1,5 +1,9 @@
-/*++\r
-Copyright (c) 2006, Intel Corporation\r
+/** @file\r
+  This file contains two sets of callback routines for undi3.0 and 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
+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
@@ -8,16 +12,7 @@ http://opensource.org/licenses/bsd-license.php
 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
- callback.c\r
-\r
-Abstract:\r
- This file contains two sets of callback routines for undi3.0 and 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
---*/\r
-\r
+**/\r
 \r
 #include "Snp.h"\r
 \r
@@ -27,49 +22,44 @@ Abstract:
 // them in the snp structure because we will not know which snp structure\r
 // in the callback context!\r
 //\r
-STATIC BOOLEAN              mInitializeLock = TRUE;\r
-STATIC EFI_LOCK             mLock;\r
+BOOLEAN              mInitializeLock = TRUE;\r
+EFI_LOCK             mLock;\r
 \r
 //\r
 // End Global variables\r
 //\r
-extern EFI_PCI_IO_PROTOCOL  *mPciIoFncs;\r
+extern EFI_PCI_IO_PROTOCOL  *mPciIo;\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
-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
@@ -82,31 +72,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
+/**\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
-snp_undi32_callback_block_30 (\r
+SnpUndi32CallbackBlock30 (\r
   IN UINT32 Enable\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 have exclusive access to a critical\r
- section of the code/data\r
-\r
-Arguments:\r
- Enable - non-zero indicates acquire\r
-          zero indicates release\r
-\r
-Returns:\r
- void\r
---*/\r
 {\r
   //\r
   // tcpip was calling snp at tpl_notify and if we acquire a lock that was\r
@@ -124,59 +109,49 @@ Returns:
   }\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
-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
+  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
-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
@@ -199,150 +174,134 @@ 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
+  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
+  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
+  @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\r
+                   zero indicates release\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
+  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 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
 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
+  This is a callback routine supplied to UNDI at undi_start time.\r
+  This is the IO routine for UNDI3.1 to start CPB.\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
 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
@@ -361,46 +320,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
@@ -408,44 +367,38 @@ Returns:
   return ;\r
 }\r
 \r
+/**\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
+  @param 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
+  @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
@@ -477,7 +430,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
@@ -488,59 +441,54 @@ 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
+  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
+  @param 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
+  @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
@@ -551,46 +499,41 @@ Returns:
     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
+  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
+  @param 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
+  @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