[PATCH 07/17] bootwrapper: Add dt_set_memory(), to fill in the /memory node.

Scott Wood scottwood at freescale.com
Sat Mar 17 04:28:48 EST 2007


This adds a library function that platforms can call to fill in the
/memory node with the specified start and size.  #address-cells and
#size-cells must be the same, but can be either 1 or 2.

Signed-off-by: Scott Wood <scottwood at freescale.com>
---
 arch/powerpc/boot/devtree.c |   25 +++++++++++++++++++++++++
 arch/powerpc/boot/ops.h     |    2 +-
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index 9fee6fb..258158e 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -205,3 +205,28 @@ int xlate_reg(void *node, int res, unsigned long *addr,
 
 	return 1;
 }
+
+void dt_set_memory(u64 start, u64 size, int ncells)
+{
+	void *devp;
+	u32 mem[4];
+
+	if (ncells < 1 || ncells > 2)
+		return;
+
+	mem[ncells - 1] = (u32)start;
+	mem[ncells*2 - 1] = (u32)size;
+
+	if (ncells == 2) {
+		mem[0] = start >> 32;
+		mem[2] = size >> 32;
+	}
+
+	devp = finddevice("/memory");
+	if (!devp) {
+		devp = create_node(NULL, "memory");
+		setprop_str(devp, "device_type", "memory");
+	}
+
+	setprop(devp, "reg", mem, ncells * 8);
+}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 086f844..1f1cda4 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -80,7 +80,7 @@ int ns16550_console_init(void *devp, struct serial_console_data *scdp);
 void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
 		u32 max_allocs);
 int xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
-
+void dt_set_memory(u64 start, u64 len, int ncells);
 
 static inline void *finddevice(const char *name)
 {
-- 
1.5.0.3




More information about the Linuxppc-dev mailing list