aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/boot/flatdevtree_misc.c
blob: 04da38fa477f541f020080348279c14e255267c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * 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 <mgreer@mvista.com>
 *
 * 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 <stddef.h>
#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 unsigned long ft_finalize(void)
{
	ft_end_tree(&cxt);
	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.finalize = ft_finalize;

	return ft_open(&cxt, dt_blob, max_size, max_find_device,
			platform_ops.realloc);
}