diff options
Diffstat (limited to 'scripts/dtc/dtc.h')
-rw-r--r-- | scripts/dtc/dtc.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index f37c97eb3dfc..d501c8605f26 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <string.h> | 25 | #include <string.h> |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <stdint.h> | 27 | #include <stdint.h> |
28 | #include <stdbool.h> | ||
28 | #include <stdarg.h> | 29 | #include <stdarg.h> |
29 | #include <assert.h> | 30 | #include <assert.h> |
30 | #include <ctype.h> | 31 | #include <ctype.h> |
@@ -109,6 +110,7 @@ struct data data_insert_at_marker(struct data d, struct marker *m, | |||
109 | const void *p, int len); | 110 | const void *p, int len); |
110 | struct data data_merge(struct data d1, struct data d2); | 111 | struct data data_merge(struct data d1, struct data d2); |
111 | struct data data_append_cell(struct data d, cell_t word); | 112 | struct data data_append_cell(struct data d, cell_t word); |
113 | struct data data_append_integer(struct data d, uint64_t word, int bits); | ||
112 | struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); | 114 | struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); |
113 | struct data data_append_addr(struct data d, uint64_t addr); | 115 | struct data data_append_addr(struct data d, uint64_t addr); |
114 | struct data data_append_byte(struct data d, uint8_t byte); | 116 | struct data data_append_byte(struct data d, uint8_t byte); |
@@ -126,11 +128,13 @@ int data_is_one_string(struct data d); | |||
126 | 128 | ||
127 | /* Live trees */ | 129 | /* Live trees */ |
128 | struct label { | 130 | struct label { |
131 | int deleted; | ||
129 | char *label; | 132 | char *label; |
130 | struct label *next; | 133 | struct label *next; |
131 | }; | 134 | }; |
132 | 135 | ||
133 | struct property { | 136 | struct property { |
137 | int deleted; | ||
134 | char *name; | 138 | char *name; |
135 | struct data val; | 139 | struct data val; |
136 | 140 | ||
@@ -140,6 +144,7 @@ struct property { | |||
140 | }; | 144 | }; |
141 | 145 | ||
142 | struct node { | 146 | struct node { |
147 | int deleted; | ||
143 | char *name; | 148 | char *name; |
144 | struct property *proplist; | 149 | struct property *proplist; |
145 | struct node *children; | 150 | struct node *children; |
@@ -156,28 +161,71 @@ struct node { | |||
156 | struct label *labels; | 161 | struct label *labels; |
157 | }; | 162 | }; |
158 | 163 | ||
164 | static inline struct label *for_each_label_next(struct label *l) | ||
165 | { | ||
166 | do { | ||
167 | l = l->next; | ||
168 | } while (l && l->deleted); | ||
169 | |||
170 | return l; | ||
171 | } | ||
172 | |||
159 | #define for_each_label(l0, l) \ | 173 | #define for_each_label(l0, l) \ |
174 | for ((l) = (l0); (l); (l) = for_each_label_next(l)) | ||
175 | |||
176 | #define for_each_label_withdel(l0, l) \ | ||
160 | for ((l) = (l0); (l); (l) = (l)->next) | 177 | for ((l) = (l0); (l); (l) = (l)->next) |
161 | 178 | ||
179 | static inline struct property *for_each_property_next(struct property *p) | ||
180 | { | ||
181 | do { | ||
182 | p = p->next; | ||
183 | } while (p && p->deleted); | ||
184 | |||
185 | return p; | ||
186 | } | ||
187 | |||
162 | #define for_each_property(n, p) \ | 188 | #define for_each_property(n, p) \ |
189 | for ((p) = (n)->proplist; (p); (p) = for_each_property_next(p)) | ||
190 | |||
191 | #define for_each_property_withdel(n, p) \ | ||
163 | for ((p) = (n)->proplist; (p); (p) = (p)->next) | 192 | for ((p) = (n)->proplist; (p); (p) = (p)->next) |
164 | 193 | ||
165 | #define for_each_child(n, c) \ | 194 | static inline struct node *for_each_child_next(struct node *c) |
195 | { | ||
196 | do { | ||
197 | c = c->next_sibling; | ||
198 | } while (c && c->deleted); | ||
199 | |||
200 | return c; | ||
201 | } | ||
202 | |||
203 | #define for_each_child(n, c) \ | ||
204 | for ((c) = (n)->children; (c); (c) = for_each_child_next(c)) | ||
205 | |||
206 | #define for_each_child_withdel(n, c) \ | ||
166 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) | 207 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) |
167 | 208 | ||
168 | void add_label(struct label **labels, char *label); | 209 | void add_label(struct label **labels, char *label); |
210 | void delete_labels(struct label **labels); | ||
169 | 211 | ||
170 | struct property *build_property(char *name, struct data val); | 212 | struct property *build_property(char *name, struct data val); |
213 | struct property *build_property_delete(char *name); | ||
171 | struct property *chain_property(struct property *first, struct property *list); | 214 | struct property *chain_property(struct property *first, struct property *list); |
172 | struct property *reverse_properties(struct property *first); | 215 | struct property *reverse_properties(struct property *first); |
173 | 216 | ||
174 | struct node *build_node(struct property *proplist, struct node *children); | 217 | struct node *build_node(struct property *proplist, struct node *children); |
218 | struct node *build_node_delete(void); | ||
175 | struct node *name_node(struct node *node, char *name); | 219 | struct node *name_node(struct node *node, char *name); |
176 | struct node *chain_node(struct node *first, struct node *list); | 220 | struct node *chain_node(struct node *first, struct node *list); |
177 | struct node *merge_nodes(struct node *old_node, struct node *new_node); | 221 | struct node *merge_nodes(struct node *old_node, struct node *new_node); |
178 | 222 | ||
179 | void add_property(struct node *node, struct property *prop); | 223 | void add_property(struct node *node, struct property *prop); |
224 | void delete_property_by_name(struct node *node, char *name); | ||
225 | void delete_property(struct property *prop); | ||
180 | void add_child(struct node *parent, struct node *child); | 226 | void add_child(struct node *parent, struct node *child); |
227 | void delete_node_by_name(struct node *parent, char *name); | ||
228 | void delete_node(struct node *node); | ||
181 | 229 | ||
182 | const char *get_unitname(struct node *node); | 230 | const char *get_unitname(struct node *node); |
183 | struct property *get_property(struct node *node, const char *propname); | 231 | struct property *get_property(struct node *node, const char *propname); |
@@ -224,6 +272,7 @@ void sort_tree(struct boot_info *bi); | |||
224 | 272 | ||
225 | /* Checks */ | 273 | /* Checks */ |
226 | 274 | ||
275 | void parse_checks_option(bool warn, bool error, const char *optarg); | ||
227 | void process_checks(int force, struct boot_info *bi); | 276 | void process_checks(int force, struct boot_info *bi); |
228 | 277 | ||
229 | /* Flattened trees */ | 278 | /* Flattened trees */ |