]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Library / DeviceManagerUiLib / DeviceManager.c
index 23ae6c5392e44f0af615f433c77f2a9c1c7b00db..5cc527679a780b87766136df93b82b83ce9fdc59 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
 The device manager reference implementation\r
 \r
-Copyright (c) 2004 - 2017, 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
-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
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -58,7 +52,7 @@ HII_VENDOR_DEVICE_PATH  mDeviceManagerHiiVendorDevicePath = {
   {\r
     END_DEVICE_PATH_TYPE,\r
     END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    { \r
+    {\r
       (UINT8) (END_DEVICE_PATH_LENGTH),\r
       (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
     }\r
@@ -101,12 +95,12 @@ DmExtractDevicePathFromHiiHandle (
 /**\r
   Get the mac address string from the device path.\r
   if the device path has the vlan, get the vanid also.\r
-  \r
-  @param MacAddressNode              Device path begin with mac address \r
+\r
+  @param MacAddressNode              Device path begin with mac address\r
   @param PBuffer                     Output string buffer contain mac address.\r
 \r
 **/\r
-BOOLEAN \r
+BOOLEAN\r
 GetMacAddressString(\r
   IN  MAC_ADDR_DEVICE_PATH   *MacAddressNode,\r
   OUT CHAR16                 **PBuffer\r
@@ -142,7 +136,7 @@ GetMacAddressString(
   *PBuffer = String;\r
   StrCpyS(String, BufferLen / sizeof (CHAR16), L"MAC:");\r
   String += 4;\r
-  \r
+\r
   //\r
   // Convert the MAC address into a unicode string.\r
   //\r
@@ -202,7 +196,7 @@ GetMacAddressString(
   @retval  EFI_SUCCESS               Add the item is successful.\r
   @return  Other values if failed to Add the item.\r
 **/\r
-BOOLEAN \r
+BOOLEAN\r
 AddIdToMacDeviceList (\r
   IN  EFI_STRING        MacAddrString\r
   )\r
@@ -240,7 +234,11 @@ AddIdToMacDeviceList (
   } else {\r
     mMacDeviceList.MaxListLen += MAX_MAC_ADDRESS_NODE_LIST_LEN;\r
     if (mMacDeviceList.CurListLen != 0) {\r
-      TempDeviceList = (MENU_INFO_ITEM *)AllocateCopyPool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen, (VOID *)mMacDeviceList.NodeList);\r
+      TempDeviceList = ReallocatePool (\r
+                         sizeof (MENU_INFO_ITEM) * mMacDeviceList.CurListLen,\r
+                         sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen,\r
+                         mMacDeviceList.NodeList\r
+                         );\r
     } else {\r
       TempDeviceList = (MENU_INFO_ITEM *)AllocatePool (sizeof (MENU_INFO_ITEM) * mMacDeviceList.MaxListLen);\r
     }\r
@@ -248,13 +246,9 @@ AddIdToMacDeviceList (
     if (TempDeviceList == NULL) {\r
       return FALSE;\r
     }\r
-    TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;  \r
+    TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;\r
     TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);\r
 \r
-    if (mMacDeviceList.CurListLen > 0) {\r
-      FreePool(mMacDeviceList.NodeList);\r
-    }\r
-\r
     mMacDeviceList.NodeList = TempDeviceList;\r
   }\r
   mMacDeviceList.CurListLen ++;\r
@@ -306,8 +300,8 @@ IsMacAddressDevicePath (
       if (DEVICE_MANAGER_FORM_ID == NextShowFormId) {\r
         *NeedAddItem = TRUE;\r
         break;\r
-      } \r
-      \r
+      }\r
+\r
       if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH*)DevicePath, &Buffer)) {\r
         break;\r
       }\r
@@ -321,7 +315,7 @@ IsMacAddressDevicePath (
 \r
       if (NETWORK_DEVICE_LIST_FORM_ID == NextShowFormId) {\r
         //\r
-        // Same handle may has two network child handle, so the questionid \r
+        // Same handle may has two network child handle, so the questionid\r
         // has the offset of SAME_HANDLE_KEY_OFFSET.\r
         //\r
         if (AddIdToMacDeviceList (Buffer)) {\r
@@ -351,7 +345,7 @@ IsMacAddressDevicePath (
   @return  FALSE         Do not need to add the menu about the network.\r
 \r
 **/\r
-BOOLEAN \r
+BOOLEAN\r
 IsNeedAddNetworkMenu (\r
   IN      EFI_HII_HANDLE      Handle,\r
   IN      EFI_FORM_ID         NextShowFormId,\r
@@ -360,7 +354,7 @@ IsNeedAddNetworkMenu (
 {\r
   EFI_STATUS     Status;\r
   UINTN          EntryCount;\r
-  UINTN          Index;  \r
+  UINTN          Index;\r
   EFI_HANDLE     DriverHandle;\r
   EFI_HANDLE     ControllerHandle;\r
   EFI_DEVICE_PATH_PROTOCOL   *DevicePath;\r
@@ -389,9 +383,9 @@ IsNeedAddNetworkMenu (
   }\r
   TmpDevicePath = DevicePath;\r
 \r
-  // \r
+  //\r
   // Check whether this device path include mac address device path.\r
-  // If this path has mac address path, get the value whether need \r
+  // If this path has mac address path, get the value whether need\r
   // add this info to the menu and return.\r
   // Else check more about the child handle devcie path.\r
   //\r
@@ -413,7 +407,7 @@ IsNeedAddNetworkMenu (
   }\r
 \r
   if (!IsDevicePathEnd (TmpDevicePath)) {\r
-    return FALSE;    \r
+    return FALSE;\r
   }\r
 \r
   //\r
@@ -452,7 +446,7 @@ IsNeedAddNetworkMenu (
         continue;\r
       }\r
 \r
-      // \r
+      //\r
       // Check whether this device path include mac address device path.\r
       //\r
       if (!IsMacAddressDevicePath(ChildDevicePath, NextShowFormId,&IsNeedAdd)) {\r
@@ -472,7 +466,7 @@ IsNeedAddNetworkMenu (
         } else {\r
           //\r
           // If need to update other form, return whether need to add to the menu.\r
-          //          \r
+          //\r
           goto Done;\r
         }\r
       }\r
@@ -481,9 +475,9 @@ IsNeedAddNetworkMenu (
 \r
 Done:\r
   if (OpenInfoBuffer != NULL) {\r
-    FreePool (OpenInfoBuffer);  \r
+    FreePool (OpenInfoBuffer);\r
   }\r
-  return IsNeedAdd; \r
+  return IsNeedAdd;\r
 }\r
 \r
 /**\r
@@ -514,10 +508,10 @@ CreateDeviceManagerForm(
   EFI_STRING                  NewStringTitle;\r
   CHAR16                      *DevicePathStr;\r
   EFI_STRING_ID               DevicePathId;\r
-  EFI_IFR_FORM_SET            *Buffer;      \r
-  UINTN                       BufferSize;   \r
-  UINT8                       ClassGuidNum; \r
-  EFI_GUID                    *ClassGuid;   \r
+  EFI_IFR_FORM_SET            *Buffer;\r
+  UINTN                       BufferSize;\r
+  UINT8                       ClassGuidNum;\r
+  EFI_GUID                    *ClassGuid;\r
   UINTN                       TempSize;\r
   UINT8                       *Ptr;\r
   EFI_STATUS                  Status;\r
@@ -599,7 +593,7 @@ CreateDeviceManagerForm(
       if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){\r
         Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length;\r
         continue;\r
-      } \r
+      }\r
 \r
       ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);\r
       ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));\r
@@ -629,7 +623,7 @@ CreateDeviceManagerForm(
 \r
         //\r
         // Network device process\r
-        // \r
+        //\r
         if (IsNeedAddNetworkMenu (HiiHandles[Index], NextShowFormId,&AddItemCount)) {\r
           if (NextShowFormId == DEVICE_MANAGER_FORM_ID) {\r
             //\r
@@ -679,7 +673,7 @@ CreateDeviceManagerForm(
               0,\r
               (EFI_QUESTION_ID) (Index + DEVICE_KEY_OFFSET),\r
               0,\r
-              &FormSetGuid,    \r
+              &FormSetGuid,\r
               DevicePathId\r
             );\r
           }\r
@@ -899,7 +893,7 @@ DeviceManagerUiLibConstructor (
   ASSERT (gDeviceManagerPrivate.HiiHandle != NULL);\r
 \r
   //\r
-  // Update boot manager page \r
+  // Update boot manager page\r
   //\r
   CreateDeviceManagerForm (DEVICE_MANAGER_FORM_ID);\r
 \r