All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
@ 2007-01-29 20:11 ` Scott Wood
  2007-01-29 20:40   ` Scott Wood
  2007-01-30 19:42   ` Segher Boessenkool
  2007-01-29 20:11 ` [PATCH 03/18] bootwrapper: Remove OF-isms Scott Wood
                   ` (15 subsequent siblings)
  16 siblings, 2 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:11 UTC (permalink / raw)
  To: linuxppc-dev

Without -msoft-float, floating point state saving code can be executed
(at least with certain buggy versions of GCC, which don't clear bit 6 of
CR before calling a varargs function with no varargs parameters).

Without the assembler target option, the assembler will use the old
dedicated mftb/mftbu instructions, rather than mfspr.  This causes the
boot to hang on e500, which doesn't have the dedicated instructions.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/Makefile      |   10 +++++++---
 arch/powerpc/boot/Makefile |    6 ++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a00fe72..8e93565 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -69,7 +69,7 @@ CFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc
 CFLAGS-$(CONFIG_PPC32)	:= -Iarch/$(ARCH) -ffixed-r2 -mmultiple
 CPPFLAGS	+= $(CPPFLAGS-y)
 AFLAGS		+= $(AFLAGS-y)
-CFLAGS		+= -msoft-float -pipe $(CFLAGS-y)
+CFLAGS		+= -pipe $(CFLAGS-y)
 CPP		= $(CC) -E $(CFLAGS)
 # Temporary hack until we have migrated to asm-powerpc
 LINUXINCLUDE-$(CONFIG_PPC32)	:= -Iarch/$(ARCH)/include
@@ -116,8 +116,12 @@ cpu-as-$(CONFIG_POWER4)		+= -Wa,-maltive
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
-AFLAGS += $(cpu-as-y)
-CFLAGS += $(cpu-as-y)
+PLATFORM_AFLAGS += $(cpu-as-y)
+PLATFORM_CFLAGS += $(cpu-as-y) -msoft-float
+export PLATFORM_AFLAGS PLATFORM_CFLAGS
+
+AFLAGS += $(PLATFORM_AFLAGS)
+CFLAGS += $(PLATFORM_CFLAGS)
 
 head-y				:= arch/powerpc/kernel/head_32.o
 head-$(CONFIG_PPC64)		:= arch/powerpc/kernel/head_64.o
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 98392fb..df92f06 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -24,8 +24,10 @@ all: $(obj)/zImage
 
 HOSTCC		:= gcc
 BOOTCFLAGS	:= $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \
-		   $(shell $(CROSS32CC) -print-file-name=include) -fPIC
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
+		   $(shell $(CROSS32CC) -print-file-name=include) -fPIC \
+		   $(PLATFORM_CFLAGS) -msoft-float
+BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc \
+		   $(PLATFORM_AFLAGS)
 
 ifeq ($(call cc-option-yn, -fstack-protector),y)
 BOOTCFLAGS	+= -fno-stack-protector
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 03/18] bootwrapper: Remove OF-isms
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
  2007-01-29 20:11 ` [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options Scott Wood
@ 2007-01-29 20:11 ` Scott Wood
  2007-01-29 20:11 ` [PATCH 04/18] bootwrapper: Add ft_root_node() Scott Wood
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:11 UTC (permalink / raw)
  To: linuxppc-dev

Remove some OF-specific assumptions in generic bootwrapper code in
preparation for an old-U-Boot compatibility target.  Up to five parameter
registers can now be passed to platform_init, and only platform code
should interpret them.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/crt0.S |    2 +-
 arch/powerpc/boot/main.c |   35 +++++++++++++++--------------------
 arch/powerpc/boot/of.c   |    9 +++++++--
 arch/powerpc/boot/ops.h  |   12 +++++++++++-
 4 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 70e65b1..fac9d3d 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -59,6 +59,6 @@ _zimage_start:
 	sync
 	isync
 
-	mr	r6,r1
+	mr	r8,r1
 	b	start
 
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 6f6b50d..f60d8cf 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -30,14 +30,9 @@ extern char _initrd_end[];
 extern char _dtb_start[];
 extern char _dtb_end[];
 
-struct addr_range {
-	unsigned long addr;
-	unsigned long size;
-	unsigned long memsize;
-};
 static struct addr_range vmlinux;
 static struct addr_range vmlinuz;
-static struct addr_range initrd;
+struct addr_range initrd;
 
 static unsigned long elfoffset;
 static int is_64bit;
@@ -46,7 +41,7 @@ static int is_64bit;
 static char scratch[46912];
 static char elfheader[256];
 
-typedef void (*kernel_entry_t)(unsigned long, unsigned long, void *);
+typedef void (*kernel_entry_t)(unsigned long, unsigned long, unsigned long);
 
 #undef DEBUG
 
@@ -169,7 +164,7 @@ static int is_elf32(void *hdr)
 	return 1;
 }
 
-static void prep_kernel(unsigned long a1, unsigned long a2)
+static void prep_kernel(void)
 {
 	int len;
 
@@ -210,9 +205,10 @@ static void prep_kernel(unsigned long a1
 	 * First see if we have an image attached to us.  If so
 	 * allocate memory for it and copy it there.
 	 */
-	initrd.size = (unsigned long)(_initrd_end - _initrd_start);
-	initrd.memsize = initrd.size;
-	if (initrd.size > 0) {
+	if (_initrd_end != _initrd_start) {
+		initrd.size = (unsigned long)(_initrd_end - _initrd_start);
+		initrd.memsize = initrd.size;
+
 		printf("Allocating 0x%lx bytes for initrd ...\n\r",
 		       initrd.size);
 		initrd.addr = (unsigned long)malloc((u32)initrd.size);
@@ -228,10 +224,8 @@ static void prep_kernel(unsigned long a1
 			initrd.size);
 		printf("initrd head: 0x%lx\n\r",
 				*((unsigned long *)initrd.addr));
-	} else if (a2 != 0) {
+	} else if (initrd.size != 0) {
 		/* Otherwise, see if yaboot or another loader gave us an initrd */
-		initrd.addr = a1;
-		initrd.memsize = initrd.size = a2;
 		printf("Using loader supplied initrd at 0x%lx (0x%lx bytes)\n\r",
 		       initrd.addr, initrd.size);
 	}
@@ -294,7 +288,8 @@ struct platform_ops platform_ops;
 struct dt_ops dt_ops;
 struct console_ops console_ops;
 
-void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
+void start(unsigned long r3, unsigned long r4, unsigned long r5,
+           unsigned long r6, unsigned long r7, void *sp)
 {
 	kernel_entry_t kentry;
 	char cmdline[COMMAND_LINE_SIZE];
@@ -305,7 +300,7 @@ void start(unsigned long a1, unsigned lo
 	memset(&dt_ops, 0, sizeof(dt_ops));
 	memset(&console_ops, 0, sizeof(console_ops));
 
-	if (platform_init(promptr, _dtb_start, _dtb_end))
+	if (platform_init(r3, r4, r5, r6, r7, _dtb_start, _dtb_end))
 		exit();
 	if (console_ops.open && (console_ops.open() < 0))
 		exit();
@@ -315,7 +310,7 @@ void start(unsigned long a1, unsigned lo
 	printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
 	       _start, sp);
 
-	prep_kernel(a1, a2);
+	prep_kernel();
 
 	/* If cmdline came from zimage wrapper or if we can edit the one
 	 * in the dt, print it out and edit it, if possible.
@@ -335,17 +330,17 @@ void start(unsigned long a1, unsigned lo
 	if (ft_addr)
 		printf(" flat tree at 0x%lx\n\r", ft_addr);
 	else
-		printf(" using OF tree (promptr=%p)\n\r", promptr);
+		printf(" using OF tree (promptr=%p)\n\r", r5);
 
 	if (console_ops.close)
 		console_ops.close();
 
 	kentry = (kernel_entry_t) vmlinux.addr;
 	if (ft_addr)
-		kentry(ft_addr, 0, NULL);
+		kentry(ft_addr, 0, 0);
 	else
 		/* XXX initrd addr/size should be passed in properties */
-		kentry(initrd.addr, initrd.size, promptr);
+		kentry(initrd.addr, initrd.size, r5);
 
 	/* console closed so printf below may not work */
 	printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");
diff --git a/arch/powerpc/boot/of.c b/arch/powerpc/boot/of.c
index 0182f38..f6a696c 100644
--- a/arch/powerpc/boot/of.c
+++ b/arch/powerpc/boot/of.c
@@ -256,7 +256,9 @@ static void of_console_write(char *buf,
 	call_prom("write", 3, 1, of_stdout_handle, buf, len);
 }
 
-int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end)
+int platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+                  unsigned long r6, unsigned long r7,
+                  char *dt_blob_start, char *dt_blob_end)
 {
 	platform_ops.image_hdr = of_image_hdr;
 	platform_ops.malloc = of_try_claim;
@@ -269,6 +271,9 @@ int platform_init(void *promptr, char *d
 	console_ops.open = of_console_open;
 	console_ops.write = of_console_write;
 
-	prom = (int (*)(void *))promptr;
+	initrd.addr = r3;
+	initrd.memsize = initrd.size = r4;
+
+	prom = (int (*)(void *))r5;
 	return 0;
 }
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 4ac7b02..42c723d 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -59,7 +59,9 @@ struct serial_console_data {
 	void		(*close)(void);
 };
 
-int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end);
+int platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+                  unsigned long r6, unsigned long r7,
+                  char *dt_blob_start, char *dt_blob_end);
 int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
 int serial_console_init(void);
 int ns16550_console_init(void *devp, struct serial_console_data *scdp);
@@ -100,4 +102,12 @@ static inline void exit(void)
 	for(;;);
 }
 
+struct addr_range {
+	unsigned long addr;
+	unsigned long size;
+	unsigned long memsize;
+};
+
+extern struct addr_range initrd;
+
 #endif /* _PPC_BOOT_OPS_H_ */
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 04/18] bootwrapper: Add ft_root_node().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
  2007-01-29 20:11 ` [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options Scott Wood
  2007-01-29 20:11 ` [PATCH 03/18] bootwrapper: Remove OF-isms Scott Wood
@ 2007-01-29 20:11 ` Scott Wood
  2007-01-30 19:44   ` Segher Boessenkool
  2007-01-29 20:11 ` [PATCH 05/18] bootwrapper: Rename ft_node_add() to ft_get_phandle() Scott Wood
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:11 UTC (permalink / raw)
  To: linuxppc-dev

Clean up some of the open-coded data structure references by providing a
function to return a pointer to the first node in the tree.  This is only
used in high-level functions trying to access the beginning of the tree,
not in low-level code that is actually manipulating the data structure.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index c76c194..02823a8 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -29,6 +29,11 @@
 
 #define _ALIGN(x, al)	(((x) + (al) - 1) & ~((al) - 1))
 
+static char *ft_root_node(struct ft_cxt *cxt)
+{
+	return cxt->rgn[FT_STRUCT].start;
+}
+
 /* Routines for keeping node ptrs returned by ft_find_device current */
 /* First entry not used b/c it would return 0 and be taken as NULL/error */
 static void *ft_node_add(struct ft_cxt *cxt, char *node)
@@ -590,7 +595,7 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u6
 
 void ft_begin_tree(struct ft_cxt *cxt)
 {
-	cxt->p = cxt->rgn[FT_STRUCT].start;
+	cxt->p = ft_root_node(cxt);
 }
 
 void ft_end_tree(struct ft_cxt *cxt)
@@ -636,7 +641,7 @@ void *ft_find_device(struct ft_cxt *cxt,
 	/* require absolute path */
 	if (srch_path[0] != '/')
 		return NULL;
-	node = ft_find_descendent(cxt, cxt->rgn[FT_STRUCT].start, srch_path);
+	node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
 	return ft_node_add(cxt, node);
 }
 
@@ -717,7 +722,7 @@ void *ft_get_parent(struct ft_cxt *cxt,
 			return cxt->genealogy[d > 0 ? d - 1 : 0];
 
 	/* have to do it the hard way... */
-	p = cxt->rgn[FT_STRUCT].start;
+	p = ft_root_node(cxt);
 	d = 0;
 	while ((p = ft_next(cxt, p, &atom)) != NULL) {
 		switch (atom.tag) {
@@ -855,7 +860,7 @@ void *ft_create_node(struct ft_cxt *cxt,
 	char *p, *next;
 	int depth = 0;
 
-	p = cxt->rgn[FT_STRUCT].start;
+	p = ft_root_node(cxt);
 	while ((next = ft_next(cxt, p, &atom)) != NULL) {
 		switch (atom.tag) {
 		case OF_DT_BEGIN_NODE:
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 05/18] bootwrapper: Rename ft_node_add() to ft_get_phandle().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (2 preceding siblings ...)
  2007-01-29 20:11 ` [PATCH 04/18] bootwrapper: Add ft_root_node() Scott Wood
@ 2007-01-29 20:11 ` Scott Wood
  2007-01-29 20:12 ` [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL Scott Wood
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:11 UTC (permalink / raw)
  To: linuxppc-dev

This name better reflects what the function does, which is to
look up the phandle for an internal node pointer, and add it to the
internal pointer to phandle table if not found.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 02823a8..971420a 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -36,7 +36,7 @@ static char *ft_root_node(struct ft_cxt
 
 /* Routines for keeping node ptrs returned by ft_find_device current */
 /* First entry not used b/c it would return 0 and be taken as NULL/error */
-static void *ft_node_add(struct ft_cxt *cxt, char *node)
+static void *ft_get_phandle(struct ft_cxt *cxt, char *node)
 {
 	unsigned int i;
 
@@ -642,7 +642,7 @@ void *ft_find_device(struct ft_cxt *cxt,
 	if (srch_path[0] != '/')
 		return NULL;
 	node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
-	return ft_node_add(cxt, node);
+	return ft_get_phandle(cxt, node);
 }
 
 void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (3 preceding siblings ...)
  2007-01-29 20:11 ` [PATCH 05/18] bootwrapper: Rename ft_node_add() to ft_get_phandle() Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-30 19:48   ` Segher Boessenkool
  2007-01-29 20:12 ` [PATCH 07/18] bootwrapper: Preserve the pp pointer in ft_make_space() when calling ft_reorder() Scott Wood
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

Currently, if ft_get_phandle() is passed NULL it will allocate an entry
for it and return a non-NULL phandle.  This patch makes it simply pass
the NULL through.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 971420a..6c18773 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -40,6 +40,9 @@ static void *ft_get_phandle(struct ft_cx
 {
 	unsigned int i;
 
+	if (!node)
+		return NULL;
+
 	for (i = 1; i < cxt->nodes_used; i++)	/* already there? */
 		if (cxt->node_tbl[i] == node)
 			return (void *)i;
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 07/18] bootwrapper: Preserve the pp pointer in ft_make_space() when calling ft_reorder().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (4 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-29 20:12 ` [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle() Scott Wood
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

The ft_reorder() function may change the start of the region of interest,
so the pointer provided by the caller into that region must be fixed up
to still point to the same datum.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 6c18773..0fa4f98 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -261,8 +261,14 @@ static int ft_make_space(struct ft_cxt *
 	char *str, *next;
 	enum ft_rgn_id r;
 
-	if (!cxt->isordered && !ft_reorder(cxt, nextra))
-		return 0;
+	if (!cxt->isordered) {
+		unsigned long rgn_off = *pp - cxt->rgn[rgn].start;
+
+		if (!ft_reorder(cxt, nextra))
+			return 0;
+
+		*pp = cxt->rgn[rgn].start + rgn_off;
+	}
 	if (ft_shuffle(cxt, pp, rgn, nextra))
 		return 1;
 
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (5 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 07/18] bootwrapper: Preserve the pp pointer in ft_make_space() when calling ft_reorder() Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-30 19:49   ` Segher Boessenkool
  2007-01-29 20:12 ` [PATCH 09/18] bootwrapper: Use map_string() instead of lookup_string() in ft_prop() Scott Wood
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

Move the caller's pointer back to match the change in the region's start,
rather than alter a byte of the device tree's content.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 0fa4f98..f2a29ca 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -246,7 +246,7 @@ static int ft_shuffle(struct ft_cxt *cxt
 			if (rgn == FT_STRUCT)
 				ft_node_update_before(cxt, p, -nextra);
 		}
-		*p -= nextra;
+		*pp -= nextra;
 		cxt->rgn[rgn].start -= nextra;
 		cxt->rgn[rgn].size += nextra;
 		return 1;
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 09/18] bootwrapper: Use map_string() instead of lookup_string() in ft_prop().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (6 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle() Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-29 20:12 ` [PATCH 10/18] bootwrapper: Add ft_find_device_rel() Scott Wood
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

When adding a property, the property name should be added to the string
table if it doesn't already exist.  map_string() does that;
lookup_string() will fail instead.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index f2a29ca..e319a65 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -429,7 +429,7 @@ int ft_prop(struct ft_cxt *cxt, const ch
 {
 	int off, len;
 
-	off = lookup_string(cxt, name);
+	off = map_string(cxt, name);
 	if (off == NO_STRING)
 		return -1;
 
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 10/18] bootwrapper: Add ft_find_device_rel().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (7 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 09/18] bootwrapper: Use map_string() instead of lookup_string() in ft_prop() Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-30 19:53   ` Segher Boessenkool
  2007-01-29 20:12 ` [PATCH 11/18] bootwrapper: Refactor ft_get_prop() into internal and external functions Scott Wood
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

Add a function to look up a relative, rather than absolute, path name.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   13 +++++++++++++
 arch/powerpc/boot/flatdevtree.h |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index e319a65..bd006f7 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -654,6 +654,19 @@ void *ft_find_device(struct ft_cxt *cxt,
 	return ft_get_phandle(cxt, node);
 }
 
+void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
+                         const char *srch_path)
+{
+	char *node;
+
+	node = ft_node_ph2node(cxt, top);
+	if (node == NULL)
+		return NULL;
+
+	node = ft_find_descendent(cxt, node, srch_path);
+	return ft_get_phandle(cxt, node);
+}
+
 void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
 {
 	struct ft_atom atom;
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index b9cd9f6..1f37ca2 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -97,6 +97,8 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u6
 void ft_dump_blob(const void *bphp);
 void ft_merge_blob(struct ft_cxt *cxt, void *blob);
 void *ft_find_device(struct ft_cxt *cxt, const char *srch_path);
+void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
+                         const char *srch_path);
 void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path);
 int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
 		void *buf, const unsigned int buflen);
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 11/18] bootwrapper: Refactor ft_get_prop() into internal and external functions.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (8 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 10/18] bootwrapper: Add ft_find_device_rel() Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-29 20:12 ` [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level Scott Wood
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

The property searching part of ft_get_prop is factored out into an
internal __ft_get_prop() which does not deal with phandles and does not
copy the property data.  ft_get_prop() is then a wrapper that does the
phandle translation and copying.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   53 +++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index bd006f7..9de267d 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -765,38 +765,53 @@ void *ft_get_parent(struct ft_cxt *cxt,
 	return NULL;
 }
 
-int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
-		void *buf, const unsigned int buflen)
+static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
+                                 const char *propname, unsigned int *len)
 {
 	struct ft_atom atom;
-	void *node;
-	char *p;
-	int depth;
-	unsigned int size;
-
-	node = ft_node_ph2node(cxt, phandle);
-	if (node == NULL)
-		return -1;
-
-	depth = 0;
-	p = (char *)node;
+	int depth = 0;
 
-	while ((p = ft_next(cxt, p, &atom)) != NULL) {
+	while ((node = ft_next(cxt, node, &atom)) != NULL) {
 		switch (atom.tag) {
 		case OF_DT_BEGIN_NODE:
 			++depth;
 			break;
+
 		case OF_DT_PROP:
-			if ((depth != 1) || strcmp(atom.name, propname))
+			if (depth != 1 || strcmp(atom.name, propname))
 				break;
-			size = min(atom.size, buflen);
-			memcpy(buf, atom.data, size);
-			return atom.size;
+
+			if (len)
+				*len = atom.size;
+
+			return atom.data;
+
 		case OF_DT_END_NODE:
 			if (--depth <= 0)
-				return -1;
+				return NULL;
 		}
 	}
+
+	return NULL;
+}
+
+int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
+		void *buf, const unsigned int buflen)
+{
+	const void *data;
+	unsigned int size;
+
+	void *node = ft_node_ph2node(cxt, phandle);
+	if (!node)
+		return -1;
+
+	data = __ft_get_prop(cxt, node, propname, &size);
+	if (data) {
+		unsigned int clipped_size = min(size, buflen);
+		memcpy(buf, data, clipped_size);
+		return size;
+	}
+
 	return -1;
 }
 
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (9 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 11/18] bootwrapper: Refactor ft_get_prop() into internal and external functions Scott Wood
@ 2007-01-29 20:12 ` Scott Wood
  2007-01-30 19:56   ` Segher Boessenkool
  2007-01-29 20:13 ` [PATCH 13/18] bootwrapper: Add ft_find_prop() Scott Wood
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:12 UTC (permalink / raw)
  To: linuxppc-dev

Most of ft_get_parent() is factored out into __ft_get_parent(), which
deals only in internal node pointers.  The ft_get_parent() wrapper
handles phandle conversion in both directions (previously,
ft_get_parent() did not convert its return value).

It also now returns NULL as the parent of the toplevel node, rather than
just returning the toplevel node again (which made it rather useless in
loops).

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   21 +++++++++++++--------
 arch/powerpc/boot/flatdevtree.h |    1 +
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 9de267d..88b178a 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -728,20 +728,15 @@ void *ft_find_descendent(struct ft_cxt *
 	return NULL;
 }
 
-void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
+void *__ft_get_parent(struct ft_cxt *cxt, void *node)
 {
-	void *node;
 	int d;
 	struct ft_atom atom;
 	char *p;
 
-	node = ft_node_ph2node(cxt, phandle);
-	if (node == NULL)
-		return NULL;
-
 	for (d = 0; cxt->genealogy[d] != NULL; ++d)
 		if (cxt->genealogy[d] == node)
-			return cxt->genealogy[d > 0 ? d - 1 : 0];
+			return d > 0 ? cxt->genealogy[d - 1] : NULL;
 
 	/* have to do it the hard way... */
 	p = ft_root_node(cxt);
@@ -753,7 +748,7 @@ void *ft_get_parent(struct ft_cxt *cxt,
 			if (node == atom.data) {
 				/* found it */
 				cxt->genealogy[d + 1] = NULL;
-				return d > 0 ? cxt->genealogy[d - 1] : node;
+				return d > 0 ? cxt->genealogy[d - 1] : NULL;
 			}
 			++d;
 			break;
@@ -765,6 +760,16 @@ void *ft_get_parent(struct ft_cxt *cxt,
 	return NULL;
 }
 
+void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
+{
+	void *node = ft_node_ph2node(cxt, phandle);
+	if (node == NULL)
+		return NULL;
+
+	node = __ft_get_parent(cxt, node);
+	return ft_get_phandle(cxt, node);
+}
+
 static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
                                  const char *propname, unsigned int *len)
 {
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 1f37ca2..9500424 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -104,5 +104,6 @@ int ft_get_prop(struct ft_cxt *cxt, cons
 		void *buf, const unsigned int buflen);
 int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
 		const void *buf, const unsigned int buflen);
+void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
 
 #endif /* FLATDEVTREE_H */
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 13/18] bootwrapper: Add ft_find_prop().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (10 preceding siblings ...)
  2007-01-29 20:12 ` [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level Scott Wood
@ 2007-01-29 20:13 ` Scott Wood
  2007-01-30 19:57   ` Segher Boessenkool
  2007-01-29 20:13 ` [PATCH 14/18] bootwrapper: Add initrd information to the device tree in ft_finalize() Scott Wood
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:13 UTC (permalink / raw)
  To: linuxppc-dev

ft_find_prop() finds nodes with the specified property/value pair.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   62 +++++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/flatdevtree.h |    2 +
 2 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 88b178a..d405359 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -820,6 +820,68 @@ int ft_get_prop(struct ft_cxt *cxt, cons
 	return -1;
 }
 
+void *__ft_find_prop(struct ft_cxt *cxt, void *prev, const char *propname,
+                     const char *propval, unsigned int proplen)
+{
+	struct ft_atom atom;
+	char *p = ft_root_node(cxt);
+	char *next;
+	int past_prev = prev ? 0 : 1;
+	int depth = -1;
+
+	while ((next = ft_next(cxt, p, &atom)) != NULL) {
+		const void *data;
+		unsigned int size;
+
+		switch (atom.tag) {
+		case OF_DT_BEGIN_NODE:
+			depth++;
+
+			if (prev == p) {
+				past_prev = 1;
+				break;
+			}
+
+			if (!past_prev || depth < 1)
+				break;
+
+			data = __ft_get_prop(cxt, p, propname, &size);
+			if (!data || size != proplen)
+				break;
+			if (memcmp(data, propval, size))
+				break;
+
+			return p;
+
+		case OF_DT_END_NODE:
+			if (depth-- == 0)
+				return NULL;
+
+			break;
+		}
+
+		p = next;
+	}
+
+	return NULL;
+}
+
+void *ft_find_prop(struct ft_cxt *cxt, const void *prev, const char *propname,
+                   const char *propval, int proplen)
+{
+	void *node = NULL;
+
+	if (prev) {
+		node = ft_node_ph2node(cxt, prev);
+
+		if (!node)
+			return NULL;
+	}
+
+	node = __ft_find_prop(cxt, node, propname, propval, proplen);
+	return ft_get_phandle(cxt, node);
+}
+
 int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
 		const void *buf, const unsigned int buflen)
 {
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 9500424..728e327 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -105,5 +105,7 @@ int ft_get_prop(struct ft_cxt *cxt, cons
 int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
 		const void *buf, const unsigned int buflen);
 void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
+void *ft_find_prop(struct ft_cxt *cxt, const void *prev, const char *propname,
+                   const char *propval, int proplen);
 
 #endif /* FLATDEVTREE_H */
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 14/18] bootwrapper: Add initrd information to the device tree in ft_finalize().
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (11 preceding siblings ...)
  2007-01-29 20:13 ` [PATCH 13/18] bootwrapper: Add ft_find_prop() Scott Wood
@ 2007-01-29 20:13 ` Scott Wood
  2007-01-29 20:13 ` [PATCH 15/18] bootwrapper: Make ft_create_node() pay attention to the parent parameter Scott Wood
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:13 UTC (permalink / raw)
  To: linuxppc-dev

linux,initrd-start and linux,initrd-end are added to the device tree
based on the values that platform code puts in the initrd struct.
ft_finalize() is also made global, so that platform code can do further
manipulation before returning to generic code.

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

diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 04da38f..39fa010 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -33,8 +33,20 @@ static int ft_setprop(const void *phandl
 	return ft_set_prop(&cxt, phandle, propname, buf, buflen);
 }
 
-static unsigned long ft_finalize(void)
+unsigned long ft_finalize(void)
 {
+	unsigned long initrd_end = initrd.addr + initrd.size;
+	void *devp;
+
+	if (initrd.size && (devp = finddevice("/chosen"))) {
+		setprop(devp, "linux,initrd-start", &initrd.addr,
+		        sizeof(initrd.addr));
+		setprop(devp, "linux,initrd-end", &initrd_end,
+		        sizeof(initrd_end));
+
+		ft_add_rsvmap(&cxt, initrd.addr, initrd.size);
+	}
+
 	ft_end_tree(&cxt);
 	return (unsigned long)cxt.bph;
 }
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 42c723d..0bc4a68 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -63,6 +63,7 @@ int platform_init(unsigned long r3, unsi
                   unsigned long r6, unsigned long r7,
                   char *dt_blob_start, char *dt_blob_end);
 int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
+unsigned long ft_finalize(void);
 int serial_console_init(void);
 int ns16550_console_init(void *devp, struct serial_console_data *scdp);
 void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 15/18] bootwrapper: Make ft_create_node() pay attention to the parent parameter.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (12 preceding siblings ...)
  2007-01-29 20:13 ` [PATCH 14/18] bootwrapper: Add initrd information to the device tree in ft_finalize() Scott Wood
@ 2007-01-29 20:13 ` Scott Wood
  2007-01-29 20:13 ` [PATCH 16/18] bootwrapper: Add dt_ops methods Scott Wood
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:13 UTC (permalink / raw)
  To: linuxppc-dev

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   17 ++++++++++++-----
 arch/powerpc/boot/flatdevtree.h |    1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index d405359..4f0365d 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -958,19 +958,26 @@ int ft_del_prop(struct ft_cxt *cxt, cons
 	return -1;
 }
 
-void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *path)
+void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
 {
 	struct ft_atom atom;
 	char *p, *next;
 	int depth = 0;
 
-	p = ft_root_node(cxt);
+	if (parent) {
+		p = ft_node_ph2node(cxt, parent);
+		if (!p)
+			return NULL;
+	} else {
+		p = ft_root_node(cxt);
+	}
+
 	while ((next = ft_next(cxt, p, &atom)) != NULL) {
 		switch (atom.tag) {
 		case OF_DT_BEGIN_NODE:
 			++depth;
-			if (depth == 1 && strcmp(atom.name, path) == 0)
-				/* duplicate node path, return error */
+			if (depth == 1 && strcmp(atom.name, name) == 0)
+				/* duplicate node name, return error */
 				return NULL;
 			break;
 		case OF_DT_END_NODE:
@@ -979,7 +986,7 @@ void *ft_create_node(struct ft_cxt *cxt,
 				break;
 			/* end of node, insert here */
 			cxt->p = p;
-			ft_begin_node(cxt, path);
+			ft_begin_node(cxt, name);
 			ft_end_node(cxt);
 			return p;
 		}
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 728e327..6741126 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -107,5 +107,6 @@ int ft_set_prop(struct ft_cxt *cxt, cons
 void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
 void *ft_find_prop(struct ft_cxt *cxt, const void *prev, const char *propname,
                    const char *propval, int proplen);
+void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name);
 
 #endif /* FLATDEVTREE_H */
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 16/18] bootwrapper: Add dt_ops methods.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (13 preceding siblings ...)
  2007-01-29 20:13 ` [PATCH 15/18] bootwrapper: Make ft_create_node() pay attention to the parent parameter Scott Wood
@ 2007-01-29 20:13 ` Scott Wood
  2007-01-30 20:01   ` Segher Boessenkool
  2007-01-29 20:13 ` [PATCH 17/18] bootwrapper: Add xlate_reg(), and use it to find serial registers Scott Wood
  2007-01-29 20:13 ` [PATCH 18/18] bootwrapper: Compatibility layer for old U-Boots (a.k.a. cuImage, cuboot) Scott Wood
  16 siblings, 1 reply; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:13 UTC (permalink / raw)
  To: linuxppc-dev

Add finddevice_rel, get_parent, create_node, and find_prop to dt_ops.
Currently only implemented by flatdevtree_misc.

Also, add a _str convenience wrapper for setprop.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree_misc.c |   25 +++++++++++++++++
 arch/powerpc/boot/ops.h              |   49 ++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 39fa010..2ec12eb 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -21,6 +21,11 @@ static void *ft_finddevice(const char *n
 	return ft_find_device(&cxt, name);
 }
 
+static void *ft_finddevice_rel(const void *phandle, const char *name)
+{
+	return ft_find_device_rel(&cxt, phandle, name);
+}
+
 static int ft_getprop(const void *phandle, const char *propname, void *buf,
 		const int buflen)
 {
@@ -51,12 +56,32 @@ unsigned long ft_finalize(void)
 	return (unsigned long)cxt.bph;
 }
 
+void *fdtm_get_parent(const void *phandle)
+{
+	return ft_get_parent(&cxt, phandle);
+}
+
+void *fdtm_create_node(const void *phandle, const char *name)
+{
+	return ft_create_node(&cxt, phandle, name);
+}
+
+void *fdtm_find_prop(const void *prev, const char *propname,
+                     const char *propval, int proplen)
+{
+	return ft_find_prop(&cxt, prev, propname, propval, proplen);
+}
+
 int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
 {
 	dt_ops.finddevice = ft_finddevice;
+	dt_ops.finddevice_rel = ft_finddevice_rel;
 	dt_ops.getprop = ft_getprop;
 	dt_ops.setprop = ft_setprop;
 	dt_ops.finalize = ft_finalize;
+	dt_ops.get_parent = fdtm_get_parent;
+	dt_ops.create_node = fdtm_create_node;
+	dt_ops.find_prop = fdtm_find_prop;
 
 	return ft_open(&cxt, dt_blob, max_size, max_find_device,
 			platform_ops.realloc);
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 0bc4a68..522b7c8 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -13,6 +13,7 @@
 
 #include <stddef.h>
 #include "types.h"
+#include "string.h"
 
 #define	COMMAND_LINE_SIZE	512
 #define	MAX_PATH_LEN		256
@@ -32,10 +33,16 @@ extern struct platform_ops platform_ops;
 /* Device Tree operations */
 struct dt_ops {
 	void *	(*finddevice)(const char *name);
+	void *	(*finddevice_rel)(const void *phandle, const char *name);
 	int	(*getprop)(const void *phandle, const char *name, void *buf,
 			const int buflen);
 	int	(*setprop)(const void *phandle, const char *name,
 			const void *buf, const int buflen);
+	void *(*get_parent)(const void *phandle);
+	/* The node must not already exist. */
+	void *(*create_node)(const void *parent, const char *name);
+	void *(*find_prop)(const void *prev, const char *propname,
+	                   const char *propval, int proplen);
 	unsigned long (*finalize)(void);
 };
 extern struct dt_ops dt_ops;
@@ -75,6 +82,14 @@ static inline void *finddevice(const cha
 	return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
 }
 
+static inline void *finddevice_rel(const void *phandle, const char *name)
+{
+	if (dt_ops.finddevice_rel)
+		return dt_ops.finddevice_rel(phandle, name);
+
+	return NULL;
+}
+
 static inline int getprop(void *devp, const char *name, void *buf, int buflen)
 {
 	return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
@@ -85,6 +100,40 @@ static inline int setprop(void *devp, co
 	return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
 }
 
+static inline int setprop_str(void *devp, const char *name, const char *buf)
+{
+	if (dt_ops.setprop)
+		return dt_ops.setprop(devp, name, buf, strlen(buf));
+
+	return -1;
+}
+
+static inline void *get_parent(const char *devp)
+{
+	return dt_ops.get_parent ? dt_ops.get_parent(devp) : NULL;
+}
+
+static inline void *create_node(const void *parent, const char *name)
+{
+	return dt_ops.create_node ? dt_ops.create_node(parent, name) : NULL;
+}
+
+
+static inline void *find_prop(const void *prev, const char *propname,
+	                      const char *propval, int proplen)
+{
+	if (dt_ops.find_prop)
+		return dt_ops.find_prop(prev, propname, propval, proplen);
+
+	return NULL;
+}
+
+static inline void *find_prop_str(const void *prev, const char *propname,
+	                          const char *propval)
+{
+	return find_prop(prev, propname, propval, strlen(propval) + 1);
+}
+
 static inline void *malloc(u32 size)
 {
 	return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 17/18] bootwrapper: Add xlate_reg(), and use it to find serial registers.
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (14 preceding siblings ...)
  2007-01-29 20:13 ` [PATCH 16/18] bootwrapper: Add dt_ops methods Scott Wood
@ 2007-01-29 20:13 ` Scott Wood
  2007-01-29 20:13 ` [PATCH 18/18] bootwrapper: Compatibility layer for old U-Boots (a.k.a. cuImage, cuboot) Scott Wood
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:13 UTC (permalink / raw)
  To: linuxppc-dev

xlate_reg() uses the ranges properties of a node's parentage to find the
absolute physical address of the node's registers.

The ns16550 driver uses this when no virtual-reg property is found.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/Makefile  |    3 +-
 arch/powerpc/boot/devtree.c |  207 +++++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/ns16550.c |    9 ++-
 arch/powerpc/boot/ops.h     |    1 +
 4 files changed, 217 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index df92f06..f6ae81a 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -43,7 +43,8 @@ $(addprefix $(obj)/,$(zlib) main.o): $(a
 		$(addprefix $(obj)/,$(zlibheader))
 
 src-wlib := string.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
-		ns16550.c serial.c simple_alloc.c div64.S util.S $(zlib)
+		ns16550.c serial.c simple_alloc.c div64.S util.S $(zlib) \
+		devtree.c
 src-plat := of.c
 src-boot := crt0.S $(src-wlib) $(src-plat) empty.c
 
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
new file mode 100644
index 0000000..9fee6fb
--- /dev/null
+++ b/arch/powerpc/boot/devtree.c
@@ -0,0 +1,207 @@
+/*
+ * Device Tree functions that are semantic, not structural
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "string.h"
+
+#define MAX_ADDR_CELLS 4
+#define MAX_RANGES 8
+
+static int get_reg_format(void *node, u32 *naddr, u32 *nsize)
+{
+	int got_addr = 0, got_size = 0;
+
+	while (node && !(got_addr && got_size)) {
+		if (!got_addr && getprop(node, "#address-cells",
+		                         naddr, 4) == 4)
+			got_addr = 1;
+		if (!got_size && getprop(node, "#size-cells",
+		                         nsize, 4) == 4)
+			got_size = 1;
+
+		node = get_parent(node);
+	}
+
+	if (*naddr <= 0 || *naddr > MAX_ADDR_CELLS ||
+	    *nsize <= 0 || *nsize > *naddr)
+		return 0;
+
+	return got_addr && got_size;
+}
+
+static int sub_reg(u32 *reg, u32 *sub, u32 naddr)
+{
+	int i, borrow = 0;
+
+	for (i = 0; i < naddr; i++) {
+		int prev_borrow = borrow;
+		borrow = reg[i] < sub[i] + prev_borrow;
+		reg[i] -= sub[i] + prev_borrow;
+	}
+
+	return !borrow;
+}
+
+static int add_reg(u32 *reg, u32 *add, u32 naddr, u32 naddr_add)
+{
+	int i, carry = 0;
+	int diff = naddr - naddr_add;
+
+	if (diff < 0) {
+		for (i = 0; i < -diff; i++)
+			if (*add++ != 0)
+				return 0;
+
+		diff = 0;
+	}
+
+	for (i = diff; i < naddr; i++) {
+		u64 tmp = (u64)reg[i] + add[i - diff] + carry;
+		carry = tmp >> 32;
+		reg[i] = (u32)tmp;
+	}
+
+	return !carry;
+}
+
+/* It is assumed that if the first byte of reg fits in a
+ * range, then the whole reg block fits.  It is also assumed
+ * that #size-cells <= #address-cells.
+ */
+static int compare_reg(u32 *reg, u32 *range, u32 *rangesize,
+                       u32 naddr, u32 nsize)
+{
+	int i, sizeoff = naddr - nsize;
+
+	for (i = 0; i < naddr; i++) {
+		if (reg[i] < range[i])
+			return 0;
+		if (reg[i] > range[i])
+			break;
+	}
+
+	for (i = sizeoff; i < naddr; i++) {
+		u32 end = range[i] + rangesize[i - sizeoff];
+
+		if (reg[i] < end)
+			break;
+		if (reg[i] > end)
+			return 0;
+		if (i == naddr && reg[i] == end)
+			return 0;
+	}
+
+	return 1;
+}
+
+static int find_range(u32 *reg, u32 *ranges, int naddr,
+                      int nsize, int nparentaddr, int buflen)
+{
+	int nrange = naddr + nparentaddr + nsize;
+	int i;
+
+	for (i = 0; i + nrange <= buflen; i += nrange) {
+		if (compare_reg(reg, ranges + i,
+		                ranges + i + naddr + nparentaddr,
+		                naddr, nsize))
+			return i;
+	}
+
+	return -1;
+}
+
+/* Currently only generic buses without special encodings are supported.
+ * In particular, PCI is not supported.  Also, only the beginning of the
+ * reg block is tracked; size is ignored except in ranges.
+ */
+int xlate_reg(void *node, int res, unsigned long *addr,
+              unsigned long *size)
+{
+	u32 last_addr[MAX_ADDR_CELLS];
+	u32 buf[MAX_ADDR_CELLS * MAX_RANGES * 3];
+	void *parent;
+	u64 ret_addr, ret_size;
+	u32 naddr, nsize, prev_naddr, prev_nsize;
+	int buflen, offset;
+
+	parent = get_parent(node);
+	if (!parent)
+		return 0;
+
+	if (!get_reg_format(parent, &naddr, &nsize))
+		return 0;
+
+	if (nsize > 2)
+		return 0;
+
+	buflen = getprop(node, "reg", buf, sizeof(buf)) / 4;
+	offset = (naddr + nsize) * res;
+
+	if (buflen < offset + naddr + nsize)
+		return 0;
+
+	memcpy(last_addr, buf + offset, 4 * naddr);
+
+	ret_size = buf[offset + naddr];
+	if (nsize == 2) {
+		ret_size <<= 32;
+		ret_size |= buf[offset + naddr + 1];
+	}
+
+	while ((node = get_parent(node))) {
+		prev_naddr = naddr;
+		prev_nsize = nsize;
+
+		if (!get_reg_format(node, &naddr, &nsize))
+			return 0;
+
+		buflen = getprop(node, "ranges",
+		                        buf, sizeof(buf));
+		if (buflen < 0)
+			continue;
+		if (buflen > sizeof(buf))
+			return 0;
+
+		offset = find_range(last_addr, buf, prev_naddr,
+		                    prev_nsize, naddr, buflen / 4);
+
+		if (offset < 0)
+			return 0;
+
+		if (!sub_reg(last_addr, buf + offset, prev_naddr) ||
+		    !add_reg(buf + offset + prev_naddr, last_addr,
+		             naddr, prev_naddr))
+			return 0;
+
+		memcpy(last_addr, buf + offset + prev_naddr, 4 * naddr);
+	}
+
+	if (naddr > 2)
+		return 0;
+
+	ret_addr = last_addr[0];
+	if (naddr == 2) {
+		ret_addr <<= 32;
+		ret_addr |= last_addr[1];
+	}
+
+	if (sizeof(void *) == 4 &&
+	    (ret_addr >= 0x100000000ULL || ret_size > 0x100000000ULL ||
+	     ret_addr + ret_size > 0x100000000ULL))
+		return 0;
+
+	*addr = ret_addr;
+	if (size)
+		*size = ret_size;
+
+	return 1;
+}
diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
index 1ffe72e..cce7a11 100644
--- a/arch/powerpc/boot/ns16550.c
+++ b/arch/powerpc/boot/ns16550.c
@@ -55,10 +55,15 @@ static u8 ns16550_tstc(void)
 int ns16550_console_init(void *devp, struct serial_console_data *scdp)
 {
 	int n;
+	unsigned long reg_phys;
 
 	n = getprop(devp, "virtual-reg", &reg_base, sizeof(reg_base));
-	if (n != sizeof(reg_base))
-		return -1;
+	if (n != sizeof(reg_base)) {
+		if (!xlate_reg(devp, 0, &reg_phys, NULL))
+			return -1;
+
+		reg_base = (void *)reg_phys;
+	}
 
 	n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
 	if (n != sizeof(reg_shift))
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 522b7c8..8027060 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -75,6 +75,7 @@ int serial_console_init(void);
 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);
 
 
 static inline void *finddevice(const char *name)
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 18/18] bootwrapper: Compatibility layer for old U-Boots (a.k.a. cuImage, cuboot)
       [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
                   ` (15 preceding siblings ...)
  2007-01-29 20:13 ` [PATCH 17/18] bootwrapper: Add xlate_reg(), and use it to find serial registers Scott Wood
@ 2007-01-29 20:13 ` Scott Wood
  16 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:13 UTC (permalink / raw)
  To: linuxppc-dev

Add a bootwrapper platform (cuboot) that takes a bd_t from a legacy
U-Boot, and inserts data from it into a device tree which has been
compiled into the kernel.  This should help ease the transition to
arch/powerpc in cases where U-Boot has not yet been updated to pass a
device tree, or where upgrading firmware isn't practical.

The device trees currently in the kernel tree must have
/chosen/linux,stdout-path added to work with cuboot.

The kernel command line, mac addresses, and various clocks will be filled
in based on the bd_t.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/Kconfig            |   21 +++++
 arch/powerpc/boot/.gitignore    |    2 +
 arch/powerpc/boot/Makefile      |   20 +++++-
 arch/powerpc/boot/cuboot-83xx.c |    4 +
 arch/powerpc/boot/cuboot-85xx.c |    4 +
 arch/powerpc/boot/cuboot-86xx.c |    4 +
 arch/powerpc/boot/cuboot.c      |  158 +++++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/ppcboot.h     |  103 +++++++++++++++++++++++++
 arch/powerpc/boot/wrapper       |   41 ++++++++--
 9 files changed, 347 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 0855d55..d933f8c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -910,6 +910,27 @@ config SECCOMP
 
 	  If unsure, say Y. Only embedded should say N here.
 
+config COMPAT_UIMAGE
+	bool "Build kernel for old non-device-tree PPCBoot/U-Boot"
+	depends on DEFAULT_UIMAGE
+	default n
+	help
+	  If selected, the kernel will be built for older U-Boot
+	  (and PPCBoot) bootloaders that pass a bd_t instead of
+	  a device tree.  Such a kernel will not work with a newer
+	  U-Boot that passes the device tree itself.  If your
+	  U-Boot does not mention a device tree in "help bootm",
+	  say Y.
+
+config CUIMAGE_DTS
+	string "Device tree source file"
+	depends on COMPAT_UIMAGE
+	help
+	  This specifies the device tree source (.dts) file to
+	  be compiled and included in the kernel image.  If
+	  a relative filename is given, then it will be relative
+	  to arch/powerpc/boot/dts.
+
 endmenu
 
 config ISA_DMA_API
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index 0734b2f..ff8852d 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -18,6 +18,8 @@ kernel-vmlinux.strip.c
 kernel-vmlinux.strip.gz
 mktree
 uImage
+uImage.bin.gz
+uImage.elf
 zImage
 zImage.chrp
 zImage.coff
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index f6ae81a..62d607d 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -35,6 +35,8 @@ endif
 
 BOOTCFLAGS	+= -I$(obj) -I$(srctree)/$(obj)
 
+cuboot-plats := 83xx 85xx 86xx
+
 zlib       := inffast.c inflate.c inftrees.c
 zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h
 zliblinuxheader := zlib.h zconf.h zutil.h
@@ -45,7 +47,7 @@ $(addprefix $(obj)/,$(zlib) main.o): $(a
 src-wlib := string.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
 		ns16550.c serial.c simple_alloc.c div64.S util.S $(zlib) \
 		devtree.c
-src-plat := of.c
+src-plat := of.c $(cuboot-plats:%=cuboot-%.c)
 src-boot := crt0.S $(src-wlib) $(src-plat) empty.c
 
 src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -122,6 +124,12 @@ quiet_cmd_wrap_initrd = WRAP    $@
       cmd_wrap_initrd =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
 				-i $(obj)/ramdisk.image.gz vmlinux
 
+dts = $(if $(shell echo $(CONFIG_CUIMAGE_DTS) | grep '^/'),\
+       ,$(srctree)/$(src)/dts/)$(CONFIG_CUIMAGE_DTS)
+quiet_cmd_wrap_dt = WRAP    $@
+      cmd_wrap_dt = $(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
+                    -s "$(dts)" vmlinux
+
 $(obj)/zImage.chrp: vmlinux $(wrapperbits)
 	$(call cmd,wrap,chrp)
 
@@ -158,8 +166,18 @@ $(obj)/zImage.ps3: vmlinux
 $(obj)/zImage.initrd.ps3: vmlinux
 	@echo "  WARNING zImage.initrd.ps3 not supported (yet)"
 
+ifeq ($(CONFIG_COMPAT_UIMAGE),y)
+cuboot-plat-$(CONFIG_83xx) += 83xx
+cuboot-plat-$(CONFIG_85xx) += 85xx
+cuboot-plat-$(CONFIG_86xx) += 86xx
+cuboot-plat-y += unknown-platform
+
+$(obj)/uImage: vmlinux $(wrapperbits)
+	$(call cmd,wrap_dt,cuboot-$(word 1,$(cuboot-plat-y)))
+else
 $(obj)/uImage: vmlinux $(wrapperbits)
 	$(call cmd,wrap,uboot)
+endif
 
 image-$(CONFIG_PPC_PSERIES)		+= zImage.pseries
 image-$(CONFIG_PPC_MAPLE)		+= zImage.pseries
diff --git a/arch/powerpc/boot/cuboot-83xx.c b/arch/powerpc/boot/cuboot-83xx.c
new file mode 100644
index 0000000..6563dcc
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-83xx.c
@@ -0,0 +1,4 @@
+#define CONFIG_83xx
+#define CONFIG_6xx
+
+#include "cuboot.c"
diff --git a/arch/powerpc/boot/cuboot-85xx.c b/arch/powerpc/boot/cuboot-85xx.c
new file mode 100644
index 0000000..16f33e1
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-85xx.c
@@ -0,0 +1,4 @@
+#define CONFIG_85xx
+#define CONFIG_E500
+
+#include "cuboot.c"
diff --git a/arch/powerpc/boot/cuboot-86xx.c b/arch/powerpc/boot/cuboot-86xx.c
new file mode 100644
index 0000000..e9cca26
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-86xx.c
@@ -0,0 +1,4 @@
+#define CONFIG_86xx
+#define CONFIG_6xx
+
+#include "cuboot.c"
diff --git a/arch/powerpc/boot/cuboot.c b/arch/powerpc/boot/cuboot.c
new file mode 100644
index 0000000..278fc9f
--- /dev/null
+++ b/arch/powerpc/boot/cuboot.c
@@ -0,0 +1,158 @@
+/*
+ * Compatibility with old U-Boots
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "flatdevtree.h"
+#include "ppcboot.h"
+
+static bd_t bd;
+extern char _start[], _end[];
+
+static void set_memory(void)
+{
+	void *devp;
+	unsigned long mem[2] = { bd.bi_memstart, bd.bi_memsize };
+
+	devp = finddevice("/memory");
+	if (!devp) {
+		devp = create_node(NULL, "memory");
+		setprop_str(devp, "device_type", "memory");
+	}
+
+	setprop(devp, "reg", mem, sizeof(mem));
+}
+
+static void set_bootargs(unsigned long cmdline_start,
+                         unsigned long cmdline_size)
+{
+	void *devp;
+
+	devp = finddevice("/chosen");
+	if (!devp)
+		devp = create_node(NULL, "chosen");
+
+	setprop(devp, "bootargs", (void *)cmdline_start, cmdline_size);
+}
+
+static void *set_one_mac(void *last_node, unsigned char *addr)
+{
+	void *node = find_prop_str(last_node, "device_type", "network");
+
+	if (node)
+		setprop(node, "local-mac-address", addr, 6);
+
+	return node;
+}
+
+static void set_mac_addrs(void)
+{
+	__attribute__((unused)) void *node =
+		set_one_mac(NULL, bd.bi_enetaddr);
+
+#ifdef HAVE_ENET1ADDR
+	if (node)
+		node = set_one_mac(node, bd.bi_enet1addr);
+#endif
+#ifdef HAVE_ENET2ADDR
+	if (node)
+		node = set_one_mac(node, bd.bi_enet2addr);
+#endif
+#ifdef HAVE_ENET3ADDR
+	if (node)
+		node = set_one_mac(node, bd.bi_enet3addr);
+#endif
+}
+
+static void set_clocks(void)
+{
+	void *node = NULL;
+
+	while ((node = find_prop_str(node, "device_type", "cpu"))) {
+		unsigned long tbfreq;
+
+		setprop(node, "clock-frequency", &bd.bi_intfreq,
+		        sizeof(bd.bi_intfreq));
+		setprop(node, "bus-frequency", &bd.bi_busfreq,
+		        sizeof(bd.bi_busfreq));
+
+#ifdef CONFIG_6xx
+		tbfreq = bd.bi_busfreq / 4;
+#elif defined(CONFIG_E500)
+		tbfreq = bd.bi_busfreq / 8;
+#else
+#error Unknown timebase frequency.
+#endif
+
+		setprop(node, "timebase-frequency", &tbfreq, sizeof(tbfreq));
+	}
+
+#if defined(CONFIG_83xx) || defined(CONFIG_85xx) || defined(CONFIG_86xx)
+	node = find_prop_str(NULL, "device_type", "soc");
+	if (node) {
+		void *serial;
+
+		setprop(node, "bus-frequency", &bd.bi_busfreq,
+		        sizeof(bd.bi_busfreq));
+
+		serial = finddevice_rel(node, "serial@4500");
+		if (serial)
+			setprop(serial, "clock-frequency", &bd.bi_busfreq,
+			        sizeof(bd.bi_busfreq));
+
+		serial = finddevice_rel(node, "serial@4600");
+		if (serial)
+			setprop(serial, "clock-frequency", &bd.bi_busfreq,
+			        sizeof(bd.bi_busfreq));
+	}
+#endif
+}
+
+/* There's not enough room on 8MiB boards to put the full
+ * heap (including a kernel image) after _end, but the device
+ * tree cannot stay in a heap that is before _start, or it
+ * will get overwritten when the kernel relocates itself.
+ *
+ * Ideally, we wouldn't move the kernel at all if not uncompressing,
+ * but that requires making sure all platforms leave enough room
+ * after _end for the BSS when setting up the heap.
+ */
+static unsigned long cuboot_finalize(void)
+{
+	struct boot_param_header *dt =
+		(struct boot_param_header *)ft_finalize();
+
+	memcpy(_end, dt, dt->totalsize);
+	return (unsigned long)_end;
+}
+
+int platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+                  unsigned long r6, unsigned long r7,
+                  char *dt_blob_start, char *dt_blob_end)
+{
+	memcpy(&bd, (bd_t *)r3, sizeof(bd));
+	initrd.addr = r4;
+	initrd.size = r4 ? r5 : 0;
+
+	if (simple_alloc_init(0, (unsigned long)_start - 0x80000, 4096, 32) >
+	    (void *)_start)
+		return -1;
+	if (ft_init(dt_blob_start, dt_blob_end - dt_blob_start, 32))
+		return -1;
+
+	set_memory();
+	set_bootargs(r6, r7 - r6 + 1);
+	set_mac_addrs();
+	set_clocks();
+
+	dt_ops.finalize = cuboot_finalize;
+	return serial_console_init();
+}
diff --git a/arch/powerpc/boot/ppcboot.h b/arch/powerpc/boot/ppcboot.h
new file mode 100644
index 0000000..d9782ae
--- /dev/null
+++ b/arch/powerpc/boot/ppcboot.h
@@ -0,0 +1,103 @@
+/*
+ * (C) Copyright 2000, 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __PPCBOOT_H__
+#define __PPCBOOT_H__
+
+/*
+ * Board information passed to kernel from PPCBoot
+ *
+ * include/asm-ppc/ppcboot.h
+ */
+
+#include "types.h"
+
+typedef struct bd_info {
+	unsigned long	bi_memstart;	/* start of DRAM memory */
+	unsigned long	bi_memsize;	/* size	 of DRAM memory in bytes */
+	unsigned long	bi_flashstart;	/* start of FLASH memory */
+	unsigned long	bi_flashsize;	/* size	 of FLASH memory */
+	unsigned long	bi_flashoffset; /* reserved area for startup monitor */
+	unsigned long	bi_sramstart;	/* start of SRAM memory */
+	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
+#if defined(CONFIG_8xx) || defined(CONFIG_CPM2) || defined(CONFIG_85xx) ||\
+	defined(CONFIG_83xx)
+	unsigned long	bi_immr_base;	/* base of IMMR register */
+#endif
+#if defined(CONFIG_PPC_MPC52xx)
+	unsigned long   bi_mbar_base;   /* base of internal registers */
+#endif
+	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
+	unsigned long	bi_ip_addr;	/* IP Address */
+	unsigned char	bi_enetaddr[6];	/* Ethernet address */
+	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
+	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
+	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
+#if defined(CONFIG_CPM2)
+	unsigned long	bi_cpmfreq;	/* CPM_CLK Freq, in MHz */
+	unsigned long	bi_brgfreq;	/* BRG_CLK Freq, in MHz */
+	unsigned long	bi_sccfreq;	/* SCC_CLK Freq, in MHz */
+	unsigned long	bi_vco;		/* VCO Out from PLL, in MHz */
+#endif
+#if defined(CONFIG_PPC_MPC52xx)
+	unsigned long   bi_ipbfreq;     /* IPB Bus Freq, in MHz */
+	unsigned long   bi_pcifreq;     /* PCI Bus Freq, in MHz */
+#endif
+	unsigned long	bi_baudrate;	/* Console Baudrate */
+#if defined(CONFIG_4xx)
+	unsigned char	bi_s_version[4];	/* Version of this structure */
+	unsigned char	bi_r_version[32];	/* Version of the ROM (IBM) */
+	unsigned int	bi_procfreq;	/* CPU (Internal) Freq, in Hz */
+	unsigned int	bi_plb_busfreq;	/* PLB Bus speed, in Hz */
+	unsigned int	bi_pci_busfreq;	/* PCI Bus speed, in Hz */
+	unsigned char	bi_pci_enetaddr[6];	/* PCI Ethernet MAC address */
+#endif
+#if defined(CONFIG_HYMOD)
+	hymod_conf_t	bi_hymod_conf;	/* hymod configuration information */
+#endif
+#if defined(CONFIG_EVB64260) || defined(CONFIG_405EP) || defined(CONFIG_44x) || \
+	defined(CONFIG_85xx) ||	defined(CONFIG_83xx)
+	/* second onboard ethernet port */
+	unsigned char	bi_enet1addr[6];
+#define HAVE_ENET1ADDR
+#endif
+#if defined(CONFIG_EVB64260) || defined(CONFIG_440GX) || defined(CONFIG_85xx)
+	/* third onboard ethernet ports */
+	unsigned char	bi_enet2addr[6];
+#define HAVE_ENET2ADDR
+#endif
+#if defined(CONFIG_440GX)
+	/* fourth onboard ethernet ports */
+	unsigned char	bi_enet3addr[6];
+#define HAVE_ENET3ADDR
+#endif
+#if defined(CONFIG_4xx)
+	unsigned int	bi_opbfreq;		/* OB clock in Hz */
+	int		bi_iic_fast[2];		/* Use fast i2c mode */
+#endif
+#if defined(CONFIG_440GX)
+	int		bi_phynum[4];		/* phy mapping */
+	int		bi_phymode[4];		/* phy mode */
+#endif
+} bd_t;
+
+#define bi_tbfreq	bi_intfreq
+
+#endif	/* __PPCBOOT_H__ */
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 024e4d4..46338d2 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -29,6 +29,7 @@ initrd=
 dtb=
 dts=
 cacheit=
+gzip=.gz
 
 # cross-compilation prefix
 CROSS=
@@ -106,7 +107,7 @@ if [ -n "$dts" ]; then
     if [ -z "$dtb" ]; then
 	dtb="$platform.dtb"
     fi
-    dtc -O dtb -o "$dtb" -b 0 -V 16 "$dts" || exit 1
+    dtc -f -O dtb -o "$dtb" -b 0 -V 16 "$dts" || exit 1
 fi
 
 if [ -z "$kernel" ]; then
@@ -137,31 +138,46 @@ miboot|uboot)
     ksection=image
     isection=initrd
     ;;
+cuboot*)
+    platformo=$object/"$platform".o
+    gzip=
+    ;;
 esac
 
 vmz="$tmpdir/`basename \"$kernel\"`.$ext"
 if [ -z "$cacheit" -o ! -f "$vmz.gz" -o "$vmz.gz" -ot "$kernel" ]; then
     ${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
-    gzip -f -9 "$vmz.$$"
+
+    if [ -n "$gzip" ]; then
+        gzip -f -9 "$vmz.$$"
+    fi
+
     if [ -n "$cacheit" ]; then
-	mv -f "$vmz.$$.gz" "$vmz.gz"
+	mv -f "$vmz.$$$gzip" "$vmz$gzip"
     else
 	vmz="$vmz.$$"
     fi
+
+    vmz="$vmz$gzip"
 fi
 
 case "$platform" in
-uboot)
-    rm -f "$ofile"
+uboot|cuboot*)
     version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
 	cut -d' ' -f3`
     if [ -n "$version" ]; then
 	version="-n Linux-$version"
     fi
+    ;;
+esac
+
+case "$platform" in
+uboot)
+    rm -f "$ofile"
     mkimage -A ppc -O linux -T kernel -C gzip -a 00000000 -e 00000000 \
-	$version -d "$vmz.gz" "$ofile"
+	$version -d "$vmz" "$ofile"
     if [ -z "$cacheit" ]; then
-	rm -f $vmz.gz
+	rm -f $vmz
     fi
     exit 0
     ;;
@@ -173,9 +189,9 @@ addsec() {
 	--set-section-flags=$3=contents,alloc,load,readonly,data
 }
 
-addsec $tmp "$vmz.gz" $ksection $object/empty.o
+addsec $tmp "$vmz" $ksection $object/empty.o
 if [ -z "$cacheit" ]; then
-    rm -f "$vmz.gz"
+    rm -f "$vmz"
 fi
 
 if [ -n "$initrd" ]; then
@@ -204,4 +220,11 @@ pmaccoff)
     ${CROSS}objcopy -O aixcoff-rs6000 --set-start 0x500000 "$ofile"
     $object/hack-coff "$ofile"
     ;;
+cuboot*)
+    mv "$ofile" "$ofile".elf
+    ${CROSS}objcopy -O binary "$ofile".elf "$ofile".bin
+    gzip -f -9 "$ofile".bin
+    mkimage -A ppc -O linux -T kernel -C gzip -a 00400000 -e 00400010 \
+            $version -d "$ofile".bin.gz "$ofile"
+    ;;
 esac
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options.
  2007-01-29 20:11 ` [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options Scott Wood
@ 2007-01-29 20:40   ` Scott Wood
  2007-01-30 19:42   ` Segher Boessenkool
  1 sibling, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-29 20:40 UTC (permalink / raw)
  To: linuxppc-dev

Without -msoft-float, floating point state saving code can be executed
(at least with certain buggy versions of GCC, which don't clear bit 6 of
CR before calling a varargs function with no varargs parameters).

Without the assembler target option, the assembler will use the old
dedicated mftb/mftbu instructions, rather than mfspr.  This causes the
boot to hang on e500, which doesn't have the dedicated instructions.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
Oops, I accidentally had -msoft-float in there twice for the bootwrapper
(once from PLATFORM_CFLAGS, and once directly specified).  This fixes it.

 arch/powerpc/Makefile      |   10 +++++++---
 arch/powerpc/boot/Makefile |    6 ++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a00fe72..8e93565 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -69,7 +69,7 @@ CFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc
 CFLAGS-$(CONFIG_PPC32)	:= -Iarch/$(ARCH) -ffixed-r2 -mmultiple
 CPPFLAGS	+= $(CPPFLAGS-y)
 AFLAGS		+= $(AFLAGS-y)
-CFLAGS		+= -msoft-float -pipe $(CFLAGS-y)
+CFLAGS		+= -pipe $(CFLAGS-y)
 CPP		= $(CC) -E $(CFLAGS)
 # Temporary hack until we have migrated to asm-powerpc
 LINUXINCLUDE-$(CONFIG_PPC32)	:= -Iarch/$(ARCH)/include
@@ -116,8 +116,12 @@ cpu-as-$(CONFIG_POWER4)		+= -Wa,-maltive
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
-AFLAGS += $(cpu-as-y)
-CFLAGS += $(cpu-as-y)
+PLATFORM_AFLAGS += $(cpu-as-y)
+PLATFORM_CFLAGS += $(cpu-as-y) -msoft-float
+export PLATFORM_AFLAGS PLATFORM_CFLAGS
+
+AFLAGS += $(PLATFORM_AFLAGS)
+CFLAGS += $(PLATFORM_CFLAGS)
 
 head-y				:= arch/powerpc/kernel/head_32.o
 head-$(CONFIG_PPC64)		:= arch/powerpc/kernel/head_64.o
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 98392fb..df92f06 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -24,8 +24,10 @@ all: $(obj)/zImage
 
 HOSTCC		:= gcc
 BOOTCFLAGS	:= $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \
-		   $(shell $(CROSS32CC) -print-file-name=include) -fPIC
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
+		   $(shell $(CROSS32CC) -print-file-name=include) -fPIC \
+		   $(PLATFORM_CFLAGS)
+BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc \
+		   $(PLATFORM_AFLAGS)
 
 ifeq ($(call cc-option-yn, -fstack-protector),y)
 BOOTCFLAGS	+= -fno-stack-protector
-- 
1.4.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options.
  2007-01-29 20:11 ` [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options Scott Wood
  2007-01-29 20:40   ` Scott Wood
@ 2007-01-30 19:42   ` Segher Boessenkool
  1 sibling, 0 replies; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:42 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> Without -msoft-float, floating point state saving code can be executed
> (at least with certain buggy versions of GCC, which don't clear bit  
> 6 of
> CR before calling a varargs function with no varargs parameters).

Even: without -msoft-float, GCC is allowed to use any
floating-point resources it wants (whether you like that
or not, and/or think it is a bug in GCC, is moot).

> Without the assembler target option, the assembler will use the old
> dedicated mftb/mftbu instructions, rather than mfspr.  This causes the
> boot to hang on e500, which doesn't have the dedicated instructions.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>

Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 04/18] bootwrapper: Add ft_root_node().
  2007-01-29 20:11 ` [PATCH 04/18] bootwrapper: Add ft_root_node() Scott Wood
@ 2007-01-30 19:44   ` Segher Boessenkool
  0 siblings, 0 replies; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:44 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> Clean up some of the open-coded data structure references by  
> providing a
> function to return a pointer to the first node in the tree.  This  
> is only

Nit: s/first node/root node/

> used in high-level functions trying to access the beginning of the  
> tree,
> not in low-level code that is actually manipulating the data  
> structure.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>

Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL.
  2007-01-29 20:12 ` [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL Scott Wood
@ 2007-01-30 19:48   ` Segher Boessenkool
  2007-01-30 19:51     ` Scott Wood
  0 siblings, 1 reply; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:48 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> Currently, if ft_get_phandle() is passed NULL it will allocate an  
> entry
> for it and return a non-NULL phandle.  This patch makes it simply pass
> the NULL through.

Seems like an obvious bug fix to me -- I assume you
audited all callers?  Although I can't imagine
anything relying on such weird behaviour ;-)

> Signed-off-by: Scott Wood <scottwood@freescale.com>

Acked-by: Segher Boessenkool <segher@kernel.crashing.org>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle().
  2007-01-29 20:12 ` [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle() Scott Wood
@ 2007-01-30 19:49   ` Segher Boessenkool
  0 siblings, 0 replies; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:49 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> Move the caller's pointer back to match the change in the region's  
> start,
> rather than alter a byte of the device tree's content.

Maybe you could change the variable names too, so it
would be harder to make such obvious coding mistakes?

> -		*p -= nextra;
> +		*pp -= nextra;


Segher

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL.
  2007-01-30 19:48   ` Segher Boessenkool
@ 2007-01-30 19:51     ` Scott Wood
  0 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-30 19:51 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Segher Boessenkool wrote:
>> Currently, if ft_get_phandle() is passed NULL it will allocate an  entry
>> for it and return a non-NULL phandle.  This patch makes it simply pass
>> the NULL through.
> 
> 
> Seems like an obvious bug fix to me -- I assume you
> audited all callers?  Although I can't imagine
> anything relying on such weird behaviour ;-)

The only caller that existed before my patches was ft_find_device(), 
which was only used to implement dt_ops.finddevice().

-Scott

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 10/18] bootwrapper: Add ft_find_device_rel().
  2007-01-29 20:12 ` [PATCH 10/18] bootwrapper: Add ft_find_device_rel() Scott Wood
@ 2007-01-30 19:53   ` Segher Boessenkool
  2007-01-30 20:25     ` Scott Wood
  0 siblings, 1 reply; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:53 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> +void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
> +                         const char *srch_path)
> +{
> +	char *node;
> +
> +	node = ft_node_ph2node(cxt, top);

Huh -- are phandles a pointer?  Why not just a u32?
Or is _your_ code buggy ;-)  [No it's not, I checked]


Segher

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level.
  2007-01-29 20:12 ` [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level Scott Wood
@ 2007-01-30 19:56   ` Segher Boessenkool
  2007-01-30 20:39     ` Scott Wood
  0 siblings, 1 reply; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:56 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> It also now returns NULL as the parent of the toplevel node, rather  
> than
> just returning the toplevel node again (which made it rather  
> useless in
> loops).

Great, that's how "real" OF handles this as well.  In
a similar vein, peer(0) should return the root node --
does it?


Segher

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 13/18] bootwrapper: Add ft_find_prop().
  2007-01-29 20:13 ` [PATCH 13/18] bootwrapper: Add ft_find_prop() Scott Wood
@ 2007-01-30 19:57   ` Segher Boessenkool
  0 siblings, 0 replies; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 19:57 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> ft_find_prop() finds nodes with the specified property/value pair.

Please invent a better name for this (find_prop_with_name_and_value()
or such?)


Segher

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 16/18] bootwrapper: Add dt_ops methods.
  2007-01-29 20:13 ` [PATCH 16/18] bootwrapper: Add dt_ops methods Scott Wood
@ 2007-01-30 20:01   ` Segher Boessenkool
  2007-01-31  7:02     ` David Gibson
  0 siblings, 1 reply; 30+ messages in thread
From: Segher Boessenkool @ 2007-01-30 20:01 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

> +static void *ft_finddevice_rel(const void *phandle, const char *name)
> +{
> +	return ft_find_device_rel(&cxt, phandle, name);
> +}

Seeing all these...  wouldn't it be better to make "cxt"
an implicit parameter to all the ft_ functions?  It's not
like you'll ever be dealing with more than one tree ;-)


Segher

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 10/18] bootwrapper: Add ft_find_device_rel().
  2007-01-30 19:53   ` Segher Boessenkool
@ 2007-01-30 20:25     ` Scott Wood
  0 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-30 20:25 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Segher Boessenkool wrote:
>> +void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
>> +                         const char *srch_path)
>> +{
>> +    char *node;
>> +
>> +    node = ft_node_ph2node(cxt, top);
> 
> 
> Huh -- are phandles a pointer?  Why not just a u32?

I can't speak for whoever designed the interface, but I'd rather keep it 
as a pointer -- it provides more flexibility to the implementation.  For 
example, if the device tree were to be maintained as a normal 
pointer-based tree, and flattened only when finalize() is called, then a 
pointer would be a natural handle to export (which wouldn't fit into a 
u32 on 64-bit platforms, unless you make assumptions about where 
bootwrapper data is located).

The downside, of course, is that it's easier to get phandles and 
internal pointers mixed up.

-Scott

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level.
  2007-01-30 19:56   ` Segher Boessenkool
@ 2007-01-30 20:39     ` Scott Wood
  0 siblings, 0 replies; 30+ messages in thread
From: Scott Wood @ 2007-01-30 20:39 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Segher Boessenkool wrote:
>> It also now returns NULL as the parent of the toplevel node, rather  than
>> just returning the toplevel node again (which made it rather  useless in
>> loops).
> 
> 
> Great, that's how "real" OF handles this as well.  In
> a similar vein, peer(0) should return the root node --
> does it?

I don't see any peer() function in the bootwrapper...

-Scott

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 16/18] bootwrapper: Add dt_ops methods.
  2007-01-30 20:01   ` Segher Boessenkool
@ 2007-01-31  7:02     ` David Gibson
  0 siblings, 0 replies; 30+ messages in thread
From: David Gibson @ 2007-01-31  7:02 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

On Tue, Jan 30, 2007 at 09:01:17PM +0100, Segher Boessenkool wrote:
> > +static void *ft_finddevice_rel(const void *phandle, const char *name)
> > +{
> > +	return ft_find_device_rel(&cxt, phandle, name);
> > +}
> 
> Seeing all these...  wouldn't it be better to make "cxt"
> an implicit parameter to all the ft_ functions?  It's not
> like you'll ever be dealing with more than one tree ;-)

Not necessarily true.  I'm contemplating some wrapper setups that
would involve selecting from one of several possible pre-built trees
depending on some id from the firmware.  Or even grafting several
trees together.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2007-01-31  7:02 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
2007-01-29 20:11 ` [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options Scott Wood
2007-01-29 20:40   ` Scott Wood
2007-01-30 19:42   ` Segher Boessenkool
2007-01-29 20:11 ` [PATCH 03/18] bootwrapper: Remove OF-isms Scott Wood
2007-01-29 20:11 ` [PATCH 04/18] bootwrapper: Add ft_root_node() Scott Wood
2007-01-30 19:44   ` Segher Boessenkool
2007-01-29 20:11 ` [PATCH 05/18] bootwrapper: Rename ft_node_add() to ft_get_phandle() Scott Wood
2007-01-29 20:12 ` [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL Scott Wood
2007-01-30 19:48   ` Segher Boessenkool
2007-01-30 19:51     ` Scott Wood
2007-01-29 20:12 ` [PATCH 07/18] bootwrapper: Preserve the pp pointer in ft_make_space() when calling ft_reorder() Scott Wood
2007-01-29 20:12 ` [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle() Scott Wood
2007-01-30 19:49   ` Segher Boessenkool
2007-01-29 20:12 ` [PATCH 09/18] bootwrapper: Use map_string() instead of lookup_string() in ft_prop() Scott Wood
2007-01-29 20:12 ` [PATCH 10/18] bootwrapper: Add ft_find_device_rel() Scott Wood
2007-01-30 19:53   ` Segher Boessenkool
2007-01-30 20:25     ` Scott Wood
2007-01-29 20:12 ` [PATCH 11/18] bootwrapper: Refactor ft_get_prop() into internal and external functions Scott Wood
2007-01-29 20:12 ` [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level Scott Wood
2007-01-30 19:56   ` Segher Boessenkool
2007-01-30 20:39     ` Scott Wood
2007-01-29 20:13 ` [PATCH 13/18] bootwrapper: Add ft_find_prop() Scott Wood
2007-01-30 19:57   ` Segher Boessenkool
2007-01-29 20:13 ` [PATCH 14/18] bootwrapper: Add initrd information to the device tree in ft_finalize() Scott Wood
2007-01-29 20:13 ` [PATCH 15/18] bootwrapper: Make ft_create_node() pay attention to the parent parameter Scott Wood
2007-01-29 20:13 ` [PATCH 16/18] bootwrapper: Add dt_ops methods Scott Wood
2007-01-30 20:01   ` Segher Boessenkool
2007-01-31  7:02     ` David Gibson
2007-01-29 20:13 ` [PATCH 17/18] bootwrapper: Add xlate_reg(), and use it to find serial registers Scott Wood
2007-01-29 20:13 ` [PATCH 18/18] bootwrapper: Compatibility layer for old U-Boots (a.k.a. cuImage, cuboot) Scott Wood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.