
Hi Heinrich,
On 27 August 2017 at 06:53, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
efi_open_protocol_information provides the agent and controller handles as well as the attributes and open count of an protocol on a handle.
Cc: Rob Clark robdclark@gmail.com Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
lib/efi_loader/efi_boottime.c | 55 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
I can't help wondering if this would be better as a linked list?
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index c9aec597a2..23b8894e73 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -985,9 +985,62 @@ static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle, struct efi_open_protocol_info_entry **entry_buffer, unsigned long *entry_count) {
unsigned long buffer_size;
unsigned long count;
struct efi_handler *handler;
size_t i;
efi_status_t r;
EFI_ENTRY("%p, %p, %p, %p", handle, protocol, entry_buffer, entry_count);
return EFI_EXIT(EFI_NOT_FOUND);
/* Check parameters */
if (!handle || !protocol || !entry_buffer) {
r = EFI_INVALID_PARAMETER;
goto out;
}
/* Find the protocol */
r = efi_search_protocol(handle, protocol, &handler);
if (r != EFI_SUCCESS)
goto out;
*entry_buffer = NULL;
/* Count entries */
count = 0;
for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) {
struct efi_open_protocol_info_entry *open_info =
&handler->open_info[i];
if (open_info->open_count)
++count;
}
*entry_count = count;
if (!count) {
r = EFI_SUCCESS;
goto out;
}
/* Copy entries */
buffer_size = count * sizeof(struct efi_open_protocol_info_entry);
r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
(void **)entry_buffer);
if (r != EFI_SUCCESS)
goto out;
count = 0;
for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) {
struct efi_open_protocol_info_entry *open_info =
&handler->open_info[i];
if (!open_info->open_count)
continue;
(*entry_buffer)[count] = *open_info;
++count;
}
+out:
return EFI_EXIT(r);
}
static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
2.14.1