Add arch custom function to get bloblist from boot arguments. Check whether boot arguments aligns with the register conventions defined in FW Handoff spec v0.9. Add bloblist related options into qemu-arm default config. Remove OF_HAS_PRIOR_STAGE and OF_BOARD from qemu-arm config.
Signed-off-by: Raymond Mao <raymond....@linaro.org> --- Changes in v2 - Remove low level code for copying boot arguments. - Refactor board_fdt_blob_setup() and remove direct access of gd->bloblist. Changes in v3 - Optimize board_bloblist_from_boot_arg(). Changes in v4 - Move the function as an Arm-arch library instead of a board-specific one. Changes in V5 - Drop the dependence on OF_BOARD. - Move external declaration to header file. - Adjust the position of BLOBLIST in defconfig file. Changes in V6 - Drop imply OF_HAS_PRIOR_STAGE from qemu-arm. arch/arm/Kconfig | 1 - arch/arm/lib/Makefile | 2 ++ arch/arm/lib/xferlist.c | 27 +++++++++++++++++++++++++++ arch/arm/lib/xferlist.h | 19 +++++++++++++++++++ configs/qemu_arm64_defconfig | 3 +++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 arch/arm/lib/xferlist.c create mode 100644 arch/arm/lib/xferlist.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2d4458b7b5..745b68f20f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1047,7 +1047,6 @@ config ARCH_QEMU imply DM_RNG imply DM_RTC imply RTC_PL031 - imply OF_HAS_PRIOR_STAGE imply VIDEO imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index b1bcd37466..67275fba61 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -85,6 +85,8 @@ obj-y += psci-dt.o obj-$(CONFIG_DEBUG_LL) += debug.o +obj-$(CONFIG_BLOBLIST) += xferlist.o + # For EABI conformant tool chains, provide eabi_compat() ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS))) extra-y += eabi_compat.o diff --git a/arch/arm/lib/xferlist.c b/arch/arm/lib/xferlist.c new file mode 100644 index 0000000000..e9734959dc --- /dev/null +++ b/arch/arm/lib/xferlist.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Linaro Limited + * Author: Raymond Mao <raymond....@linaro.org> + */ +#include <linux/types.h> +#include <errno.h> +#include <bloblist.h> +#include "xferlist.h" + +int xferlist_from_boot_arg(ulong addr, ulong size) +{ + int ret; + + ret = bloblist_check(saved_args[3], size); + if (ret) + return ret; + + /* Check the register conventions */ + ret = bloblist_check_reg_conv(saved_args[0], saved_args[2], + saved_args[1]); + if (!ret) + /* Relocate the bloblist to the fixed address */ + ret = bloblist_reloc((void *)addr, size); + + return ret; +} diff --git a/arch/arm/lib/xferlist.h b/arch/arm/lib/xferlist.h new file mode 100644 index 0000000000..60d79c1a8e --- /dev/null +++ b/arch/arm/lib/xferlist.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */ +/* + * Copyright (C) 2023 Linaro Limited + * Author: Raymond Mao <raymond....@linaro.org> + */ + +#ifndef _XFERLIST_H_ +#define _XFERLIST_H_ + +/* + * Boot parameters saved from start.S + * saved_args[0]: FDT base address + * saved_args[1]: Bloblist signature + * saved_args[2]: must be 0 + * saved_args[3]: Bloblist base address + */ +extern unsigned long saved_args[]; + +#endif /* _XFERLIST_H_ */ diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig index 5100e193be..80a5409c51 100644 --- a/configs/qemu_arm64_defconfig +++ b/configs/qemu_arm64_defconfig @@ -27,6 +27,9 @@ CONFIG_USE_PREBOOT=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_PCI_INIT_R=y +CONFIG_BLOBLIST=y +CONFIG_BLOBLIST_ADDR=0x40004000 +CONFIG_BLOBLIST_SIZE=0x4000 CONFIG_CMD_BOOTZ=y CONFIG_CMD_BOOTEFI_SELFTEST=y CONFIG_CMD_NVEDIT_EFI=y -- 2.25.1