flatdevtree_misc.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 void ft_pack(void)
  32. {
  33. ft_end_tree(&cxt);
  34. }
  35. static unsigned long ft_addr(void)
  36. {
  37. return (unsigned long)cxt.bph;
  38. }
  39. int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
  40. {
  41. dt_ops.finddevice = ft_finddevice;
  42. dt_ops.getprop = ft_getprop;
  43. dt_ops.setprop = ft_setprop;
  44. dt_ops.ft_pack = ft_pack;
  45. dt_ops.ft_addr = ft_addr;
  46. return ft_open(&cxt, dt_blob, max_size, max_find_device,
  47. platform_ops.realloc);
  48. }