]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Snp.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Snp.c
index 267dde67d58dc0e55f8f3e70932946b9ee8d1ce3..80a05f102f90f261a92c74d50c9661c126f38ec3 100644 (file)
 /** @file\r
 /** @file\r
-Copyright (c) 2004 - 2005, 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
+    Implementation of driver entry point and driver binding protocol.\r
\r
+Copyright (c) 2004 - 2008, Intel Corporation. <BR> \r
+All rights reserved. This program and the accompanying materials are licensed \r
+and made available under the terms and conditions of the BSD License which \r
+accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \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
-    snp.c\r
-\r
-Abstract:\r
-\r
-\r
 **/\r
 \r
 #include "Snp.h"\r
 \r
 **/\r
 \r
 #include "Snp.h"\r
 \r
-EFI_STATUS\r
-pxe_start (\r
-  SNP_DRIVER *snp\r
-  );\r
-EFI_STATUS\r
-pxe_stop (\r
-  SNP_DRIVER *snp\r
-  );\r
-EFI_STATUS\r
-pxe_init (\r
-  SNP_DRIVER *snp,\r
-  UINT16     OpFlags\r
-  );\r
-EFI_STATUS\r
-pxe_shutdown (\r
-  SNP_DRIVER *snp\r
-  );\r
-EFI_STATUS\r
-pxe_get_stn_addr (\r
-  SNP_DRIVER *snp\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeSnpNiiDriver (\r
-  IN EFI_HANDLE       image_handle,\r
-  IN EFI_SYSTEM_TABLE *system_table\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SimpleNetworkDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SimpleNetworkDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SimpleNetworkDriverStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN  EFI_HANDLE                     Controller,\r
-  IN  UINTN                          NumberOfChildren,\r
-  IN  EFI_HANDLE                     *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// Simple Network Protocol Driver Global Variables\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL mSimpleNetworkDriverBinding = {\r
-  SimpleNetworkDriverSupported,\r
-  SimpleNetworkDriverStart,\r
-  SimpleNetworkDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
 //\r
 //  Module global variables needed to support undi 3.0 interface\r
 //\r
 //\r
 //  Module global variables needed to support undi 3.0 interface\r
 //\r
-EFI_PCI_IO_PROTOCOL         *mPciIoFncs;\r
-struct s_v2p                *_v2p = NULL; // undi3.0 map_list head\r
+EFI_PCI_IO_PROTOCOL         *mPciIo;\r
+V2P                         *mV2p = NULL; // undi3.0 map_list head\r
 // End Global variables\r
 //\r
 \r
 // End Global variables\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  vaddr                virtual address (or CPU address) to be mapped\r
-  @param  bsize                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
-add_v2p (\r
-  IN OUT struct s_v2p           **v2p,\r
-  EFI_PCI_IO_PROTOCOL_OPERATION type,\r
-  VOID                          *vaddr,\r
-  UINTN                         bsize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if ((v2p == NULL) || (vaddr == NULL) || (bsize == 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *v2p = AllocatePool (sizeof (struct s_v2p));\r
-  if (*v2p != NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Status = mPciIoFncs->Map (\r
-                        mPciIoFncs,\r
-                        type,\r
-                        vaddr,\r
-                        &bsize,\r
-                        &(*v2p)->paddr,\r
-                        &(*v2p)->unmap\r
-                        );\r
-  if (Status != EFI_SUCCESS) {\r
-    FreePool (*v2p);\r
-    return Status;\r
-  }\r
-  (*v2p)->vaddr = vaddr;\r
-  (*v2p)->bsize = bsize;\r
-  (*v2p)->next  = _v2p;\r
-  _v2p          = *v2p;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\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  vaddr                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
+  Unsupport currently.\r
+  \r
+  @param Cdb   command to be sent to UNDI.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
-find_v2p (\r
-  struct s_v2p **v2p,\r
-  VOID         *vaddr\r
+IssueHwUndiCommand (\r
+  UINT64 Cdb\r
   )\r
 {\r
   )\r
 {\r
-  struct s_v2p  *v;\r
+  DEBUG ((EFI_D_ERROR, "\nIssueHwUndiCommand() - This should not be called!"));\r
 \r
 \r
-  if (v2p == NULL || vaddr == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  for (v = _v2p; v != NULL; v = v->next) {\r
-    if (v->vaddr == vaddr) {\r
-      *v2p = v;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\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  vaddr                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
-del_v2p (\r
-  VOID *vaddr\r
-  )\r
-{\r
-  struct s_v2p  *v;\r
-  struct s_v2p  *t;\r
-  EFI_STATUS    Status;\r
-\r
-  if (vaddr == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (_v2p == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Is our node at the head of the list??\r
-  //\r
-  if ((v = _v2p)->vaddr == vaddr) {\r
-    _v2p    = _v2p->next;\r
-\r
-    Status  = mPciIoFncs->Unmap (mPciIoFncs, v->unmap);\r
-\r
-    FreePool (v);\r
-\r
-    if (Status) {\r
-      DEBUG ((EFI_D_ERROR, "Unmap failed with status = %r\n", Status));\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  for (; v->next != NULL; v = t) {\r
-    if ((t = v->next)->vaddr == vaddr) {\r
-      v->next = t->next;\r
-      Status  = mPciIoFncs->Unmap (mPciIoFncs, t->unmap);\r
-      FreePool (t);\r
-\r
-      if (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
-EFI_STATUS\r
-issue_hwundi_command (\r
-  UINT64 cdb\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
-  DEBUG ((EFI_D_ERROR, "\nissue_hwundi_command() - This should not be called!"));\r
-\r
-  if (cdb == 0) {\r
+  if (Cdb == 0) {\r
     return EFI_INVALID_PARAMETER;\r
 \r
   }\r
     return EFI_INVALID_PARAMETER;\r
 \r
   }\r
@@ -272,48 +50,52 @@ Returns:
 /**\r
   Compute 8-bit checksum of a buffer.\r
 \r
 /**\r
   Compute 8-bit checksum of a buffer.\r
 \r
-  @param  ptr                  Pointer to buffer.\r
-  @param  len                  Length of buffer in bytes.\r
+  @param  Buffer               Pointer to buffer.\r
+  @param  Length               Length of buffer in bytes.\r
 \r
   @return 8-bit checksum of all bytes in buffer.\r
   @return If ptr is NULL or len is zero, zero is returned.\r
 \r
 **/\r
 UINT8\r
 \r
   @return 8-bit checksum of all bytes in buffer.\r
   @return If ptr is NULL or len is zero, zero is returned.\r
 \r
 **/\r
 UINT8\r
-calc_8bit_cksum (\r
-  VOID  *ptr,\r
-  UINTN len\r
+Calc8BitCksum (\r
+  VOID  *Buffer,\r
+  UINTN Length\r
   )\r
 {\r
   )\r
 {\r
-  UINT8 *bptr;\r
-  UINT8 cksum;\r
+  UINT8 *Ptr;\r
+  UINT8 Cksum;\r
 \r
 \r
-  bptr  = ptr;\r
-  cksum = 0;\r
+  Ptr   = Buffer;\r
+  Cksum = 0;\r
 \r
 \r
-  if (ptr == NULL || len == 0) {\r
+  if (Ptr == NULL || Length == 0) {\r
     return 0;\r
   }\r
 \r
     return 0;\r
   }\r
 \r
-  while (len--) {\r
-    cksum = (UINT8) (cksum +*bptr++);\r
+  while (Length-- != 0) {\r
+    Cksum = (UINT8) (Cksum + *Ptr++);\r
   }\r
 \r
   }\r
 \r
-  return cksum;\r
+  return Cksum;\r
 }\r
 \r
 }\r
 \r
-\r
 /**\r
 /**\r
-  Test to see if this driver supports Controller. Any Controller\r
-  that contains a Nii protocol can be supported.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  Controller           Handle of device to test.\r
-  @param  RemainingDevicePath  Not used.\r
-\r
-  @retval EFI_SUCCESS          This driver supports this device.\r
-  @retval EFI_ALREADY_STARTED  This driver is already running on this device.\r
-  @retval other                This driver does not support this device.\r
+  Test to see if this driver supports ControllerHandle. This service\r
+  is called by the EFI boot service ConnectController(). In\r
+  order to make drivers as small as possible, there are a few calling\r
+  restrictions for this service. ConnectController() must\r
+  follow these calling restrictions. If any other agent wishes to call\r
+  Supported() it must also follow these calling restrictions.\r
+\r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
+  @retval other               This driver does not support this device\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -326,7 +108,7 @@ SimpleNetworkDriverSupported (
 {\r
   EFI_STATUS                                Status;\r
   EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *NiiProtocol;\r
 {\r
   EFI_STATUS                                Status;\r
   EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *NiiProtocol;\r
-  PXE_UNDI                                  *pxe;\r
+  PXE_UNDI                                  *Pxe;\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -374,30 +156,30 @@ SimpleNetworkDriverSupported (
     goto Done;\r
   }\r
 \r
     goto Done;\r
   }\r
 \r
-  pxe = (PXE_UNDI *) (UINTN) (NiiProtocol->ID);\r
+  Pxe = (PXE_UNDI *) (UINTN) (NiiProtocol->ID);\r
 \r
   //\r
   //  Verify !PXE revisions.\r
   //\r
 \r
   //\r
   //  Verify !PXE revisions.\r
   //\r
-  if (pxe->hw.Signature != PXE_ROMID_SIGNATURE) {\r
+  if (Pxe->hw.Signature != PXE_ROMID_SIGNATURE) {\r
     DEBUG ((EFI_D_NET, "\n!PXE signature is not valid.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
     DEBUG ((EFI_D_NET, "\n!PXE signature is not valid.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
-  if (pxe->hw.Rev < PXE_ROMID_REV) {\r
+  if (Pxe->hw.Rev < PXE_ROMID_REV) {\r
     DEBUG ((EFI_D_NET, "\n!PXE.Rev is not supported.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
     DEBUG ((EFI_D_NET, "\n!PXE.Rev is not supported.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
-  if (pxe->hw.MajorVer < PXE_ROMID_MAJORVER) {\r
+  if (Pxe->hw.MajorVer < PXE_ROMID_MAJORVER) {\r
 \r
     DEBUG ((EFI_D_NET, "\n!PXE.MajorVer is not supported.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
 \r
 \r
     DEBUG ((EFI_D_NET, "\n!PXE.MajorVer is not supported.\n"));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
 \r
-  } else if (pxe->hw.MajorVer == PXE_ROMID_MAJORVER && pxe->hw.MinorVer < PXE_ROMID_MINORVER) {\r
+  } else if (Pxe->hw.MajorVer == PXE_ROMID_MAJORVER && Pxe->hw.MinorVer < PXE_ROMID_MINORVER) {\r
     DEBUG ((EFI_D_NET, "\n!PXE.MinorVer is not supported."));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
     DEBUG ((EFI_D_NET, "\n!PXE.MinorVer is not supported."));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
@@ -405,14 +187,14 @@ SimpleNetworkDriverSupported (
   //\r
   // Do S/W UNDI specific checks.\r
   //\r
   //\r
   // Do S/W UNDI specific checks.\r
   //\r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) == 0) {\r
-    if (pxe->sw.EntryPoint < pxe->sw.Len) {\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) == 0) {\r
+    if (Pxe->sw.EntryPoint < Pxe->sw.Len) {\r
       DEBUG ((EFI_D_NET, "\n!PXE S/W entry point is not valid."));\r
       Status = EFI_UNSUPPORTED;\r
       goto Done;\r
     }\r
 \r
       DEBUG ((EFI_D_NET, "\n!PXE S/W entry point is not valid."));\r
       Status = EFI_UNSUPPORTED;\r
       goto Done;\r
     }\r
 \r
-    if (pxe->sw.BusCnt == 0) {\r
+    if (Pxe->sw.BusCnt == 0) {\r
       DEBUG ((EFI_D_NET, "\n!PXE.BusCnt is zero."));\r
       Status = EFI_UNSUPPORTED;\r
       goto Done;\r
       DEBUG ((EFI_D_NET, "\n!PXE.BusCnt is zero."));\r
       Status = EFI_UNSUPPORTED;\r
       goto Done;\r
@@ -433,16 +215,22 @@ Done:
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
-\r
 /**\r
 /**\r
-  called for any handle that we said "supported" in the above call!\r
+  Start this driver on ControllerHandle. This service is called by the\r
+  EFI boot service ConnectController(). In order to make\r
+  drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these\r
+  calling restrictions. If any other agent wishes to call Start() it\r
+  must also follow these calling restrictions.\r
 \r
   @param  This                 Protocol instance pointer.\r
 \r
   @param  This                 Protocol instance pointer.\r
-  @param  Controller           Handle of device to start\r
-  @param  RemainingDevicePath  Not used.\r
+  @param  ControllerHandle     Handle of device to bind driver to.\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
 \r
 \r
-  @retval EFI_SUCCESS          This driver supports this device.\r
-  @retval other                This driver failed to start this device.\r
+  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
+  @retval other                This driver does not support this device\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -456,9 +244,9 @@ SimpleNetworkDriverStart (
   EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;\r
   EFI_DEVICE_PATH_PROTOCOL                  *NiiDevicePath;\r
   EFI_STATUS                                Status;\r
   EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;\r
   EFI_DEVICE_PATH_PROTOCOL                  *NiiDevicePath;\r
   EFI_STATUS                                Status;\r
-  PXE_UNDI                                  *pxe;\r
-  SNP_DRIVER                                *snp;\r
-  VOID                                      *addr;\r
+  PXE_UNDI                                  *Pxe;\r
+  SNP_DRIVER                                *Snp;\r
+  VOID                                      *Address;\r
   EFI_HANDLE                                Handle;\r
   PXE_PCI_CONFIG_INFO                       ConfigInfo;\r
   PCI_TYPE00                                *ConfigHeader;\r
   EFI_HANDLE                                Handle;\r
   PXE_PCI_CONFIG_INFO                       ConfigInfo;\r
   PCI_TYPE00                                *ConfigHeader;\r
@@ -494,7 +282,7 @@ SimpleNetworkDriverStart (
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiPciIoProtocolGuid,\r
   Status = gBS->OpenProtocol (\r
                   Handle,\r
                   &gEfiPciIoProtocolGuid,\r
-                  (VOID **) &mPciIoFncs,\r
+                  (VOID **) &mPciIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
@@ -525,18 +313,18 @@ SimpleNetworkDriverStart (
 \r
   DEBUG ((EFI_D_INFO, "Start(): UNDI3.1 found\n"));\r
 \r
 \r
   DEBUG ((EFI_D_INFO, "Start(): UNDI3.1 found\n"));\r
 \r
-  pxe = (PXE_UNDI *) (UINTN) (Nii->ID);\r
+  Pxe = (PXE_UNDI *) (UINTN) (Nii->ID);\r
 \r
 \r
-  if (calc_8bit_cksum (pxe, pxe->hw.Len) != 0) {\r
+  if (Calc8BitCksum (Pxe, Pxe->hw.Len) != 0) {\r
     DEBUG ((EFI_D_NET, "\n!PXE checksum is not correct.\n"));\r
     goto NiiError;\r
   }\r
 \r
     DEBUG ((EFI_D_NET, "\n!PXE checksum is not correct.\n"));\r
     goto NiiError;\r
   }\r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED) != 0) {\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED) != 0) {\r
     //\r
     //  We can get any packets.\r
     //\r
     //\r
     //  We can get any packets.\r
     //\r
-  } else if ((pxe->hw.Implementation & PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED) != 0) {\r
+  } else if ((Pxe->hw.Implementation & PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED) != 0) {\r
     //\r
     //  We need to be able to get broadcast packets for DHCP.\r
     //  If we do not have promiscuous support, we must at least have\r
     //\r
     //  We need to be able to get broadcast packets for DHCP.\r
     //  If we do not have promiscuous support, we must at least have\r
@@ -550,12 +338,12 @@ 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 = mPciIoFncs->AllocateBuffer (\r
-                        mPciIoFncs,\r
+  Status = mPciIo->AllocateBuffer (\r
+                        mPciIo,\r
                         AllocateAnyPages,\r
                         EfiBootServicesData,\r
                         SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
                         AllocateAnyPages,\r
                         EfiBootServicesData,\r
                         SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
-                        &addr,\r
+                        &Address,\r
                         0\r
                         );\r
 \r
                         0\r
                         );\r
 \r
@@ -564,48 +352,48 @@ SimpleNetworkDriverStart (
     goto NiiError;\r
   }\r
 \r
     goto NiiError;\r
   }\r
 \r
-  snp = (SNP_DRIVER *) (UINTN) addr;\r
+  Snp = (SNP_DRIVER *) (UINTN) Address;\r
 \r
 \r
-  ZeroMem (snp, sizeof (SNP_DRIVER));\r
+  ZeroMem (Snp, sizeof (SNP_DRIVER));\r
 \r
 \r
-  snp->IoFncs     = mPciIoFncs;\r
-  snp->Signature  = SNP_DRIVER_SIGNATURE;\r
+  Snp->PciIo      = mPciIo;\r
+  Snp->Signature  = SNP_DRIVER_SIGNATURE;\r
 \r
 \r
-  EfiInitializeLock (&snp->lock, TPL_NOTIFY);\r
+  EfiInitializeLock (&Snp->Lock, TPL_NOTIFY);\r
 \r
 \r
-  snp->snp.Revision       = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION;\r
-  snp->snp.Start          = snp_undi32_start;\r
-  snp->snp.Stop           = snp_undi32_stop;\r
-  snp->snp.Initialize     = snp_undi32_initialize;\r
-  snp->snp.Reset          = snp_undi32_reset;\r
-  snp->snp.Shutdown       = snp_undi32_shutdown;\r
-  snp->snp.ReceiveFilters = snp_undi32_receive_filters;\r
-  snp->snp.StationAddress = snp_undi32_station_address;\r
-  snp->snp.Statistics     = snp_undi32_statistics;\r
-  snp->snp.MCastIpToMac   = snp_undi32_mcast_ip_to_mac;\r
-  snp->snp.NvData         = snp_undi32_nvdata;\r
-  snp->snp.GetStatus      = snp_undi32_get_status;\r
-  snp->snp.Transmit       = snp_undi32_transmit;\r
-  snp->snp.Receive        = snp_undi32_receive;\r
-  snp->snp.WaitForPacket  = NULL;\r
+  Snp->Snp.Revision       = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION;\r
+  Snp->Snp.Start          = SnpUndi32Start;\r
+  Snp->Snp.Stop           = SnpUndi32Stop;\r
+  Snp->Snp.Initialize     = SnpUndi32Initialize;\r
+  Snp->Snp.Reset          = SnpUndi32Reset;\r
+  Snp->Snp.Shutdown       = SnpUndi32Shutdown;\r
+  Snp->Snp.ReceiveFilters = SnpUndi32ReceiveFilters;\r
+  Snp->Snp.StationAddress = SnpUndi32StationAddress;\r
+  Snp->Snp.Statistics     = SnpUndi32Statistics;\r
+  Snp->Snp.MCastIpToMac   = SnpUndi32McastIpToMac;\r
+  Snp->Snp.NvData         = SnpUndi32NvData;\r
+  Snp->Snp.GetStatus      = SnpUndi32GetStatus;\r
+  Snp->Snp.Transmit       = SnpUndi32Transmit;\r
+  Snp->Snp.Receive        = SnpUndi32Receive;\r
+  Snp->Snp.WaitForPacket  = NULL;\r
 \r
 \r
-  snp->snp.Mode           = &snp->mode;\r
+  Snp->Snp.Mode           = &Snp->Mode;\r
 \r
 \r
-  snp->tx_rx_bufsize      = 0;\r
-  snp->tx_rx_buffer       = NULL;\r
+  Snp->TxRxBufferSize     = 0;\r
+  Snp->TxRxBuffer         = NULL;\r
 \r
 \r
-  snp->if_num             = Nii->IfNum;\r
+  Snp->IfNum              = Nii->IfNum;\r
 \r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) != 0) {\r
-    snp->is_swundi            = FALSE;\r
-    snp->issue_undi32_command = &issue_hwundi_command;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_HW_UNDI) != 0) {\r
+    Snp->IsSwUndi             = FALSE;\r
+    Snp->IssueUndi32Command   = &IssueHwUndiCommand;\r
   } else {\r
   } else {\r
-    snp->is_swundi = TRUE;\r
+    Snp->IsSwUndi = TRUE;\r
 \r
 \r
-    if ((pxe->sw.Implementation & PXE_ROMID_IMP_SW_VIRT_ADDR) != 0) {\r
-      snp->issue_undi32_command = (issue_undi32_command) (UINTN) pxe->sw.EntryPoint;\r
+    if ((Pxe->sw.Implementation & PXE_ROMID_IMP_SW_VIRT_ADDR) != 0) {\r
+      Snp->IssueUndi32Command = (ISSUE_UNDI32_COMMAND) (UINTN) Pxe->sw.EntryPoint;\r
     } else {\r
     } else {\r
-      snp->issue_undi32_command = (issue_undi32_command) (UINTN) ((UINT8) (UINTN) pxe + pxe->sw.EntryPoint);\r
+      Snp->IssueUndi32Command = (ISSUE_UNDI32_COMMAND) (UINTN) ((UINT8) (UINTN) Pxe + Pxe->sw.EntryPoint);\r
     }\r
   }\r
   //\r
     }\r
   }\r
   //\r
@@ -624,12 +412,12 @@ 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 = mPciIoFncs->AllocateBuffer (\r
-                        mPciIoFncs,\r
+  Status = mPciIo->AllocateBuffer (\r
+                        mPciIo,\r
                         AllocateAnyPages,\r
                         EfiBootServicesData,\r
                         SNP_MEM_PAGES (4096),\r
                         AllocateAnyPages,\r
                         EfiBootServicesData,\r
                         SNP_MEM_PAGES (4096),\r
-                        &addr,\r
+                        &Address,\r
                         0\r
                         );\r
 \r
                         0\r
                         );\r
 \r
@@ -638,81 +426,81 @@ SimpleNetworkDriverStart (
     goto Error_DeleteSNP;\r
   }\r
 \r
     goto Error_DeleteSNP;\r
   }\r
 \r
-  snp->cpb  = (VOID *) (UINTN) addr;\r
-  snp->db   = (VOID *) ((UINTN) addr + 2048);\r
+  Snp->Cpb  = (VOID *) (UINTN) Address;\r
+  Snp->Db   = (VOID *) ((UINTN) Address + 2048);\r
 \r
   //\r
 \r
   //\r
-  // pxe_start call is going to give the callback functions to UNDI, these callback\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
   // functions use the BarIndex values from the snp structure, so these must be initialized\r
-  // with default values before doing a pxe_start. The correct values can be obtained after\r
+  // with default values before doing a PxeStart. The correct values can be obtained after\r
   // getting the config information from UNDI\r
   //\r
   // getting the config information from UNDI\r
   //\r
-  snp->MemoryBarIndex = 0;\r
-  snp->IoBarIndex     = 1;\r
+  Snp->MemoryBarIndex = 0;\r
+  Snp->IoBarIndex     = 1;\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
 \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 = pxe_start (snp);\r
+  Status = PxeStart (Snp);\r
 \r
   if (Status != EFI_SUCCESS) {\r
     goto Error_DeleteSNP;\r
   }\r
 \r
 \r
   if (Status != EFI_SUCCESS) {\r
     goto Error_DeleteSNP;\r
   }\r
 \r
-  snp->cdb.OpCode     = PXE_OPCODE_GET_INIT_INFO;\r
-  snp->cdb.OpFlags    = PXE_OPFLAGS_NOT_USED;\r
+  Snp->Cdb.OpCode     = PXE_OPCODE_GET_INIT_INFO;\r
+  Snp->Cdb.OpFlags    = PXE_OPFLAGS_NOT_USED;\r
 \r
 \r
-  snp->cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
-  snp->cdb.CPBaddr    = PXE_DBADDR_NOT_USED;\r
+  Snp->Cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
+  Snp->Cdb.CPBaddr    = PXE_DBADDR_NOT_USED;\r
 \r
 \r
-  snp->cdb.DBsize     = sizeof snp->init_info;\r
-  snp->cdb.DBaddr     = (UINT64)(UINTN) &snp->init_info;\r
+  Snp->Cdb.DBsize     = sizeof Snp->InitInfo;\r
+  Snp->Cdb.DBaddr     = (UINT64)(UINTN) &Snp->InitInfo;\r
 \r
 \r
-  snp->cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
-  snp->cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
+  Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
+  Snp->Cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
 \r
 \r
-  snp->cdb.IFnum      = snp->if_num;\r
-  snp->cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+  Snp->Cdb.IFnum      = Snp->IfNum;\r
+  Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
 \r
 \r
-  DEBUG ((EFI_D_NET, "\nsnp->undi.get_init_info()  "));\r
+  DEBUG ((EFI_D_NET, "\nSnp->undi.get_init_info()  "));\r
 \r
 \r
-  (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
+  (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
 \r
   //\r
   // Save the INIT Stat Code...\r
   //\r
 \r
   //\r
   // Save the INIT Stat Code...\r
   //\r
-  InitStatFlags = snp->cdb.StatFlags;\r
+  InitStatFlags = Snp->Cdb.StatFlags;\r
 \r
 \r
-  if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
-    DEBUG ((EFI_D_NET, "\nsnp->undi.init_info()  %xh:%xh\n", snp->cdb.StatFlags, snp->cdb.StatCode));\r
-    pxe_stop (snp);\r
+  if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
+    DEBUG ((EFI_D_NET, "\nSnp->undi.init_info()  %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
+    PxeStop (Snp);\r
     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
+  Snp->Cdb.OpCode     = PXE_OPCODE_GET_CONFIG_INFO;\r
+  Snp->Cdb.OpFlags    = PXE_OPFLAGS_NOT_USED;\r
 \r
 \r
-  snp->cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
-  snp->cdb.CPBaddr    = PXE_DBADDR_NOT_USED;\r
+  Snp->Cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
+  Snp->Cdb.CPBaddr    = PXE_DBADDR_NOT_USED;\r
 \r
 \r
-  snp->cdb.DBsize     = sizeof ConfigInfo;\r
-  snp->cdb.DBaddr     = (UINT64)(UINTN) &ConfigInfo;\r
+  Snp->Cdb.DBsize     = sizeof ConfigInfo;\r
+  Snp->Cdb.DBaddr     = (UINT64)(UINTN) &ConfigInfo;\r
 \r
 \r
-  snp->cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
-  snp->cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
+  Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
+  Snp->Cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
 \r
 \r
-  snp->cdb.IFnum      = snp->if_num;\r
-  snp->cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+  Snp->Cdb.IFnum      = Snp->IfNum;\r
+  Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
 \r
 \r
-  DEBUG ((EFI_D_NET, "\nsnp->undi.get_config_info()  "));\r
+  DEBUG ((EFI_D_NET, "\nSnp->undi.get_config_info()  "));\r
 \r
 \r
-  (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
+  (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
 \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
-    pxe_stop (snp);\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
     goto Error_DeleteSNP;\r
   }\r
   //\r
@@ -735,7 +523,7 @@ SimpleNetworkDriverStart (
     }\r
 \r
     if ((*TempBar & PCI_BAR_IO_MASK) == PCI_BAR_IO_MODE) {\r
     }\r
 \r
     if ((*TempBar & PCI_BAR_IO_MASK) == PCI_BAR_IO_MODE) {\r
-      snp->IoBarIndex = BarIndex;\r
+      Snp->IoBarIndex = BarIndex;\r
       break;\r
     }\r
 \r
       break;\r
     }\r
 \r
@@ -745,102 +533,102 @@ SimpleNetworkDriverStart (
   //\r
   //  Initialize simple network protocol mode structure\r
   //\r
   //\r
   //  Initialize simple network protocol mode structure\r
   //\r
-  snp->mode.State               = EfiSimpleNetworkStopped;\r
-  snp->mode.HwAddressSize       = snp->init_info.HWaddrLen;\r
-  snp->mode.MediaHeaderSize     = snp->init_info.MediaHeaderLen;\r
-  snp->mode.MaxPacketSize       = snp->init_info.FrameDataLen;\r
-  snp->mode.NvRamAccessSize     = snp->init_info.NvWidth;\r
-  snp->mode.NvRamSize           = snp->init_info.NvCount * snp->mode.NvRamAccessSize;\r
-  snp->mode.IfType              = snp->init_info.IFtype;\r
-  snp->mode.MaxMCastFilterCount = snp->init_info.MCastFilterCnt;\r
-  snp->mode.MCastFilterCount    = 0;\r
+  Snp->Mode.State               = EfiSimpleNetworkStopped;\r
+  Snp->Mode.HwAddressSize       = Snp->InitInfo.HWaddrLen;\r
+  Snp->Mode.MediaHeaderSize     = Snp->InitInfo.MediaHeaderLen;\r
+  Snp->Mode.MaxPacketSize       = Snp->InitInfo.FrameDataLen;\r
+  Snp->Mode.NvRamAccessSize     = Snp->InitInfo.NvWidth;\r
+  Snp->Mode.NvRamSize           = Snp->InitInfo.NvCount * Snp->Mode.NvRamAccessSize;\r
+  Snp->Mode.IfType              = Snp->InitInfo.IFtype;\r
+  Snp->Mode.MaxMCastFilterCount = Snp->InitInfo.MCastFilterCnt;\r
+  Snp->Mode.MCastFilterCount    = 0;\r
 \r
   switch (InitStatFlags & PXE_STATFLAGS_CABLE_DETECT_MASK) {\r
   case PXE_STATFLAGS_CABLE_DETECT_SUPPORTED:\r
 \r
   switch (InitStatFlags & PXE_STATFLAGS_CABLE_DETECT_MASK) {\r
   case PXE_STATFLAGS_CABLE_DETECT_SUPPORTED:\r
-    snp->mode.MediaPresentSupported = TRUE;\r
+    Snp->Mode.MediaPresentSupported = TRUE;\r
     break;\r
 \r
   case PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED:\r
   default:\r
     break;\r
 \r
   case PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED:\r
   default:\r
-    snp->mode.MediaPresentSupported = FALSE;\r
+    Snp->Mode.MediaPresentSupported = FALSE;\r
   }\r
 \r
   }\r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_STATION_ADDR_SETTABLE) != 0) {\r
-    snp->mode.MacAddressChangeable = TRUE;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_STATION_ADDR_SETTABLE) != 0) {\r
+    Snp->Mode.MacAddressChangeable = TRUE;\r
   } else {\r
   } else {\r
-    snp->mode.MacAddressChangeable = FALSE;\r
+    Snp->Mode.MacAddressChangeable = FALSE;\r
   }\r
 \r
   }\r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED) != 0) {\r
-    snp->mode.MultipleTxSupported = TRUE;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED) != 0) {\r
+    Snp->Mode.MultipleTxSupported = TRUE;\r
   } else {\r
   } else {\r
-    snp->mode.MultipleTxSupported = FALSE;\r
+    Snp->Mode.MultipleTxSupported = FALSE;\r
   }\r
 \r
   }\r
 \r
-  snp->mode.ReceiveFilterMask = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r
+  Snp->Mode.ReceiveFilterMask = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r
 \r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED) != 0) {\r
-    snp->mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED) != 0) {\r
+    Snp->Mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
 \r
   }\r
 \r
 \r
   }\r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED) != 0) {\r
-    snp->mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED) != 0) {\r
+    Snp->Mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r
 \r
   }\r
 \r
 \r
   }\r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED) != 0) {\r
-    snp->mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED) != 0) {\r
+    Snp->Mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r
 \r
   }\r
 \r
 \r
   }\r
 \r
-  if ((pxe->hw.Implementation & PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED) != 0) {\r
-    snp->mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r
+  if ((Pxe->hw.Implementation & PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED) != 0) {\r
+    Snp->Mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r
 \r
   }\r
 \r
 \r
   }\r
 \r
-  if (pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED) {\r
-    snp->mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
+  if (Pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED) {\r
+    Snp->Mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r
 \r
   }\r
 \r
 \r
   }\r
 \r
-  snp->mode.ReceiveFilterSetting = 0;\r
+  Snp->Mode.ReceiveFilterSetting = 0;\r
 \r
   //\r
   //  need to get the station address to save in the mode structure. we need to\r
   // initialize the UNDI first for this.\r
   //\r
 \r
   //\r
   //  need to get the station address to save in the mode structure. we need to\r
   // initialize the UNDI first for this.\r
   //\r
-  snp->tx_rx_bufsize  = snp->init_info.MemoryRequired;\r
-  Status              = pxe_init (snp, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE);\r
+  Snp->TxRxBufferSize = Snp->InitInfo.MemoryRequired;\r
+  Status              = PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE);\r
 \r
 \r
-  if (Status) {\r
-    pxe_stop (snp);\r
+  if (EFI_ERROR (Status)) {\r
+    PxeStop (Snp);\r
     goto Error_DeleteSNP;\r
   }\r
 \r
     goto Error_DeleteSNP;\r
   }\r
 \r
-  Status = pxe_get_stn_addr (snp);\r
+  Status = PxeGetStnAddr (Snp);\r
 \r
   if (Status != EFI_SUCCESS) {\r
 \r
   if (Status != EFI_SUCCESS) {\r
-    DEBUG ((EFI_D_ERROR, "\nsnp->undi.get_station_addr()  failed.\n"));\r
-    pxe_shutdown (snp);\r
-    pxe_stop (snp);\r
+    DEBUG ((EFI_D_ERROR, "\nSnp->undi.get_station_addr()  failed.\n"));\r
+    PxeShutdown (Snp);\r
+    PxeStop (Snp);\r
     goto Error_DeleteSNP;\r
   }\r
 \r
     goto Error_DeleteSNP;\r
   }\r
 \r
-  snp->mode.MediaPresent = FALSE;\r
+  Snp->Mode.MediaPresent = FALSE;\r
 \r
   //\r
   // We should not leave UNDI started and initialized here. this DriverStart()\r
   // routine must only find and attach the SNP interface to UNDI layer that it\r
   // finds on the given handle!\r
 \r
   //\r
   // We should not leave UNDI started and initialized here. this DriverStart()\r
   // routine must only find and attach the SNP interface to UNDI layer that it\r
   // finds on the given handle!\r
-  // The UNDI layer will be started when upper layers call snp->start.\r
+  // The UNDI layer will be started when upper layers call Snp->start.\r
   // How ever, this DriverStart() must fill up the snp mode structure which\r
   // contains the MAC address of the NIC. For this reason we started and\r
   // initialized UNDI here, now we are done, do a shutdown and stop of the\r
   // UNDI interface!\r
   //\r
   // How ever, this DriverStart() must fill up the snp mode structure which\r
   // contains the MAC address of the NIC. For this reason we started and\r
   // initialized UNDI here, now we are done, do a shutdown and stop of the\r
   // UNDI interface!\r
   //\r
-  pxe_shutdown (snp);\r
-  pxe_stop (snp);\r
+  PxeShutdown (Snp);\r
+  PxeStop (Snp);\r
 \r
   //\r
   //  add SNP to the undi handle\r
 \r
   //\r
   //  add SNP to the undi handle\r
@@ -849,25 +637,25 @@ SimpleNetworkDriverStart (
                   &Controller,\r
                   &gEfiSimpleNetworkProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
                   &Controller,\r
                   &gEfiSimpleNetworkProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
-                  &(snp->snp)\r
+                  &(Snp->Snp)\r
                   );\r
 \r
   if (!EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
                   );\r
 \r
   if (!EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Status = mPciIoFncs->FreeBuffer (\r
-                        mPciIoFncs,\r
+  Status = mPciIo->FreeBuffer (\r
+                        mPciIo,\r
                         SNP_MEM_PAGES (4096),\r
                         SNP_MEM_PAGES (4096),\r
-                        snp->cpb\r
+                        Snp->Cpb\r
                         );\r
 \r
 Error_DeleteSNP:\r
 \r
                         );\r
 \r
 Error_DeleteSNP:\r
 \r
-  mPciIoFncs->FreeBuffer (\r
-                mPciIoFncs,\r
+  mPciIo->FreeBuffer (\r
+                mPciIo,\r
                 SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
                 SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
-                snp\r
+                Snp\r
                 );\r
 NiiError:\r
   gBS->CloseProtocol (\r
                 );\r
 NiiError:\r
   gBS->CloseProtocol (\r
@@ -887,10 +675,22 @@ NiiError:
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
-\r
 /**\r
 /**\r
-\r
-\r
+  Stop this driver on ControllerHandle. This service is called by the\r
+  EFI boot service DisconnectController(). In order to\r
+  make drivers as small as possible, there are a few calling\r
+  restrictions for this service. DisconnectController()\r
+  must follow these calling restrictions. If any other agent wishes\r
+  to call Stop() it must also follow these calling restrictions.\r
+  \r
+  @param  This              Protocol instance pointer.\r
+  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
+  @retval other             This driver was not removed from this device\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -927,7 +727,7 @@ SimpleNetworkDriverStop (
   Status = gBS->UninstallProtocolInterface (\r
                   Controller,\r
                   &gEfiSimpleNetworkProtocolGuid,\r
   Status = gBS->UninstallProtocolInterface (\r
                   Controller,\r
                   &gEfiSimpleNetworkProtocolGuid,\r
-                  &Snp->snp\r
+                  &Snp->Snp\r
                   );\r
 \r
   if (EFI_ERROR (Status)) {\r
                   );\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -948,17 +748,17 @@ SimpleNetworkDriverStop (
                   Controller\r
                   );\r
 \r
                   Controller\r
                   );\r
 \r
-  pxe_shutdown (Snp);\r
-  pxe_stop (Snp);\r
+  PxeShutdown (Snp);\r
+  PxeStop (Snp);\r
 \r
 \r
-  mPciIoFncs->FreeBuffer (\r
-                mPciIoFncs,\r
+  mPciIo->FreeBuffer (\r
+                mPciIo,\r
                 SNP_MEM_PAGES (4096),\r
                 SNP_MEM_PAGES (4096),\r
-                Snp->cpb\r
+                Snp->Cpb\r
                 );\r
 \r
                 );\r
 \r
-  mPciIoFncs->FreeBuffer (\r
-                mPciIoFncs,\r
+  mPciIo->FreeBuffer (\r
+                mPciIo,\r
                 SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
                 Snp\r
                 );\r
                 SNP_MEM_PAGES (sizeof (SNP_DRIVER)),\r
                 Snp\r
                 );\r
@@ -966,18 +766,183 @@ SimpleNetworkDriverStop (
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
+//\r
+// Simple Network Protocol Driver Global Variables\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL mSimpleNetworkDriverBinding = {\r
+  SimpleNetworkDriverSupported,\r
+  SimpleNetworkDriverStart,\r
+  SimpleNetworkDriverStop,\r
+  0xa,\r
+  NULL,\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          if a match found!\r
+  @retval Other                match not 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
+  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
+  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
 \r
 /**\r
-  Install all the driver protocol\r
+  The SNP driver entry point.\r
 \r
 \r
-  @param  entry                EFI_IMAGE_ENTRY_POINT)\r
+  @param ImageHandle       The driver image handle.\r
+  @param SystemTable       The system table.\r
 \r
 \r
-  @retval EFI_SUCEESS          Initialization routine has found UNDI hardware,\r
-                               loaded it's ROM, and installed a notify event for\r
-                               the Network Indentifier Interface Protocol\r
-                               successfully.\r
-  @retval Other                Return value from HandleProtocol for\r
-                               DeviceIoProtocol or LoadedImageProtocol\r
+  @retval EFI_SUCEESS      Initialization routine has found UNDI hardware,\r
+                           loaded it's ROM, and installed a notify event for\r
+                           the Network Indentifier Interface Protocol\r
+                           successfully.\r
+  @retval Other            Return value from HandleProtocol for\r
+                           DeviceIoProtocol or LoadedImageProtocol\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r