From patchwork Thu Nov 1 04:47:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 149925 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp349035ljp; Wed, 31 Oct 2018 21:46:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5cIYAOL+I+ASXWibMO0w3wrwH9AVipOeWzCip8YXmFBxxVibOBPxR4Z9Pp3Lbp1DxL8OzFF X-Received: by 2002:a17:906:d187:: with SMTP id c7-v6mr3088074ejz.190.1541047601067; Wed, 31 Oct 2018 21:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541047601; cv=none; d=google.com; s=arc-20160816; b=YSV7SgREUY5mUOqB9qKpX2m6LIGXSK8Ph2fQkXr2Hnx9RrALkilCclFieqn4+LXFlt z1KBKQoL9NGWAnN2xN680X+7ViIB47+Za9zv5q8OXPaSdb3FhwYWAsZnEfTL8Mx/baOy OyTTmf7XZqfTkUg3xebsblgDHKCkHvhcdgCP47nH9DTDe3NBwBGqi0KK/CXT9XCYDBrD EQs6nsZf0UjTa4dfdPa5GN5FjTCNVp3f6Jmvc+vd6u4vsoPT82FnYgWfmU2ajvpYg8EM XRHDeU0a9n2QiyViLlewB9466Eru1Oce2sYk//FCPV+AepKrGoPmkKjt3tTTTu3sTRVX AY2w== 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=D/NM0qYPkL9C+m0aAnTDgVpdyy4CeefPsy5y4jV2GFs=; b=ol4QfT4+znA/XFFTeCGyXtxty39AR+RNStqd7eTRbzsF4U+pIscbkQkROzd1LBa+S8 0P4Vs6to9BxKi4GeG+tS+LhvewCxPUb3YdViHaQIL3Htj5dufscL2SVEI+yPexGi4up9 UEybpeJaimGV0X54DmnI9t8qLKSxTbp3HYyo7/nISb+BF2ZCemfbDzOs6BPPf+6cAemB +diVewyWLms3iqC/vwwQjwFdLOvt2thHegzt9nsG9yeVGd3XEFjUBl2VYd4wdDhPUTRC kila1IWJxUGhUgydmMJ9jDSYS7x9RpRjrvAdeON7vxztiBEXLzBuyvaOuQHBRnuQf23p Ky4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DwL+QBIP; 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 q15-v6si293428edj.219.2018.10.31.21.46.40; Wed, 31 Oct 2018 21:46:41 -0700 (PDT) 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=DwL+QBIP; 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 93E68C22325; Thu, 1 Nov 2018 04:46:36 +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 16EA6C22336; Thu, 1 Nov 2018 04:45:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 75386C22309; Thu, 1 Nov 2018 04:45:37 +0000 (UTC) Received: from mail-yw1-f67.google.com (mail-yw1-f67.google.com [209.85.161.67]) by lists.denx.de (Postfix) with ESMTPS id 3D245C22306 for ; Thu, 1 Nov 2018 04:45:24 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id d126-v6so7423511ywa.5 for ; Wed, 31 Oct 2018 21:45:24 -0700 (PDT) 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=1fbi24/Cjq5kp7UDyW5uMCv9Jxb+vGk43p7tkhyscDQ=; b=DwL+QBIPJNdDrjGSr1LK3zBBbqmoVu4cvsTAu9wAnqvbwuBOwO0TBaTzUOdnDwaCuO 1ZkZCY+0/Ckz5UvlMayJCQes7pOdkOe6napgcgNTB1aypsBH36oQV3JHU+IV+Y/W52NC ia26/qJ/M598MZx9cCkf+MhbEtgnVICFYpi2o= 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=1fbi24/Cjq5kp7UDyW5uMCv9Jxb+vGk43p7tkhyscDQ=; b=QLDIYUobqVyo1geX5XdYci8de8wV7Xu9CZq1NSB7udF5KDG2PmyRzqFKwPL497U3m0 IY5jeq96KV3YjUMKE1lnm1eJK4ASiPQ+G4ksLw3Mx6mNVOvaQxBFAr7EV7U+cvJNDbxy Kw2mUtlmam96h2tLEmYi8lKLO2/rNaIupDkKRE6aw7Ho9euevY0CPb77gQ6YyMz6UYf9 FokkGcQR5ErEprocg/1RsHq2qeMdUn8QnOELfGUazzYQYPhwok+V2Tl+Vyvy1CNOno0Z OqFTnb0XJ8yHZXWpALu9/nxcljiAsPowS6it2fnNE7grBXGSUsvU/MjqdMIFPmCiXeLw pZ3g== X-Gm-Message-State: AGRZ1gKRNTUHFofRFBS+8xAC/hfM+m2Oi6MNoRivnEYwJL/ddExfbMen 3s+NWV3uuyX2760wwbDPOS1OOg== X-Received: by 2002:a81:3b53:: with SMTP id i80-v6mr6125500ywa.166.1541047523055; Wed, 31 Oct 2018 21:45:23 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f7-v6sm15910795ywf.108.2018.10.31.21.45.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 21:45:22 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Thu, 1 Nov 2018 13:47:43 +0900 Message-Id: <20181101044746.19977-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181101044746.19977-1-takahiro.akashi@linaro.org> References: <20181101044039.19755-1-takahiro.akashi@linaro.org> <20181101044746.19977-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 ec1b759d810a..c51b83ca4ec7 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -826,6 +826,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");