From patchwork Fri Nov 16 01:18:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 151267 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7716045ljp; Thu, 15 Nov 2018 17:18:18 -0800 (PST) X-Google-Smtp-Source: AJdET5dENClOyMxVrszLzQEzoDZvxAljV13wL/X7eOvDL+TclV9D66lxWxV6G3/DYP92Gz+SjUJi X-Received: by 2002:a50:9a81:: with SMTP id p1-v6mr7873368edb.112.1542331098458; Thu, 15 Nov 2018 17:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542331098; cv=none; d=google.com; s=arc-20160816; b=gTetZnUPg14gSjSaGzHOaRmzcVSo6IkixggCSAL3rD0ZVegSwtgDPw3BRqKKuXkpF5 9lKf9Pi1S2iQO69DIk859I/7CHzcMtjm4Pq9zixTIrTVlcuZBgmmdwmNoWB+CWqb9a5G abCcFgSf0xFgSszc6zav072ekizPKfeF9J7k6yqn9HAc0wOGIISxSn6Yi2EgDPZEo9DH FH9+R/yltHyMvcBphZ/nugeofhpJalg8SamIJ2ShpVcYAFyCP9MqdNzkYcGHA+pRlZPR AwwOqfyMgr+V4Gtl/UQgAwttZiRvwXpkNLeP5q8kzPPN8bRZXbwLWSvqta3jHAyFixHw qq7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature; bh=z4MSvm1IlofzvF91V8cCitds7CkDOtYkFzFQ1kFq4nc=; b=uLwlwTEZNxlXWsx497+iGoqSsVHbZa1fmMxTAUY+bSxLwzBSNc8W767m0yuCRdMwWH 7c9xqOxEqruGGvB36nNz29j4EY1HBveyEmDsa+/QQL0jrLwmqeUhTPi+v1/GDOnlVgwF Jrb5I5PS3pZzhR4+QtXrxevlKno5JyqSCN/iKFvUzeB6Hz7Qd5eb8eQGDLzn7MYcFYw6 JI+UWfG2ZgE5eDZJuYQlFHe3HS2tKJBkGuVe69cqvWIXRXSiGUTdyKd3HZjQbWvJRkBQ GyjQ8k/YbjAJw8GufSBHSrGwEIqcaKxwKreIP5oioCdfuNRLJaiXv3OZ0AKh05VRiGSt jWTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="e1a/83oB"; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id p12si3105532edq.284.2018.11.15.17.18.18; Thu, 15 Nov 2018 17:18:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="e1a/83oB"; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 13012C22246; Fri, 16 Nov 2018 01:17:35 +0000 (UTC) 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_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D9469C22119; Fri, 16 Nov 2018 01:17:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 46ED2C2219A; Fri, 16 Nov 2018 01:16:44 +0000 (UTC) Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by lists.denx.de (Postfix) with ESMTPS id A8807C22250 for ; Fri, 16 Nov 2018 01:16:40 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id p144-v6so9150147yba.11 for ; Thu, 15 Nov 2018 17:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nP4CxEJAZqKPbfjBmwxpDf8OuTqdthiv7R9aNIH5yV0=; b=e1a/83oBE2GD6QnpbAJ6HV2+W2Gsuvcxrg7m3U6h5At3UF00wzuY+ChEapbNN7LIJV B92+qddi4ENjnfIzco0SHY0BoDvmCEHhadP+q5y+brXCREvgzUMI+0kgIaZKF3W2GDKr 2jkrjvejSBa21VREbYk1OVqQxxhNXJKwk4qWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nP4CxEJAZqKPbfjBmwxpDf8OuTqdthiv7R9aNIH5yV0=; b=HfSeMC5OHY3K8HlqzSuCbAlmHLP1VPz8RC0/5qZfjD718H+9wsT3727NhdpRTuIrPy xWkiAfH02lZj+8aCnq/IJ4ZyRUGl2KYEhGlARUaJjRHiyHNyPb1gNoTgw75+gOxagOr/ Zu9fy8btEKWrtETdlo4Df0Uw5zEn8WY+GProojbL6DHY1I/DtZQ9+0fcY3bivtxZMPuO 26ZQ/vxqf5WddujZTxlMO0+3XlcYlGRybgkDK0LZVpCC9wQF9n6ufIb+J7OC88Sga7nU zkAs6LxVU4t83XfL5/xQadknfjqq7JxzzA7TvLFmYuwALD86pRNF989AK9+Mq/nJX+L5 j0bg== X-Gm-Message-State: AGRZ1gLq+6wpO2GPDeCwYUOHovDd5Dv64jd1nq+5uvxgI0C7/t526AUq jhSdlOUP9eAkaU63pqabsNuvcA== X-Received: by 2002:a5b:943:: with SMTP id x3-v6mr8491434ybq.300.1542330999547; Thu, 15 Nov 2018 17:16:39 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id x10-v6sm7772204ywa.94.2018.11.15.17.16.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 17:16:39 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Fri, 16 Nov 2018 10:18:34 +0900 Message-Id: <20181116011837.27542-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181116011837.27542-1-takahiro.akashi@linaro.org> References: <20181116011837.27542-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 3/6] efi: hii: add guid package support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Allow for handling GUID package in HII database protocol. Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 9 ++++++++ lib/efi_loader/efi_hii.c | 48 +++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/include/efi_api.h b/include/efi_api.h index 427bbba59aed..f3a0b4396b5a 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -835,6 +835,15 @@ efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk) (u16_strlen(blk->string_text) + 1) * 2; } +/* + * Guid package + */ +struct efi_hii_guid_package { + struct efi_hii_package_header header; + efi_guid_t guid; + char data[]; +} __packed; + typedef void *efi_hii_handle_t; struct efi_hii_database_protocol { diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index 40034c27473d..036aa8eac956 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -25,6 +25,7 @@ struct efi_hii_packagelist { efi_handle_t driver_handle; u32 max_string_id; struct list_head string_tables; /* list of efi_string_table */ + struct list_head guid_list; /* we could also track fonts, images, etc */ }; @@ -47,6 +48,11 @@ struct efi_string_table { struct efi_string_info *strings; }; +struct efi_guid_data { + struct list_head link; + struct efi_hii_guid_package package; +}; + static void free_strings_table(struct efi_string_table *stbl) { int i; @@ -178,6 +184,35 @@ error: return ret; } +static void remove_guid_package(struct efi_hii_packagelist *hii) +{ + struct efi_guid_data *data; + + while (!list_empty(&hii->guid_list)) { + data = list_first_entry(&hii->guid_list, + struct efi_guid_data, link); + list_del(&data->link); + free(data); + } +} + +static efi_status_t +add_guid_package(struct efi_hii_packagelist *hii, + struct efi_hii_guid_package *package) +{ + struct efi_guid_data *data; + + data = calloc(sizeof(*data), 1); + if (!data) + return EFI_OUT_OF_RESOURCES; + + /* TODO: we don't know any about data field */ + memcpy(&data->package, package, sizeof(*package)); + list_add_tail(&data->link, &hii->guid_list); + + return EFI_SUCCESS; +} + static struct efi_hii_packagelist *new_packagelist(void) { struct efi_hii_packagelist *hii; @@ -186,6 +221,7 @@ static struct efi_hii_packagelist *new_packagelist(void) hii->signature = hii_package_signature; hii->max_string_id = 0; INIT_LIST_HEAD(&hii->string_tables); + INIT_LIST_HEAD(&hii->guid_list); return hii; } @@ -193,6 +229,7 @@ static struct efi_hii_packagelist *new_packagelist(void) static void free_packagelist(struct efi_hii_packagelist *hii) { remove_strings_package(hii); + remove_guid_package(hii); list_del(&hii->link); free(hii); @@ -219,8 +256,8 @@ add_packages(struct efi_hii_packagelist *hii, switch (efi_hii_package_type(package)) { case EFI_HII_PACKAGE_TYPE_GUID: - printf("\tGuid package not supported\n"); - ret = EFI_INVALID_PARAMETER; + ret = add_guid_package(hii, + (struct efi_hii_guid_package *)package); break; case EFI_HII_PACKAGE_FORMS: printf("\tForm package not supported\n"); @@ -355,8 +392,7 @@ update_package_list(const struct efi_hii_database_protocol *this, switch (efi_hii_package_type(package)) { case EFI_HII_PACKAGE_TYPE_GUID: - printf("\tGuid package not supported\n"); - ret = EFI_INVALID_PARAMETER; + remove_guid_package(hii); break; case EFI_HII_PACKAGE_FORMS: printf("\tForm package not supported\n"); @@ -442,8 +478,8 @@ list_package_lists(const struct efi_hii_database_protocol *this, case EFI_HII_PACKAGE_TYPE_ALL: break; case EFI_HII_PACKAGE_TYPE_GUID: - printf("\tGuid package not supported\n"); - ret = EFI_INVALID_PARAMETER; + if (!list_empty(&hii->guid_list)) + break; continue; case EFI_HII_PACKAGE_FORMS: printf("\tForm package not supported\n");