Wolfgang Denk | 814d98f | 2005-10-13 01:59:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * OF Flat tree builder |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | #ifndef FT_BUILD_H |
| 7 | #define FT_BUILD_H |
| 8 | |
| 9 | #include <linux/types.h> |
| 10 | #include <asm/u-boot.h> |
| 11 | |
| 12 | /* Definitions used by the flattened device tree */ |
| 13 | #define OF_DT_HEADER 0xd00dfeed /* marker */ |
| 14 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ |
| 15 | #define OF_DT_END_NODE 0x2 /* End node */ |
| 16 | #define OF_DT_PROP 0x3 /* Property: name off, size, |
| 17 | * content */ |
| 18 | #define OF_DT_NOP 0x4 /* nop */ |
| 19 | #define OF_DT_END 0x9 |
| 20 | |
| 21 | #define OF_DT_VERSION 0x10 |
| 22 | |
| 23 | struct boot_param_header { |
| 24 | u32 magic; /* magic word OF_DT_HEADER */ |
| 25 | u32 totalsize; /* total size of DT block */ |
| 26 | u32 off_dt_struct; /* offset to structure */ |
| 27 | u32 off_dt_strings; /* offset to strings */ |
| 28 | u32 off_mem_rsvmap; /* offset to memory reserve map */ |
| 29 | u32 version; /* format version */ |
| 30 | u32 last_comp_version; /* last compatible version */ |
| 31 | /* version 2 fields below */ |
| 32 | u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ |
| 33 | /* version 3 fields below */ |
| 34 | u32 dt_strings_size; /* size of the DT strings block */ |
| 35 | }; |
| 36 | |
| 37 | struct ft_cxt { |
| 38 | struct boot_param_header *bph; |
Matthew McClintock | 1b380ec | 2006-06-28 10:42:24 -0500 | [diff] [blame] | 39 | u8 *p_rsvmap; |
| 40 | u8 *p_start; /* pointer to beginning of dt_struct */ |
| 41 | u8 *p_end; /* pointer to end of dt_strings */ |
| 42 | u8 *p; /* pointer to end of dt_struct and beginning of dt_strings */ |
Wolfgang Denk | 814d98f | 2005-10-13 01:59:29 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | void ft_begin_node(struct ft_cxt *cxt, const char *name); |
Matthew McClintock | 1b380ec | 2006-06-28 10:42:24 -0500 | [diff] [blame] | 46 | void ft_init_cxt(struct ft_cxt *cxt, void *blob); |
Wolfgang Denk | 814d98f | 2005-10-13 01:59:29 +0200 | [diff] [blame] | 47 | void ft_end_node(struct ft_cxt *cxt); |
| 48 | |
Matthew McClintock | 1b380ec | 2006-06-28 10:42:24 -0500 | [diff] [blame] | 49 | void ft_end_tree(struct ft_cxt *cxt); |
| 50 | void ft_finalize_tree(struct ft_cxt *cxt); |
Wolfgang Denk | 814d98f | 2005-10-13 01:59:29 +0200 | [diff] [blame] | 51 | |
| 52 | void ft_nop(struct ft_cxt *cxt); |
| 53 | void ft_prop(struct ft_cxt *cxt, const char *name, const void *data, int sz); |
| 54 | void ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str); |
| 55 | void ft_prop_int(struct ft_cxt *cxt, const char *name, int val); |
| 56 | void ft_begin(struct ft_cxt *cxt, void *blob, int max_size); |
| 57 | void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size); |
| 58 | |
Matthew McClintock | 1b380ec | 2006-06-28 10:42:24 -0500 | [diff] [blame] | 59 | void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end); |
Wolfgang Denk | 814d98f | 2005-10-13 01:59:29 +0200 | [diff] [blame] | 60 | |
| 61 | void ft_dump_blob(const void *bphp); |
| 62 | void ft_merge_blob(struct ft_cxt *cxt, void *blob); |
| 63 | void *ft_get_prop(void *bphp, const char *propname, int *szp); |
| 64 | |
Matthew McClintock | 1b380ec | 2006-06-28 10:42:24 -0500 | [diff] [blame] | 65 | #ifdef CONFIG_OF_BOARD_SETUP |
Kumar Gala | 4e25313 | 2006-01-11 13:54:17 -0600 | [diff] [blame] | 66 | void ft_board_setup(void *blob, bd_t *bd); |
Matthew McClintock | 7376eb8 | 2006-10-11 15:13:01 -0500 | [diff] [blame] | 67 | void ft_cpu_setup(void *blob, bd_t *bd); |
| 68 | void ft_pci_setup(void *blob, bd_t *bd); |
Matthew McClintock | 1b380ec | 2006-06-28 10:42:24 -0500 | [diff] [blame] | 69 | #endif |
Kumar Gala | 4e25313 | 2006-01-11 13:54:17 -0600 | [diff] [blame] | 70 | |
Wolfgang Denk | 814d98f | 2005-10-13 01:59:29 +0200 | [diff] [blame] | 71 | #endif |