Lines Matching +full:bool +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0-or-later
19 if (streq(new->label, label)) {
20 new->deleted = 0;
26 new->label = label;
27 new->next = *labels;
36 label->deleted = 1;
39 struct property *build_property(const char *name, struct data val,
42 struct property *new = xmalloc(sizeof(*new));
46 new->name = xstrdup(name);
47 new->val = val;
48 new->srcpos = srcpos_copy(srcpos);
53 struct property *build_property_delete(const char *name)
55 struct property *new = xmalloc(sizeof(*new));
59 new->name = xstrdup(name);
60 new->deleted = 1;
65 struct property *chain_property(struct property *first, struct property *list)
67 assert(first->next == NULL);
69 first->next = list;
73 struct property *reverse_properties(struct property *first)
75 struct property *p = first;
76 struct property *head = NULL;
77 struct property *next;
80 next = p->next;
81 p->next = head;
88 struct node *build_node(struct property *proplist, struct node *children,
96 new->proplist = reverse_properties(proplist);
97 new->children = children;
98 new->srcpos = srcpos_copy(srcpos);
101 child->parent = new;
113 new->deleted = 1;
114 new->srcpos = srcpos_copy(srcpos);
121 assert(node->name == NULL);
123 node->name = xstrdup(name);
130 node->omit_if_unused = 1;
137 node->is_referenced = 1;
144 struct property *new_prop, *old_prop;
148 old_node->deleted = 0;
151 for_each_label_withdel(new_node->labels, l)
152 add_label(&old_node->labels, l->label);
156 while (new_node->proplist) {
157 /* Pop the property off the list */
158 new_prop = new_node->proplist;
159 new_node->proplist = new_prop->next;
160 new_prop->next = NULL;
162 if (new_prop->deleted) {
163 delete_property_by_name(old_node, new_prop->name);
170 if (streq(old_prop->name, new_prop->name)) {
171 /* Add new labels to old property */
172 for_each_label_withdel(new_prop->labels, l)
173 add_label(&old_prop->labels, l->label);
175 old_prop->val = new_prop->val;
176 old_prop->deleted = 0;
177 srcpos_free(old_prop->srcpos);
178 old_prop->srcpos = new_prop->srcpos;
185 /* if no collision occurred, add property to the old node. */
192 while (new_node->children) {
194 new_child = new_node->children;
195 new_node->children = new_child->next_sibling;
196 new_child->parent = NULL;
197 new_child->next_sibling = NULL;
199 if (new_child->deleted) {
200 delete_node_by_name(old_node, new_child->name);
207 if (streq(old_child->name, new_child->name)) {
219 old_node->srcpos = srcpos_extend(old_node->srcpos, new_node->srcpos);
232 struct property *p;
240 p = build_property("target-path", d, NULL);
261 assert(first->next_sibling == NULL);
263 first->next_sibling = list;
267 void add_property(struct node *node, struct property *prop)
269 struct property **p;
271 prop->next = NULL;
273 p = &node->proplist;
275 p = &((*p)->next);
282 struct property *prop = node->proplist;
285 if (streq(prop->name, name)) {
289 prop = prop->next;
293 void delete_property(struct property *prop)
295 prop->deleted = 1;
296 delete_labels(&prop->labels);
303 child->next_sibling = NULL;
304 child->parent = parent;
306 p = &parent->children;
308 p = &((*p)->next_sibling);
315 struct node *node = parent->children;
318 if (streq(node->name, name)) {
322 node = node->next_sibling;
328 struct property *prop;
331 node->deleted = 1;
336 delete_labels(&node->labels);
344 struct property *p;
348 d = data_add_marker(p->val, type, name);
350 p->val = d;
365 new->address = address;
366 new->size = size;
374 assert(first->next == NULL);
376 first->next = list;
385 new->next = NULL;
390 for (last = list; last->next; last = last->next)
393 last->next = new;
405 dti->dtsflags = dtsflags;
406 dti->reservelist = reservelist;
407 dti->dt = tree;
408 dti->boot_cpuid_phys = boot_cpuid_phys;
419 if (node->name[node->basenamelen] == '\0')
422 return node->name + node->basenamelen + 1;
425 struct property *get_property(struct node *node, const char *propname)
427 struct property *prop;
430 if (streq(prop->name, propname))
436 cell_t propval_cell(struct property *prop)
438 assert(prop->val.len == sizeof(cell_t));
439 return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
442 cell_t propval_cell_n(struct property *prop, unsigned int n)
444 assert(prop->val.len / sizeof(cell_t) > n);
445 return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n));
448 struct property *get_property_by_label(struct node *tree, const char *label,
451 struct property *prop;
459 for_each_label(prop->labels, l)
460 if (streq(l->label, label))
475 struct node **node, struct property **prop)
478 struct property *p;
485 m = p->val.markers;
487 if (streq(m->ref, label))
507 if (streq(child->name, nodename) && !child->deleted)
519 if (tree->deleted)
530 if (p && strprefixeq(path, (size_t)(p - path), child->name))
532 else if (!p && streq(path, child->name))
546 for_each_label(tree->labels, l)
547 if (streq(l->label, label))
568 if (tree->phandle == phandle) {
569 if (tree->deleted)
601 buf = xstrndup(label, slash - label);
631 d = data_append_cell(d, node->phandle);
640 if (phandle_is_valid(node->phandle))
641 return node->phandle;
646 node->phandle = phandle;
651 /* If the node *does* have a phandle property, we must
652 * be dealing with a self-referencing phandle, which will be
655 return node->phandle;
661 struct property *reg;
668 bootcpu = cpus->children;
673 if (!reg || (reg->val.len != sizeof(uint32_t)))
688 if (a->address < b->address)
689 return -1;
690 else if (a->address > b->address)
692 else if (a->size < b->size)
693 return -1;
694 else if (a->size > b->size)
705 for (ri = dti->reservelist;
707 ri = ri->next)
715 for (ri = dti->reservelist;
717 ri = ri->next)
722 dti->reservelist = tbl[0];
723 for (i = 0; i < (n-1); i++)
724 tbl[i]->next = tbl[i+1];
725 tbl[n-1]->next = NULL;
732 const struct property *a, *b;
734 a = *((const struct property * const *)ax);
735 b = *((const struct property * const *)bx);
737 return strcmp(a->name, b->name);
743 struct property *prop, **tbl;
758 node->proplist = tbl[0];
759 for (i = 0; i < (n-1); i++)
760 tbl[i]->next = tbl[i+1];
761 tbl[n-1]->next = NULL;
773 return strcmp(a->name, b->name);
794 node->children = tbl[0];
795 for (i = 0; i < (n-1); i++)
796 tbl[i]->next_sibling = tbl[i+1];
797 tbl[n-1]->next_sibling = NULL;
815 sort_node(dti->dt);
844 static bool any_label_tree(struct dt_info *dti, struct node *node)
848 if (node->labels)
860 bool allocph)
862 struct node *dt = dti->dt;
864 struct property *p;
868 if (node->labels) {
871 for_each_label(node->labels, l) {
874 p = get_property(an, l->label);
877 " exists in /%s", l->label,
878 an->name);
883 p = build_property(l->label,
884 data_copy_escape_string(node->fullpath,
885 strlen(node->fullpath)),
899 static bool any_fixup_tree(struct dt_info *dti, struct node *node)
902 struct property *prop;
906 m = prop->val.markers;
908 if (!get_node_by_ref(dti->dt, m->ref))
922 struct node *node, struct property *prop,
927 /* m->ref can only be a REF_PHANDLE, but check anyway */
928 assert(m->type == REF_PHANDLE);
932 if (strchr(m->ref, '/'))
934 m->ref);
937 if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
941 node->fullpath, prop->name, m->offset);
942 append_to_property(fn, m->ref, entry, strlen(entry) + 1, TYPE_STRING);
951 struct node *dt = dti->dt;
953 struct property *prop;
958 m = prop->val.markers;
960 refnode = get_node_by_ref(dt, m->ref);
970 static bool any_local_fixup_tree(struct dt_info *dti, struct node *node)
973 struct property *prop;
977 m = prop->val.markers;
979 if (get_node_by_ref(dti->dt, m->ref))
994 struct property *prop, struct marker *m,
1004 for (wn = node; wn; wn = wn->parent)
1011 for (wn = node, i = depth - 1; wn; wn = wn->parent, i--)
1012 compp[i] = wn->name;
1022 value_32 = cpu_to_fdt32(m->offset);
1023 append_to_property(wn, prop->name, &value_32, sizeof(value_32), TYPE_UINT32);
1030 struct node *dt = dti->dt;
1032 struct property *prop;
1037 m = prop->val.markers;
1039 refnode = get_node_by_ref(dt, m->ref);
1049 void generate_label_tree(struct dt_info *dti, const char *name, bool allocph)
1051 if (!any_label_tree(dti, dti->dt))
1053 generate_label_tree_internal(dti, build_root_node(dti->dt, name),
1054 dti->dt, allocph);
1059 struct node *n = get_subnode(dti->dt, name);
1063 n->deleted = true;
1065 if (!any_fixup_tree(dti, dti->dt))
1068 build_and_name_child_node(dti->dt, name),
1069 dti->dt);
1074 struct node *n = get_subnode(dti->dt, name);
1078 n->deleted = true;
1079 if (!any_local_fixup_tree(dti, dti->dt))
1082 build_and_name_child_node(dti->dt, name),
1083 dti->dt);