]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/UndiRuntimeDxe/Init.c
BaseTools: Fix the bug to display the single SKUID info
[mirror_edk2.git] / OptionRomPkg / UndiRuntimeDxe / Init.c
index d6ad430a6331bb0eb58fc67fd6f388344b5e2771..41892ca2b6aff8949d05fb14e2254903a9bd6057 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Initialization functions for EFI UNDI32 driver.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 PXE_SW_UNDI             *pxe_31 = NULL;  // 3.1 entry\r
 UNDI32_DEV              *UNDI32DeviceList[MAX_NIC_INTERFACES];\r
-NII_TABLE               *UndiDataPointer = NULL;\r
+UNDI_CONFIG_TABLE       *UndiDataPointer = NULL;\r
 \r
 //\r
 // UNDI Class Driver Global Variables\r
@@ -64,7 +64,7 @@ UndiNotifyVirtual (
     //\r
     // UNDI32DeviceList is an array of pointers\r
     //\r
-    for (Index = 0; Index < pxe_31->IFcnt; Index++) {\r
+    for (Index = 0; Index < (pxe_31->IFcnt | pxe_31->IFcntExt << 8); Index++) {\r
       UNDI32DeviceList[Index]->NIIProtocol_31.Id = (UINT64) (UINTN) Pxe31Pointer;\r
       EfiConvertPointer (\r
         EFI_OPTIONAL_PTR,\r
@@ -99,7 +99,7 @@ UndiNotifyVirtual (
 **/\r
 VOID\r
 EFIAPI\r
-UndiNotifyExitBs (\r
+UndiNotifyReadyToBoot (\r
   EFI_EVENT Event,\r
   VOID      *Context\r
   )\r
@@ -409,7 +409,7 @@ UndiDriverStart (
   // the IfNum index for the current interface will be the total number\r
   // of interfaces initialized so far\r
   //\r
-  UNDI32Device->NIIProtocol_31.IfNum  = pxe_31->IFcnt;\r
+  UNDI32Device->NIIProtocol_31.IfNum  = pxe_31->IFcnt | pxe_31->IFcntExt << 8;\r
 \r
   PxeUpdate (&UNDI32Device->NicInfo, pxe_31);\r
 \r
@@ -435,7 +435,7 @@ UndiDriverStart (
   UNDI32Device->NIIProtocol_31.MinorVer       = PXE_ROMID_MINORVER_31;\r
   UNDI32Device->NIIProtocol_31.ImageSize      = 0;\r
   UNDI32Device->NIIProtocol_31.ImageAddr      = 0;\r
-  UNDI32Device->NIIProtocol_31.Ipv6Supported  = FALSE;\r
+  UNDI32Device->NIIProtocol_31.Ipv6Supported  = TRUE;\r
 \r
   UNDI32Device->NIIProtocol_31.StringId[0]    = 'U';\r
   UNDI32Device->NIIProtocol_31.StringId[1]    = 'N';\r
@@ -444,6 +444,10 @@ UndiDriverStart (
 \r
   UNDI32Device->DeviceHandle                  = NULL;\r
 \r
+  UNDI32Device->Aip.GetInformation            = UndiAipGetInfo;\r
+  UNDI32Device->Aip.SetInformation            = UndiAipSetInfo;\r
+  UNDI32Device->Aip.GetSupportedTypes         = UndiAipGetSupportedTypes;\r
+\r
   //\r
   // install both the 3.0 and 3.1 NII protocols.\r
   //\r
@@ -453,6 +457,8 @@ UndiDriverStart (
                   &UNDI32Device->NIIProtocol_31,\r
                   &gEfiDevicePathProtocolGuid,\r
                   UNDI32Device->Undi32DevPath,\r
+                  &gEfiAdapterInformationProtocolGuid,\r
+                  &UNDI32Device->Aip,\r
                   NULL\r
                   );\r
 \r
@@ -470,7 +476,7 @@ UndiDriverStart (
     goto UndiErrorDeleteDevicePath;\r
   }\r
 \r
-  Len = (pxe_31->IFcnt * sizeof (NII_ENTRY)) + sizeof (UndiDataPointer);\r
+  Len = ((pxe_31->IFcnt|pxe_31->IFcntExt << 8)* sizeof (UndiDataPointer->NII_entry)) + sizeof (UndiDataPointer);\r
   Status = gBS->AllocatePool (EfiRuntimeServicesData, Len, (VOID **) &UndiDataPointer);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -497,6 +503,8 @@ UndiErrorAllocDataPointer:
                   &UNDI32Device->NIIProtocol_31,\r
                   &gEfiDevicePathProtocolGuid,\r
                   UNDI32Device->Undi32DevPath,\r
+                  &gEfiAdapterInformationProtocolGuid,\r
+                  &UNDI32Device->Aip,\r
                   NULL\r
                   );\r
 \r
@@ -616,38 +624,38 @@ UndiDriverStop (
 \r
       UNDI32Device = UNDI_DEV_FROM_THIS (NIIProtocol);\r
 \r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      ChildHandleBuffer[Index],\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      UNDI32Device->Undi32DevPath,\r
-                      &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
-                      &UNDI32Device->NIIProtocol_31,\r
-                      NULL\r
+      Status = gBS->CloseProtocol (\r
+                      Controller,\r
+                      &gEfiPciIoProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      ChildHandleBuffer[Index]\r
                       );\r
       if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Restore original PCI attributes\r
-        //\r
-        Status = UNDI32Device->NicInfo.Io_Function->Attributes (\r
-                                                      UNDI32Device->NicInfo.Io_Function,\r
-                                                      EfiPciIoAttributeOperationSet,\r
-                                                      UNDI32Device->NicInfo.OriginalPciAttributes,\r
-                                                      NULL\r
-                                                      );\r
-        ASSERT_EFI_ERROR (Status);\r
-\r
-        Status = gBS->CloseProtocol (\r
-                        Controller,\r
-                        &gEfiPciIoProtocolGuid,\r
-                        This->DriverBindingHandle,\r
-                        ChildHandleBuffer[Index]\r
+        Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                        ChildHandleBuffer[Index],\r
+                        &gEfiDevicePathProtocolGuid,\r
+                        UNDI32Device->Undi32DevPath,\r
+                        &gEfiNetworkInterfaceIdentifierProtocolGuid_31,\r
+                        &UNDI32Device->NIIProtocol_31,\r
+                        NULL\r
                         );\r
-\r
-        ASSERT_EFI_ERROR (Status);\r
-\r
-        gBS->FreePool (UNDI32Device->Undi32DevPath);\r
-        gBS->FreePool (UNDI32Device);\r
-\r
+        if (!EFI_ERROR (Status)) {\r
+          //\r
+          // Restore original PCI attributes\r
+          //\r
+          Status = UNDI32Device->NicInfo.Io_Function->Attributes (\r
+                                                        UNDI32Device->NicInfo.Io_Function,\r
+                                                        EfiPciIoAttributeOperationSet,\r
+                                                        UNDI32Device->NicInfo.OriginalPciAttributes,\r
+                                                        NULL\r
+                                                        );\r
+\r
+          ASSERT_EFI_ERROR (Status);\r
+\r
+          gBS->FreePool (UNDI32Device->Undi32DevPath);\r
+          gBS->FreePool (UNDI32Device);\r
+\r
+        }\r
       }\r
     }\r
 \r
@@ -935,9 +943,9 @@ InstallConfigTable (
 {\r
   EFI_STATUS              Status;\r
   EFI_CONFIGURATION_TABLE *CfgPtr;\r
-  NII_TABLE               *TmpData;\r
+  UNDI_CONFIG_TABLE       *TmpData;\r
   UINT16                  Index;\r
-  NII_TABLE               *UndiData;\r
+  UNDI_CONFIG_TABLE       *UndiData;\r
 \r
   if (pxe_31 == NULL) {\r
     return EFI_SUCCESS;\r
@@ -947,14 +955,14 @@ InstallConfigTable (
     return EFI_SUCCESS;\r
   }\r
 \r
-  UndiData = (NII_TABLE *)UndiDataPointer;\r
+  UndiData = (UNDI_CONFIG_TABLE *)UndiDataPointer;\r
 \r
-  UndiData->NumEntries  = pxe_31->IFcnt;\r
-  UndiData->NextLink    = NULL;\r
+  UndiData->NumberOfInterfaces  = (pxe_31->IFcnt | pxe_31->IFcntExt << 8);\r
+  UndiData->nextlink            = NULL;\r
 \r
-  for (Index = 0; Index < pxe_31->IFcnt; Index++) {\r
-    UndiData->NiiEntry[Index].InterfacePointer  = &UNDI32DeviceList[Index]->NIIProtocol_31;\r
-    UndiData->NiiEntry[Index].DevicePathPointer = UNDI32DeviceList[Index]->Undi32DevPath;\r
+  for (Index = 0; Index < (pxe_31->IFcnt | pxe_31->IFcntExt << 8); Index++) {\r
+    UndiData->NII_entry[Index].NII_InterfacePointer = &UNDI32DeviceList[Index]->NIIProtocol_31;\r
+    UndiData->NII_entry[Index].DevicePathPointer    = UNDI32DeviceList[Index]->Undi32DevPath;\r
   }\r
 \r
   //\r
@@ -975,21 +983,21 @@ InstallConfigTable (
   }\r
 \r
   if (Index < gST->NumberOfTableEntries) {\r
-    TmpData = (NII_TABLE *) CfgPtr->VendorTable;\r
+    TmpData = (UNDI_CONFIG_TABLE *) CfgPtr->VendorTable;\r
 \r
     //\r
     // go to the last link\r
     //\r
-    while (TmpData->NextLink != NULL) {\r
-      TmpData = TmpData->NextLink;\r
+    while (TmpData->nextlink != NULL) {\r
+      TmpData = TmpData->nextlink;\r
     }\r
 \r
-    TmpData->NextLink = UndiData;\r
+    TmpData->nextlink = UndiData;\r
 \r
     //\r
     // 1st one in chain\r
     //\r
-    UndiData = (NII_TABLE *) CfgPtr->VendorTable;\r
+    UndiData = (UNDI_CONFIG_TABLE *) CfgPtr->VendorTable;\r
   }\r
 \r
   //\r
@@ -1015,20 +1023,22 @@ InitializeUndi(
   EFI_EVENT     Event;\r
   EFI_STATUS    Status;\r
 \r
-  Status = EfiLibInstallDriverBinding (\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
              ImageHandle,\r
              SystemTable,\r
              &gUndiDriverBinding,\r
-             ImageHandle\r
+             ImageHandle,\r
+             &gUndiComponentName,\r
+             &gUndiComponentName2\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   Status = gBS->CreateEventEx (\r
                   EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
-                  UndiNotifyExitBs,\r
+                  UndiNotifyReadyToBoot,\r
                   NULL,\r
-                  &gEfiEventExitBootServicesGuid,\r
+                  &gEfiEventReadyToBootGuid,\r
                   &Event\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r