mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH 3/4] bootm: split split bootm_load_devicetree function
Date: Thu, 31 May 2018 22:48:50 +0200	[thread overview]
Message-ID: <20180531204851.1719-3-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20180531204851.1719-1-o.rempel@pengutronix.de>

In some cases we don't won't to load devicetree some where in free ram
area, it is easier to keep it withing allocated area of barebox
and then give the pointer to the kernel.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 common/bootm.c  | 39 +++++++++++++++++++++++++++++++++------
 include/bootm.h |  1 +
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 5ff6683fe..a9d18fb57 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -320,20 +320,17 @@ static int bootm_open_oftree_uimage(struct image_data *data, size_t *size,
 }
 
 /*
- * bootm_load_devicetree() - load devicetree
+ * bootm_get_devicetree() - get devicetree
  *
  * @data:		image data context
- * @load_address:	The address where the devicetree should be loaded to
  *
- * This loads the devicetree to a RAM location. load_address must be a valid
- * address. The resulting devicetree will be found at data->oftree.
+ * Prepare devicetree for later use by boot handler.
  *
  * Return: 0 on success, negative error code otherwise
  */
-int bootm_load_devicetree(struct image_data *data, unsigned long load_address)
+int bootm_get_devicetree(struct image_data *data)
 {
 	enum filetype type;
-	int fdt_size;
 	struct fdt_header *oftree;
 	int ret;
 
@@ -410,6 +407,36 @@ int bootm_load_devicetree(struct image_data *data, unsigned long load_address)
 	if (!oftree)
 		return -EINVAL;
 
+	data->oftree = oftree;
+
+	return 0;
+}
+
+/*
+ * bootm_load_devicetree() - load devicetree
+ *
+ * @data:		image data context
+ * @load_address:	The address where the devicetree should be loaded to
+ *
+ * This loads the devicetree to a RAM location. load_address must be a valid
+ * address. The resulting devicetree will be found at data->oftree.
+ *
+ * Return: 0 on success, negative error code otherwise
+ */
+
+int bootm_load_devicetree(struct image_data *data, unsigned long load_address)
+{
+	struct fdt_header *oftree;
+	int fdt_size;
+	int ret;
+
+	ret = bootm_get_devicetree(data);
+	if (ret)
+		return ret;
+
+	oftree = data->oftree;
+
+
 	fdt_size = be32_to_cpu(oftree->totalsize);
 
 	data->oftree_res = request_sdram_region("oftree", load_address,
diff --git a/include/bootm.h b/include/bootm.h
index 62951d605..410b42cde 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -126,6 +126,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address);
 bool bootm_has_initrd(struct image_data *data);
 int bootm_load_initrd(struct image_data *data, unsigned long load_address);
 
+int bootm_get_devicetree(struct image_data *data);
 int bootm_load_devicetree(struct image_data *data, unsigned long load_address);
 int bootm_get_os_size(struct image_data *data);
 
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-05-31 20:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 20:48 [PATCH 1/4] filetype: add ELF type Oleksij Rempel
2018-05-31 20:48 ` [PATCH 2/4] add basic ELF parser Oleksij Rempel
2018-06-01  6:49   ` Sascha Hauer
2018-06-01 18:12   ` Sam Ravnborg
2018-05-31 20:48 ` Oleksij Rempel [this message]
2018-05-31 20:48 ` [PATCH 4/4] MIPS: bootm: add ELF handler Oleksij Rempel
2018-06-01  6:54   ` Sascha Hauer

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=20180531204851.1719-3-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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