public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Randolph <randolph@andestech.com>
To: <u-boot@lists.denx.de>
Cc: <randolph.sklin@gmail.com>, <dylan@andestech.com>,
	<tim609@andestech.com>,  <peterlin@andestech.com>,
	Randolph <randolph@andestech.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH V2 1/7] spl: riscv: opensbi: change the default os_type as varible
Date: Thu, 12 Oct 2023 14:35:03 +0800	[thread overview]
Message-ID: <20231012063509.2963258-2-randolph@andestech.com> (raw)
In-Reply-To: <20231012063509.2963258-1-randolph@andestech.com>

In order to introduce the Opensbi OS boot mode, the next stage boot
image of OpenSBI should be configurable.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 common/spl/spl_opensbi.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index 0df611623a..6583b31953 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct fw_dynamic_info opensbi_info;
 
-static int spl_opensbi_find_uboot_node(void *blob, int *uboot_node)
+static int spl_opensbi_find_os_node(void *blob, int *uboot_node, int os_type)
 {
 	int fit_images_node, node;
 	const char *fit_os;
@@ -35,7 +35,7 @@ static int spl_opensbi_find_uboot_node(void *blob, int *uboot_node)
 		if (!fit_os)
 			continue;
 
-		if (genimg_get_os_id(fit_os) == IH_OS_U_BOOT) {
+		if (genimg_get_os_id(fit_os) == os_type) {
 			*uboot_node = node;
 			return 0;
 		}
@@ -46,8 +46,9 @@ static int spl_opensbi_find_uboot_node(void *blob, int *uboot_node)
 
 void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
 {
-	int ret, uboot_node;
-	ulong uboot_entry;
+	int ret, os_node;
+	ulong os_entry;
+	int os_type;
 	typedef void __noreturn (*opensbi_entry_t)(ulong hartid, ulong dtb, ulong info);
 	opensbi_entry_t opensbi_entry;
 
@@ -56,22 +57,27 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image)
 		hang();
 	}
 
-	/* Find U-Boot image in /fit-images */
-	ret = spl_opensbi_find_uboot_node(spl_image->fdt_addr, &uboot_node);
+	/*
+	 * Find next os image in /fit-images
+	 * The next os image default is u-boot proper
+	 */
+	os_type = IH_OS_U_BOOT;
+	ret = spl_opensbi_find_os_node(spl_image->fdt_addr, &os_node, os_type);
 	if (ret) {
-		pr_err("Can't find U-Boot node, %d\n", ret);
+		pr_err("Can't find %s node for opensbi, %d\n",
+		       genimg_get_os_name(os_type), ret);
 		hang();
 	}
 
 	/* Get U-Boot entry point */
-	ret = fit_image_get_entry(spl_image->fdt_addr, uboot_node, &uboot_entry);
+	ret = fit_image_get_entry(spl_image->fdt_addr, os_node, &os_entry);
 	if (ret)
-		ret = fit_image_get_load(spl_image->fdt_addr, uboot_node, &uboot_entry);
+		ret = fit_image_get_load(spl_image->fdt_addr, os_node, &os_entry);
 
 	/* Prepare opensbi_info object */
 	opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
 	opensbi_info.version = FW_DYNAMIC_INFO_VERSION;
-	opensbi_info.next_addr = uboot_entry;
+	opensbi_info.next_addr = os_entry;
 	opensbi_info.next_mode = FW_DYNAMIC_INFO_NEXT_MODE_S;
 	opensbi_info.options = CONFIG_SPL_OPENSBI_SCRATCH_OPTIONS;
 	opensbi_info.boot_hart = gd->arch.boot_hart;
-- 
2.34.1


  reply	other threads:[~2023-10-12  6:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12  6:35 [PATCH V2 0/7] riscv: spl: OpenSBI OS boot mode Randolph
2023-10-12  6:35 ` Randolph [this message]
2023-10-12  6:35 ` [PATCH V2 2/7] riscv: kconfig: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol Randolph
2023-10-12 15:28   ` Simon Glass
2023-10-12  6:35 ` [PATCH V2 3/7] riscv: dts: binman: add condition for opensbi os boot Randolph
2023-10-12 15:28   ` Simon Glass
2023-10-12  6:35 ` [PATCH V2 4/7] Makefile: delete file *.itb when make clean Randolph
2023-10-12 15:28   ` Simon Glass
2023-10-12  6:35 ` [PATCH V2 5/7] spl: riscv: add os type for next booting stage Randolph
2023-10-12 15:28   ` Simon Glass
2023-10-12  6:35 ` [PATCH V2 6/7] andes: config: add riscv falcon mode for ae350 platform Randolph
2023-10-17  7:19   ` Leo Liang
2023-10-12  6:35 ` [PATCH V2 7/7] riscv: spl: andes: Move the DTB in front of kernel Randolph
2023-10-17  7:20   ` Leo Liang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231012063509.2963258-2-randolph@andestech.com \
    --to=randolph@andestech.com \
    --cc=dylan@andestech.com \
    --cc=peterlin@andestech.com \
    --cc=randolph.sklin@gmail.com \
    --cc=sjg@chromium.org \
    --cc=tim609@andestech.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox