From 6fb4efc68f5c0e095153510dcfa8b54a42e914ba Mon Sep 17 00:00:00 2001 From: "Mark A. Greer" Date: Mon, 16 Oct 2006 13:50:05 -0700 Subject: [POWERPC] Add flatdevtree source Add the latest version of the flatdevtree code and corresponding glue. A phandle table now tracks values returned by ft_find_device(). The value returned by ft_find_device() is a phandle which is really an index into the phandle table. The phandle table contains the address of the corresponding node. When the flat dt is edited/moved, the node pointers in the phandle table are updated accordingly so no phandles kept by the caller become stale. Signed-off-by: Mark A. Greer Signed-off-by: Paul Mackerras --- arch/powerpc/boot/flatdevtree_misc.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 arch/powerpc/boot/flatdevtree_misc.c (limited to 'arch/powerpc/boot/flatdevtree_misc.c') diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c new file mode 100644 index 00000000000..c7f9adbf827 --- /dev/null +++ b/arch/powerpc/boot/flatdevtree_misc.c @@ -0,0 +1,56 @@ +/* + * This file does the necessary interface mapping between the bootwrapper + * device tree operations and the interface provided by shared source + * files flatdevicetree.[ch]. + * + * Author: Mark A. Greer + * + * 2006 (c) MontaVista Software, Inc. This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. + */ +#include +#include "flatdevtree.h" +#include "ops.h" + +static struct ft_cxt cxt; + +static void *ft_finddevice(const char *name) +{ + return ft_find_device(&cxt, name); +} + +static int ft_getprop(const void *phandle, const char *propname, void *buf, + const int buflen) +{ + return ft_get_prop(&cxt, phandle, propname, buf, buflen); +} + +static int ft_setprop(const void *phandle, const char *propname, + const void *buf, const int buflen) +{ + return ft_set_prop(&cxt, phandle, propname, buf, buflen); +} + +static void ft_pack(void) +{ + ft_end_tree(&cxt); +} + +static unsigned long ft_addr(void) +{ + return (unsigned long)cxt.bph; +} + +int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device) +{ + dt_ops.finddevice = ft_finddevice; + dt_ops.getprop = ft_getprop; + dt_ops.setprop = ft_setprop; + dt_ops.ft_pack = ft_pack; + dt_ops.ft_addr = ft_addr; + + return ft_open(&cxt, dt_blob, max_size, max_find_device, + platform_ops.realloc); +} -- cgit v1.2.3 From 35af89eb491a0741005e474626053266e6e635b7 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 21 Nov 2006 11:37:37 +1100 Subject: [POWERPC] Cleanup zImage handling of kernel entry with flat device tree This makes 2 changes to clean up the flat device tree handling logic in the zImage wrapper. First, there were two callbacks from the dt_ops structure used for producing a final flat tree to pass to the kerne: dt_ops.ft_pack() which packed the flat tree (possibly a no-op) and dt_ops.ft_addr() which retreived the address of the final blob. Since they were only ever called together, this patch combines the two into a single new callback, dt_ops.finalize(). This new callback does whatever platform-dependent things are necessary to produce a final flat device tree blob, and returns the blob's addres. Second, the current logic calls the kernel with a flat device tree if one is build into the zImage wrapper, otherwise it boots the kernel with a PROM pointer, expecting the kernel to copy the OF device tree itself. This approach precludes the possibility of the platform wrapper code building a flat device tree from whatever platform-specific information firmware provides. Thus, this patch takes the more sensible approach of invoking the kernel with a flat tree if the dt_ops.finalize callback provides one (by whatever means). So, the dt_ops.finalize callback can be NULL, or can be a function which returns NULL. In either case, the zImage wrapper logic assumes that this is a platform with OF and invokes the kernel accordingly. Signed-off-by: David Gibson Signed-off-by: Paul Mackerras --- arch/powerpc/boot/flatdevtree_misc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'arch/powerpc/boot/flatdevtree_misc.c') diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c index c7f9adbf827..04da38fa477 100644 --- a/arch/powerpc/boot/flatdevtree_misc.c +++ b/arch/powerpc/boot/flatdevtree_misc.c @@ -33,13 +33,9 @@ static int ft_setprop(const void *phandle, const char *propname, return ft_set_prop(&cxt, phandle, propname, buf, buflen); } -static void ft_pack(void) +static unsigned long ft_finalize(void) { ft_end_tree(&cxt); -} - -static unsigned long ft_addr(void) -{ return (unsigned long)cxt.bph; } @@ -48,8 +44,7 @@ int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device) dt_ops.finddevice = ft_finddevice; dt_ops.getprop = ft_getprop; dt_ops.setprop = ft_setprop; - dt_ops.ft_pack = ft_pack; - dt_ops.ft_addr = ft_addr; + dt_ops.finalize = ft_finalize; return ft_open(&cxt, dt_blob, max_size, max_find_device, platform_ops.realloc); -- cgit v1.2.3