]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Hand/Handle.c
Remove DEBUG_LOAD for InstallProtocolInterface() to align with PPI installation debug...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Hand / Handle.c
index 99c265996ead8420d8d65431d87053586b8afa22..deae9d62513f7fa982154c9292b408107040eec6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI handle & protocol handling.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\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
@@ -12,7 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <DxeMain.h>\r
+#include "DxeMain.h"\r
+#include "Handle.h"\r
 \r
 \r
 //\r
@@ -22,9 +23,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // gHandleDatabaseKey    -  The Key to show that the handle has been created/modified\r
 //\r
 LIST_ENTRY      mProtocolDatabase     = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase);\r
-LIST_ENTRY             gHandleList           = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList);\r
-EFI_LOCK               gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
-UINT64                 gHandleDatabaseKey    = 0;\r
+LIST_ENTRY      gHandleList           = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList);\r
+EFI_LOCK        gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
+UINT64          gHandleDatabaseKey    = 0;\r
 \r
 \r
 \r
@@ -132,7 +133,7 @@ CoreFindProtocolEntry (
   // allocate a new entry\r
   //\r
   if ((ProtEntry == NULL) && Create) {\r
-    ProtEntry = CoreAllocateBootServicesPool (sizeof(PROTOCOL_ENTRY));\r
+    ProtEntry = AllocatePool (sizeof(PROTOCOL_ENTRY));\r
 \r
     if (ProtEntry != NULL) {\r
       //\r
@@ -364,15 +365,13 @@ CoreInstallProtocolInterfaceNotify (
   //\r
   // Print debug message\r
   //\r
-  DEBUG((DEBUG_LOAD | DEBUG_INFO, "InstallProtocolInterface: %g %p\n", Protocol, Interface));\r
+  DEBUG((DEBUG_INFO, "InstallProtocolInterface: %g %p\n", Protocol, Interface));\r
 \r
   Status = EFI_OUT_OF_RESOURCES;\r
   Prot = NULL;\r
   Handle = NULL;\r
 \r
-  ASSERT (gDxeCoreBS != NULL);\r
-\r
-  if (*UserHandle != NULL_HANDLE) {\r
+  if (*UserHandle != NULL) {\r
     Status = CoreHandleProtocol (*UserHandle, Protocol, (VOID **)&ExistingInterface);\r
     if (!EFI_ERROR (Status)) {\r
       return EFI_INVALID_PARAMETER;\r
@@ -395,7 +394,7 @@ CoreInstallProtocolInterfaceNotify (
   //\r
   // Allocate a new protocol interface structure\r
   //\r
-  Prot = CoreAllocateZeroBootServicesPool (sizeof(PROTOCOL_INTERFACE));\r
+  Prot = AllocateZeroPool (sizeof(PROTOCOL_INTERFACE));\r
   if (Prot == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
@@ -406,7 +405,7 @@ CoreInstallProtocolInterfaceNotify (
   //\r
   Handle = (IHANDLE *)*UserHandle;\r
   if (Handle == NULL) {\r
-    Handle = CoreAllocateZeroBootServicesPool (sizeof(IHANDLE));\r
+    Handle = AllocateZeroPool (sizeof(IHANDLE));\r
     if (Handle == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Done;\r
@@ -566,7 +565,7 @@ CoreInstallMultipleProtocolInterfaces (
       DeviceHandle = NULL;\r
       DevicePath   = Interface;\r
       Status = CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, &DeviceHandle);\r
-      if (!EFI_ERROR (Status) && (DeviceHandle != NULL_HANDLE) && IsDevicePathEnd(DevicePath)) {\r
+      if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(DevicePath)) {\r
         Status = EFI_ALREADY_STARTED;\r
         continue;\r
       }\r
@@ -577,6 +576,7 @@ CoreInstallMultipleProtocolInterfaces (
     //\r
     Status = CoreInstallProtocolInterface (Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);\r
   }\r
+  VA_END (Args);\r
 \r
   //\r
   // If there was an error, remove all the interfaces that were installed without any errors\r
@@ -591,6 +591,8 @@ CoreInstallMultipleProtocolInterfaces (
       Interface = VA_ARG (Args, VOID *);\r
       CoreUninstallProtocolInterface (*Handle, Protocol, Interface);\r
     }\r
+    VA_END (Args);\r
+    \r
     *Handle = OldHandle;\r
   }\r
 \r
@@ -638,7 +640,7 @@ CoreDisconnectControllersUsingProtocolInterface (
           (Link != &Prot->OpenList) && !ItemFound;\r
           Link = Link->ForwardLink ) {\r
       OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);\r
-      if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) {\r
+      if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
         ItemFound = TRUE;\r
         CoreReleaseProtocolLock ();\r
         Status = CoreDisconnectController (UserHandle, OpenData->AgentHandle, NULL);\r
@@ -661,8 +663,8 @@ CoreDisconnectControllersUsingProtocolInterface (
             (Link != &Prot->OpenList) && !ItemFound;\r
             Link = Link->ForwardLink ) {\r
         OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);\r
-        if (OpenData->Attributes &\r
-            (EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {\r
+        if ((OpenData->Attributes &\r
+            (EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) != 0) {\r
           ItemFound = TRUE;\r
           RemoveEntryList (&OpenData->Link);\r
           Prot->OpenListCount--;\r
@@ -846,6 +848,7 @@ CoreUninstallMultipleProtocolInterfaces (
     //\r
     Status = CoreUninstallProtocolInterface (Handle, Protocol, Interface);\r
   }\r
+  VA_END (Args);\r
 \r
   //\r
   // If there was an error, add all the interfaces that were\r
@@ -861,6 +864,7 @@ CoreUninstallMultipleProtocolInterfaces (
       Interface = VA_ARG(Args, VOID *);\r
       CoreInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);\r
     }\r
+    VA_END (Args);\r
   }\r
 \r
   return Status;\r
@@ -918,7 +922,11 @@ CoreGetProtocolInterface (
   @param  Interface              Supplies the address where a pointer to the\r
                                  corresponding Protocol Interface is returned.\r
 \r
-  @return The requested protocol interface for the handle\r
+  @retval EFI_SUCCESS            The interface information for the specified protocol was returned.\r
+  @retval EFI_UNSUPPORTED        The device does not support the specified protocol.\r
+  @retval EFI_INVALID_PARAMETER  Handle is not a valid EFI_HANDLE..\r
+  @retval EFI_INVALID_PARAMETER  Protocol is NULL.\r
+  @retval EFI_INVALID_PARAMETER  Interface is NULL.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1078,14 +1086,14 @@ CoreOpenProtocol (
     ExactMatch =  (BOOLEAN)((OpenData->AgentHandle == ImageHandle) &&\r
                             (OpenData->Attributes == Attributes)  &&\r
                             (OpenData->ControllerHandle == ControllerHandle));\r
-    if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) {\r
+    if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
       ByDriver = TRUE;\r
       if (ExactMatch) {\r
         Status = EFI_ALREADY_STARTED;\r
         goto Done;\r
       }\r
     }\r
-    if (OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) {\r
+    if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) != 0) {\r
       Exclusive = TRUE;\r
     } else if (ExactMatch) {\r
       OpenData->OpenCount++;\r
@@ -1119,7 +1127,7 @@ CoreOpenProtocol (
         Disconnect = FALSE;\r
         for ( Link = Prot->OpenList.ForwardLink; (Link != &Prot->OpenList) && (!Disconnect); Link = Link->ForwardLink) {\r
           OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);\r
-          if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) {\r
+          if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
             Disconnect = TRUE;\r
             CoreReleaseProtocolLock ();\r
             Status = CoreDisconnectController (UserHandle, OpenData->AgentHandle, NULL);\r
@@ -1147,7 +1155,7 @@ CoreOpenProtocol (
   //\r
   // Create new entry\r
   //\r
-  OpenData = CoreAllocateBootServicesPool (sizeof(OPEN_PROTOCOL_DATA));\r
+  OpenData = AllocatePool (sizeof(OPEN_PROTOCOL_DATA));\r
   if (OpenData == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
   } else {\r
@@ -1221,7 +1229,7 @@ CoreCloseProtocol (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  if (ControllerHandle != NULL_HANDLE) {\r
+  if (ControllerHandle != NULL) {\r
     Status = CoreValidateHandle (ControllerHandle);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -1276,11 +1284,15 @@ Done:
 \r
   @param  UserHandle             The handle to close the protocol interface on\r
   @param  Protocol               The ID of the protocol\r
-  @param  EntryBuffer            A pointer to a buffer of open protocol\r
-                                 information in the form of\r
-                                 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.\r
+  @param  EntryBuffer            A pointer to a buffer of open protocol information in the\r
+                                 form of EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.\r
   @param  EntryCount             Number of EntryBuffer entries\r
 \r
+  @retval EFI_SUCCESS            The open protocol information was returned in EntryBuffer, \r
+                                 and the number of entries was returned EntryCount.\r
+  @retval EFI_NOT_FOUND          Handle does not support the protocol specified by Protocol.\r
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to allocate EntryBuffer.\r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1333,7 +1345,7 @@ CoreOpenProtocolInformation (
     Size = Count * sizeof(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY);\r
   }\r
 \r
-  Buffer = CoreAllocateBootServicesPool (Size);\r
+  Buffer = AllocatePool (Size);\r
   if (Buffer == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
@@ -1436,7 +1448,7 @@ CoreProtocolsPerHandle (
     goto Done;\r
   }\r
 \r
-  Buffer = CoreAllocateBootServicesPool (sizeof (EFI_GUID *) * ProtocolCount);\r
+  Buffer = AllocatePool (sizeof (EFI_GUID *) * ProtocolCount);\r
   if (Buffer == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
@@ -1507,7 +1519,7 @@ CoreConnectHandlesByKey (
     }\r
   }\r
 \r
-  HandleBuffer = CoreAllocateBootServicesPool (Count * sizeof (EFI_HANDLE));\r
+  HandleBuffer = AllocatePool (Count * sizeof (EFI_HANDLE));\r
   if (HandleBuffer == NULL) {\r
     CoreReleaseProtocolLock ();\r
     return;\r