aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-03-20 15:14:59 -0400
committerTom Rini <trini@konsulko.com>2022-03-20 15:14:59 -0400
commit5f68470d69f853b1652ebe93525b60064717fe2e (patch)
tree6e2f61a2ee43a37f1217289c5896ea1067743ffb
parent9776c4e9d00ac49d6388ffe9e084ff03b37ae479 (diff)
parent9c045a49a9c96ffb6e6b43f7e615fc2bd0e2077d (diff)
downloadu-boot-WIP/20Mar2022.zip
u-boot-WIP/20Mar2022.tar.gz
u-boot-WIP/20Mar2022.tar.bz2
Merge tag 'efi-2022-04-rc5' of https://source.denx.de/u-boot/custodians/u-boot-efiWIP/20Mar2022
Pull request for efi-2022-04-rc5 Documentation: * Fix documentation of FIP creation for Amlogic boards * Update Nokia RX-51 QEMU documentation * Add Raspberry Pi documentation UEFI: * Fix booting via short form device paths * Support short form device paths in 'efidebug boot add' * Fix ESP detection for capsule updates * Allow ACPI table usage even if device-tree exists - ignore DT * OP-TEE based GetVariable(): return attributes when buffer too small
-rw-r--r--Makefile4
-rw-r--r--cmd/bootefi.c4
-rw-r--r--cmd/efidebug.c70
-rw-r--r--doc/board/amlogic/beelink-gtking.rst2
-rw-r--r--doc/board/amlogic/beelink-gtkingpro.rst2
-rw-r--r--doc/board/amlogic/index.rst8
-rw-r--r--doc/board/amlogic/jethub-j100.rst2
-rw-r--r--doc/board/amlogic/jethub-j80.rst2
-rw-r--r--doc/board/amlogic/khadas-vim.rst2
-rw-r--r--doc/board/amlogic/khadas-vim2.rst2
-rw-r--r--doc/board/amlogic/khadas-vim3.rst2
-rw-r--r--doc/board/amlogic/khadas-vim3l.rst2
-rw-r--r--doc/board/amlogic/libretech-ac.rst2
-rw-r--r--doc/board/amlogic/libretech-cc.rst2
-rw-r--r--doc/board/amlogic/nanopi-k2.rst2
-rw-r--r--doc/board/amlogic/odroid-c2.rst2
-rw-r--r--doc/board/amlogic/odroid-c4.rst2
-rw-r--r--doc/board/amlogic/odroid-n2.rst2
-rw-r--r--doc/board/amlogic/p200.rst59
-rw-r--r--doc/board/amlogic/p201.rst59
-rw-r--r--doc/board/amlogic/p212.rst2
-rw-r--r--doc/board/amlogic/pre-generated-fip.rst93
-rw-r--r--doc/board/amlogic/radxa-zero.rst2
-rw-r--r--doc/board/amlogic/s400.rst2
-rw-r--r--doc/board/amlogic/sei510.rst2
-rw-r--r--doc/board/amlogic/sei610.rst2
-rw-r--r--doc/board/amlogic/u200.rst2
-rw-r--r--doc/board/amlogic/wetek-core2.rst2
-rw-r--r--doc/board/broadcom/index.rst10
-rw-r--r--doc/board/broadcom/raspberrypi.rst54
-rw-r--r--doc/board/index.rst1
-rw-r--r--doc/board/nokia/rx51.rst57
-rw-r--r--doc/develop/uefi/uefi.rst2
-rw-r--r--include/efi_loader.h12
-rw-r--r--lib/efi_loader/Makefile12
-rw-r--r--lib/efi_loader/dtbdump.c (renamed from lib/efi_selftest/dtbdump.c)0
-rw-r--r--lib/efi_loader/efi_boottime.c22
-rw-r--r--lib/efi_loader/efi_capsule.c13
-rw-r--r--lib/efi_loader/efi_device_path.c138
-rw-r--r--lib/efi_loader/efi_disk.c31
-rw-r--r--lib/efi_loader/efi_variable_tee.c31
-rw-r--r--lib/efi_loader/initrddump.c (renamed from lib/efi_selftest/initrddump.c)2
-rw-r--r--lib/efi_selftest/Makefile12
-rw-r--r--tools/buildman/test.py2
44 files changed, 519 insertions, 219 deletions
diff --git a/Makefile b/Makefile
index 8e2441e..14fd286 100644
--- a/Makefile
+++ b/Makefile
@@ -1080,7 +1080,7 @@ define deprecated
echo >&2 "for $(2)). Please update the board to use"; \
echo >&2 "$(firstword $(1)) before the $(3) release. Failure to"; \
echo >&2 "update by the deadline may result in board removal."; \
- echo >&2 "See doc/driver-model/migration.rst for more info."; \
+ echo >&2 "See doc/develop/driver-model/migration.rst for more info."; \
echo >&2 "===================================================="; \
fi; fi
@@ -1121,7 +1121,7 @@ ifneq ($(CONFIG_DM),y)
@echo >&2 "This board does not use CONFIG_DM. CONFIG_DM will be"
@echo >&2 "compulsory starting with the v2020.01 release."
@echo >&2 "Failure to update may result in board removal."
- @echo >&2 "See doc/driver-model/migration.rst for more info."
+ @echo >&2 "See doc/develop/driver-model/migration.rst for more info."
@echo >&2 "===================================================="
endif
$(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 46eebd5..53d9f0e 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -265,8 +265,8 @@ efi_status_t efi_install_fdt(void *fdt)
*/
#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
if (fdt) {
- log_err("ERROR: can't have ACPI table and device tree.\n");
- return EFI_LOAD_ERROR;
+ log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n");
+ return EFI_SUCCESS;
}
#else
bootm_headers_t img = { 0 };
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 401d13c..51e2850 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -734,20 +734,20 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag,
}
/**
- * create_initrd_dp() - Create a special device for our Boot### option
- *
- * @dev: Device
- * @part: Disk partition
- * @file: Filename
- * Return: Pointer to the device path or ERR_PTR
+ * create_initrd_dp() - create a special device for our Boot### option
*
+ * @dev: device
+ * @part: disk partition
+ * @file: filename
+ * @shortform: create short form device path
+ * Return: pointer to the device path or ERR_PTR
*/
static
struct efi_device_path *create_initrd_dp(const char *dev, const char *part,
- const char *file)
+ const char *file, int shortform)
{
- struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL;
+ struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL, *short_fp = NULL;
struct efi_device_path *initrd_dp = NULL;
efi_status_t ret;
const struct efi_initrd_dp id_dp = {
@@ -771,9 +771,13 @@ struct efi_device_path *create_initrd_dp(const char *dev, const char *part,
printf("Cannot create device path for \"%s %s\"\n", part, file);
goto out;
}
+ if (shortform)
+ short_fp = efi_dp_shorten(tmp_fp);
+ if (!short_fp)
+ short_fp = tmp_fp;
initrd_dp = efi_dp_append((const struct efi_device_path *)&id_dp,
- tmp_fp);
+ short_fp);
out:
efi_free_pool(tmp_dp);
@@ -807,6 +811,7 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
size_t label_len, label_len16;
u16 *label;
struct efi_device_path *device_path = NULL, *file_path = NULL;
+ struct efi_device_path *fp_free = NULL;
struct efi_device_path *final_fp = NULL;
struct efi_device_path *initrd_dp = NULL;
struct efi_load_option lo;
@@ -826,7 +831,18 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
argc--;
argv++; /* 'add' */
for (; argc > 0; argc--, argv++) {
- if (!strcmp(argv[0], "-b")) {
+ int shortform;
+
+ if (*argv[0] != '-' || strlen(argv[0]) != 2) {
+ r = CMD_RET_USAGE;
+ goto out;
+ }
+ shortform = 0;
+ switch (argv[0][1]) {
+ case 'b':
+ shortform = 1;
+ /* fallthrough */
+ case 'B':
if (argc < 5 || lo.label) {
r = CMD_RET_USAGE;
goto out;
@@ -849,24 +865,33 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
/* file path */
ret = efi_dp_from_name(argv[3], argv[4], argv[5],
- &device_path, &file_path);
+ &device_path, &fp_free);
if (ret != EFI_SUCCESS) {
printf("Cannot create device path for \"%s %s\"\n",
argv[3], argv[4]);
r = CMD_RET_FAILURE;
goto out;
}
+ if (shortform)
+ file_path = efi_dp_shorten(fp_free);
+ if (!file_path)
+ file_path = fp_free;
fp_size += efi_dp_size(file_path) +
sizeof(struct efi_device_path);
argc -= 5;
argv += 5;
- } else if (!strcmp(argv[0], "-i")) {
+ break;
+ case 'i':
+ shortform = 1;
+ /* fallthrough */
+ case 'I':
if (argc < 3 || initrd_dp) {
r = CMD_RET_USAGE;
goto out;
}
- initrd_dp = create_initrd_dp(argv[1], argv[2], argv[3]);
+ initrd_dp = create_initrd_dp(argv[1], argv[2], argv[3],
+ shortform);
if (!initrd_dp) {
printf("Cannot add an initrd\n");
r = CMD_RET_FAILURE;
@@ -876,7 +901,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
argv += 3;
fp_size += efi_dp_size(initrd_dp) +
sizeof(struct efi_device_path);
- } else if (!strcmp(argv[0], "-s")) {
+ break;
+ case 's':
if (argc < 1 || lo.optional_data) {
r = CMD_RET_USAGE;
goto out;
@@ -884,7 +910,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
lo.optional_data = (const u8 *)argv[1];
argc -= 1;
argv += 1;
- } else {
+ break;
+ default:
r = CMD_RET_USAGE;
goto out;
}
@@ -927,7 +954,7 @@ out:
efi_free_pool(final_fp);
efi_free_pool(initrd_dp);
efi_free_pool(device_path);
- efi_free_pool(file_path);
+ efi_free_pool(fp_free);
free(lo.label);
return r;
@@ -1571,12 +1598,11 @@ static int do_efidebug(struct cmd_tbl *cmdtp, int flag,
static char efidebug_help_text[] =
" - UEFI Shell-like interface to configure UEFI environment\n"
"\n"
- "efidebug boot add "
- "-b <bootid> <label> <interface> <devnum>[:<part>] <file path> "
- "-i <interface> <devnum>[:<part>] <initrd file path> "
- "-s '<optional data>'\n"
- " - set UEFI BootXXXX variable\n"
- " <load options> will be passed to UEFI application\n"
+ "efidebug boot add - set UEFI BootXXXX variable\n"
+ " -b|-B <bootid> <label> <interface> <devnum>[:<part>] <file path>\n"
+ " -i|-I <interface> <devnum>[:<part>] <initrd file path>\n"
+ " (-b, -i for short form device path)\n"
+ " -s '<optional data>'\n"
"efidebug boot rm <bootid#1> [<bootid#2> [<bootid#3> [...]]]\n"
" - delete UEFI BootXXXX variables\n"
"efidebug boot dump\n"
diff --git a/doc/board/amlogic/beelink-gtking.rst b/doc/board/amlogic/beelink-gtking.rst
index 56ce2cb..2fb50c5 100644
--- a/doc/board/amlogic/beelink-gtking.rst
+++ b/doc/board/amlogic/beelink-gtking.rst
@@ -44,6 +44,8 @@ https://github.com/LibreELEC/amlogic-boot-fip/tree/master/beelink-s922x
NB: Beelink use a common board config for GT-King, GT-King Pro and the
GS-King-X model, hence the "beelink-s922x" name.
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `beelink-s922x`
+
.. code-block:: bash
$ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip
diff --git a/doc/board/amlogic/beelink-gtkingpro.rst b/doc/board/amlogic/beelink-gtkingpro.rst
index d750351..07bb04b 100644
--- a/doc/board/amlogic/beelink-gtkingpro.rst
+++ b/doc/board/amlogic/beelink-gtkingpro.rst
@@ -45,6 +45,8 @@ https://github.com/LibreELEC/amlogic-boot-fip/tree/master/beelink-s922x
NB: Beelink use a common board config for GT-King, GT-King Pro and the
GS-King-X model, hence the "beelink-s922x" name.
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `beelink-s922x`
+
.. code-block:: bash
$ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 189b1ef..9ef1440 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -74,6 +74,14 @@ This matrix concerns the actual source code version.
| PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** |
+-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
+Boot Documentation
+------------------
+
+.. toctree::
+ :maxdepth: 1
+
+ pre-generated-fip
+
Board Documentation
-------------------
diff --git a/doc/board/amlogic/jethub-j100.rst b/doc/board/amlogic/jethub-j100.rst
index 5860278..d54519a 100644
--- a/doc/board/amlogic/jethub-j100.rst
+++ b/doc/board/amlogic/jethub-j100.rst
@@ -37,6 +37,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `jethub-j100`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain binaries
from the git tree published by the board vendor:
diff --git a/doc/board/amlogic/jethub-j80.rst b/doc/board/amlogic/jethub-j80.rst
index 6b7bdc7..f669a01 100644
--- a/doc/board/amlogic/jethub-j80.rst
+++ b/doc/board/amlogic/jethub-j80.rst
@@ -33,6 +33,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `jethub-j80`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain binaries
from the git tree published by the board vendor:
diff --git a/doc/board/amlogic/khadas-vim.rst b/doc/board/amlogic/khadas-vim.rst
index bbb61c2..04025d7 100644
--- a/doc/board/amlogic/khadas-vim.rst
+++ b/doc/board/amlogic/khadas-vim.rst
@@ -30,6 +30,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/khadas-vim2.rst b/doc/board/amlogic/khadas-vim2.rst
index c57d96d..7ac3bdc 100644
--- a/doc/board/amlogic/khadas-vim2.rst
+++ b/doc/board/amlogic/khadas-vim2.rst
@@ -31,6 +31,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim2`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/khadas-vim3.rst b/doc/board/amlogic/khadas-vim3.rst
index 8b7196d..73dc32b 100644
--- a/doc/board/amlogic/khadas-vim3.rst
+++ b/doc/board/amlogic/khadas-vim3.rst
@@ -57,6 +57,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim3`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/khadas-vim3l.rst b/doc/board/amlogic/khadas-vim3l.rst
index aed8955..692ab3d 100644
--- a/doc/board/amlogic/khadas-vim3l.rst
+++ b/doc/board/amlogic/khadas-vim3l.rst
@@ -57,6 +57,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim3l`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/libretech-ac.rst b/doc/board/amlogic/libretech-ac.rst
index 39bae86..7a915f9 100644
--- a/doc/board/amlogic/libretech-ac.rst
+++ b/doc/board/amlogic/libretech-ac.rst
@@ -30,6 +30,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `lafrite`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/libretech-cc.rst b/doc/board/amlogic/libretech-cc.rst
index 94c74c5..596ce45 100644
--- a/doc/board/amlogic/libretech-cc.rst
+++ b/doc/board/amlogic/libretech-cc.rst
@@ -54,6 +54,8 @@ These binaries and the tools required below have been collected and prebuilt
for convenience at <https://github.com/BayLibre/u-boot/releases/>. These
apply to both v1 and v2.
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `lepotato`
+
Download and extract the libretech-cc release from there, and set FIPDIR to
point to the `fip` subdirectory.
diff --git a/doc/board/amlogic/nanopi-k2.rst b/doc/board/amlogic/nanopi-k2.rst
index 1222ee4..76ff874 100644
--- a/doc/board/amlogic/nanopi-k2.rst
+++ b/doc/board/amlogic/nanopi-k2.rst
@@ -30,6 +30,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `nanopi-k2`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/odroid-c2.rst b/doc/board/amlogic/odroid-c2.rst
index 966c18b..8a1be4b 100644
--- a/doc/board/amlogic/odroid-c2.rst
+++ b/doc/board/amlogic/odroid-c2.rst
@@ -30,6 +30,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `odroid-c2`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/odroid-c4.rst b/doc/board/amlogic/odroid-c4.rst
index f66d60a..b512c6a 100644
--- a/doc/board/amlogic/odroid-c4.rst
+++ b/doc/board/amlogic/odroid-c4.rst
@@ -34,6 +34,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `odroid-c4` or `odroid-hc4`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/odroid-n2.rst b/doc/board/amlogic/odroid-n2.rst
index fe63113..7aad36e 100644
--- a/doc/board/amlogic/odroid-n2.rst
+++ b/doc/board/amlogic/odroid-n2.rst
@@ -29,6 +29,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `odroid-n2` or `odroid-n2-plus`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/p200.rst b/doc/board/amlogic/p200.rst
index c3d6441..5e7c6b0 100644
--- a/doc/board/amlogic/p200.rst
+++ b/doc/board/amlogic/p200.rst
@@ -31,6 +31,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `p200`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
@@ -54,44 +56,39 @@ Go back to mainline U-boot source tree then :
$ mkdir fip
- $ cp $FIPDIR/gxl/bl2.bin fip/
- $ cp $FIPDIR/gxl/acs.bin fip/
- $ cp $FIPDIR/gxl/bl21.bin fip/
- $ cp $FIPDIR/gxl/bl30.bin fip/
- $ cp $FIPDIR/gxl/bl301.bin fip/
- $ cp $FIPDIR/gxl/bl31.img fip/
+ $ cp $FIPDIR/gxb/bl2.bin fip/
+ $ cp $FIPDIR/gxb/acs.bin fip/
+ $ cp $FIPDIR/gxb/bl21.bin fip/
+ $ cp $FIPDIR/gxb/bl30.bin fip/
+ $ cp $FIPDIR/gxb/bl301.bin fip/
+ $ cp $FIPDIR/gxb/bl31.img fip/
$ cp u-boot.bin fip/bl33.bin
$ $FIPDIR/blx_fix.sh \
fip/bl30.bin \
- fip/zero_tmp \
- fip/bl30_zero.bin \
- fip/bl301.bin \
- fip/bl301_zero.bin \
- fip/bl30_new.bin \
- bl30
+ fip/zero_tmp \
+ fip/bl30_zero.bin \
+ fip/bl301.bin \
+ fip/bl301_zero.bin \
+ fip/bl30_new.bin \
+ bl30
- $ $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
+ $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
$ $FIPDIR/blx_fix.sh \
- fip/bl2_acs.bin \
- fip/zero_tmp \
- fip/bl2_zero.bin \
- fip/bl21.bin \
- fip/bl21_zero.bin \
- fip/bl2_new.bin \
- bl2
-
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig
- $ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \
- --output fip/u-boot.bin \
- --bl2 fip/bl2.n.bin.sig \
- --bl30 fip/bl30_new.bin.enc \
- --bl31 fip/bl31.img.enc \
- --bl33 fip/bl33.bin.enc
+ fip/bl2_acs.bin \
+ fip/zero_tmp \
+ fip/bl2_zero.bin \
+ fip/bl21.bin \
+ fip/bl21_zero.bin \
+ fip/bl2_new.bin \
+ bl2
+
+ $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin --bl31 fip/bl31.img --bl33 fip/bl33.bin fip/fip.bin
+
+ $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin
+
+ $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig --input fip/boot_new.bin --output fip/u-boot.bin
and then write the image to SD with:
diff --git a/doc/board/amlogic/p201.rst b/doc/board/amlogic/p201.rst
index 06da933..2cd2365 100644
--- a/doc/board/amlogic/p201.rst
+++ b/doc/board/amlogic/p201.rst
@@ -31,6 +31,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `p201`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
@@ -54,44 +56,39 @@ Go back to mainline U-boot source tree then :
$ mkdir fip
- $ cp $FIPDIR/gxl/bl2.bin fip/
- $ cp $FIPDIR/gxl/acs.bin fip/
- $ cp $FIPDIR/gxl/bl21.bin fip/
- $ cp $FIPDIR/gxl/bl30.bin fip/
- $ cp $FIPDIR/gxl/bl301.bin fip/
- $ cp $FIPDIR/gxl/bl31.img fip/
+ $ cp $FIPDIR/gxb/bl2.bin fip/
+ $ cp $FIPDIR/gxb/acs.bin fip/
+ $ cp $FIPDIR/gxb/bl21.bin fip/
+ $ cp $FIPDIR/gxb/bl30.bin fip/
+ $ cp $FIPDIR/gxb/bl301.bin fip/
+ $ cp $FIPDIR/gxb/bl31.img fip/
$ cp u-boot.bin fip/bl33.bin
$ $FIPDIR/blx_fix.sh \
fip/bl30.bin \
- fip/zero_tmp \
- fip/bl30_zero.bin \
- fip/bl301.bin \
- fip/bl301_zero.bin \
- fip/bl30_new.bin \
- bl30
+ fip/zero_tmp \
+ fip/bl30_zero.bin \
+ fip/bl301.bin \
+ fip/bl301_zero.bin \
+ fip/bl30_new.bin \
+ bl30
- $ $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
+ $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
$ $FIPDIR/blx_fix.sh \
- fip/bl2_acs.bin \
- fip/zero_tmp \
- fip/bl2_zero.bin \
- fip/bl21.bin \
- fip/bl21_zero.bin \
- fip/bl2_new.bin \
- bl2
-
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin
- $ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig
- $ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \
- --output fip/u-boot.bin \
- --bl2 fip/bl2.n.bin.sig \
- --bl30 fip/bl30_new.bin.enc \
- --bl31 fip/bl31.img.enc \
- --bl33 fip/bl33.bin.enc
+ fip/bl2_acs.bin \
+ fip/zero_tmp \
+ fip/bl2_zero.bin \
+ fip/bl21.bin \
+ fip/bl21_zero.bin \
+ fip/bl2_new.bin \
+ bl2
+
+ $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin --bl31 fip/bl31.img --bl33 fip/bl33.bin fip/fip.bin
+
+ $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin
+
+ $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig --input fip/boot_new.bin --output fip/u-boot.bin
and then write the image to SD with:
diff --git a/doc/board/amlogic/p212.rst b/doc/board/amlogic/p212.rst
index e2f3fe3..c1b73e8 100644
--- a/doc/board/amlogic/p212.rst
+++ b/doc/board/amlogic/p212.rst
@@ -31,6 +31,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `p212`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/pre-generated-fip.rst b/doc/board/amlogic/pre-generated-fip.rst
new file mode 100644
index 0000000..c63ea61
--- /dev/null
+++ b/doc/board/amlogic/pre-generated-fip.rst
@@ -0,0 +1,93 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Pre-Generated FIP file set
+==========================
+
+The Amlogic ARMv8 based SoCs uses a vendor variant of the Trusted Firmware-A
+boot architecture.
+
+You can find documentation on the Trusted Firmware-A architecture on: https://www.trustedfirmware.org/projects/tf-a/
+
+The Trusted Firmware-A uses the following boot elements (simplified):
+
+- BL1: First boot step, implemented in ROM on Amlogic SoCs
+- BL2: Second boot step, used to initialize the SoC main clocks & DDR interface. The BL21 and ACS board-specific binaries are "inserted" in the BL32 binary before signing/packaging in order to be flashed on the platform.
+- BL30: Amlogic Secure Co-Processor (SCP) firmware used to handle all the system management operations (DVFS, suspend/resume, ...)
+- BL301: Amlogic Secure Co-Processor (SCP) board-specific firmware "plug-in" to handle custom DVFS & suspend-resume parameters
+- BL31: Initializes the interrupt controller and the system management interface (PSCI)
+- BL32 (Optional): Is the Trusted Environment Execution (TEE) Operating System to run secure Trusted Apps, e.g. OP-TEE
+- BL33: Is the last non-secure step, usually U-Boot which loads Linux
+
+Amlogic provides in binary form:
+
+- bl2.bin
+- bl30.bin
+- bl30.bin
+- bl31.img
+- bl32.bin
+
+And for lastest SoCs, Amlogic also provides the DDR drivers used by the BL2 binary.
+
+The licence of these files wasn't clear until recently, the currently Amlogic distribution licence
+is the following:
+
+.. code-block:: C
+
+ // Copyright (C) 2018 Amlogic, Inc. All rights reserved.
+ //
+ // All information contained herein is Amlogic confidential.
+ //
+ // This software is provided to you pursuant to Software License
+ // Agreement (SLA) with Amlogic Inc ("Amlogic"). This software may be
+ // used only in accordance with the terms of this agreement.
+ //
+ // Redistribution and use in source and binary forms, with or without
+ // modification is strictly prohibited without prior written permission
+ // from Amlogic.
+ //
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The following files are generated from the Amlogic U-Boot fork:
+
+- acs.bin: contains the PLL & DDR parameters for the board
+- bl301.bin: contains the DVFS & suspend-resume handling code for the board
+- bl33.bin: U-boot binary image
+
+The acs.bin & bl301.bin uses the U-Boot GPL-2.0+ headers & build systems, thus those
+are considered issued from GPL-2.0+ source code.
+
+The tools used to sign & package those binary files are delivered in binary format
+for Intel x86-64 and Python 2.x only.
+
+A collection of pre-built with the corresponding Amlogic binaries for the common
+commercially available boards were collected in the https://github.com/LibreELEC/amlogic-boot-fip
+repository.
+
+Using this collection for a commercially available board is very easy.
+
+Here considering the Libre Computer AML-S905X-CC, which codename is `lepotato`:
+
+.. code-block:: bash
+
+ $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+ $ cd amlogic-boot-fip
+ $ mkdir my-output-dir
+ $ ./build-fip.sh lepotato /path/to/u-boot/u-boot.bin my-output-dir
+
+and then write the image to SD with:
+
+.. code-block:: bash
+
+ $ DEV=/dev/your_sd_device
+ $ dd if=my-output-dir/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
+ $ dd if=my-output-dir/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444
diff --git a/doc/board/amlogic/radxa-zero.rst b/doc/board/amlogic/radxa-zero.rst
index 423403f..f5611f5 100644
--- a/doc/board/amlogic/radxa-zero.rst
+++ b/doc/board/amlogic/radxa-zero.rst
@@ -34,6 +34,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `radxa-zero`
+
Amlogic does not provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
git trees published by the board vendor:
diff --git a/doc/board/amlogic/s400.rst b/doc/board/amlogic/s400.rst
index 52c7b27..c92817b 100644
--- a/doc/board/amlogic/s400.rst
+++ b/doc/board/amlogic/s400.rst
@@ -31,6 +31,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `s400`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/sei510.rst b/doc/board/amlogic/sei510.rst
index 2d296b1..c55e778 100644
--- a/doc/board/amlogic/sei510.rst
+++ b/doc/board/amlogic/sei510.rst
@@ -27,6 +27,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `sei510`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/sei610.rst b/doc/board/amlogic/sei610.rst
index 9434e6f..2d75449 100644
--- a/doc/board/amlogic/sei610.rst
+++ b/doc/board/amlogic/sei610.rst
@@ -29,6 +29,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `sei610`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/u200.rst b/doc/board/amlogic/u200.rst
index 5aa3936..53213fd 100644
--- a/doc/board/amlogic/u200.rst
+++ b/doc/board/amlogic/u200.rst
@@ -32,6 +32,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `u200`
+
Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor:
diff --git a/doc/board/amlogic/wetek-core2.rst b/doc/board/amlogic/wetek-core2.rst
index 1012079..0147d5f 100644
--- a/doc/board/amlogic/wetek-core2.rst
+++ b/doc/board/amlogic/wetek-core2.rst
@@ -29,6 +29,8 @@ U-Boot compilation
Image creation
--------------
+For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `wetek-core2`
+
Amlogic does not provide sources for the firmware or the tools needed
to create the bootloader image, and WeTek has not publicly shared the
precompiled FIP binaries. However the public Khadas VIM2 sources also
diff --git a/doc/board/broadcom/index.rst b/doc/board/broadcom/index.rst
new file mode 100644
index 0000000..4f0e825
--- /dev/null
+++ b/doc/board/broadcom/index.rst
@@ -0,0 +1,10 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2022 Matthias Brugger <mbrugger@suse.com>
+
+Broadcom
+========
+
+.. toctree::
+ :maxdepth: 2
+
+ raspberrypi
diff --git a/doc/board/broadcom/raspberrypi.rst b/doc/board/broadcom/raspberrypi.rst
new file mode 100644
index 0000000..1d00b38
--- /dev/null
+++ b/doc/board/broadcom/raspberrypi.rst
@@ -0,0 +1,54 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2022 Matthias Brugger <mbrugger@suse.com>
+
+Raspberry Pi
+============
+
+About this
+----------
+
+This document describes the information about Raspberry Pi boards
+and it's usage steps.
+
+Raspberry Pi boards
+-------------------
+
+List of the supported Rasbperry Pi boards and the corresponding defconfig files:
+
+32 bit
+^^^^^^
+
+* rpi_defconfig
+ - Raspberry Pi
+* rpi_0_w_defconfig
+ - Raspberry Pi 1
+ - Raspberry Pi zero
+* rpi_2_defconfig
+ - Raspberry Pi 2
+* rpi_3_32b_defconfig
+ - Raspberry Pi 3b
+* rpi_4_32b_defconfig
+ - Raspberry Pi 4b
+
+64 bit
+^^^^^^
+
+* rpi_3_defconfig
+ - Raspberry Pi 3b
+* rpi_3_b_plus_defconfig
+ - Raspberry Pi 3b+
+* rpi_4_defconfig
+ - Raspberry Pi 4b
+* rpi_arm64_defconfig
+ - Raspberry Pi 3b
+ - Raspberry Pi 3b+
+ - Raspberry Pi 4b
+ - Raspberry Pi 400
+ - Raspberry Pi CM 3
+ - Raspberry Pi CM 3+
+ - Raspberry Pi CM 4
+ - Raspberry Pi zero 2 w
+
+rpi_arm64_defconfig uses the device-tree provided by the firmware instead of
+the embedded one. It allows to use the same U-Boot binary to boot different
+boards.
diff --git a/doc/board/index.rst b/doc/board/index.rst
index be9ba4d..f7bfc44 100644
--- a/doc/board/index.rst
+++ b/doc/board/index.rst
@@ -14,6 +14,7 @@ Board-specific doc
apple/index
armltd/index
atmel/index
+ broadcom/index
congatec/index
coreboot/index
emulation/index
diff --git a/doc/board/nokia/rx51.rst b/doc/board/nokia/rx51.rst
index 941f78e..061fe76 100644
--- a/doc/board/nokia/rx51.rst
+++ b/doc/board/nokia/rx51.rst
@@ -160,3 +160,60 @@ UBIFS support add following lines into file ``configs/nokia_rx51_defconfig``::
CONFIG_CMD_UBIFS=y
CONFIG_MTD_UBI_FASTMAP=y
CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1
+
+Run in QEMU
+-----------
+
+Download and compile Linaro version of qemu which contains ``n900`` qemu
+machine. Source code is available in qemu-linaro git repository and the
+last working version is at commit 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1.
+
+Use following commands to compile ``qemu-system-arm`` binary with ``n900``
+qemu machine support:
+
+.. code-block:: bash
+
+ git clone https://git.linaro.org/qemu/qemu-linaro.git
+ cd qemu-linaro
+ git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1
+ ./configure --enable-system --target-list=arm-softmmu --disable-werror
+ make -j4
+ cd ..
+ ln -s qemu-linaro/arm-softmmu/qemu-system-arm .
+
+Using ``n900`` qemu machine requires proprietary Nokia qemu ``qflasher`` tool
+(in reality it is just generator of qemu MTD images) with first stage images
+(``xloader-qemu.bin`` and ``secondary-qemu.bin``), similar what is required
+on the real HW. License of flasher and images allows non-commercial
+redistribution and it is available at maemo.org website:
+
+.. code-block:: bash
+
+ wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz
+ tar -xf qemu-n900.tar.gz
+
+To generate qemu bootable MTD image ``mtd.img`` from U-Boot binary
+``u-boot.bin`` and unpacked first stage images, run following command:
+
+.. code-block:: bash
+
+ ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd.img
+
+Instead of ``u-boot.bin`` binary it is possible to also used combined
+U-Boot + kernel binary ``combined.bin``.
+
+Finally, to boot ``mtd.img`` with graphics display and keyboard with optional
+serial console on current terminal, run:
+
+.. code-block:: bash
+
+ ./qemu-system-arm -M n900 -mtdblock mtd.img -serial /dev/tty
+
+Additionally it is possible to emulate also eMMC and uSD card by appending
+qemu ``-sd`` arguments:
+
+.. code-block:: bash
+
+ ./qemu-system-arm -M n900 -mtdblock mtd.img -sd emmc.img -sd sd.img -serial /dev/tty
+
+For more examples, look into the ``test/nokia_rx51_test.sh`` CI testing script.
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
index b7bf135..fe337c8 100644
--- a/doc/develop/uefi/uefi.rst
+++ b/doc/develop/uefi/uefi.rst
@@ -105,7 +105,7 @@ The UEFI specification[1] defines a secure way of executing UEFI images
by verifying a signature (or message digest) of image with certificates.
This feature on U-Boot is enabled with::
- CONFIG_UEFI_SECURE_BOOT=y
+ CONFIG_EFI_SECURE_BOOT=y
To make the boot sequence safe, you need to establish a chain of trust;
In UEFI secure boot the chain trust is defined by the following UEFI variables
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 110d8ae..af36639 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -260,6 +260,8 @@ extern const efi_guid_t efi_block_io_guid;
extern const efi_guid_t efi_global_variable_guid;
extern const efi_guid_t efi_guid_console_control;
extern const efi_guid_t efi_guid_device_path;
+/* GUID of the EFI system partition */
+extern const efi_guid_t efi_system_partition_guid;
/* GUID of the EFI_DRIVER_BINDING_PROTOCOL */
extern const efi_guid_t efi_guid_driver_binding_protocol;
/* event group ExitBootServices() invoked */
@@ -539,8 +541,6 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
const char *if_typename, int diskid,
const char *pdevname);
-/* Check if it is EFI system partition */
-bool efi_disk_is_system_part(efi_handle_t handle);
/* Called by bootefi to make GOP (graphical) interface available */
efi_status_t efi_gop_register(void);
/* Called by bootefi to make the network interface available */
@@ -725,12 +725,14 @@ extern void *efi_bounce_buffer;
#define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024)
#endif
-
+/* shorten device path */
+struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp);
struct efi_device_path *efi_dp_next(const struct efi_device_path *dp);
int efi_dp_match(const struct efi_device_path *a,
const struct efi_device_path *b);
-struct efi_object *efi_dp_find_obj(struct efi_device_path *dp,
- struct efi_device_path **rem);
+efi_handle_t efi_dp_find_obj(struct efi_device_path *dp,
+ const efi_guid_t *guid,
+ struct efi_device_path **rem);
/* get size of the first device path instance excluding end node */
efi_uintn_t efi_dp_instance_size(const struct efi_device_path *dp);
/* size of multi-instance device path excluding end node */
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index b2c664d..befed71 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -14,12 +14,24 @@ CFLAGS_efi_boottime.o += \
-DFW_PATCHLEVEL="0x$(PATCHLEVEL)"
CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
+CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding
+CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI)
+CFLAGS_initrddump_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
+CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
always += helloworld.efi
targets += helloworld.o
endif
+ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
+always += dtbdump.efi
+endif
+
+ifdef CONFIG_EFI_LOAD_FILE2_INITRD
+always += initrddump.efi
+endif
+
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
obj-y += efi_boottime.o
diff --git a/lib/efi_selftest/dtbdump.c b/lib/efi_loader/dtbdump.c
index 3ce2a07..3ce2a07 100644
--- a/lib/efi_selftest/dtbdump.c
+++ b/lib/efi_loader/dtbdump.c
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index d0f3e05..5bcb825 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1750,7 +1750,7 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
info->system_table = &systab;
if (device_path) {
- info->device_handle = efi_dp_find_obj(device_path, NULL);
+ info->device_handle = efi_dp_find_obj(device_path, NULL, NULL);
dp = efi_dp_append(device_path, file_path);
if (!dp) {
@@ -1940,7 +1940,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
{
efi_handle_t device;
efi_status_t ret;
- struct efi_device_path *dp;
+ struct efi_device_path *dp, *rem;
struct efi_load_file_protocol *load_file_protocol = NULL;
efi_uintn_t buffer_size;
uint64_t addr, pages;
@@ -1951,18 +1951,18 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
*size = 0;
dp = file_path;
- ret = EFI_CALL(efi_locate_device_path(
- &efi_simple_file_system_protocol_guid, &dp, &device));
+ device = efi_dp_find_obj(dp, NULL, &rem);
+ ret = efi_search_protocol(device, &efi_simple_file_system_protocol_guid,
+ NULL);
if (ret == EFI_SUCCESS)
return efi_load_image_from_file(file_path, buffer, size);
- ret = EFI_CALL(efi_locate_device_path(
- &efi_guid_load_file_protocol, &dp, &device));
+ ret = efi_search_protocol(device, &efi_guid_load_file_protocol, NULL);
if (ret == EFI_SUCCESS) {
guid = &efi_guid_load_file_protocol;
} else if (!boot_policy) {
guid = &efi_guid_load_file2_protocol;
- ret = EFI_CALL(efi_locate_device_path(guid, &dp, &device));
+ ret = efi_search_protocol(device, guid, NULL);
}
if (ret != EFI_SUCCESS)
return EFI_NOT_FOUND;
@@ -1971,9 +1971,9 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
if (ret != EFI_SUCCESS)
return EFI_NOT_FOUND;
buffer_size = 0;
- ret = load_file_protocol->load_file(load_file_protocol, dp,
- boot_policy, &buffer_size,
- NULL);
+ ret = EFI_CALL(load_file_protocol->load_file(
+ load_file_protocol, rem, boot_policy,
+ &buffer_size, NULL));
if (ret != EFI_BUFFER_TOO_SMALL)
goto out;
pages = efi_size_in_pages(buffer_size);
@@ -1984,7 +1984,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
goto out;
}
ret = EFI_CALL(load_file_protocol->load_file(
- load_file_protocol, dp, boot_policy,
+ load_file_protocol, rem, boot_policy,
&buffer_size, (void *)(uintptr_t)addr));
if (ret != EFI_SUCCESS)
efi_free_pages(addr, pages);
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 613b531..f004401 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -669,22 +669,29 @@ static efi_status_t get_dp_device(u16 *boot_var,
/**
* device_is_present_and_system_part - check if a device exists
- * @dp Device path
*
* Check if a device pointed to by the device path, @dp, exists and is
* located in UEFI system partition.
*
+ * @dp device path
* Return: true - yes, false - no
*/
static bool device_is_present_and_system_part(struct efi_device_path *dp)
{
efi_handle_t handle;
+ struct efi_device_path *rem;
- handle = efi_dp_find_obj(dp, NULL);
+ /* Check device exists */
+ handle = efi_dp_find_obj(dp, NULL, NULL);
if (!handle)
return false;
- return efi_disk_is_system_part(handle);
+ /* Check device is on system partition */
+ handle = efi_dp_find_obj(dp, &efi_system_partition_guid, &rem);
+ if (!handle)
+ return false;
+
+ return true;
}
/**
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index dc787b4..0a88029 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -122,20 +122,25 @@ int efi_dp_match(const struct efi_device_path *a,
}
}
-/*
+/**
+ * efi_dp_shorten() - shorten device-path
+ *
* We can have device paths that start with a USB WWID or a USB Class node,
* and a few other cases which don't encode the full device path with bus
* hierarchy:
*
- * - MESSAGING:USB_WWID
- * - MESSAGING:USB_CLASS
- * - MEDIA:FILE_PATH
- * - MEDIA:HARD_DRIVE
- * - MESSAGING:URI
+ * * MESSAGING:USB_WWID
+ * * MESSAGING:USB_CLASS
+ * * MEDIA:FILE_PATH
+ * * MEDIA:HARD_DRIVE
+ * * MESSAGING:URI
*
* See UEFI spec (section 3.1.2, about short-form device-paths)
+ *
+ * @dp: original devie-path
+ * @Return: shortened device-path or NULL
*/
-static struct efi_device_path *shorten_path(struct efi_device_path *dp)
+struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp)
{
while (dp) {
/*
@@ -154,69 +159,90 @@ static struct efi_device_path *shorten_path(struct efi_device_path *dp)
return dp;
}
-static struct efi_object *find_obj(struct efi_device_path *dp, bool short_path,
- struct efi_device_path **rem)
+/**
+ * find_handle() - find handle by device path and installed protocol
+ *
+ * If @rem is provided, the handle with the longest partial match is returned.
+ *
+ * @dp: device path to search
+ * @guid: GUID of protocol that must be installed on path or NULL
+ * @short_path: use short form device path for matching
+ * @rem: pointer to receive remaining device path
+ * Return: matching handle
+ */
+static efi_handle_t find_handle(struct efi_device_path *dp,
+ const efi_guid_t *guid, bool short_path,
+ struct efi_device_path **rem)
{
- struct efi_object *efiobj;
- efi_uintn_t dp_size = efi_dp_instance_size(dp);
+ efi_handle_t handle, best_handle = NULL;
+ efi_uintn_t len, best_len = 0;
+
+ len = efi_dp_instance_size(dp);
- list_for_each_entry(efiobj, &efi_obj_list, link) {
+ list_for_each_entry(handle, &efi_obj_list, link) {
struct efi_handler *handler;
- struct efi_device_path *obj_dp;
+ struct efi_device_path *dp_current;
+ efi_uintn_t len_current;
efi_status_t ret;
- ret = efi_search_protocol(efiobj,
- &efi_guid_device_path, &handler);
+ if (guid) {
+ ret = efi_search_protocol(handle, guid, &handler);
+ if (ret != EFI_SUCCESS)
+ continue;
+ }
+ ret = efi_search_protocol(handle, &efi_guid_device_path,
+ &handler);
if (ret != EFI_SUCCESS)
continue;
- obj_dp = handler->protocol_interface;
-
- do {
- if (efi_dp_match(dp, obj_dp) == 0) {
- if (rem) {
- /*
- * Allow partial matches, but inform
- * the caller.
- */
- *rem = ((void *)dp) +
- efi_dp_instance_size(obj_dp);
- return efiobj;
- } else {
- /* Only return on exact matches */
- if (efi_dp_instance_size(obj_dp) ==
- dp_size)
- return efiobj;
- }
- }
-
- obj_dp = shorten_path(efi_dp_next(obj_dp));
- } while (short_path && obj_dp);
+ dp_current = handler->protocol_interface;
+ if (short_path) {
+ dp_current = efi_dp_shorten(dp_current);
+ if (!dp_current)
+ continue;
+ }
+ len_current = efi_dp_instance_size(dp_current);
+ if (rem) {
+ if (len_current > len)
+ continue;
+ } else {
+ if (len_current != len)
+ continue;
+ }
+ if (memcmp(dp_current, dp, len_current))
+ continue;
+ if (!rem)
+ return handle;
+ if (len_current > best_len) {
+ best_len = len_current;
+ best_handle = handle;
+ *rem = (void*)((u8 *)dp + len_current);
+ }
}
-
- return NULL;
+ return best_handle;
}
-/*
- * Find an efiobj from device-path, if 'rem' is not NULL, returns the
- * remaining part of the device path after the matched object.
+/**
+ * efi_dp_find_obj() - find handle by device path
+ *
+ * If @rem is provided, the handle with the longest partial match is returned.
+ *
+ * @dp: device path to search
+ * @guid: GUID of protocol that must be installed on path or NULL
+ * @rem: pointer to receive remaining device path
+ * Return: matching handle
*/
-struct efi_object *efi_dp_find_obj(struct efi_device_path *dp,
- struct efi_device_path **rem)
+efi_handle_t efi_dp_find_obj(struct efi_device_path *dp,
+ const efi_guid_t *guid,
+ struct efi_device_path **rem)
{
- struct efi_object *efiobj;
-
- /* Search for an exact match first */
- efiobj = find_obj(dp, false, NULL);
-
- /* Then for a fuzzy match */
- if (!efiobj)
- efiobj = find_obj(dp, false, rem);
+ efi_handle_t handle;
- /* And now for a fuzzy short match */
- if (!efiobj)
- efiobj = find_obj(dp, true, rem);
+ handle = find_handle(dp, guid, false, rem);
+ if (!handle)
+ /* Match short form device path */
+ handle = find_handle(dp, guid, true, rem);
- return efiobj;
+ return handle;
}
/*
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 45127d1..c905c12 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -302,7 +302,7 @@ efi_fs_from_path(struct efi_device_path *full_path)
efi_free_pool(file_path);
/* Get the EFI object for the partition */
- efiobj = efi_dp_find_obj(device_path, NULL);
+ efiobj = efi_dp_find_obj(device_path, NULL, NULL);
efi_free_pool(device_path);
if (!efiobj)
return NULL;
@@ -587,32 +587,3 @@ efi_status_t efi_disk_register(void)
return EFI_SUCCESS;
}
-
-/**
- * efi_disk_is_system_part() - check if handle refers to an EFI system partition
- *
- * @handle: handle of partition
- *
- * Return: true if handle refers to an EFI system partition
- */
-bool efi_disk_is_system_part(efi_handle_t handle)
-{
- struct efi_handler *handler;
- struct efi_disk_obj *diskobj;
- struct disk_partition info;
- efi_status_t ret;
- int r;
-
- /* check if this is a block device */
- ret = efi_search_protocol(handle, &efi_block_io_guid, &handler);
- if (ret != EFI_SUCCESS)
- return false;
-
- diskobj = container_of(handle, struct efi_disk_obj, header);
-
- r = part_get_info(diskobj->desc, diskobj->part, &info);
- if (r)
- return false;
-
- return !!(info.bootable & PART_EFI_SYSTEM_PARTITION);
-}
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 58931c4..dfef184 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -368,7 +368,7 @@ efi_status_t efi_get_variable_int(const u16 *variable_name,
efi_uintn_t name_size;
efi_uintn_t tmp_dsize;
u8 *comm_buf = NULL;
- efi_status_t ret;
+ efi_status_t ret, tmp;
if (!variable_name || !vendor || !data_size) {
ret = EFI_INVALID_PARAMETER;
@@ -407,23 +407,32 @@ efi_status_t efi_get_variable_int(const u16 *variable_name,
/* Communicate */
ret = mm_communicate(comm_buf, payload_size);
- if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
- /* Update with reported data size for trimmed case */
- *data_size = var_acc->data_size;
- }
- if (ret != EFI_SUCCESS)
- goto out;
-
- ret = get_property_int(variable_name, name_size, vendor, &var_property);
- if (ret != EFI_SUCCESS)
+ if (ret != EFI_SUCCESS && ret != EFI_BUFFER_TOO_SMALL)
goto out;
+ /* Update with reported data size for trimmed case */
+ *data_size = var_acc->data_size;
+ /*
+ * UEFI > 2.7 needs the attributes set even if the buffer is
+ * smaller
+ */
if (attributes) {
+ tmp = get_property_int(variable_name, name_size, vendor,
+ &var_property);
+ if (tmp != EFI_SUCCESS) {
+ ret = tmp;
+ goto out;
+ }
*attributes = var_acc->attr;
- if (var_property.property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY)
+ if (var_property.property &
+ VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY)
*attributes |= EFI_VARIABLE_READ_ONLY;
}
+ /* return if ret is EFI_BUFFER_TOO_SMALL */
+ if (ret != EFI_SUCCESS)
+ goto out;
+
if (data)
memcpy(data, (u8 *)var_acc->name + var_acc->name_size,
var_acc->data_size);
diff --git a/lib/efi_selftest/initrddump.c b/lib/efi_loader/initrddump.c
index 4648d54..7de43bc 100644
--- a/lib/efi_selftest/initrddump.c
+++ b/lib/efi_loader/initrddump.c
@@ -420,7 +420,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
cout->clear_screen(cout);
cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK);
- print(u"INITRD Dump\r\n========\r\n\r\n");
+ print(u"INITRD Dump\r\n===========\r\n\r\n");
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
for (;;) {
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 9ff6e17..be8040d 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -8,16 +8,12 @@
asflags-y += -DHOST_ARCH="$(HOST_ARCH)"
ccflags-y += -DHOST_ARCH="$(HOST_ARCH)"
-CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_exception.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_exception.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_return.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_return.o := $(CFLAGS_NON_EFI)
-CFLAGS_initrddump_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
obj-y += \
efi_selftest.o \
@@ -83,14 +79,6 @@ efi_selftest_miniapp_exception.efi \
efi_selftest_miniapp_exit.efi \
efi_selftest_miniapp_return.efi
-ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
-always += dtbdump.efi
-endif
-
-ifdef CONFIG_EFI_LOAD_FILE2_INITRD
-always += initrddump.efi
-endif
-
$(obj)/efi_miniapp_file_image_exception.h: $(obj)/efi_selftest_miniapp_exception.efi
$(obj)/../../tools/file2include $(obj)/efi_selftest_miniapp_exception.efi > \
$(obj)/efi_miniapp_file_image_exception.h
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 714bb3e..2728743 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -37,7 +37,7 @@ migration = '''===================== WARNING ======================
This board does not use CONFIG_DM. CONFIG_DM will be
compulsory starting with the v2020.01 release.
Failure to update may result in board removal.
-See doc/driver-model/migration.rst for more info.
+See doc/develop/driver-model/migration.rst for more info.
====================================================
'''