flatdevtree_misc.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. static struct ft_cxt cxt;
  17. static void *ft_finddevice(const char *name)
  18. {
  19. return ft_find_device(&cxt, name);
  20. }
  21. static int ft_getprop(const void *phandle, const char *propname, void *buf,
  22. const int buflen)
  23. {
  24. return ft_get_prop(&cxt, phandle, propname, buf, buflen);
  25. }
  26. static int ft_setprop(const void *phandle, const char *propname,
  27. const void *buf, const int buflen)
  28. {
  29. return ft_set_prop(&cxt, phandle, propname, buf, buflen);
  30. }
  31. static unsigned long ft_finalize(void)
  32. {
  33. ft_end_tree(&cxt);
  34. return (unsigned long)cxt.bph;
  35. }
  36. int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
  37. {
  38. dt_ops.finddevice = ft_finddevice;
  39. dt_ops.getprop = ft_getprop;
  40. dt_ops.setprop = ft_setprop;
  41. dt_ops.finalize = ft_finalize;
  42. return ft_open(&cxt, dt_blob, max_size, max_find_device,
  43. platform_ops.realloc);
  44. }