]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Hand/Locate.c
Update DXE Core so its own PE/COFF image is passed to the PeCoffExtraActionLib
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Hand / Locate.c
index de3152107b5f14c17193487fd531a164f4d1ef27..9714f64d952a0b93a7c9bf131fbbc0fb7391d0e1 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Locate handle functions\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2010, 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
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "DxeMain.h"\r
+#include "Handle.h"\r
 \r
 //\r
 // ProtocolRequest - Last LocateHandle request ID\r
@@ -128,7 +129,7 @@ CoreLocateHandle (
   VOID                *Interface;\r
 \r
   if (BufferSize == NULL) {\r
-    Status = EFI_INVALID_PARAMETER;\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   if ((*BufferSize > 0) && (Buffer == NULL)) {\r
@@ -199,6 +200,7 @@ CoreLocateHandle (
     return Status;\r
   }\r
 \r
+  ASSERT (GetNext != NULL);\r
   //\r
   // Enumerate out the matching handles\r
   //\r
@@ -245,6 +247,7 @@ CoreLocateHandle (
       // If this is a search by register notify and a handle was\r
       // returned, update the register notification position\r
       //\r
+      ASSERT (SearchKey != NULL);\r
       ProtNotify = SearchKey;\r
       ProtNotify->Position = ProtNotify->Position->ForwardLink;\r
     }\r
@@ -450,16 +453,20 @@ CoreLocateDevicePath (
 \r
   *Device = NULL;\r
   SourcePath = *DevicePath;\r
-  SourceSize = GetDevicePathSize (SourcePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);\r
-\r
-  //\r
-  // The source path can only have 1 instance\r
-  //\r
-  if (IsDevicePathMultiInstance (SourcePath)) {\r
-    DEBUG((DEBUG_ERROR, "LocateDevicePath: Device path has too many instances\n"));\r
-    return EFI_INVALID_PARAMETER;\r
+  TmpDevicePath = SourcePath;\r
+  while (!IsDevicePathEnd (TmpDevicePath)) {\r
+    if (IsDevicePathEndInstance (TmpDevicePath)) {\r
+      //\r
+      // If DevicePath is a multi-instance device path,\r
+      // the function will operate on the first instance \r
+      //\r
+      break;\r
+    }\r
+    TmpDevicePath = NextDevicePathNode (TmpDevicePath);\r
   }\r
 \r
+  SourceSize = (UINTN) TmpDevicePath - (UINTN) SourcePath;\r
+\r
   //\r
   // Get a list of all handles that support the requested protocol\r
   //\r
@@ -486,7 +493,7 @@ CoreLocateDevicePath (
     if ((Size <= SourceSize) && CompareMem (SourcePath, TmpDevicePath, Size) == 0) {\r
       //\r
       // If the size is equal to the best match, then we\r
-      // have a duplice device path for 2 different device\r
+      // have a duplicate device path for 2 different device\r
       // handles\r
       //\r
       ASSERT (Size != BestMatch);\r
@@ -521,8 +528,8 @@ CoreLocateDevicePath (
 \r
 /**\r
   Return the first Protocol Interface that matches the Protocol GUID. If\r
-  Registration is pasased in return a Protocol Instance that was just add\r
-  to the system. If Retistration is NULL return the first Protocol Interface\r
+  Registration is passed in, return a Protocol Instance that was just add\r
+  to the system. If Registration is NULL return the first Protocol Interface\r
   you find.\r
 \r
   @param  Protocol               The protocol to search for\r