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: 991810 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DwL+QBIP"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42lt2m6nttz9sS3 for ; Thu, 1 Nov 2018 15:46:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5AAE9C222EC; 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-Google-Smtp-Source: AJdET5fBXFLs4cL262IYxERmIe5GMCppYVLJ4H7MlwnLIiIrgCvb3izO4dqqbDQqp8YtLXp0xLhOaw== 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");