Mark A. Greer | 6fb4efc | 2006-10-16 13:50:05 -0700 | [diff] [blame] | 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 | |
David Gibson | 35af89e | 2006-11-21 11:37:37 +1100 | [diff] [blame] | 36 | static unsigned long ft_finalize(void) |
Mark A. Greer | 6fb4efc | 2006-10-16 13:50:05 -0700 | [diff] [blame] | 37 | { |
| 38 | ft_end_tree(&cxt); |
Mark A. Greer | 6fb4efc | 2006-10-16 13:50:05 -0700 | [diff] [blame] | 39 | return (unsigned long)cxt.bph; |
| 40 | } |
| 41 | |
| 42 | int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device) |
| 43 | { |
| 44 | dt_ops.finddevice = ft_finddevice; |
| 45 | dt_ops.getprop = ft_getprop; |
| 46 | dt_ops.setprop = ft_setprop; |
David Gibson | 35af89e | 2006-11-21 11:37:37 +1100 | [diff] [blame] | 47 | dt_ops.finalize = ft_finalize; |
Mark A. Greer | 6fb4efc | 2006-10-16 13:50:05 -0700 | [diff] [blame] | 48 | |
| 49 | return ft_open(&cxt, dt_blob, max_size, max_find_device, |
| 50 | platform_ops.realloc); |
| 51 | } |