aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/dtc.h
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dtc/dtc.h')
-rw-r--r--scripts/dtc/dtc.h51
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);
110struct data data_merge(struct data d1, struct data d2); 111struct data data_merge(struct data d1, struct data d2);
111struct data data_append_cell(struct data d, cell_t word); 112struct data data_append_cell(struct data d, cell_t word);
113struct data data_append_integer(struct data d, uint64_t word, int bits);
112struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); 114struct data data_append_re(struct data d, const struct fdt_reserve_entry *re);
113struct data data_append_addr(struct data d, uint64_t addr); 115struct data data_append_addr(struct data d, uint64_t addr);
114struct data data_append_byte(struct data d, uint8_t byte); 116struct 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 */
128struct label { 130struct label {
131 int deleted;
129 char *label; 132 char *label;
130 struct label *next; 133 struct label *next;
131}; 134};
132 135
133struct property { 136struct 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
142struct node { 146struct 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
164static 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
179static 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) \ 194static 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
168void add_label(struct label **labels, char *label); 209void add_label(struct label **labels, char *label);
210void delete_labels(struct label **labels);
169 211
170struct property *build_property(char *name, struct data val); 212struct property *build_property(char *name, struct data val);
213struct property *build_property_delete(char *name);
171struct property *chain_property(struct property *first, struct property *list); 214struct property *chain_property(struct property *first, struct property *list);
172struct property *reverse_properties(struct property *first); 215struct property *reverse_properties(struct property *first);
173 216
174struct node *build_node(struct property *proplist, struct node *children); 217struct node *build_node(struct property *proplist, struct node *children);
218struct node *build_node_delete(void);
175struct node *name_node(struct node *node, char *name); 219struct node *name_node(struct node *node, char *name);
176struct node *chain_node(struct node *first, struct node *list); 220struct node *chain_node(struct node *first, struct node *list);
177struct node *merge_nodes(struct node *old_node, struct node *new_node); 221struct node *merge_nodes(struct node *old_node, struct node *new_node);
178 222
179void add_property(struct node *node, struct property *prop); 223void add_property(struct node *node, struct property *prop);
224void delete_property_by_name(struct node *node, char *name);
225void delete_property(struct property *prop);
180void add_child(struct node *parent, struct node *child); 226void add_child(struct node *parent, struct node *child);
227void delete_node_by_name(struct node *parent, char *name);
228void delete_node(struct node *node);
181 229
182const char *get_unitname(struct node *node); 230const char *get_unitname(struct node *node);
183struct property *get_property(struct node *node, const char *propname); 231struct 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
275void parse_checks_option(bool warn, bool error, const char *optarg);
227void process_checks(int force, struct boot_info *bi); 276void process_checks(int force, struct boot_info *bi);
228 277
229/* Flattened trees */ 278/* Flattened trees */