]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/powerpc/boot/flatdevtree_misc.c
c7f9adbf827d071077ddb487df7826ffacf7e811
[linux-2.6-omap-h63xx.git] / arch / powerpc / boot / flatdevtree_misc.c
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
17 static struct ft_cxt cxt;
18
19 static void *ft_finddevice(const char *name)
20 {
21         return ft_find_device(&cxt, name);
22 }
23
24 static 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
30 static 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
36 static void ft_pack(void)
37 {
38         ft_end_tree(&cxt);
39 }
40
41 static unsigned long ft_addr(void)
42 {
43         return (unsigned long)cxt.bph;
44 }
45
46 int 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 }