Merge libfdt into the bootwrapper
Subsystems (2)
cover Merge libfdt into the bootwrapper
Since there's still argument about what to do with dtc w.r.t. the kernel, for now here's a cut down series which merges libfdt into the powerpc bootwrapper.
Signature · 4 lines
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
PATCH 1/3 Merge libfdt upstream source
This large patch incorporates a copy of dtc libfdt into the kernel source, in arch/powerpc/boot/libfdt. This patch only imports the upstream sources verbatim, later patches are needed to actually link it into the kernel Makefiles.
--- arch/powerpc/boot/libfdt/Makefile.libfdt | 14 10 files changed, 2568 insertions(+)
--- arch/powerpc/boot/libfdt/Makefile.libfdt | 14 arch/powerpc/boot/libfdt/fdt.c | 156 ++++++ arch/powerpc/boot/libfdt/fdt.h | 60 ++ arch/powerpc/boot/libfdt/fdt_ro.c | 583 +++++++++++++++++++++++ arch/powerpc/boot/libfdt/fdt_rw.c | 447 +++++++++++++++++ arch/powerpc/boot/libfdt/fdt_strerror.c | 96 +++ arch/powerpc/boot/libfdt/fdt_sw.c | 258 ++++++++++ arch/powerpc/boot/libfdt/fdt_wip.c | 144 +++++ arch/powerpc/boot/libfdt/libfdt.h | 721 +++++++++++++++++++++++++++++ arch/powerpc/boot/libfdt/libfdt_internal.h | 89 +++ 10 files changed, 2568 insertions(+)
arch/powerpc/boot/libfdt/Makefile.libfdt new file +14 -0
@@ -0,0 +1,14 @@ +# Makefile.libfdt +# +# This is not a complete Makefile of itself. Instead, it is designed to +# be easily embeddable into other systems of Makefiles. +# +LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c +LIBFDT_INCLUDES = fdt.h libfdt.h +LIBFDT_EXTRA = libfdt_internal.h +LIBFDT_LIB = libfdt/libfdt.a + +LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) + +$(LIBFDT_objdir)/$(LIBFDT_LIB): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) +
arch/powerpc/boot/libfdt/fdt.c new file +156 -0
156 lines not on this page · raw message
arch/powerpc/boot/libfdt/fdt.h new file +60 -0
60 lines not on this page · raw message
arch/powerpc/boot/libfdt/fdt_ro.c new file +583 -0
583 lines not on this page · raw message
arch/powerpc/boot/libfdt/fdt_rw.c new file +447 -0
447 lines not on this page · raw message
arch/powerpc/boot/libfdt/fdt_strerror.c new file +96 -0
96 lines not on this page · raw message
arch/powerpc/boot/libfdt/fdt_sw.c new file +258 -0
258 lines not on this page · raw message
arch/powerpc/boot/libfdt/fdt_wip.c new file +144 -0
144 lines not on this page · raw message
arch/powerpc/boot/libfdt/libfdt.h new file +721 -0
721 lines not on this page · raw message
arch/powerpc/boot/libfdt/libfdt_internal.h new file +89 -0
89 lines not on this page · raw message
PATCH 2/3 Use embedded libfdt in the bootwrapper
In reply to David GibsonThis patch incorporates libfdt (from the source embedded in an earlier patch) into the wrapper.a library used by the bootwrapper. This includes adding a libfdt_env.h file, which the libfdt sources need in order to integrate into the bootwrapper environment, and a libfdt-wrapper.c which provides glue to connect the bootwrapper's abstract device tree callbacks to the libfdt functions.
In addition, this patch changes the various wrapper and platform files to use libfdt functions instead of the older flatdevtree.c library.
--- arch/powerpc/boot/Makefile | 6 - arch/powerpc/boot/bamboo.c | 2 arch/powerpc/boot/cuboot-52xx.c | 2 arch/powerpc/boot/cuboot-83xx.c | 2 arch/powerpc/boot/cuboot-85xx.c | 2 arch/powerpc/boot/cuboot-8xx.c | 2 arch/powerpc/boot/cuboot-hpc2.c | 2 arch/powerpc/boot/cuboot-pq2.c | 2 arch/powerpc/boot/cuboot-sequoia.c | 2 arch/powerpc/boot/ebony.c | 2 arch/powerpc/boot/ep88xc.c | 2 arch/powerpc/boot/holly.c | 2 arch/powerpc/boot/libfdt-wrapper.c | 182 ++++++++++++++++++++++++++++++++++++ arch/powerpc/boot/libfdt_env.h | 17 +++ arch/powerpc/boot/ops.h | 1 arch/powerpc/boot/prpmc2800.c | 3 arch/powerpc/boot/ps3.c | 2 arch/powerpc/boot/treeboot-walnut.c | 2 18 files changed, 219 insertions(+), 16 deletions(-)
arch/powerpc/boot/Makefile +5 -1
@@ -33,7 +33,7 @@ ifeq ($(call cc-option-yn, -fstack-prote BOOTCFLAGS += -fno-stack-protector endif -BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) +BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) -I$(srctree)/$(src)/libfdt $(obj)/4xx.o: BOOTCFLAGS += -mcpu=440 $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
@@ -46,7 +46,9 @@ zliblinuxheader := zlib.h zconf.h zutil. $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) +src-libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ + $(addprefix libfdt/,$(src-libfdt)) libfdt-wrapper.c \ ns16550.c serial.c simple_alloc.c div64.S util.S \ gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
@@ -101,8 +103,10 @@ quiet_cmd_bootar = BOOTAR $@ cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE + $(Q)mkdir -p $(dir $@) $(call if_changed_dep,bootcc) $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE + $(Q)mkdir -p $(dir $@) $(call if_changed_dep,bootas) $(obj)/wrapper.a: $(obj-wlib) FORCE
arch/powerpc/boot/libfdt_env.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef _ARCH_POWERPC_BOOT_LIBFDT_ENV_H +#define _ARCH_POWERPC_BOOT_LIBFDT_ENV_H + +#include <types.h> +#include <string.h> + +typedef u32 uint32_t ; +typedef u64 uint64_t ; + +#define fdt16_to_cpu (x) (x) +#define cpu_to_fdt16 (x) (x) +#define fdt32_to_cpu (x) (x) +#define cpu_to_fdt32 (x) (x) +#define fdt64_to_cpu (x) (x) +#define cpu_to_fdt64 (x) (x) + +#endif /* _ARCH_POWERPC_BOOT_LIBFDT_ENV_H */
arch/powerpc/boot/bamboo.c +1 -1
@@ -42,6 +42,6 @@ void bamboo_init(void *mac0, void *mac1) platform_ops.exit = ibm44x_dbcr_reset; bamboo_mac0 = mac0; bamboo_mac1 = mac1; -ft_init (_dtb_start,0 ,32 ); +fdt_init (_dtb_start);serial_console_init (); }
arch/powerpc/boot/cuboot-52xx.c +1 -1
@@ -53,7 +53,7 @@ void platform_init(unsigned long r3, uns unsigned long r6, unsigned long r7) {CUBOOT_INIT (); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); platform_ops.fixups = platform_fixups; }
arch/powerpc/boot/cuboot-83xx.c +1 -1
@@ -52,7 +52,7 @@ void platform_init(unsigned long r3, uns unsigned long r6, unsigned long r7) {CUBOOT_INIT (); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); platform_ops.fixups = platform_fixups; }
arch/powerpc/boot/cuboot-85xx.c +1 -1
@@ -53,7 +53,7 @@ void platform_init(unsigned long r3, uns unsigned long r6, unsigned long r7) {CUBOOT_INIT (); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); platform_ops.fixups = platform_fixups; }
arch/powerpc/boot/cuboot-8xx.c +1 -1
@@ -41,7 +41,7 @@ void platform_init(unsigned long r3, uns unsigned long r6, unsigned long r7) {CUBOOT_INIT (); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); platform_ops.fixups = platform_fixups; }
arch/powerpc/boot/cuboot-hpc2.c +1 -1
@@ -42,7 +42,7 @@ void platform_init(unsigned long r3, uns unsigned long r6, unsigned long r7) {CUBOOT_INIT (); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); platform_ops.fixups = platform_fixups; }
arch/powerpc/boot/cuboot-pq2.c +1 -1
@@ -255,7 +255,7 @@ void platform_init(unsigned long r3, uns unsigned long r6, unsigned long r7) {CUBOOT_INIT (); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); platform_ops.fixups = pq2_platform_fixups; }
arch/powerpc/boot/cuboot-sequoia.c +1 -1
@@ -51,6 +51,6 @@ void platform_init(unsigned long r3, unsCUBOOT_INIT (); platform_ops.fixups = sequoia_fixups; platform_ops.exit = ibm44x_dbcr_reset; -ft_init (_dtb_start,0 ,32 ); +fdt_init (_dtb_start);serial_console_init (); }
arch/powerpc/boot/ebony.c +1 -1
@@ -146,6 +146,6 @@ void ebony_init(void *mac0, void *mac1) platform_ops.exit = ibm44x_dbcr_reset; ebony_mac0 = mac0; ebony_mac1 = mac1; -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); }
arch/powerpc/boot/ep88xc.c +1 -1
@@ -45,7 +45,7 @@ void platform_init(unsigned long r3, uns mem_size *=1024 *1024 ;simple_alloc_init (_end, mem_size - (unsigned long )_end,32 ,64 ); -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);planetcore_set_stdout_path (table);
arch/powerpc/boot/holly.c +1 -1
@@ -28,6 +28,6 @@ void platform_init(unsigned long r3, unsu32 heapsize =0x8000000 - (u32 )_end;/* 128M */ simple_alloc_init (_end, heapsize,32 ,64 ); -ft_init (_dtb_start,0 ,4 ); +fdt_init (_dtb_start);serial_console_init (); }
arch/powerpc/boot/libfdt-wrapper.c new file +182 -0
182 lines not on this page · raw message
arch/powerpc/boot/ops.h +1 -0
@@ -80,6 +80,7 @@ extern struct loader_info loader_info;void start (void );int ft_init (void *dt_blob,unsigned int max_size,unsigned int max_find_device); +void fdt_init (void *blob);int serial_console_init (void );int ns16550_console_init (void *devp,struct serial_console_data *scdp);int mpsc_console_init (void *devp,struct serial_console_data *scdp);
arch/powerpc/boot/prpmc2800.c +1 -2
@@ -547,8 +547,7 @@ void platform_init(unsigned long r3, unsif (!dtb)exit ();memmove (dtb, _dtb_start, dt_size); -if (ft_init (dtb, dt_size,16 )) -exit (); +fdt_init (dtb); bridge_base =mv64x60_get_bridge_base ();
arch/powerpc/boot/ps3.c +1 -1
@@ -131,7 +131,7 @@ void platform_init(void)printf ("\n-- PS3 bootwrapper --\n" );simple_alloc_init (_end, heapsize,32 ,64 ); -ft_init (_dtb_start,0 ,4 ); +fdt_init (_dtb_start); chosen =finddevice ("/chosen" );
arch/powerpc/boot/treeboot-walnut.c +1 -1
@@ -128,6 +128,6 @@ void platform_init(void)simple_alloc_init (_end, avail_ram,32 ,32 ); platform_ops.fixups = walnut_fixups; platform_ops.exit = ibm40x_dbcr_reset; -ft_init (_dtb_start, _dtb_end - _dtb_start,32 ); +fdt_init (_dtb_start);serial_console_init (); }
Re: [PATCH 2/3] Use embedded libfdt in the bootwrapper
Quoted 7 lines · David Gibson
arch/powerpc/boot/libfdt-wrapper.c new file +7
-0+#define check_err (err) \ + ({ \ + if (BAD_ERROR(err) || ((err < 0) && DEBUG)) \ + printf("%s():%d %s\n\r", __FUNCTION__, __LINE__, \ + fdt_strerror(err)); \ + if (BAD_ERROR(err)) \ + exit(); \
arch/powerpc/boot/libfdt-wrapper.c line 51
Quoted 10 lines
arch/powerpc/boot/libfdt-wrapper.c new file +10
-0+ (err <0 ) ?-1 :0 ; \ + }) + +#define offset_devp (off) \ + ({ \ + int offset = (off); \ + check_err(offset) ? NULL : (void *)(offset+1); \ + }) + +#define devp_offset (devp) (((int)(devp))-1)
How does using offsets as devps work if a devp was previously acquired to a node that has to be moved due to a change later made in an earlier part of the tree?
-Scott
Re: [PATCH 2/3] Use embedded libfdt in the bootwrapper
Quoted 14 lines · Scott Wood
Quoted 13 lines · David Gibson
arch/powerpc/boot/libfdt-wrapper.c new file +13
-0+#define check_err (err) \ + ({ \ + if (BAD_ERROR(err) || ((err < 0) && DEBUG)) \ + printf("%s():%d %s\n\r", __FUNCTION__, __LINE__, \ + fdt_strerror(err)); \ + if (BAD_ERROR(err)) \ + exit(); \ + (err < 0) ? -1 : 0; \ + }) + +#define offset_devp (off) \ + ({ \ + int offset = (off); \
Quoted 8 lines
arch/powerpc/boot/libfdt-wrapper.c line 51
Quoted 4 lines
arch/powerpc/boot/libfdt-wrapper.c new file +4
-0+check_err (offset) ?NULL : (void *)(offset+1 ); \ + }) + +#define devp_offset (devp) (((int)(devp))-1)How does using offsets as devps work if a devp was previously acquired to a node that has to be moved due to a change later made in an earlier part of the tree?
It doesn't; don't do that. I just don't think truly persistent phandles are worth the code complexity to implement them. Especially since their use more-or-less completely precludes libfdt's "stateless" approach, which has significant other advantages.
To reduce the confusion over this, the libfdt native interface always refers to the offsets explicitly as offsets. For the bootwrapper abstraction layer, unfortunately I'm stuck with the "devp" terminology for the time being.
Signature · 4 lines
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
Re: [PATCH 2/3] Use embedded libfdt in the bootwrapper
Quoted 6 lines · David Gibson
Quoted 3 lines · Scott Wood
How does using offsets as devps work if a devp was previously acquired to a node that has to be moved due to a change later made in an earlier part of the tree?
It doesn't; don't do that. I just don't think truly persistent phandles are worth the code complexity to implement them.
We already have working code to implement them. This is a regression over flatdevicetree.c, and it (or something else in libfdt) seems to be breaking the ep8248e wrapper (it didn't make it in to the last window because of dependency on a netdev patch, but I'll probably send it out tomorrow).
It breaks the extremely common and useful usage of:
devp = create node;setprop(devp, "foo", something);setprop(devp, "bar", something);
Quoted 2 lines
Especially since their use more-or-less completely precludes libfdt's "stateless" approach, which has significant other advantages.
It doesn't preclude stateless read-only -- what are the benefits to stateless read-write that are worth invalidating all node references any time something changes?
-Scott
Re: [PATCH 2/3] Use embedded libfdt in the bootwrapper
Quoted 7 lines · Scott Wood
Quoted 6 lines · David Gibson
Quoted 3 lines · Scott Wood
How does using offsets as devps work if a devp was previously acquired to a node that has to be moved due to a change later made in an earlier part of the tree?
It doesn't; don't do that. I just don't think truly persistent phandles are worth the code complexity to implement them.
[snip]
Quoted 5 lines
It breaks the extremely common and useful usage of:
devp = create node;
setprop(devp, "foo", something);setprop(devp, "bar", something);
BTW, there's code in devtree.c with your name on it that does exactly this. :-)
-Scott
Re: [PATCH 2/3] Use embedded libfdt in the bootwrapper
In reply to Scott WoodQuoted 15 lines · Scott Wood
Quoted 7 lines · David Gibson
Quoted 3 lines · Scott Wood
How does using offsets as devps work if a devp was previously acquired to a node that has to be moved due to a change later made in an earlier part of the tree?
It doesn't; don't do that. I just don't think truly persistent phandles are worth the code complexity to implement them.
We already have working code to implement them. This is a regression over
flatdevicetree.c, and it (or something else in libfdt) seems to be breaking the ep8248e wrapper (it didn't make it in to the last window because of dependency on a netdev patch, but I'll probably send it out tomorrow).
Quoted 5 lines
It breaks the extremely common and useful usage of:
devp = create node;
setprop(devp, "foo", something);setprop(devp, "bar", something);
Uh.. no, that idiom is fine. setprop() in the node itself, or any descendent is guaranteed to be safe.
Quoted 7 lines
Quoted 3 lines
Especially since their use more-or-less completely precludes libfdt's "stateless" approach, which has significant other advantages.
It doesn't preclude stateless read-only -- what are the benefits to stateless read-write that are worth invalidating all node references any time something changes?
It precludes stateless read-only too, unless you have an interface where devps for read-write are different from those for read-only which would be nasty.
Signature · 4 lines
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
PATCH 3/3 Kill flatdevtree.c
In reply to David GibsonNow that earlier patches have switched the bootwrapper to using libfdt for device tree manipulation, this patch removes the now unused flatdevtree.c and related files.
--- arch/powerpc/boot/Makefile | 2 arch/powerpc/boot/flatdevtree.c | 1036 ----------------------------------- arch/powerpc/boot/flatdevtree.h | 113 --- arch/powerpc/boot/flatdevtree_misc.c | 79 -- arch/powerpc/boot/main.c | 1 arch/powerpc/boot/ops.h | 1 6 files changed, 1 insertion(+), 1231 deletions(-)
arch/powerpc/boot/Makefile +1 -1
@@ -47,7 +47,7 @@ $(addprefix $(obj)/,$(zlib) gunzip_util. $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) src-libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c -src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ +src-wlib := string.S crt0.S stdio.c main.c \ $(addprefix libfdt/,$(src-libfdt)) libfdt-wrapper.c \ ns16550.c serial.c simple_alloc.c div64.S util.S \ gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
arch/powerpc/boot/flatdevtree.c deleted +0 -1036
1,036 lines not on this page · raw message
arch/powerpc/boot/flatdevtree.h deleted +0 -113
113 lines not on this page · raw message
arch/powerpc/boot/flatdevtree_misc.c deleted +0 -79
79 lines not on this page · raw message
arch/powerpc/boot/main.c +0 -1
@@ -16,7 +16,6 @@#include "stdio.h" #include "ops.h" #include "gunzip_util.h" -#include "flatdevtree.h" #include "reg.h" static struct gunzip_state gzstate;
arch/powerpc/boot/ops.h +0 -1
@@ -79,7 +79,6 @@ struct loader_info {extern struct loader_info loader_info;void start (void ); -int ft_init (void *dt_blob,unsigned int max_size,unsigned int max_find_device);void fdt_init (void *blob);int serial_console_init (void );int ns16550_console_init (void *devp,struct serial_console_data *scdp);