[{"id":1760943,"web_url":"http://patchwork.ozlabs.org/comment/1760943/","msgid":"<CAPnjgZ1oHMaCeoeTMRPM2w+Ovzk4EOVdK13-iz5qF4FUUJx0kw@mail.gmail.com>","list_archive_url":null,"date":"2017-08-31T12:51:51","subject":"Re: [U-Boot] [PATCH 12/23] efi_loader: implement\n\tOpenProtocolInformation","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"Hi Heinrich,\n\nOn 27 August 2017 at 06:53, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:\n> efi_open_protocol_information provides the agent and controller\n> handles as well as the attributes and open count of an protocol\n> on a handle.\n>\n> Cc: Rob Clark <robdclark@gmail.com>\n> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n> ---\n>  lib/efi_loader/efi_boottime.c | 55 ++++++++++++++++++++++++++++++++++++++++++-\n>  1 file changed, 54 insertions(+), 1 deletion(-)\n\nReviewed-by: Simon Glass <sjg@chromium.org>\n\nI can't help wondering if this would be better as a linked list?\n\n>\n> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\n> index c9aec597a2..23b8894e73 100644\n> --- a/lib/efi_loader/efi_boottime.c\n> +++ b/lib/efi_loader/efi_boottime.c\n> @@ -985,9 +985,62 @@ static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,\n>                         struct efi_open_protocol_info_entry **entry_buffer,\n>                         unsigned long *entry_count)\n>  {\n> +       unsigned long buffer_size;\n> +       unsigned long count;\n> +       struct efi_handler *handler;\n> +       size_t i;\n> +       efi_status_t r;\n> +\n>         EFI_ENTRY(\"%p, %p, %p, %p\", handle, protocol, entry_buffer,\n>                   entry_count);\n> -       return EFI_EXIT(EFI_NOT_FOUND);\n> +\n> +       /* Check parameters */\n> +       if (!handle || !protocol || !entry_buffer) {\n> +               r = EFI_INVALID_PARAMETER;\n> +               goto out;\n> +       }\n> +\n> +       /* Find the protocol */\n> +       r = efi_search_protocol(handle, protocol, &handler);\n> +       if (r != EFI_SUCCESS)\n> +               goto out;\n> +\n> +       *entry_buffer = NULL;\n> +\n> +       /* Count entries */\n> +       count = 0;\n> +       for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) {\n> +               struct efi_open_protocol_info_entry *open_info =\n> +                       &handler->open_info[i];\n> +\n> +               if (open_info->open_count)\n> +                       ++count;\n> +       }\n> +       *entry_count = count;\n> +       if (!count) {\n> +               r = EFI_SUCCESS;\n> +               goto out;\n> +       }\n> +\n> +       /* Copy entries */\n> +       buffer_size = count * sizeof(struct efi_open_protocol_info_entry);\n> +       r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,\n> +                             (void **)entry_buffer);\n> +       if (r != EFI_SUCCESS)\n> +               goto out;\n> +       count = 0;\n> +       for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) {\n> +               struct efi_open_protocol_info_entry *open_info =\n> +                       &handler->open_info[i];\n> +\n> +               if (!open_info->open_count)\n> +                       continue;\n> +               (*entry_buffer)[count] = *open_info;\n> +               ++count;\n> +       }\n> +\n> +out:\n> +       return EFI_EXIT(r);\n>  }\n>\n>  static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,\n> --\n> 2.14.1\n>","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"DNM2UY4B\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"QohjXVpd\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjj7M2sR6z9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 22:56:47 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 06376C21E0C; Thu, 31 Aug 2017 12:54:03 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id C81A3C21D09;\n\tThu, 31 Aug 2017 12:53:10 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 8D29CC21E0A; Thu, 31 Aug 2017 12:52:16 +0000 (UTC)","from mail-qk0-f177.google.com (mail-qk0-f177.google.com\n\t[209.85.220.177])\n\tby lists.denx.de (Postfix) with ESMTPS id 536EAC21E24\n\tfor <u-boot@lists.denx.de>; Thu, 31 Aug 2017 12:52:13 +0000 (UTC)","by mail-qk0-f177.google.com with SMTP id a77so2310721qkb.1\n\tfor <u-boot@lists.denx.de>; Thu, 31 Aug 2017 05:52:13 -0700 (PDT)","by 10.200.28.106 with HTTP; Thu, 31 Aug 2017 05:51:51 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=IajhncWTltiCGygf3P2Mqim99sn7rm3lihYmYHPd60Q=;\n\tb=DNM2UY4Bnhia7YhaGkg5U47JeRHr9Q9+obAEh1HjUdzITY81QATM/s06NEsJTFzCfi\n\tcHznpVghHdFxNVd6p1icLqYwdNWmmLBb2DbnI+i2ZQoSHr5dRGSSWxydL+m52sTbDHQe\n\tjrpRfoohs46deQnTb0lJk8U0TfKJrhjEM9mrLqNb3VkCXPnrFe7AF0HamJ+ly4/6Osue\n\t+hKshidVqPJErwo0HbMv8XKE6kGuat48kvycRr0kV/mSxY1kBE4Tpki3xl/T1hudAcOo\n\tRtWIFNUSrVGW2CVMg3HgSrhK12P/4YKYdMvhZxXYqLoiXJofHmtlm/RgYYxJ1+hA1EtU\n\tUEDA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=IajhncWTltiCGygf3P2Mqim99sn7rm3lihYmYHPd60Q=;\n\tb=QohjXVpd9hnU0lkf6Umb+vpAmp7CK0GkoxN/1ftotoA8lGNW4fS80RjWTx+OBh1zSx\n\tIyLqroGumjiFro/b0EAIRn+R+U+fx+V5zARUf6abbMIOxbK/G2m+ju9pwt6RJO0is7W6\n\t4OQCkJbVoKI6Fal8i21AmGdhGi1LgQ8HY197k="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=IajhncWTltiCGygf3P2Mqim99sn7rm3lihYmYHPd60Q=;\n\tb=N/QkgVu9cSctffrTiDmi04J+LUHXW+7sinbPaZvrIQDzT6Cg8ZYC7G8zcct8g9ElLD\n\t071fmwwqFhFkid1/R+K3oKlSXihCzd30LIdB2tWBvoLe6zsm02P+5xjzm5NMmHdpKckb\n\tfT5qazbKLmAqgp1wnJrqnJLz1L2Fk+WCkGfI6yqD1BNCwkMD5FnCmBmsqGAfr5z5+xrs\n\tsOuDxQmQPVdgWccFuZyQ43kVrPo3xq2j89IlE8y1qWsy2VTvIhZyROIx4pde0jKWlaoG\n\tsvXhBowHiGEx7TvaBF/ozPDB0Fds8CDia6ICsp2hyYa4JWbP1Ov6BXw62vB1K2Totk6i\n\t27Ig==","X-Gm-Message-State":"AHYfb5gGYVzvUBKkT4SFKaR3yieQHSUSSEbqiIWhGBOc+6lhXjsIGBaE\n\tqQrPn5autHTyL2DLDNFirMIxl7PFLptG","X-Google-Smtp-Source":"ADKCNb4ePsrJKjBuQKm9rq+AaoIW+FOjmFOGoJ2OxMpvD721w8DYRygCrYr6Mkm6EeRc8Uiwm6UUuXtQWtcHGckxumc=","X-Received":"by 10.55.207.91 with SMTP id e88mr3784220qkj.38.1504183932079;\n\tThu, 31 Aug 2017 05:52:12 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170826225328.7550-3-xypron.glpk@gmx.de>","References":"<20170826225110.7381-1-xypron.glpk@gmx.de>\n\t<20170826225328.7550-1-xypron.glpk@gmx.de>\n\t<20170826225328.7550-3-xypron.glpk@gmx.de>","From":"Simon Glass <sjg@chromium.org>","Date":"Thu, 31 Aug 2017 20:51:51 +0800","X-Google-Sender-Auth":"Kkau_3UX65NQuwUIb6x4A1uzmG8","Message-ID":"<CAPnjgZ1oHMaCeoeTMRPM2w+Ovzk4EOVdK13-iz5qF4FUUJx0kw@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 12/23] efi_loader: implement\n\tOpenProtocolInformation","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1761216,"web_url":"http://patchwork.ozlabs.org/comment/1761216/","msgid":"<51ba9821-abb1-8266-933c-722badb8f5e6@gmx.de>","list_archive_url":null,"date":"2017-08-31T17:39:11","subject":"Re: [U-Boot] [PATCH 12/23] efi_loader: implement\n\tOpenProtocolInformation","submitter":{"id":61270,"url":"http://patchwork.ozlabs.org/api/people/61270/","name":"Heinrich Schuchardt","email":"xypron.glpk@gmx.de"},"content":"On 08/31/2017 02:51 PM, Simon Glass wrote:\n> Hi Heinrich,\n> \n> On 27 August 2017 at 06:53, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:\n>> efi_open_protocol_information provides the agent and controller\n>> handles as well as the attributes and open count of an protocol\n>> on a handle.\n>>\n>> Cc: Rob Clark <robdclark@gmail.com>\n>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n>> ---\n>>  lib/efi_loader/efi_boottime.c | 55 ++++++++++++++++++++++++++++++++++++++++++-\n>>  1 file changed, 54 insertions(+), 1 deletion(-)\n> \n> Reviewed-by: Simon Glass <sjg@chromium.org>\n> \n> I can't help wondering if this would be better as a linked list?\n\nThis is an API function. The interface of the function has to be kept\nthe way it is.\n\nInternally we could use other storage models.\n\nBest regards\n\nHeinrich\n\n> \n>>\n>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\n>> index c9aec597a2..23b8894e73 100644\n>> --- a/lib/efi_loader/efi_boottime.c\n>> +++ b/lib/efi_loader/efi_boottime.c\n>> @@ -985,9 +985,62 @@ static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,\n>>                         struct efi_open_protocol_info_entry **entry_buffer,\n>>                         unsigned long *entry_count)\n>>  {\n>> +       unsigned long buffer_size;\n>> +       unsigned long count;\n>> +       struct efi_handler *handler;\n>> +       size_t i;\n>> +       efi_status_t r;\n>> +\n>>         EFI_ENTRY(\"%p, %p, %p, %p\", handle, protocol, entry_buffer,\n>>                   entry_count);\n>> -       return EFI_EXIT(EFI_NOT_FOUND);\n>> +\n>> +       /* Check parameters */\n>> +       if (!handle || !protocol || !entry_buffer) {\n>> +               r = EFI_INVALID_PARAMETER;\n>> +               goto out;\n>> +       }\n>> +\n>> +       /* Find the protocol */\n>> +       r = efi_search_protocol(handle, protocol, &handler);\n>> +       if (r != EFI_SUCCESS)\n>> +               goto out;\n>> +\n>> +       *entry_buffer = NULL;\n>> +\n>> +       /* Count entries */\n>> +       count = 0;\n>> +       for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) {\n>> +               struct efi_open_protocol_info_entry *open_info =\n>> +                       &handler->open_info[i];\n>> +\n>> +               if (open_info->open_count)\n>> +                       ++count;\n>> +       }\n>> +       *entry_count = count;\n>> +       if (!count) {\n>> +               r = EFI_SUCCESS;\n>> +               goto out;\n>> +       }\n>> +\n>> +       /* Copy entries */\n>> +       buffer_size = count * sizeof(struct efi_open_protocol_info_entry);\n>> +       r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,\n>> +                             (void **)entry_buffer);\n>> +       if (r != EFI_SUCCESS)\n>> +               goto out;\n>> +       count = 0;\n>> +       for (i = 0; i < ARRAY_SIZE(handler->open_info); ++i) {\n>> +               struct efi_open_protocol_info_entry *open_info =\n>> +                       &handler->open_info[i];\n>> +\n>> +               if (!open_info->open_count)\n>> +                       continue;\n>> +               (*entry_buffer)[count] = *open_info;\n>> +               ++count;\n>> +       }\n>> +\n>> +out:\n>> +       return EFI_EXIT(r);\n>>  }\n>>\n>>  static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,\n>> --\n>> 2.14.1\n>>\n>","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjqQs2Qddz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 03:40:37 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid E4F7CC21E2B; Thu, 31 Aug 2017 17:40:31 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 3DBD2C21D7A;\n\tThu, 31 Aug 2017 17:40:29 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 92439C21D7A; Thu, 31 Aug 2017 17:40:27 +0000 (UTC)","from mout.gmx.net (mout.gmx.net [212.227.15.15])\n\tby lists.denx.de (Postfix) with ESMTPS id 42DA5C21D63\n\tfor <u-boot@lists.denx.de>; Thu, 31 Aug 2017 17:40:27 +0000 (UTC)","from [192.168.123.58] ([84.118.154.110]) by mail.gmx.com (mrgmx002\n\t[212.227.17.190]) with ESMTPSA (Nemesis) id\n\t0M2ts6-1dXbDN2x3m-00sbf7; Thu, 31 Aug 2017 19:39:43 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,\n\tRCVD_IN_MSPIKE_WL autolearn=unavailable\n\tautolearn_force=no version=3.4.0","To":"Simon Glass <sjg@chromium.org>","References":"<20170826225110.7381-1-xypron.glpk@gmx.de>\n\t<20170826225328.7550-1-xypron.glpk@gmx.de>\n\t<20170826225328.7550-3-xypron.glpk@gmx.de>\n\t<CAPnjgZ1oHMaCeoeTMRPM2w+Ovzk4EOVdK13-iz5qF4FUUJx0kw@mail.gmail.com>","From":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Message-ID":"<51ba9821-abb1-8266-933c-722badb8f5e6@gmx.de>","Date":"Thu, 31 Aug 2017 19:39:11 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<CAPnjgZ1oHMaCeoeTMRPM2w+Ovzk4EOVdK13-iz5qF4FUUJx0kw@mail.gmail.com>","Content-Language":"en-US","X-Provags-ID":"V03:K0:0Oxcg1L3gE/nGD2G7Co8QnSWVJlNNaWjy4ZDGy4cckkehUD2Az8\n\tJiH5oR7OvRFDbLZa9zwX/qj2poUcVEEn8VTw3/jz5oOf0cCQapz56KaRVQdPutCQA6wG4qW\n\tdzKhmFmSUInmdSTkMzrRcZgOL7PMyBRavqeUDlHwTYEdNkRtQQYHo82l4154DRvNH7kUoiR\n\tAG64wBCrZkZz7xfYpVK6w==","X-UI-Out-Filterresults":"notjunk:1; V01:K0:q6aFPJWtMnM=:BBIfq3XxEwnwG26DPqWs+9\n\txd4TRjWsGBJk6ss6fSxDWzi1qjlpKi6JEaDeZlUbxvYyMnFX0zcIvh7992/2TPg7otSQDX27G\n\tZ+VOVLr9Qxmy6x7Aoc8mnwZuwIWtr4p3841sg06ExS4dDoogc0fOaFZ/n1DDPP1bXBKpuWOUP\n\t1YS7VNvcLwcAsvrCezQvg2zj+D+TU/A+c0HY1/I0bCgFn3K0sIckJAN0mZ2H4QF12Og4CeLMr\n\tN3rHdLrFB7I5TJDP3iQR+6NaPN7P9v0yKSwyS/qT5h0nib/va1Yc03eJqZJDrmEmfQtkdtcoF\n\t5wymvXOj5SLeAOjeR7lhL9iRPWoO+47DfRWxYV29LwldKCM2IXF1NNNL3gLUt30Cqx0SklRa9\n\tMUCQsAYHN3iPdq1iKZ1B87wPzUOrz/cC5HhVwIJYh9T7LMdfoWldwBcrRxZHU30xVPiT9PEkv\n\tOvTDKYvFR9AFeSBUydVH2M7CS06NR2VhzJ9+WBTUvCryknM6JP5W9qiuSV5kzJSSoEOAOqwqk\n\tNvzs3+40h8aMmFa75CdBmEHmw/QBTNzOV+HRSxTWdKw5VwZ75K7r8NdEoyAnsKMIw7vdi54lo\n\tRjNOHA/TBy/xrDIy4WsvVcACwadJfgRcoeZ+mRVdafUgi4ZFW5PEM//xC3ibEVFbMca27ydiQ\n\tu1cXkDL/SIj2NxAcrwpt8TDXOdoerIJMicNL4X2ZQzCXFzlRRNHWc82DA1xAQ8G73+jUVDNJS\n\tGETc1spYFwxhwzrG6tNd66FpCRDpKgwyRoHwRbUxHcahzOUCUnmQ6YylNrT6QnoagSQH4im7w\n\trHtIMZRkrl9CZ/EsasoVw1EMsRy8v5dIMfVLW2LemgfLj9tBrs=","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 12/23] efi_loader: implement\n\tOpenProtocolInformation","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]