diff options
author | John Bonesio <bones@secretlab.ca> | 2010-11-17 18:28:20 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-01-03 18:02:49 -0500 |
commit | 658f29a51e9830e620bb9a1ce3534b318a38bfeb (patch) | |
tree | e6cc7cd9b9e17d97308619fd8516b77bcc038114 /scripts/dtc/dtc.h | |
parent | cd1e65044d4473cca9a01bae7b7938f065044a4b (diff) |
of/flattree: Update dtc to current mainline.
Pull in recent changes from the main dtc repository. These changes
primarily allow multiple device trees to be declared which are merged
by dtc. This feature allows us to include a basic dts file and then
provide more information for the specific system through the merging
functionality.
Changes pulled from git://git.jdl.com/software/dtc.git
commit id: 37c0b6a0, "dtc: Add code to make diffing trees easier"
Signed-off-by: John Bonesio <bones@secretlab.ca>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'scripts/dtc/dtc.h')
-rw-r--r-- | scripts/dtc/dtc.h | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 08d54c870086..f37c97eb3dfc 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
@@ -34,7 +34,17 @@ | |||
34 | #include <libfdt_env.h> | 34 | #include <libfdt_env.h> |
35 | #include <fdt.h> | 35 | #include <fdt.h> |
36 | 36 | ||
37 | #include "util.h" | ||
38 | |||
39 | #ifdef DEBUG | ||
40 | #define debug(fmt,args...) printf(fmt, ##args) | ||
41 | #else | ||
42 | #define debug(fmt,args...) | ||
43 | #endif | ||
44 | |||
45 | |||
37 | #define DEFAULT_FDT_VERSION 17 | 46 | #define DEFAULT_FDT_VERSION 17 |
47 | |||
38 | /* | 48 | /* |
39 | * Command line options | 49 | * Command line options |
40 | */ | 50 | */ |
@@ -42,36 +52,11 @@ extern int quiet; /* Level of quietness */ | |||
42 | extern int reservenum; /* Number of memory reservation slots */ | 52 | extern int reservenum; /* Number of memory reservation slots */ |
43 | extern int minsize; /* Minimum blob size */ | 53 | extern int minsize; /* Minimum blob size */ |
44 | extern int padsize; /* Additional padding to blob */ | 54 | extern int padsize; /* Additional padding to blob */ |
55 | extern int phandle_format; /* Use linux,phandle or phandle properties */ | ||
45 | 56 | ||
46 | static inline void __attribute__((noreturn)) die(char * str, ...) | 57 | #define PHANDLE_LEGACY 0x1 |
47 | { | 58 | #define PHANDLE_EPAPR 0x2 |
48 | va_list ap; | 59 | #define PHANDLE_BOTH 0x3 |
49 | |||
50 | va_start(ap, str); | ||
51 | fprintf(stderr, "FATAL ERROR: "); | ||
52 | vfprintf(stderr, str, ap); | ||
53 | exit(1); | ||
54 | } | ||
55 | |||
56 | static inline void *xmalloc(size_t len) | ||
57 | { | ||
58 | void *new = malloc(len); | ||
59 | |||
60 | if (! new) | ||
61 | die("malloc() failed\n"); | ||
62 | |||
63 | return new; | ||
64 | } | ||
65 | |||
66 | static inline void *xrealloc(void *p, size_t len) | ||
67 | { | ||
68 | void *new = realloc(p, len); | ||
69 | |||
70 | if (! new) | ||
71 | die("realloc() failed (len=%d)\n", len); | ||
72 | |||
73 | return new; | ||
74 | } | ||
75 | 60 | ||
76 | typedef uint32_t cell_t; | 61 | typedef uint32_t cell_t; |
77 | 62 | ||
@@ -140,13 +125,18 @@ int data_is_one_string(struct data d); | |||
140 | #define MAX_NODENAME_LEN 31 | 125 | #define MAX_NODENAME_LEN 31 |
141 | 126 | ||
142 | /* Live trees */ | 127 | /* Live trees */ |
128 | struct label { | ||
129 | char *label; | ||
130 | struct label *next; | ||
131 | }; | ||
132 | |||
143 | struct property { | 133 | struct property { |
144 | char *name; | 134 | char *name; |
145 | struct data val; | 135 | struct data val; |
146 | 136 | ||
147 | struct property *next; | 137 | struct property *next; |
148 | 138 | ||
149 | char *label; | 139 | struct label *labels; |
150 | }; | 140 | }; |
151 | 141 | ||
152 | struct node { | 142 | struct node { |
@@ -163,22 +153,28 @@ struct node { | |||
163 | cell_t phandle; | 153 | cell_t phandle; |
164 | int addr_cells, size_cells; | 154 | int addr_cells, size_cells; |
165 | 155 | ||
166 | char *label; | 156 | struct label *labels; |
167 | }; | 157 | }; |
168 | 158 | ||
159 | #define for_each_label(l0, l) \ | ||
160 | for ((l) = (l0); (l); (l) = (l)->next) | ||
161 | |||
169 | #define for_each_property(n, p) \ | 162 | #define for_each_property(n, p) \ |
170 | for ((p) = (n)->proplist; (p); (p) = (p)->next) | 163 | for ((p) = (n)->proplist; (p); (p) = (p)->next) |
171 | 164 | ||
172 | #define for_each_child(n, c) \ | 165 | #define for_each_child(n, c) \ |
173 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) | 166 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) |
174 | 167 | ||
175 | struct property *build_property(char *name, struct data val, char *label); | 168 | void add_label(struct label **labels, char *label); |
169 | |||
170 | struct property *build_property(char *name, struct data val); | ||
176 | struct property *chain_property(struct property *first, struct property *list); | 171 | struct property *chain_property(struct property *first, struct property *list); |
177 | struct property *reverse_properties(struct property *first); | 172 | struct property *reverse_properties(struct property *first); |
178 | 173 | ||
179 | struct node *build_node(struct property *proplist, struct node *children); | 174 | struct node *build_node(struct property *proplist, struct node *children); |
180 | struct node *name_node(struct node *node, char *name, char *label); | 175 | struct node *name_node(struct node *node, char *name); |
181 | struct node *chain_node(struct node *first, struct node *list); | 176 | struct node *chain_node(struct node *first, struct node *list); |
177 | struct node *merge_nodes(struct node *old_node, struct node *new_node); | ||
182 | 178 | ||
183 | void add_property(struct node *node, struct property *prop); | 179 | void add_property(struct node *node, struct property *prop); |
184 | void add_child(struct node *parent, struct node *child); | 180 | void add_child(struct node *parent, struct node *child); |
@@ -186,6 +182,10 @@ void add_child(struct node *parent, struct node *child); | |||
186 | const char *get_unitname(struct node *node); | 182 | const char *get_unitname(struct node *node); |
187 | struct property *get_property(struct node *node, const char *propname); | 183 | struct property *get_property(struct node *node, const char *propname); |
188 | cell_t propval_cell(struct property *prop); | 184 | cell_t propval_cell(struct property *prop); |
185 | struct property *get_property_by_label(struct node *tree, const char *label, | ||
186 | struct node **node); | ||
187 | struct marker *get_marker_label(struct node *tree, const char *label, | ||
188 | struct node **node, struct property **prop); | ||
189 | struct node *get_subnode(struct node *node, const char *nodename); | 189 | struct node *get_subnode(struct node *node, const char *nodename); |
190 | struct node *get_node_by_path(struct node *tree, const char *path); | 190 | struct node *get_node_by_path(struct node *tree, const char *path); |
191 | struct node *get_node_by_label(struct node *tree, const char *label); | 191 | struct node *get_node_by_label(struct node *tree, const char *label); |
@@ -193,6 +193,8 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle); | |||
193 | struct node *get_node_by_ref(struct node *tree, const char *ref); | 193 | struct node *get_node_by_ref(struct node *tree, const char *ref); |
194 | cell_t get_node_phandle(struct node *root, struct node *node); | 194 | cell_t get_node_phandle(struct node *root, struct node *node); |
195 | 195 | ||
196 | uint32_t guess_boot_cpuid(struct node *tree); | ||
197 | |||
196 | /* Boot info (tree plus memreserve information */ | 198 | /* Boot info (tree plus memreserve information */ |
197 | 199 | ||
198 | struct reserve_info { | 200 | struct reserve_info { |
@@ -200,10 +202,10 @@ struct reserve_info { | |||
200 | 202 | ||
201 | struct reserve_info *next; | 203 | struct reserve_info *next; |
202 | 204 | ||
203 | char *label; | 205 | struct label *labels; |
204 | }; | 206 | }; |
205 | 207 | ||
206 | struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label); | 208 | struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len); |
207 | struct reserve_info *chain_reserve_entry(struct reserve_info *first, | 209 | struct reserve_info *chain_reserve_entry(struct reserve_info *first, |
208 | struct reserve_info *list); | 210 | struct reserve_info *list); |
209 | struct reserve_info *add_reserve_entry(struct reserve_info *list, | 211 | struct reserve_info *add_reserve_entry(struct reserve_info *list, |
@@ -218,6 +220,7 @@ struct boot_info { | |||
218 | 220 | ||
219 | struct boot_info *build_boot_info(struct reserve_info *reservelist, | 221 | struct boot_info *build_boot_info(struct reserve_info *reservelist, |
220 | struct node *tree, uint32_t boot_cpuid_phys); | 222 | struct node *tree, uint32_t boot_cpuid_phys); |
223 | void sort_tree(struct boot_info *bi); | ||
221 | 224 | ||
222 | /* Checks */ | 225 | /* Checks */ |
223 | 226 | ||
@@ -239,8 +242,4 @@ struct boot_info *dt_from_source(const char *f); | |||
239 | 242 | ||
240 | struct boot_info *dt_from_fs(const char *dirname); | 243 | struct boot_info *dt_from_fs(const char *dirname); |
241 | 244 | ||
242 | /* misc */ | ||
243 | |||
244 | char *join_path(const char *path, const char *name); | ||
245 | |||
246 | #endif /* _DTC_H */ | 245 | #endif /* _DTC_H */ |