ft_build.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * OF Flat tree builder
  3. *
  4. */
  5. #ifndef FT_BUILD_H
  6. #define FT_BUILD_H
  7. #include <linux/types.h>
  8. #include <asm/u-boot.h>
  9. /* Definitions used by the flattened device tree */
  10. #define OF_DT_HEADER 0xd00dfeed /* marker */
  11. #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
  12. #define OF_DT_END_NODE 0x2 /* End node */
  13. #define OF_DT_PROP 0x3 /* Property: name off, size,
  14. * content */
  15. #define OF_DT_NOP 0x4 /* nop */
  16. #define OF_DT_END 0x9
  17. #define OF_DT_VERSION 0x10
  18. struct boot_param_header {
  19. u32 magic; /* magic word OF_DT_HEADER */
  20. u32 totalsize; /* total size of DT block */
  21. u32 off_dt_struct; /* offset to structure */
  22. u32 off_dt_strings; /* offset to strings */
  23. u32 off_mem_rsvmap; /* offset to memory reserve map */
  24. u32 version; /* format version */
  25. u32 last_comp_version; /* last compatible version */
  26. /* version 2 fields below */
  27. u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
  28. /* version 3 fields below */
  29. u32 dt_strings_size; /* size of the DT strings block */
  30. };
  31. struct ft_cxt {
  32. struct boot_param_header *bph;
  33. int max_size; /* maximum size of tree */
  34. int overflow; /* set when this happens */
  35. u8 *p, *pstr, *pres; /* running pointers */
  36. u8 *p_begin, *pstr_begin, *pres_begin; /* starting pointers */
  37. u8 *p_anchor; /* start of constructed area */
  38. int struct_size, strings_size, res_size;
  39. };
  40. void ft_begin_node(struct ft_cxt *cxt, const char *name);
  41. void ft_end_node(struct ft_cxt *cxt);
  42. void ft_begin_tree(struct ft_cxt *cxt);
  43. int ft_end_tree(struct ft_cxt *cxt);
  44. void ft_nop(struct ft_cxt *cxt);
  45. void ft_prop(struct ft_cxt *cxt, const char *name, const void *data, int sz);
  46. void ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str);
  47. void ft_prop_int(struct ft_cxt *cxt, const char *name, int val);
  48. void ft_begin(struct ft_cxt *cxt, void *blob, int max_size);
  49. void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
  50. void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_end);
  51. void ft_dump_blob(const void *bphp);
  52. void ft_merge_blob(struct ft_cxt *cxt, void *blob);
  53. void *ft_get_prop(void *bphp, const char *propname, int *szp);
  54. void ft_board_setup(void *blob, bd_t *bd);
  55. #endif