From patchwork Fri Dec 14 10:10:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 153799 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1876370ljp; Fri, 14 Dec 2018 02:09:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/VkKvPeZcFwXY8Iot2ui7Wg5mqKS/viLv4yF9Qu1GIrHpBWfe8q2mx6dDvUv41sILa3KQlz X-Received: by 2002:a05:6402:486:: with SMTP id k6mr275680edv.291.1544782172449; Fri, 14 Dec 2018 02:09:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782172; cv=none; d=google.com; s=arc-20160816; b=fJ8F1bE20ErEoRKKlpEJLULvKAXzGNPwEphtFwpyczkjnqmb090sZm1cW18e/YCPQP wBqAD2W+2n3GQf/iCUX5QhwjqJuIq0SVy4vhMFU4XJUEJtyhcLLUSuTCWkmvDqnyFsWn dSRjmuy4VN/IWuVulc4XhtGlx0XVl89lFFCqXenLLSXcu3CawVWZL36SIPChX5iNaeGZ qfVIAmNwF2DX0NnI+fwFbGIa2FDy2r07Xe/HE+bSAKMXzbdhT17maPnDRKW4FKfa82Ax 0vO14s8cAVIcNXSgBsYmDrQA3FM/htyELJt6i6ymtldR/lSHN84so9MlSoi/8x/3txRz xT+Q== 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=cjY343wKnrGClYYDE7jlBaauEMjMO4H25MljvmPc3fY=; b=sSc55UjWhP7ybRVwokQkc84McaeHliso/yJGFAau+TfreK8eoA5DRexEtFQNIetbdL eUJ2H6WF8AQWDO/XqIQ5czNO2q8EToU47aZRnE9PtQN3A05YPn6o/qPrvmKP23g7A2dj 3akGIp9ax7f4QJ+I5FxPvB1xLJHjMjpVA2vMMViyBvLSmY1J2I5y3tjkBEVEguqO6aWW Bom7f7PDbcbKSjIhNKORcJ77KcnSaQ6f4BllJrHOXg+1l/FBkKFNSzSnPiabpMHTDqSC gfK+doymK8hL45HlDtJgoV/TjHUK7nyUssGBdleDKdK0WuUtCta7HFPhYrKp//bwjdeV uO3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TGlCo13I; 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 d12si1211223edh.283.2018.12.14.02.09.32; Fri, 14 Dec 2018 02:09:32 -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=TGlCo13I; 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 F23B4C21F49; Fri, 14 Dec 2018 10:09:06 +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_H3, RCVD_IN_MSPIKE_WL, 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 20316C22795; Fri, 14 Dec 2018 10:08:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 101CDC22767; Fri, 14 Dec 2018 10:07:41 +0000 (UTC) Received: from mail-yw1-f66.google.com (mail-yw1-f66.google.com [209.85.161.66]) by lists.denx.de (Postfix) with ESMTPS id 33103C2212B for ; Fri, 14 Dec 2018 10:07:38 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id i22so2039443ywa.11 for ; Fri, 14 Dec 2018 02:07:38 -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=Q9SgnWgltNdPo94AoskTCX6+em0EdbSNiWitpA5lTMo=; b=TGlCo13I5nBlfJAQRLYzH08TlQjPIAQNL8IHhEn/fCXhw35kASmwqJHr16SsJl5yOE 0uPe3GKbCZNSbNuT+BuxugMX/kYQ9fc0Kf0vJVLqawi7dKPMBEWN1UGdXHClBNj/4wwH FTuj7tr4QIyNQBCrYi86Y/k5ER79ReVG0XYxI= 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=Q9SgnWgltNdPo94AoskTCX6+em0EdbSNiWitpA5lTMo=; b=n9wrI0gfx6gDArJQk+1W5kEYNeyYoSfUI096B18Trd/aQ0lZBYuTiH4vMDXRBnknSi vitPod6uWysRqZZCNVSc7TrbgyApNPmrdL7U1/UXVtc5E8KBus9ECn44uy4ilWiqid6H QEfHxzy5sHy5+lPOPASN5mu5+lJQciJkuTEdx/10rZJkkxDDvzlByMJn22Rgf2+fAx5I jJjwfSrInoWGCtTTEtZUhI1del7WhUn8xViEemKDz8A2N6pAuqTcqD8f5q9gaiRNdt1h fFAtNUuGWojr8uOPUbW1UEU4myqlHXycFUJzVOBagm+t/KchppzpV8/aPxLTazFL1YFx JtgQ== X-Gm-Message-State: AA+aEWY9NwG23M1a6f91537AiAyRKo5pM0Mg3DaP+xDvJqaoKK9NiXgo v5mpujVw7vAGQMnc+K+AtRTV4w== X-Received: by 2002:a0d:e6ca:: with SMTP id p193mr2188884ywe.217.1544782057147; Fri, 14 Dec 2018 02:07:37 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id m126sm1427428ywd.39.2018.12.14.02.07.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:07:36 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Fri, 14 Dec 2018 19:10:40 +0900 Message-Id: <20181214101043.14067-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181214101043.14067-1-takahiro.akashi@linaro.org> References: <20181214101043.14067-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RESEND 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 c9dbd5a6037d..7209f268c78f 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");