[U-Boot] [RFC,PATCH v4 14/16] env: fat: support UEFI context
AKASHI Takahiro
takahiro.akashi at linaro.org
Wed Jul 17 08:25:23 UTC 2019
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 <takahiro.akashi at linaro.org>
---
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,
};
--
2.21.0
More information about the U-Boot
mailing list