mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Subject: [PATCH v2 5/8] of: add reserved_mem_read initcall
Date: Tue,  3 Aug 2021 11:44:15 +0200
Message-ID: <20210803094418.475609-6-r.czerwinski@pengutronix.de> (raw)
In-Reply-To: <20210803094418.475609-1-r.czerwinski@pengutronix.de>

Add a reserved_mem_read initcall which parses the reserved-memory
entries and adds barebox of reserve entries. Also remove the OP-TEE size
of reserve entry, since this is now parsed from the DT and does not need
to be statically configured any longer.

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
 drivers/of/Makefile       |  1 +
 drivers/of/reserved-mem.c | 43 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 drivers/of/reserved-mem.c

diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index b6847752d2..b69cb84b99 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_OF_GPIO) += of_gpio.o
 obj-$(CONFIG_OF_PCI) += of_pci.o
 obj-y += partition.o
 obj-y += of_net.o
+obj-$(CONFIG_OFDEVICE) += reserved-mem.o
 obj-$(CONFIG_MTD) += of_mtd.o
 obj-$(CONFIG_OF_BAREBOX_DRIVERS) += barebox.o
 obj-$(CONFIG_OF_OVERLAY) += overlay.o resolver.o of_firmware.o
diff --git a/drivers/of/reserved-mem.c b/drivers/of/reserved-mem.c
new file mode 100644
index 0000000000..8519a7e3dd
--- /dev/null
+++ b/drivers/of/reserved-mem.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2021 Rouven Czerwinski <r.czerwinski@pengutronix.de>, Pengutronix
+
+#define pr_fmt(fmt) "reserved-memory: " fmt
+
+#define DEBUG
+
+#include <common.h>
+#include <init.h>
+#include <of.h>
+#include <of_address.h>
+#include <malloc.h>
+#include <partition.h>
+
+static int reserved_mem_read(void)
+{
+	struct device_node *node, *child;
+	struct resource resource;
+	int flag;
+
+	node = of_find_node_by_path("/reserved-memory");
+	if (!node)
+		return 0;
+
+	for_each_child_of_node(node, child) {
+		flag = OF_RESERVE_ENTRY_FLAG_NO_RESERVE;
+
+		of_address_to_resource(child, 0, &resource);
+
+		pr_err("Res-Mem start: 0x%08x\n", resource.start);
+		pr_err("Res-Mem end: 0x%08x\n", resource.end);
+
+		if (of_find_property(child, "no-map", 0)) {
+			pr_debug("child %p: no-map\n", child);
+			flag |= OF_RESERVE_ENTRY_FLAG_XN;
+		}
+
+		of_add_reserve_entry(resource.start, resource.end, flag);
+	}
+
+	return 0;
+}
+postconsole_initcall(reserved_mem_read);
-- 
2.32.0


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


  parent reply	other threads:[~2021-08-03  9:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03  9:44 [PATCH v2 0/8] XN Support for reserved-memory areas Rouven Czerwinski
2021-08-03  9:44 ` [PATCH v2 1/8] of: reserve: add xn flag mem entries Rouven Czerwinski
2021-08-05 13:54   ` Ahmad Fatoum
2021-08-09 18:26   ` Sascha Hauer
2021-08-03  9:44 ` [PATCH v2 2/8] of: add of_get_reserve_map stub for !CONFIG_OFTREE Rouven Czerwinski
2021-08-05 13:55   ` Ahmad Fatoum
2021-08-03  9:44 ` [PATCH v2 3/8] ARM: mmu: use reserve mem entries to modify maps Rouven Czerwinski
2021-08-05 14:06   ` Ahmad Fatoum
2021-08-09 18:30     ` Sascha Hauer
2021-08-24  7:09       ` Ahmad Fatoum
2021-08-03  9:44 ` [PATCH v2 4/8] of: add flag to not create resmem DT entries Rouven Czerwinski
2021-08-05 14:09   ` Ahmad Fatoum
2021-08-03  9:44 ` Rouven Czerwinski [this message]
2021-08-05 14:14   ` [PATCH v2 5/8] of: add reserved_mem_read initcall Ahmad Fatoum
2021-08-03  9:44 ` [PATCH v2 6/8] pbl: fdt: add support to parse reserved mem Rouven Czerwinski
2021-08-05 14:20   ` Ahmad Fatoum
2021-08-03  9:44 ` [PATCH v2 7/8] ARM: mmu-early: map no-map entries XN & uncached Rouven Czerwinski
2021-08-05 14:24   ` Ahmad Fatoum
2021-08-03  9:44 ` [PATCH v2 8/8] PBL: enable LIBFDT for OP-TEE early loading Rouven Czerwinski
2021-08-05 13:53   ` Ahmad Fatoum
2021-08-24  6:47     ` Rouven Czerwinski

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=20210803094418.475609-6-r.czerwinski@pengutronix.de \
    --to=r.czerwinski@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

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git