From patchwork Mon Jan 21 03:12:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 156142 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5900464jaa; Sun, 20 Jan 2019 19:15:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN4G6BvvOpjEoi1yxBRaH6nI1CTe5X40pJsfZ5HdHaIrC8M5ZTELAzFxNCGg3W1B0+q465El X-Received: by 2002:a17:906:e2c9:: with SMTP id gr9-v6mr23158816ejb.108.1548040507654; Sun, 20 Jan 2019 19:15:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548040507; cv=none; d=google.com; s=arc-20160816; b=vz/itRZxatecsR6e521qXVt0+ob0bS/Pq01h254T2lPxA/rRTZv4E+l2CDwpTufELE aI/wLaqOchQI554FJK8z/Z37mWxK2oCrsaC3vqOXnVmE45FPeYAd2PdGGFTWS5MQqM/a Dx9gqwY+mJhinqdonXx57yZeCzXbidYUPTm7pkvN+3nFJjNyEcTYyy6fWC02J4OF+Rpb Abf8sr7VDq6s/VWi3pWHEThun3/s+E8kCKEycWiyMu6521Zy67RJTvu3FTRRQDGRJR3k Z5KZp78vMf49FB1uQjFAfk67UlcyPhyvjAWn++d7BK8amyWXpoEVb6UrKWC6XIcMr+mb 8Bcw== 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=ppbr+ZwcDMB/ULSp+qLuMUrdX7MGJ+u4biGJxudNpOU=; b=GtlFKkEbBuBEkE/wYId9uy0UOzEa2xpB7YlWUjgxZnyFfF6S3hbnopMwL3nuBXlr64 VeWf0uZq5pGnvh5CyUvCEBfcInW7LlvT1Z2wXPvoEglwSq7jnuE3qs5AMcxF1Y1BNwhq ozeHez1ffmBXH31KjVGN54+34V0CFWC/WogT6WGoWkRJAxAUUN6jtYtzHRuD5U3ABOcQ Kwgb7LzLWj6tCDfC9nJpOf1eYS3VBBSyr+msXuDCQME1CFjZQwWO3ehLdVMiIMQC2PAJ uGigVyLX4HrafTNLCSojxas0ITncj+eRPK+A0IMCSI2RW/Jnx4IZwtlropQ43i6w2VO0 Sj0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dao+W7Hk; 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 f47si3055416edf.53.2019.01.20.19.15.07; Sun, 20 Jan 2019 19:15:07 -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=dao+W7Hk; 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 31D3FC21E36; Mon, 21 Jan 2019 03:14:40 +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_DNSWL_BLOCKED, 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 C9166C21E77; Mon, 21 Jan 2019 03:13:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A0F4AC21E77; Mon, 21 Jan 2019 03:12:59 +0000 (UTC) Received: from mail-yw1-f65.google.com (mail-yw1-f65.google.com [209.85.161.65]) by lists.denx.de (Postfix) with ESMTPS id A4960C21E36 for ; Mon, 21 Jan 2019 03:12:55 +0000 (UTC) Received: by mail-yw1-f65.google.com with SMTP id t13so7507157ywe.13 for ; Sun, 20 Jan 2019 19:12:55 -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=ckEUdn3+CdP+ZhrUQYklgWRmUAX7mXf/s3L2CMPD7xM=; b=dao+W7HkhiuJE8wMmo+S9y2dEpmDrcKwc2tYDZbsi7Y+U3hU+dAbkRMJyCic8IAvDE vWDPZB7dzHt2Xjxb1D6sWItBVjDwVbpO811kbBSIDjD6Oo0lOex1SGfhbVakNCUHt+xg w98URdFnfG6CY1A2ql0pquOGU3fKQXwRsgQn8= 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=ckEUdn3+CdP+ZhrUQYklgWRmUAX7mXf/s3L2CMPD7xM=; b=TBdaqJiLeS2wuLkErs31S3I/Zlj8dAkQ4CknX+iWgE1si8eszXANXfNf+t6l30MSih uiu64AghrjAijT94T+Vtq9zXXQN6mUa2nDBgL7GFdjI9he1c/Ur1z5TkncwdyxG9SB9y vqHNda3wvFciuKWwvoT3mW8yY7K104PTIjPIzv/PyS1mRL8l9/nfkUgK9I3PDKHC13BF 1yBb+RKcjPNtsFpGykaFfF8lNV/63hRxDzbJGugdvJjQBAhe/1gOiOyuEvINQl5esGMS xlhXd6tAhSquVHBYIAePKNe4wkmWN6f8zD8fqjg9DGNF23OeGWvTOKCXizj98YlLa9Ff rDvg== X-Gm-Message-State: AJcUukcXJqEy8IyKbBawtubOf901wPgSDVSV0csiYonwm9suUt2Hmj2S JSrwl2LaDEArkdUBf88Q18k8TQ== X-Received: by 2002:a0d:fd83:: with SMTP id n125mr24515392ywf.193.1548040374607; Sun, 20 Jan 2019 19:12:54 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id k127sm5002695ywa.81.2019.01.20.19.12.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 19:12:54 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Mon, 21 Jan 2019 12:12:58 +0900 Message-Id: <20190121031301.1808-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190121031301.1808-1-takahiro.akashi@linaro.org> References: <20190121031301.1808-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 2/5] 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 67c3753de0b1..b2e77832a756 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -741,6 +741,15 @@ struct efi_hii_package_header { #define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0 #define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF +/* + * HII GUID package + */ +struct efi_hii_guid_package { + struct efi_hii_package_header header; + efi_guid_t guid; + char data[]; +} __packed; + /* * HII string package */ diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index d6dba5719cdb..d7cd0c4f0fc6 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -23,6 +23,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 */ }; @@ -80,6 +81,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; @@ -218,6 +224,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; @@ -225,6 +260,7 @@ static struct efi_hii_packagelist *new_packagelist(void) hii = malloc(sizeof(*hii)); hii->max_string_id = 0; INIT_LIST_HEAD(&hii->string_tables); + INIT_LIST_HEAD(&hii->guid_list); return hii; } @@ -232,6 +268,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); @@ -259,8 +296,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"); @@ -395,8 +432,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"); @@ -482,8 +518,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");