]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c
add UndiRuntimeDxe from MdeModulePkg to OptionRomPkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UndiRuntimeDxe / Init.c
index 3e3391ebee3be4160b7e22181608e0490dbd9c16..42dd5fd21f7676a9e1b2f6cd8ca5338207916d9c 100644 (file)
@@ -1,6 +1,7 @@
-/*++\r
+/** @file\r
+  Initialization functions for EFI UNDI32 driver.\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2008, 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
@@ -9,52 +10,45 @@ 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
-\r
-    init.c\r
-\r
-Abstract:\r
-\r
-    Initialization functions for EFI UNDI32 driver\r
-\r
-Revision History\r
-\r
---*/\r
+**/\r
 \r
 #include "Undi32.h"\r
-#include <Library/BaseLib.h>\r
 //\r
 // Global Variables\r
 //\r
-PXE_SW_UNDI             *pxe = 0;     // 3.0 entry point\r
-PXE_SW_UNDI             *pxe_31 = 0;  // 3.1 entry\r
-UNDI32_DEV              *UNDI32DeviceList[MAX_NIC_INTERFACES];\r
 \r
+PXE_SW_UNDI             *pxe_31 = NULL;  // 3.1 entry\r
+UNDI32_DEV              *UNDI32DeviceList[MAX_NIC_INTERFACES];\r
 NII_TABLE               *UndiDataPointer = NULL;\r
 \r
-VOID\r
-EFIAPI\r
-UndiNotifyVirtual (\r
-  EFI_EVENT Event,\r
-  VOID      *Context\r
-  )\r
-/*++\r
+//\r
+// UNDI Class Driver Global Variables\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL  gUndiDriverBinding = {\r
+  UndiDriverSupported,\r
+  UndiDriverStart,\r
+  UndiDriverStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
 \r
-Routine Description:\r
 \r
+/**\r
   When address mapping changes to virtual this should make the appropriate\r
   address conversions.\r
 \r
-Arguments:\r
-\r
   (Standard Event handler)\r
 \r
-Returns:\r
+  @return None\r
 \r
-  None\r
-\r
---*/\r
-// TODO:    Context - add argument and description to function comment\r
+**/\r
+VOID\r
+EFIAPI\r
+UndiNotifyVirtual (\r
+  EFI_EVENT Event,\r
+  VOID      *Context\r
+  )\r
 {\r
   UINT16  Index;\r
   VOID    *Pxe31Pointer;\r
@@ -63,7 +57,7 @@ Returns:
     Pxe31Pointer = (VOID *) pxe_31;\r
 \r
     EfiConvertPointer (\r
-      EFI_OPTIONAL_POINTER,\r
+      EFI_OPTIONAL_PTR,\r
       (VOID **) &Pxe31Pointer\r
       );\r
 \r
@@ -71,15 +65,15 @@ Returns:
     // UNDI32DeviceList is an array of pointers\r
     //\r
     for (Index = 0; Index < pxe_31->IFcnt; Index++) {\r
-      UNDI32DeviceList[Index]->NIIProtocol_31.ID = (UINT64) (UINTN) Pxe31Pointer;\r
+      UNDI32DeviceList[Index]->NIIProtocol_31.Id = (UINT64) (UINTN) Pxe31Pointer;\r
       EfiConvertPointer (\r
-        EFI_OPTIONAL_POINTER,\r
+        EFI_OPTIONAL_PTR,\r
         (VOID **) &(UNDI32DeviceList[Index])\r
         );\r
     }\r
 \r
     EfiConvertPointer (\r
-      EFI_OPTIONAL_POINTER,\r
+      EFI_OPTIONAL_PTR,\r
       (VOID **) &(pxe_31->EntryPoint)\r
       );\r
     pxe_31 = Pxe31Pointer;\r
@@ -87,83 +81,55 @@ Returns:
 \r
   for (Index = 0; Index <= PXE_OPCODE_LAST_VALID; Index++) {\r
     EfiConvertPointer (\r
-      EFI_OPTIONAL_POINTER,\r
+      EFI_OPTIONAL_PTR,\r
       (VOID **) &api_table[Index].api_ptr\r
       );\r
   }\r
 }\r
 \r
-VOID\r
-EFIAPI\r
-UndiNotifyExitBs (\r
-  EFI_EVENT Event,\r
-  VOID      *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   When EFI is shuting down the boot services, we need to install a\r
   configuration table for UNDI to work at runtime!\r
 \r
-Arguments:\r
-\r
   (Standard Event handler)\r
 \r
-Returns:\r
-\r
-  None\r
+  @return None\r
 \r
---*/\r
-// TODO:    Context - add argument and description to function comment\r
+**/\r
+VOID\r
+EFIAPI\r
+UndiNotifyExitBs (\r
+  EFI_EVENT Event,\r
+  VOID      *Context\r
+  )\r
 {\r
   InstallConfigTable ();\r
 }\r
-//\r
-// UNDI Class Driver Global Variables\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL  gUndiDriverBinding = {\r
-  UndiDriverSupported,\r
-  UndiDriverStart,\r
-  UndiDriverStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
 \r
 \r
-EFI_STATUS\r
-EFIAPI\r
-UndiDriverSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
   than contains a  DevicePath, PciIo protocol, Class code of 2, Vendor ID of 0x8086,\r
   and DeviceId of (D100_DEVICE_ID || D102_DEVICE_ID || ICH3_DEVICE_ID_1 ||\r
   ICH3_DEVICE_ID_2 || ICH3_DEVICE_ID_3 || ICH3_DEVICE_ID_4 || ICH3_DEVICE_ID_5 ||\r
   ICH3_DEVICE_ID_6 || ICH3_DEVICE_ID_7 || ICH3_DEVICE_ID_8) can be supported.\r
 \r
-Arguments:\r
-\r
-  This                - Protocol instance pointer.\r
-\r
-  Controller          - Handle of device to test.\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to test.\r
+  @param  RemainingDevicePath  Not used.\r
 \r
-  RemainingDevicePath - Not used.\r
+  @retval EFI_SUCCESS          This driver supports this device.\r
+  @retval other                This driver does not support this device.\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS         - This driver supports this device.\r
-\r
-  other               - This driver does not support this device.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UndiDriverSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
 {\r
   EFI_STATUS          Status;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
@@ -247,37 +213,28 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-UndiDriverStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Start this driver on Controller by opening PciIo and DevicePath protocol.\r
   Initialize PXE structures, create a copy of the Controller Device Path with the\r
   NIC's MAC address appended to it, install the NetworkInterfaceIdentifier protocol\r
   on the newly created Device Path.\r
 \r
-Arguments:\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to work with.\r
+  @param  RemainingDevicePath  Not used, always produce all possible children.\r
 \r
-  This                - Protocol instance pointer.\r
+  @retval EFI_SUCCESS          This driver is added to Controller.\r
+  @retval other                This driver does not support this device.\r
 \r
-  Controller          - Handle of device to work with.\r
-\r
-  RemainingDevicePath - Not used, always produce all possible children.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS         - This driver is added to Controller.\r
-\r
-  other               - This driver does not support this device.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UndiDriverStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Controller,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  )\r
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *UndiDevicePath;\r
@@ -288,6 +245,7 @@ Returns:
   EFI_PCI_IO_PROTOCOL       *PciIoFncs;\r
   UINTN                     Len;\r
   UINT64                    Supports;\r
+  BOOLEAN                   PciAttributesSaved;\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -322,6 +280,8 @@ Returns:
     return Status;\r
   }\r
 \r
+  PciAttributesSaved = FALSE;\r
+\r
   Status = gBS->AllocatePool (\r
                   EfiRuntimeServicesData,\r
                   sizeof (UNDI32_DEV),\r
@@ -345,8 +305,9 @@ Returns:
                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto UndiErrorDeleteDevice;\r
   }\r
+  PciAttributesSaved = TRUE;\r
 \r
   //\r
   // allocate and initialize both (old and new) the !pxe structures here,\r
@@ -381,17 +342,11 @@ Returns:
     } else {\r
       pxe_31 = (PXE_SW_UNDI *) TmpPxePointer;\r
     }\r
-    //\r
-    // assuming that the sizeof pxe_31 is a 16 byte multiple\r
-    //\r
-    pxe = (PXE_SW_UNDI *) ((CHAR8 *) (pxe_31) + sizeof (PXE_SW_UNDI));\r
 \r
-    PxeStructInit (pxe, 0x30);\r
-    PxeStructInit (pxe_31, 0x31);\r
+    PxeStructInit (pxe_31);\r
   }\r
 \r
-  UNDI32Device->NIIProtocol.ID    = (UINT64) (UINTN) (pxe);\r
-  UNDI32Device->NIIProtocol_31.ID = (UINT64) (UINTN) (pxe_31);\r
+  UNDI32Device->NIIProtocol_31.Id = (UINT64) (UINTN) (pxe_31);\r
 \r
   Status = PciIoFncs->Attributes (\r
                         PciIoFncs,\r
@@ -454,15 +409,13 @@ Returns:
   // the IfNum index for the current interface will be the total number\r
   // of interfaces initialized so far\r
   //\r
-  UNDI32Device->NIIProtocol.IfNum     = pxe->IFcnt;\r
   UNDI32Device->NIIProtocol_31.IfNum  = pxe_31->IFcnt;\r
 \r
-  PxeUpdate (&UNDI32Device->NicInfo, pxe);\r
   PxeUpdate (&UNDI32Device->NicInfo, pxe_31);\r
 \r
-  UNDI32Device->NicInfo.Io_Function                 = PciIoFncs;\r
-  UNDI32DeviceList[UNDI32Device->NIIProtocol.IfNum] = UNDI32Device;\r
-  UNDI32Device->Undi32BaseDevPath                   = UndiDevicePath;\r
+  UNDI32Device->NicInfo.Io_Function                    = PciIoFncs;\r
+  UNDI32DeviceList[UNDI32Device->NIIProtocol_31.IfNum] = UNDI32Device;\r
+  UNDI32Device->Undi32BaseDevPath                      = UndiDevicePath;\r
 \r
   Status = AppendMac2DevPath (\r
             &UNDI32Device->Undi32DevPath,\r
@@ -476,19 +429,6 @@ Returns:
 \r
   UNDI32Device->Signature                     = UNDI_DEV_SIGNATURE;\r
 \r
-  UNDI32Device->NIIProtocol.Revision          = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION;\r
-  UNDI32Device->NIIProtocol.Type              = EfiNetworkInterfaceUndi;\r
-  UNDI32Device->NIIProtocol.MajorVer          = PXE_ROMID_MAJORVER;\r
-  UNDI32Device->NIIProtocol.MinorVer          = PXE_ROMID_MINORVER;\r
-  UNDI32Device->NIIProtocol.ImageSize         = 0;\r
-  UNDI32Device->NIIProtocol.ImageAddr         = 0;\r
-  UNDI32Device->NIIProtocol.Ipv6Supported     = FALSE;\r
-\r
-  UNDI32Device->NIIProtocol.StringId[0]       = 'U';\r
-  UNDI32Device->NIIProtocol.StringId[1]       = 'N';\r
-  UNDI32Device->NIIProtocol.StringId[2]       = 'D';\r
-  UNDI32Device->NIIProtocol.StringId[3]       = 'I';\r
-\r
   UNDI32Device->NIIProtocol_31.Revision       = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31;\r
   UNDI32Device->NIIProtocol_31.Type           = EfiNetworkInterfaceUndi;\r
   UNDI32Device->NIIProtocol_31.MajorVer       = PXE_ROMID_MAJORVER;\r
@@ -511,8 +451,6 @@ Returns:
                   &UNDI32Device->DeviceHandle,\r
                   &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
                   &UNDI32Device->NIIProtocol_31,\r
-                  &gEfiNetworkInterfaceIdentifierProtocolGuid,\r
-                  &UNDI32Device->NIIProtocol,\r
                   &gEfiDevicePathProtocolGuid,\r
                   UNDI32Device->Undi32DevPath,\r
                   NULL\r
@@ -526,7 +464,7 @@ Returns:
   // if the table exists, free it and alloc again, or alloc it directly\r
   //\r
   if (UndiDataPointer != NULL) {\r
-       Status = gBS->FreePool(UndiDataPointer);\r
+    Status = gBS->FreePool(UndiDataPointer);\r
   }\r
   if (EFI_ERROR (Status)) {\r
     goto UndiErrorDeleteDevicePath;\r
@@ -557,19 +495,16 @@ UndiErrorAllocDataPointer:
                   &UNDI32Device->DeviceHandle,\r
                   &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
                   &UNDI32Device->NIIProtocol_31,\r
-                  &gEfiNetworkInterfaceIdentifierProtocolGuid,\r
-                  &UNDI32Device->NIIProtocol,\r
                   &gEfiDevicePathProtocolGuid,\r
                   UNDI32Device->Undi32DevPath,\r
                   NULL\r
                   );\r
 \r
 UndiErrorDeleteDevicePath:\r
-  UNDI32DeviceList[UNDI32Device->NIIProtocol.IfNum] = NULL;\r
+  UNDI32DeviceList[UNDI32Device->NIIProtocol_31.IfNum] = NULL;\r
   gBS->FreePool (UNDI32Device->Undi32DevPath);\r
 \r
 UndiErrorDeletePxe:\r
-  PxeUpdate (NULL, pxe);\r
   PxeUpdate (NULL, pxe_31);\r
   if (TmpPxePointer != NULL) {\r
     gBS->FreePool (TmpPxePointer);\r
@@ -577,15 +512,17 @@ UndiErrorDeletePxe:
   }\r
 \r
 UndiErrorDeleteDevice:\r
-  //\r
-  // Restore original PCI attributes\r
-  //\r
-  PciIoFncs->Attributes (\r
-                  PciIoFncs,\r
-                  EfiPciIoAttributeOperationSet,\r
-                  UNDI32Device->NicInfo.OriginalPciAttributes,\r
-                  NULL\r
-                  );\r
+  if (PciAttributesSaved) {\r
+    //\r
+    // Restore original PCI attributes\r
+    //\r
+    PciIoFncs->Attributes (\r
+                    PciIoFncs,\r
+                    EfiPciIoAttributeOperationSet,\r
+                    UNDI32Device->NicInfo.OriginalPciAttributes,\r
+                    NULL\r
+                    );\r
+  }\r
 \r
   gBS->FreePool (UNDI32Device);\r
 \r
@@ -607,6 +544,21 @@ UndiError:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and\r
+  closing the DevicePath and PciIo protocols on Controller.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  Controller           Handle of device to stop driver on.\r
+  @param  NumberOfChildren     How many children need to be stopped.\r
+  @param  ChildHandleBuffer    Not used.\r
+\r
+  @retval EFI_SUCCESS          This driver is removed Controller.\r
+  @retval other                This driver was not removed from this device.\r
+\r
+**/\r
+// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
 EFI_STATUS\r
 EFIAPI\r
 UndiDriverStop (\r
@@ -615,24 +567,6 @@ UndiDriverStop (
   IN  UINTN                          NumberOfChildren,\r
   IN  EFI_HANDLE                     *ChildHandleBuffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and\r
-  closing the DevicePath and PciIo protocols on Controller.\r
-\r
-Arguments:\r
-  This              - Protocol instance pointer.\r
-  Controller        - Handle of device to stop driver on.\r
-  NumberOfChildren  - How many children need to be stopped.\r
-  ChildHandleBuffer - Not used.\r
-\r
-Returns:\r
-  EFI_SUCCESS       - This driver is removed Controller.\r
-  other             - This driver was not removed from this device.\r
-\r
---*/\r
-// TODO:    EFI_DEVICE_ERROR - add return value to function comment\r
 {\r
   EFI_STATUS                                Status;\r
   BOOLEAN                                   AllChildrenStopped;\r
@@ -673,7 +607,7 @@ Returns:
 \r
     Status = gBS->OpenProtocol (\r
                     ChildHandleBuffer[Index],\r
-                    &gEfiNetworkInterfaceIdentifierProtocolGuid,\r
+                    &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
                     (VOID **) &NIIProtocol,\r
                     This->DriverBindingHandle,\r
                     Controller,\r
@@ -707,8 +641,6 @@ Returns:
                       UNDI32Device->Undi32DevPath,\r
                       &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
                       &UNDI32Device->NIIProtocol_31,\r
-                      &gEfiNetworkInterfaceIdentifierProtocolGuid,\r
-                      &UNDI32Device->NIIProtocol,\r
                       NULL\r
                       );\r
 \r
@@ -740,34 +672,44 @@ Returns:
 \r
 }\r
 \r
-VOID\r
-TmpDelay (\r
-  IN UINT64 UnqId,\r
-  IN UINTN  MicroSeconds\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Use the EFI boot services to produce a pause. This is also the routine which\r
   gets replaced during RunTime by the O/S in the NIC_DATA_INSTANCE so it can\r
   do it's own pause.\r
 \r
-Arguments:\r
+  @param  UnqId                Runtime O/S routine might use this, this temp\r
+                               routine does not use it\r
+  @param  MicroSeconds         Determines the length of pause.\r
 \r
-  UnqId             - Runtime O/S routine might use this, this temp routine does not use it\r
+  @return none\r
 \r
-  MicroSeconds      - Determines the length of pause.\r
-\r
-Returns:\r
-\r
-  none\r
-\r
---*/\r
+**/\r
+VOID\r
+TmpDelay (\r
+  IN UINT64 UnqId,\r
+  IN UINTN  MicroSeconds\r
+  )\r
 {\r
   gBS->Stall ((UINT32) MicroSeconds);\r
 }\r
 \r
+\r
+/**\r
+  Use the PCI IO abstraction to issue memory or I/O reads and writes.  This is also the routine which\r
+  gets replaced during RunTime by the O/S in the NIC_DATA_INSTANCE so it can do it's own I/O abstractions.\r
+\r
+  @param  UnqId                Runtime O/S routine may use this field, this temp\r
+                               routine does not.\r
+  @param  ReadWrite            Determine if it is an I/O or Memory Read/Write\r
+                               Operation.\r
+  @param  Len                  Determines the width of the data operation.\r
+  @param  Port                 What port to Read/Write from.\r
+  @param  BuffAddr             Address to read to or write from.\r
+\r
+  @return none\r
+\r
+**/\r
 VOID\r
 TmpMemIo (\r
   IN UINT64 UnqId,\r
@@ -776,30 +718,6 @@ TmpMemIo (
   IN UINT64 Port,\r
   IN UINT64 BuffAddr\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Use the PCI IO abstraction to issue memory or I/O reads and writes.  This is also the routine which\r
-  gets replaced during RunTime by the O/S in the NIC_DATA_INSTANCE so it can do it's own I/O abstractions.\r
-\r
-Arguments:\r
-\r
-  UnqId             - Runtime O/S routine may use this field, this temp routine does not.\r
-\r
-  ReadWrite         - Determine if it is an I/O or Memory Read/Write Operation.\r
-\r
-  Len               - Determines the width of the data operation.\r
-\r
-  Port              - What port to Read/Write from.\r
-\r
-  BuffAddr          - Address to read to or write from.\r
-\r
-Returns:\r
-\r
-  none\r
-\r
---*/\r
 {\r
   EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
   NIC_DATA_INSTANCE         *AdapterInfo;\r
@@ -869,35 +787,31 @@ Returns:
   return ;\r
 }\r
 \r
-EFI_STATUS\r
-AppendMac2DevPath (\r
-  IN OUT  EFI_DEVICE_PATH_PROTOCOL **DevPtr,\r
-  IN      EFI_DEVICE_PATH_PROTOCOL *BaseDevPtr,\r
-  IN      NIC_DATA_INSTANCE        *AdapterInfo\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Using the NIC data structure information, read the EEPROM to get the MAC address and then allocate space\r
   for a new devicepath (**DevPtr) which will contain the original device path the NIC was found on (*BaseDevPtr)\r
   and an added MAC node.\r
 \r
-Arguments:\r
-\r
-  DevPtr            - Pointer which will point to the newly created device path with the MAC node attached.\r
-\r
-  BaseDevPtr        - Pointer to the device path which the UNDI device driver is latching on to.\r
-\r
-  AdapterInfo       - Pointer to the NIC data structure information which the UNDI driver is layering on..\r
+  @param  DevPtr               Pointer which will point to the newly created device\r
+                               path with the MAC node attached.\r
+  @param  BaseDevPtr           Pointer to the device path which the UNDI device\r
+                               driver is latching on to.\r
+  @param  AdapterInfo          Pointer to the NIC data structure information which\r
+                               the UNDI driver is layering on..\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS          A MAC address was successfully appended to the Base\r
+                               Device Path.\r
+  @retval other                Not enough resources available to create new Device\r
+                               Path node.\r
 \r
-  EFI_SUCCESS       - A MAC address was successfully appended to the Base Device Path.\r
-\r
-  other             - Not enough resources available to create new Device Path node.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+AppendMac2DevPath (\r
+  IN OUT  EFI_DEVICE_PATH_PROTOCOL **DevPtr,\r
+  IN      EFI_DEVICE_PATH_PROTOCOL *BaseDevPtr,\r
+  IN      NIC_DATA_INSTANCE        *AdapterInfo\r
+  )\r
 {\r
   EFI_MAC_ADDRESS           MACAddress;\r
   PCI_CONFIG_HEADER         *CfgHdr;\r
@@ -1009,28 +923,23 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-InstallConfigTable (\r
-  IN VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
 \r
+/**\r
   Install a GUID/Pointer pair into the system's configuration table.\r
 \r
-Arguments:\r
-\r
   none\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS       - Install a GUID/Pointer pair into the system's configuration table.\r
-\r
-  other             - Did not successfully install the GUID/Pointer pair into the configuration table.\r
+  @retval EFI_SUCCESS          Install a GUID/Pointer pair into the system's\r
+                               configuration table.\r
+  @retval other                Did not successfully install the GUID/Pointer pair\r
+                               into the configuration table.\r
 \r
---*/\r
+**/\r
 // TODO:    VOID - add argument and description to function comment\r
+EFI_STATUS\r
+InstallConfigTable (\r
+  IN VOID\r
+  )\r
 {\r
   EFI_STATUS              Status;\r
   EFI_CONFIGURATION_TABLE *CfgPtr;\r
@@ -1043,7 +952,7 @@ Returns:
   }\r
 \r
   if(UndiDataPointer == NULL) {\r
-       return EFI_SUCCESS;\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   UndiData = (NII_TABLE *)UndiDataPointer;\r
@@ -1103,14 +1012,6 @@ Returns:
 \r
 /**\r
 \r
-  Install driver binding protocol of UNDI.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1130,20 +1031,22 @@ InitializeUndi(
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = gBS->CreateEvent (\r
-                  EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
                   UndiNotifyExitBs,\r
                   NULL,\r
+                  &gEfiEventExitBootServicesGuid,\r
                   &Event\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = gBS->CreateEvent (\r
-                  EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
                   UndiNotifyVirtual,\r
                   NULL,\r
+                  &gEfiEventVirtualAddressChangeGuid,\r
                   &Event\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r