aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot/flatdevtree_misc.c
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@mvista.com>2006-10-16 16:50:05 -0400
committerPaul Mackerras <paulus@samba.org>2006-10-22 22:49:18 -0400
commit6fb4efc68f5c0e095153510dcfa8b54a42e914ba (patch)
tree2d03a14beb5ee4cc46e1d1b9f104e9d41b5e9d8e /arch/powerpc/boot/flatdevtree_misc.c
parentc888554bf95a5a0a6ac3e2389c6bf1e03e9480ba (diff)
[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 <mgreer@mvista.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/flatdevtree_misc.c')
-rw-r--r--arch/powerpc/boot/flatdevtree_misc.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
new file mode 100644
index 000000000000..c7f9adbf827d
--- /dev/null
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -0,0 +1,56 @@
1/*
2 * This file does the necessary interface mapping between the bootwrapper
3 * device tree operations and the interface provided by shared source
4 * files flatdevicetree.[ch].
5 *
6 * Author: Mark A. Greer <mgreer@mvista.com>
7 *
8 * 2006 (c) MontaVista Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13#include <stddef.h>
14#include "flatdevtree.h"
15#include "ops.h"
16
17static struct ft_cxt cxt;
18
19static void *ft_finddevice(const char *name)
20{
21 return ft_find_device(&cxt, name);
22}
23
24static int ft_getprop(const void *phandle, const char *propname, void *buf,
25 const int buflen)
26{
27 return ft_get_prop(&cxt, phandle, propname, buf, buflen);
28}
29
30static int ft_setprop(const void *phandle, const char *propname,
31 const void *buf, const int buflen)
32{
33 return ft_set_prop(&cxt, phandle, propname, buf, buflen);
34}
35
36static void ft_pack(void)
37{
38 ft_end_tree(&cxt);
39}
40
41static unsigned long ft_addr(void)
42{
43 return (unsigned long)cxt.bph;
44}
45
46int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
47{
48 dt_ops.finddevice = ft_finddevice;
49 dt_ops.getprop = ft_getprop;
50 dt_ops.setprop = ft_setprop;
51 dt_ops.ft_pack = ft_pack;
52 dt_ops.ft_addr = ft_addr;
53
54 return ft_open(&cxt, dt_blob, max_size, max_find_device,
55 platform_ops.realloc);
56}