]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Handle.c
3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Support for Handle lib fucntions.
23 #include "EfiDriverLib.h"
26 EfiLibLocateHandleProtocolByProtocols (
27 IN OUT EFI_HANDLE
* Handle
, OPTIONAL
28 OUT VOID
**Interface
, OPTIONAL
34 Function locates Protocol and/or Handle on which all Protocols specified
35 as a variable list are installed.
36 It supports continued search. The caller must assure that no handles are added
37 or removed while performing continued search, by e.g., rising the TPL and not
38 calling any handle routines. Otherwise the behavior is undefined.
42 Handle - The address of handle to receive the handle on which protocols
43 indicated by the variable list are installed.
44 If points to NULL, all handles are searched. If pointing to a
45 handle returned from previous call, searches starting from next handle.
46 If NULL, the parameter is ignored.
48 Interface - The address of a pointer to a protocol interface that will receive
49 the interface indicated by first variable argument.
50 If NULL, the parameter is ignored.
52 ... - A variable argument list containing protocol GUIDs. Must end with NULL.
56 EFI_SUCCESS - All the protocols where found on same handle.
57 EFI_NOT_FOUND - A Handle with all the protocols installed was not found.
58 Other values as may be returned from LocateHandleBuffer() or HandleProtocol().
65 EFI_GUID
*ProtocolFirst
;
66 EFI_HANDLE
*HandleBuffer
;
67 UINTN NumberOfHandles
;
72 VA_START (args
, Interface
);
73 ProtocolFirst
= VA_ARG (args
, EFI_GUID
*);
76 // Get list of all handles that support the first protocol.
78 Status
= gBS
->LocateHandleBuffer (
85 if (EFI_ERROR (Status
)) {
90 // Check if this is a countinuation of handle searching.
93 if ((Handle
!= NULL
) && (*Handle
!= NULL
)) {
95 // Leave the Idx just beyond the matching handle.
97 for (; Idx
< NumberOfHandles
;) {
98 if (*Handle
== HandleBuffer
[Idx
++]) {
105 // Iterate handles testing for presence of remaining protocols.
107 for (; Idx
< NumberOfHandles
; Idx
++) {
110 // Start with the second protocol, the first one is sure on this handle.
112 VA_START (args
, Interface
);
113 VA_ARG (args
, EFI_GUID
*);
116 // Iterate protocols from the variable list.
120 Protocol
= VA_ARG (args
, EFI_GUID
*);
122 if (Protocol
== NULL
) {
125 // If here, the list was iterated successfully
126 // finding each protocol on a single handle.
129 Status
= EFI_SUCCESS
;
132 // OPTIONAL parameter returning the Handle.
134 if (Handle
!= NULL
) {
135 *Handle
= HandleBuffer
[Idx
];
139 // OPTIONAL parameter returning the first rotocol's Interface.
141 if (Interface
!= NULL
) {
142 Status
= gBS
->HandleProtocol (
152 Status
= gBS
->HandleProtocol (
157 if (EFI_ERROR (Status
)) {
160 // This handle does not have the iterated protocol.
169 // If here, no handle that bears all the protocols was found.
171 Status
= EFI_NOT_FOUND
;
174 gBS
->FreePool (HandleBuffer
);