From patchwork Wed Jul 17 08:25:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1133193 X-Patchwork-Delegate: xypron.glpk@gmx.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" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UbgsVDsm"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45pVv63llfz9sLt for ; Wed, 17 Jul 2019 18:34:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 44B20C21DB3; Wed, 17 Jul 2019 08:32:32 +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 C5D13C21E0D; Wed, 17 Jul 2019 08:26:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C6408C21E0D; Wed, 17 Jul 2019 08:26:07 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by lists.denx.de (Postfix) with ESMTPS id 45087C21E3E for ; Wed, 17 Jul 2019 08:26:01 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id y15so10474330pfn.5 for ; Wed, 17 Jul 2019 01:26:01 -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=pEXBWRZW2dSb4yMImPK4GILjRnm55slinNQZy0mVYZU=; b=UbgsVDsmglp7vD3UsZMgM2vzLZkJuLJrw2RqCPv0K3uy+NBPbAxdR8Ljz93Wh39Iqf aC23modtWdTUniIJ6BvV19HvHCdtKNm061zLKmhaj/hnDUDwqUjJTQ4AXuj5ui6jhyHY fi75nPoyKxScxSdSzLrC+C7FbvvXOD14puGGEyngN80T+PjA/ryofQuiGbUktAOfUXxs c+TRqjat2hMJukv76BzWwuq4cPfBVgPJH+BunD2t+hJ8iyN3ATvvcNlN16+YX6ho1rp4 LL++wNKNf6Bc0HVyVonWrzFA7DNjh4oCfA3hAFys2rfgO5drIvBNTJGu7HDbK9we4hQS jqLw== 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=pEXBWRZW2dSb4yMImPK4GILjRnm55slinNQZy0mVYZU=; b=UuZMh6rxNMZOfpswQMAyuMs54Zyjii+9NNJJMyebI7Ka9t1vVeUQOMK+XUR+m+c0Cv ttJl9FBMq7mkGsdHydT0foEZ0OyunnIV8hGFI4lRkVluOJE7rtkOsceYXHZoZE5cYYY+ 9XEe3CDABPF51YREPOmKBwsD5CsCfoCmkuLD7AJsE4axRTGNr9Kixm6p5sHSBQQENdcC +S7BEA0q3lxvOTSQ0sflEi1F7ON8QCy/89nP79MhTLkFrQFsJbQg+GF2/OKy1JJhSKhe zHRwZ9KBjSvQ87NgitWyN3io2yyJUatettVnsBU8cfrLvZxipL8+PW67oPBuRtuMVA42 jEYQ== X-Gm-Message-State: APjAAAWRjRSFOuTnO1f1n5NG2+9lWS0HEqsPOtni4MApVNr3yqGAjJ0c o7yClzqNvSf7avnI0RyDfaF2Tg== X-Google-Smtp-Source: APXvYqz+Vpgbll6KDjX7UPNVzXuzM+j022CSEQK8jUm5QuSVFSJMij19HLhM+k/SYdNlNUREooibTg== X-Received: by 2002:a17:90a:1b0c:: with SMTP id q12mr42894796pjq.76.1563351959914; Wed, 17 Jul 2019 01:25:59 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id s20sm26351338pfe.169.2019.07.17.01.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 01:25:59 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de, wd@denx.de Date: Wed, 17 Jul 2019 17:25:23 +0900 Message-Id: <20190717082525.891-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190717082525.891-1-takahiro.akashi@linaro.org> References: <20190717082525.891-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RFC,PATCH v4 14/16] env: fat: support UEFI context 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" With this patch, UEFI will be allowed to save/load variables to fat filesystem. The following configurations should be defined. CONFIG_EFI_ENV_FAT CONFIG_EFI_ENV_FAT_INTERFACE CONFIG_EFI_ENV_FAT_DEVICE_AND_PART CONFIG_EFI_ENV_FAT_FILE Signed-off-by: AKASHI Takahiro --- env/Kconfig | 42 +++++++++++++++++++++++++++++++++++++++++- env/fat.c | 11 ++++++++++- include/environment.h | 4 ++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index b9439171fd56..23e450a3e5bd 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -402,7 +402,7 @@ config ENV_FAT_INTERFACE Define this to a string that is the name of the block device. config ENV_FAT_DEVICE_AND_PART - string "Device and partition for where to store the environemt in FAT" + string "Device and partition for where to store the environment in FAT" depends on ENV_IS_IN_FAT default "0:1" if TI_COMMON_CMD_OPTIONS default "0:auto" if ARCH_ZYNQMP @@ -432,6 +432,46 @@ config ENV_FAT_FILE It's a string of the FAT file name. This file use to store the environment. +config ENV_EFI_FAT + bool "Enable UEFI variable context on a FAT filesystem" + depends on ENV_IS_IN_FAT + depends on EFI_VARIABLE_USE_ENV + help + Enable this option if you want to load/save UEFI variables + from/to fat file system. + +if ENV_EFI_FAT +config ENV_EFI_FAT_INTERFACE + string "UEFI: Name of the block device for the environment" + help + Define this to a string that is the name of the block device. + +config ENV_EFI_FAT_DEVICE_AND_PART + string "UEFI: Device and partition for where to store the environemt in FAT" + help + Define this to a string to specify the partition of the device. It can + be as following: + + "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1) + - "D:P": device D partition P. Error occurs if device D has no + partition table. + - "D:0": device D. + - "D" or "D:": device D partition 1 if device D has partition + table, or the whole device D if has no partition + table. + - "D:auto": first partition in device D with bootable flag set. + If none, first valid partition in device D. If no + partition table then means device D. + +config ENV_EFI_FAT_FILE + string "UEFI: Name of the FAT file to use for the environment" + default "uboot_efi.env" + help + It's a string of the FAT file name. This file use to store the + environment. + +endif + config ENV_EXT4_INTERFACE string "Name of the block device for the environment" depends on ENV_IS_IN_EXT4 diff --git a/env/fat.c b/env/fat.c index e4a672d2730a..963ddaf8e9f6 100644 --- a/env/fat.c +++ b/env/fat.c @@ -30,7 +30,7 @@ # endif #endif -static struct evn_fat_context { +static struct env_fat_context { char *interface; char *dev_and_part; char *file; @@ -43,6 +43,15 @@ static struct evn_fat_context { CONFIG_ENV_FAT_FILE, }, #endif +#if defined(CONFIG_ENV_EFI_FAT_INTERFACE) && \ + defined(CONFIG_ENV_FAT_DEVICE_AND_PART) && \ + defined(CONFIG_ENV_EFI_FAT_FILE) + [ENVCTX_UEFI] = { + CONFIG_ENV_EFI_FAT_INTERFACE, + CONFIG_ENV_EFI_FAT_DEVICE_AND_PART, + CONFIG_ENV_EFI_FAT_FILE, + }, +#endif }; #ifdef CMD_SAVEENV diff --git a/include/environment.h b/include/environment.h index 9fa085a9b728..12b562823eb0 100644 --- a/include/environment.h +++ b/include/environment.h @@ -214,6 +214,10 @@ enum env_operation { enum env_context { ENVCTX_UBOOT, +#ifdef CONFIG_EFI_LOADER + /* Even if !EFI_VARIABLE_USE_ENV, "env -e" should work */ + ENVCTX_UEFI, +#endif ENVCTX_COUNT, };