X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdeModulePkg%2FCore%2FDxe%2FHand%2FHandle.c;h=6708ef8729ace640424f08c2296a90785c25798f;hb=4a23eaa9e0400325624e7d45b4a0e1e39c431d30;hp=72657d8756cf2d92a5d732e95422c683f87937ee;hpb=e94a9ff7271367e649ee4f9a86da1f1bea6d112e;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c index 72657d8756..6708ef8729 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c @@ -1,8 +1,8 @@ /** @file UEFI handle & protocol handling. -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -12,7 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include +#include "DxeMain.h" +#include "Handle.h" // @@ -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 // LIST_ENTRY mProtocolDatabase = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase); -LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList); -EFI_LOCK gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); -UINT64 gHandleDatabaseKey = 0; +LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList); +EFI_LOCK gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); +UINT64 gHandleDatabaseKey = 0; @@ -59,9 +60,9 @@ CoreReleaseProtocolLock ( /** Check whether a handle is a valid EFI_HANDLE - @param UserHandle The handle to check + @param UserHandle The handle to check - @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE. + @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE. @retval EFI_SUCCESS The handle is valid EFI_HANDLE. **/ @@ -88,8 +89,8 @@ CoreValidateHandle ( Finds the protocol entry for the requested protocol. The gProtocolDatabaseLock must be owned - @param Protocol The ID of the protocol - @param Create Create a new entry if not found + @param Protocol The ID of the protocol + @param Create Create a new entry if not found @return Protocol entry @@ -111,8 +112,8 @@ CoreFindProtocolEntry ( // ProtEntry = NULL; - for (Link = mProtocolDatabase.ForwardLink; - Link != &mProtocolDatabase; + for (Link = mProtocolDatabase.ForwardLink; + Link != &mProtocolDatabase; Link = Link->ForwardLink) { Item = CR(Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE); @@ -128,12 +129,12 @@ CoreFindProtocolEntry ( } // - // If the protocol entry was not found and Create is TRUE, then + // If the protocol entry was not found and Create is TRUE, then // allocate a new entry - // + // if ((ProtEntry == NULL) && Create) { - ProtEntry = CoreAllocateBootServicesPool (sizeof(PROTOCOL_ENTRY)); - + ProtEntry = AllocatePool (sizeof(PROTOCOL_ENTRY)); + if (ProtEntry != NULL) { // // Initialize new protocol entry structure @@ -160,9 +161,9 @@ CoreFindProtocolEntry ( Note: This function doesn't do parameters checking, it's caller's responsibility to pass in valid parameters. - @param Handle The handle to search the protocol on - @param Protocol GUID of the protocol - @param Interface The interface for the protocol being searched + @param Handle The handle to search the protocol on + @param Protocol GUID of the protocol + @param Interface The interface for the protocol being searched @return Protocol instance (NULL: Not found) @@ -212,8 +213,8 @@ CoreFindProtocolInterface ( /** Removes an event from a register protocol notify list on a protocol. - @param Event The event to search for in the protocol - database. + @param Event The event to search for in the protocol + database. @return EFI_SUCCESS if the event was found and removed. @return EFI_NOT_FOUND if the event was not found in the protocl database. @@ -231,14 +232,14 @@ CoreUnregisterProtocolNotifyEvent ( CoreAcquireProtocolLock (); - for ( Link = mProtocolDatabase.ForwardLink; - Link != &mProtocolDatabase; + for ( Link = mProtocolDatabase.ForwardLink; + Link != &mProtocolDatabase; Link = Link->ForwardLink) { ProtEntry = CR(Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE); - for ( NotifyLink = ProtEntry->Notify.ForwardLink; - NotifyLink != &ProtEntry->Notify; + for ( NotifyLink = ProtEntry->Notify.ForwardLink; + NotifyLink != &ProtEntry->Notify; NotifyLink = NotifyLink->ForwardLink) { ProtNotify = CR(NotifyLink, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE); @@ -261,8 +262,8 @@ CoreUnregisterProtocolNotifyEvent ( /** Removes all the events in the protocol database that match Event. - @param Event The event to search for in the protocol - database. + @param Event The event to search for in the protocol + database. @return EFI_SUCCESS when done searching the entire database. @@ -288,12 +289,12 @@ CoreUnregisterProtocolNotify ( Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which Calls the private one which contains a BOOLEAN parameter for notifications - @param UserHandle The handle to install the protocol handler on, - or NULL if a new handle is to be allocated - @param Protocol The protocol to add to the handle - @param InterfaceType Indicates whether Interface is supplied in - native form. - @param Interface The interface for the protocol being added + @param UserHandle The handle to install the protocol handler on, + or NULL if a new handle is to be allocated + @param Protocol The protocol to add to the handle + @param InterfaceType Indicates whether Interface is supplied in + native form. + @param Interface The interface for the protocol being added @return Status code @@ -308,10 +309,10 @@ CoreInstallProtocolInterface ( ) { return CoreInstallProtocolInterfaceNotify ( - UserHandle, - Protocol, - InterfaceType, - Interface, + UserHandle, + Protocol, + InterfaceType, + Interface, TRUE ); } @@ -320,17 +321,17 @@ CoreInstallProtocolInterface ( /** Installs a protocol interface into the boot services environment. - @param UserHandle The handle to install the protocol handler on, - or NULL if a new handle is to be allocated - @param Protocol The protocol to add to the handle - @param InterfaceType Indicates whether Interface is supplied in - native form. - @param Interface The interface for the protocol being added - @param Notify indicates whether notify the notification list - for this protocol - - @retval EFI_INVALID_PARAMETER Invalid parameter - @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate + @param UserHandle The handle to install the protocol handler on, + or NULL if a new handle is to be allocated + @param Protocol The protocol to add to the handle + @param InterfaceType Indicates whether Interface is supplied in + native form. + @param Interface The interface for the protocol being added + @param Notify indicates whether notify the notification list + for this protocol + + @retval EFI_INVALID_PARAMETER Invalid parameter + @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate @retval EFI_SUCCESS Protocol interface successfully installed **/ @@ -364,15 +365,13 @@ CoreInstallProtocolInterfaceNotify ( // // Print debug message // - DEBUG((DEBUG_ERROR | DEBUG_INFO, "InstallProtocolInterface: %g %p\n", Protocol, Interface)); + DEBUG((DEBUG_INFO, "InstallProtocolInterface: %g %p\n", Protocol, Interface)); Status = EFI_OUT_OF_RESOURCES; Prot = NULL; Handle = NULL; - ASSERT (NULL != gDxeCoreBS); - - if (*UserHandle != NULL_HANDLE) { + if (*UserHandle != NULL) { Status = CoreHandleProtocol (*UserHandle, Protocol, (VOID **)&ExistingInterface); if (!EFI_ERROR (Status)) { return EFI_INVALID_PARAMETER; @@ -380,7 +379,7 @@ CoreInstallProtocolInterfaceNotify ( } // - // Lock the protocol database + // Lock the protocol database // CoreAcquireProtocolLock (); @@ -395,7 +394,7 @@ CoreInstallProtocolInterfaceNotify ( // // Allocate a new protocol interface structure // - Prot = CoreAllocateZeroBootServicesPool (sizeof(PROTOCOL_INTERFACE)); + Prot = AllocateZeroPool (sizeof(PROTOCOL_INTERFACE)); if (Prot == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; @@ -406,7 +405,7 @@ CoreInstallProtocolInterfaceNotify ( // Handle = (IHANDLE *)*UserHandle; if (Handle == NULL) { - Handle = CoreAllocateZeroBootServicesPool (sizeof(IHANDLE)); + Handle = AllocateZeroPool (sizeof(IHANDLE)); if (Handle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; @@ -429,7 +428,7 @@ CoreInstallProtocolInterfaceNotify ( // in the system // InsertTailList (&gHandleList, &Handle->AllHandles); - } + } Status = CoreValidateHandle (Handle); if (EFI_ERROR (Status)) { @@ -456,19 +455,19 @@ CoreInstallProtocolInterfaceNotify ( Prot->OpenListCount = 0; // - // Add this protocol interface to the head of the supported + // Add this protocol interface to the head of the supported // protocol list for this handle // InsertHeadList (&Handle->Protocols, &Prot->Link); // - // Add this protocol interface to the tail of the + // Add this protocol interface to the tail of the // protocol entry - // + // InsertTailList (&ProtEntry->Protocols, &Prot->ByProtocol); // - // Notify the notification list for this protocol + // Notify the notification list for this protocol // if (Notify) { CoreNotifyProtocolEntry (ProtEntry); @@ -506,14 +505,15 @@ Done: occures all the protocols added by this function are removed. This is basically a lib function to save space. - @param Handle The handle to install the protocol handlers on, - or NULL if a new handle is to be allocated - @param ... EFI_GUID followed by protocol instance. A NULL - terminates the list. The pairs are the - arguments to InstallProtocolInterface(). All the - protocols are added to Handle. + @param Handle The pointer to a handle to install the new + protocol interfaces on, or a pointer to NULL + if a new handle is to be allocated. + @param ... EFI_GUID followed by protocol instance. A NULL + terminates the list. The pairs are the + arguments to InstallProtocolInterface(). All the + protocols are added to Handle. - @retval EFI_INVALID_PARAMETER Handle is NULL. + @retval EFI_INVALID_PARAMETER Handle is NULL. @retval EFI_SUCCESS Protocol interfaces successfully installed. **/ @@ -533,14 +533,14 @@ CoreInstallMultipleProtocolInterfaces ( EFI_HANDLE OldHandle; EFI_HANDLE DeviceHandle; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - + if (Handle == NULL) { return EFI_INVALID_PARAMETER; } - + + // + // Syncronize with notifcations. // - // Syncronize with notifcations. - // OldTpl = CoreRaiseTpl (TPL_NOTIFY); OldHandle = *Handle; @@ -566,18 +566,19 @@ CoreInstallMultipleProtocolInterfaces ( DeviceHandle = NULL; DevicePath = Interface; Status = CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, &DeviceHandle); - if (!EFI_ERROR (Status) && (DeviceHandle != NULL_HANDLE) && IsDevicePathEnd(DevicePath)) { + if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(DevicePath)) { Status = EFI_ALREADY_STARTED; continue; } } - + // // Install it // Status = CoreInstallProtocolInterface (Handle, Protocol, EFI_NATIVE_INTERFACE, Interface); } - + VA_END (Args); + // // If there was an error, remove all the interfaces that were installed without any errors // @@ -590,7 +591,9 @@ CoreInstallMultipleProtocolInterfaces ( Protocol = VA_ARG (Args, EFI_GUID *); Interface = VA_ARG (Args, VOID *); CoreUninstallProtocolInterface (*Handle, Protocol, Interface); - } + } + VA_END (Args); + *Handle = OldHandle; } @@ -608,11 +611,11 @@ CoreInstallMultipleProtocolInterfaces ( Note: This function doesn't do parameters checking, it's caller's responsibility to pass in valid parameters. - @param UserHandle The handle on which the protocol is installed - @param Prot The protocol to disconnect drivers from + @param UserHandle The handle on which the protocol is installed + @param Prot The protocol to disconnect drivers from - @retval EFI_SUCCESS Drivers using the protocol interface are all - disconnected + @retval EFI_SUCCESS Drivers using the protocol interface are all + disconnected @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers **/ @@ -628,7 +631,7 @@ CoreDisconnectControllersUsingProtocolInterface ( OPEN_PROTOCOL_DATA *OpenData; Status = EFI_SUCCESS; - + // // Attempt to disconnect all drivers from this protocol interface // @@ -638,7 +641,7 @@ CoreDisconnectControllersUsingProtocolInterface ( (Link != &Prot->OpenList) && !ItemFound; Link = Link->ForwardLink ) { OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); - if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) { + if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { ItemFound = TRUE; CoreReleaseProtocolLock (); Status = CoreDisconnectController (UserHandle, OpenData->AgentHandle, NULL); @@ -661,10 +664,10 @@ CoreDisconnectControllersUsingProtocolInterface ( (Link != &Prot->OpenList) && !ItemFound; Link = Link->ForwardLink ) { OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); - if (OpenData->Attributes & - (EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) { + if ((OpenData->Attributes & + (EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) != 0) { ItemFound = TRUE; - RemoveEntryList (&OpenData->Link); + RemoveEntryList (&OpenData->Link); Prot->OpenListCount--; CoreFreePool (OpenData); } @@ -692,11 +695,11 @@ CoreDisconnectControllersUsingProtocolInterface ( If the last protocol interface is remove from the handle, the handle is freed. - @param UserHandle The handle to remove the protocol handler from - @param Protocol The protocol, of protocol:interface, to remove - @param Interface The interface, of protocol:interface, to remove + @param UserHandle The handle to remove the protocol handler from + @param Protocol The protocol, of protocol:interface, to remove + @param Interface The interface, of protocol:interface, to remove - @retval EFI_INVALID_PARAMETER Protocol is NULL. + @retval EFI_INVALID_PARAMETER Protocol is NULL. @retval EFI_SUCCESS Protocol interface successfully uninstalled. **/ @@ -768,7 +771,7 @@ CoreUninstallProtocolInterface ( // gHandleDatabaseKey++; Handle->Key = gHandleDatabaseKey; - + // // Remove the protocol interface from the handle // @@ -791,7 +794,7 @@ CoreUninstallProtocolInterface ( CoreFreePool (Handle); } -Done: +Done: // // Done, unlock the database and return // @@ -807,11 +810,11 @@ Done: This function calls UnisatllProtocolInterface() in a loop. This is basically a lib function to save space. - @param Handle The handle to uninstall the protocol - @param ... EFI_GUID followed by protocol instance. A NULL - terminates the list. The pairs are the - arguments to UninstallProtocolInterface(). All - the protocols are added to Handle. + @param Handle The handle to uninstall the protocol + @param ... EFI_GUID followed by protocol instance. A NULL + terminates the list. The pairs are the + arguments to UninstallProtocolInterface(). All + the protocols are added to Handle. @return Status code @@ -846,6 +849,7 @@ CoreUninstallMultipleProtocolInterfaces ( // Status = CoreUninstallProtocolInterface (Handle, Protocol, Interface); } + VA_END (Args); // // If there was an error, add all the interfaces that were @@ -860,18 +864,19 @@ CoreUninstallMultipleProtocolInterfaces ( Protocol = VA_ARG(Args, EFI_GUID *); Interface = VA_ARG(Args, VOID *); CoreInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface); - } + } + VA_END (Args); } return Status; -} +} /** Locate a certain GUID protocol interface in a Handle's protocols. - @param UserHandle The handle to obtain the protocol interface on - @param Protocol The GUID of the protocol + @param UserHandle The handle to obtain the protocol interface on + @param Protocol The GUID of the protocol @return The requested protocol interface for the handle @@ -892,7 +897,7 @@ CoreGetProtocolInterface ( if (EFI_ERROR (Status)) { return NULL; } - + Handle = (IHANDLE *)UserHandle; // @@ -913,12 +918,16 @@ CoreGetProtocolInterface ( /** Queries a handle to determine if it supports a specified protocol. - @param UserHandle The handle being queried. - @param Protocol The published unique identifier of the protocol. - @param Interface Supplies the address where a pointer to the - corresponding Protocol Interface is returned. + @param UserHandle The handle being queried. + @param Protocol The published unique identifier of the protocol. + @param Interface Supplies the address where a pointer to the + corresponding Protocol Interface is returned. - @return The requested protocol interface for the handle + @retval EFI_SUCCESS The interface information for the specified protocol was returned. + @retval EFI_UNSUPPORTED The device does not support the specified protocol. + @retval EFI_INVALID_PARAMETER Handle is NULL.. + @retval EFI_INVALID_PARAMETER Protocol is NULL. + @retval EFI_INVALID_PARAMETER Interface is NULL. **/ EFI_STATUS @@ -930,11 +939,11 @@ CoreHandleProtocol ( ) { return CoreOpenProtocol ( - UserHandle, - Protocol, - Interface, - gDxeCoreImageHandle, - NULL, + UserHandle, + Protocol, + Interface, + gDxeCoreImageHandle, + NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL ); } @@ -946,18 +955,18 @@ CoreHandleProtocol ( invokes it to obtain the protocol interface. Usage information is registered in the protocol data base. - @param UserHandle The handle to obtain the protocol interface on - @param Protocol The ID of the protocol - @param Interface The location to return the protocol interface - @param ImageHandle The handle of the Image that is opening the - protocol interface specified by Protocol and - Interface. - @param ControllerHandle The controller handle that is requiring this - interface. - @param Attributes The open mode of the protocol interface - specified by Handle and Protocol. - - @retval EFI_INVALID_PARAMETER Protocol is NULL. + @param UserHandle The handle to obtain the protocol interface on + @param Protocol The ID of the protocol + @param Interface The location to return the protocol interface + @param ImageHandle The handle of the Image that is opening the + protocol interface specified by Protocol and + Interface. + @param ControllerHandle The controller handle that is requiring this + interface. + @param Attributes The open mode of the protocol interface + specified by Handle and Protocol. + + @retval EFI_INVALID_PARAMETER Protocol is NULL. @retval EFI_SUCCESS Get the protocol interface. **/ @@ -998,7 +1007,7 @@ CoreOpenProtocol ( *Interface = NULL; } } - + // // Check for invalid UserHandle // @@ -1065,7 +1074,7 @@ CoreOpenProtocol ( // // This is the protocol interface entry for this protocol - // + // if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { *Interface = Prot->Interface; } @@ -1075,17 +1084,17 @@ CoreOpenProtocol ( Exclusive = FALSE; for ( Link = Prot->OpenList.ForwardLink; Link != &Prot->OpenList; Link = Link->ForwardLink) { OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); - ExactMatch = (BOOLEAN)((OpenData->AgentHandle == ImageHandle) && + ExactMatch = (BOOLEAN)((OpenData->AgentHandle == ImageHandle) && (OpenData->Attributes == Attributes) && (OpenData->ControllerHandle == ControllerHandle)); - if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) { + if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { ByDriver = TRUE; if (ExactMatch) { Status = EFI_ALREADY_STARTED; goto Done; } } - if (OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) { + if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) != 0) { Exclusive = TRUE; } else if (ExactMatch) { OpenData->OpenCount++; @@ -1119,7 +1128,7 @@ CoreOpenProtocol ( Disconnect = FALSE; for ( Link = Prot->OpenList.ForwardLink; (Link != &Prot->OpenList) && (!Disconnect); Link = Link->ForwardLink) { OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); - if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) { + if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { Disconnect = TRUE; CoreReleaseProtocolLock (); Status = CoreDisconnectController (UserHandle, OpenData->AgentHandle, NULL); @@ -1131,7 +1140,7 @@ CoreOpenProtocol ( } } } while (Disconnect); - } + } break; case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER : case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL : @@ -1147,7 +1156,7 @@ CoreOpenProtocol ( // // Create new entry // - OpenData = CoreAllocateBootServicesPool (sizeof(OPEN_PROTOCOL_DATA)); + OpenData = AllocatePool (sizeof(OPEN_PROTOCOL_DATA)); if (OpenData == NULL) { Status = EFI_OUT_OF_RESOURCES; } else { @@ -1174,25 +1183,25 @@ Done: /** Closes a protocol on a handle that was opened using OpenProtocol(). - @param UserHandle The handle for the protocol interface that was - previously opened with OpenProtocol(), and is - now being closed. - @param Protocol The published unique identifier of the protocol. - It is the caller's responsibility to pass in a - valid GUID. - @param AgentHandle The handle of the agent that is closing the - protocol interface. - @param ControllerHandle If the agent that opened a protocol is a driver - that follows the EFI Driver Model, then this - parameter is the controller handle that required - the protocol interface. If the agent does not - follow the EFI Driver Model, then this parameter - is optional and may be NULL. - - @retval EFI_SUCCESS The protocol instance was closed. - @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a - valid EFI_HANDLE. - @retval EFI_NOT_FOUND Can not find the specified protocol or + @param UserHandle The handle for the protocol interface that was + previously opened with OpenProtocol(), and is + now being closed. + @param Protocol The published unique identifier of the protocol. + It is the caller's responsibility to pass in a + valid GUID. + @param AgentHandle The handle of the agent that is closing the + protocol interface. + @param ControllerHandle If the agent that opened a protocol is a driver + that follows the EFI Driver Model, then this + parameter is the controller handle that required + the protocol interface. If the agent does not + follow the EFI Driver Model, then this parameter + is optional and may be NULL. + + @retval EFI_SUCCESS The protocol instance was closed. + @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a + valid EFI_HANDLE. + @retval EFI_NOT_FOUND Can not find the specified protocol or AgentHandle. **/ @@ -1202,7 +1211,7 @@ CoreCloseProtocol ( IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, IN EFI_HANDLE AgentHandle, - IN EFI_HANDLE ControllerHandle + IN EFI_HANDLE ControllerHandle ) { EFI_STATUS Status; @@ -1221,7 +1230,7 @@ CoreCloseProtocol ( if (EFI_ERROR (Status)) { return Status; } - if (ControllerHandle != NULL_HANDLE) { + if (ControllerHandle != NULL) { Status = CoreValidateHandle (ControllerHandle); if (EFI_ERROR (Status)) { return Status; @@ -1253,7 +1262,7 @@ CoreCloseProtocol ( OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); Link = Link->ForwardLink; if ((OpenData->AgentHandle == AgentHandle) && (OpenData->ControllerHandle == ControllerHandle)) { - RemoveEntryList (&OpenData->Link); + RemoveEntryList (&OpenData->Link); ProtocolInterface->OpenListCount--; CoreFreePool (OpenData); Status = EFI_SUCCESS; @@ -1274,13 +1283,17 @@ Done: /** Return information about Opened protocols in the system - @param UserHandle The handle to close the protocol interface on - @param Protocol The ID of the protocol - @param EntryBuffer A pointer to a buffer of open protocol - information in the form of - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures. + @param UserHandle The handle to close the protocol interface on + @param Protocol The ID of the protocol + @param EntryBuffer A pointer to a buffer of open protocol information in the + form of EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures. @param EntryCount Number of EntryBuffer entries + @retval EFI_SUCCESS The open protocol information was returned in EntryBuffer, + and the number of entries was returned EntryCount. + @retval EFI_NOT_FOUND Handle does not support the protocol specified by Protocol. + @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate EntryBuffer. + **/ EFI_STATUS EFIAPI @@ -1319,11 +1332,11 @@ CoreOpenProtocolInformation ( // // Count the number of Open Entries // - for ( Link = ProtocolInterface->OpenList.ForwardLink, Count = 0; + for ( Link = ProtocolInterface->OpenList.ForwardLink, Count = 0; (Link != &ProtocolInterface->OpenList) ; Link = Link->ForwardLink ) { Count++; - } + } ASSERT (Count == ProtocolInterface->OpenListCount); @@ -1333,14 +1346,14 @@ CoreOpenProtocolInformation ( Size = Count * sizeof(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY); } - Buffer = CoreAllocateBootServicesPool (Size); + Buffer = AllocatePool (Size); if (Buffer == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } Status = EFI_SUCCESS; - for ( Link = ProtocolInterface->OpenList.ForwardLink, Count = 0; + for ( Link = ProtocolInterface->OpenList.ForwardLink, Count = 0; (Link != &ProtocolInterface->OpenList); Link = Link->ForwardLink, Count++ ) { OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); @@ -1349,14 +1362,14 @@ CoreOpenProtocolInformation ( Buffer[Count].ControllerHandle = OpenData->ControllerHandle; Buffer[Count].Attributes = OpenData->Attributes; Buffer[Count].OpenCount = OpenData->OpenCount; - } + } *EntryBuffer = Buffer; *EntryCount = Count; - + Done: // - // Done. Release the database lock are return + // Done. Release the database lock. // CoreReleaseProtocolLock (); return Status; @@ -1369,22 +1382,22 @@ Done: Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated from pool. - @param UserHandle The handle from which to retrieve the list of - protocol interface GUIDs. - @param ProtocolBuffer A pointer to the list of protocol interface GUID - pointers that are installed on Handle. - @param ProtocolBufferCount A pointer to the number of GUID pointers present - in ProtocolBuffer. - - @retval EFI_SUCCESS The list of protocol interface GUIDs installed - on Handle was returned in ProtocolBuffer. The - number of protocol interface GUIDs was returned - in ProtocolBufferCount. - @retval EFI_INVALID_PARAMETER Handle is NULL. - @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL. - @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL. - @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the + @param UserHandle The handle from which to retrieve the list of + protocol interface GUIDs. + @param ProtocolBuffer A pointer to the list of protocol interface GUID + pointers that are installed on Handle. + @param ProtocolBufferCount A pointer to the number of GUID pointers present + in ProtocolBuffer. + + @retval EFI_SUCCESS The list of protocol interface GUIDs installed + on Handle was returned in ProtocolBuffer. The + number of protocol interface GUIDs was returned + in ProtocolBufferCount. + @retval EFI_INVALID_PARAMETER Handle is NULL. + @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE. + @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL. + @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL. + @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the results. **/ @@ -1423,7 +1436,7 @@ CoreProtocolsPerHandle ( ProtocolCount = 0; CoreAcquireProtocolLock (); - + for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) { ProtocolCount++; } @@ -1436,7 +1449,7 @@ CoreProtocolsPerHandle ( goto Done; } - Buffer = CoreAllocateBootServicesPool (sizeof (EFI_GUID *) * ProtocolCount); + Buffer = AllocatePool (sizeof (EFI_GUID *) * ProtocolCount); if (Buffer == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; @@ -1446,7 +1459,7 @@ CoreProtocolsPerHandle ( *ProtocolBufferCount = ProtocolCount; for ( Link = Handle->Protocols.ForwardLink, ProtocolCount = 0; - Link != &Handle->Protocols; + Link != &Handle->Protocols; Link = Link->ForwardLink, ProtocolCount++) { Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE); Buffer[ProtocolCount] = &(Prot->Protocol->ProtocolID); @@ -1480,7 +1493,7 @@ CoreGetHandleDatabaseKey ( /** Go connect any handles that were created or modified while a image executed. - @param Key The Key to show that the handle has been + @param Key The Key to show that the handle has been created/modified **/ @@ -1507,12 +1520,12 @@ CoreConnectHandlesByKey ( } } - HandleBuffer = CoreAllocateBootServicesPool (Count * sizeof (EFI_HANDLE)); + HandleBuffer = AllocatePool (Count * sizeof (EFI_HANDLE)); if (HandleBuffer == NULL) { CoreReleaseProtocolLock (); return; } - + for (Link = gHandleList.ForwardLink, Count = 0; Link != &gHandleList; Link = Link->ForwardLink) { Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE); if (Handle->Key > Key) { @@ -1531,6 +1544,6 @@ CoreConnectHandlesByKey ( for (Index = 0; Index < Count; Index++) { CoreConnectController (HandleBuffer[Index], NULL, NULL, TRUE); } - + CoreFreePool(HandleBuffer); }