Lines Matching refs:node

88 struct node *build_node(struct property *proplist, struct node *children,
91 struct node *new = xmalloc(sizeof(*new));
92 struct node *child;
107 struct node *build_node_delete(struct srcpos *srcpos)
109 struct node *new = xmalloc(sizeof(*new));
119 struct node *name_node(struct node *node, char *name)
121 assert(node->name == NULL);
123 node->name = name;
125 return node;
128 struct node *omit_node_if_unused(struct node *node)
130 node->omit_if_unused = 1;
132 return node;
135 struct node *reference_node(struct node *node)
137 node->is_referenced = 1;
139 return node;
142 struct node *merge_nodes(struct node *old_node, struct node *new_node)
145 struct node *new_child, *old_child;
150 /* Add new node labels to old node */
154 /* Move properties from the new node to the old node. If there
185 /* if no collision occurred, add property to the old node. */
190 /* Move the override child nodes into the primary node. If
193 /* Pop the child node off the list */
214 /* if no collision occurred, add child to the old node. */
221 /* The new node contents are now merged into the old node. Free
222 * the new node. */
228 struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
231 struct node *node;
251 node = build_node(p, new_node, NULL);
252 name_node(node, name);
254 add_child(dt, node);
258 struct node *chain_node(struct node *first, struct node *list)
266 void add_property(struct node *node, struct property *prop)
272 p = &node->proplist;
279 void delete_property_by_name(struct node *node, char *name)
281 struct property *prop = node->proplist;
298 void add_child(struct node *parent, struct node *child)
300 struct node **p;
312 void delete_node_by_name(struct node *parent, char *name)
314 struct node *node = parent->children;
316 while (node) {
317 if (streq(node->name, name)) {
318 delete_node(node);
321 node = node->next_sibling;
325 void delete_node(struct node *node)
328 struct node *child;
330 node->deleted = 1;
331 for_each_child(node, child)
333 for_each_property(node, prop)
335 delete_labels(&node->labels);
338 void append_to_property(struct node *node,
345 p = get_property(node, name);
354 add_property(node, p);
399 struct node *tree, uint32_t boot_cpuid_phys)
416 const char *get_unitname(struct node *node)
418 if (node->name[node->basenamelen] == '\0')
421 return node->name + node->basenamelen + 1;
424 struct property *get_property(struct node *node, const char *propname)
428 for_each_property(node, prop)
447 struct property *get_property_by_label(struct node *tree, const char *label,
448 struct node **node)
451 struct node *c;
453 *node = tree;
464 prop = get_property_by_label(c, label, node);
469 *node = NULL;
473 struct marker *get_marker_label(struct node *tree, const char *label,
474 struct node **node, struct property **prop)
478 struct node *c;
480 *node = tree;
491 m = get_marker_label(c, label, node, prop);
497 *node = NULL;
501 struct node *get_subnode(struct node *node, const char *nodename)
503 struct node *child;
505 for_each_child(node, child)
512 struct node *get_node_by_path(struct node *tree, const char *path)
515 struct node *child;
538 struct node *get_node_by_label(struct node *tree, const char *label)
540 struct node *child, *node;
550 node = get_node_by_label(child, label);
551 if (node)
552 return node;
558 struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
560 struct node *child, *node;
574 node = get_node_by_phandle(child, phandle);
575 if (node)
576 return node;
582 struct node *get_node_by_ref(struct node *tree, const char *ref)
592 cell_t get_node_phandle(struct node *root, struct node *node)
597 if ((node->phandle != 0) && (node->phandle != -1))
598 return node->phandle;
603 node->phandle = phandle;
608 if (!get_property(node, "linux,phandle")
610 add_property(node, build_property("linux,phandle", d, NULL));
612 if (!get_property(node, "phandle")
614 add_property(node, build_property("phandle", d, NULL));
616 /* If the node *does* have a phandle property, we must
620 return node->phandle;
623 uint32_t guess_boot_cpuid(struct node *tree)
625 struct node *cpus, *bootcpu;
641 /* FIXME: Sanity check node? */
705 static void sort_properties(struct node *node)
710 for_each_property_withdel(node, prop)
718 for_each_property_withdel(node, prop)
723 node->proplist = tbl[0];
733 const struct node *a, *b;
735 a = *((const struct node * const *)ax);
736 b = *((const struct node * const *)bx);
741 static void sort_subnodes(struct node *node)
744 struct node *subnode, **tbl;
746 for_each_child_withdel(node, subnode)
754 for_each_child_withdel(node, subnode)
759 node->children = tbl[0];
767 static void sort_node(struct node *node)
769 struct node *c;
771 sort_properties(node);
772 sort_subnodes(node);
773 for_each_child_withdel(node, c)
784 static struct node *build_and_name_child_node(struct node *parent, char *name)
786 struct node *node;
788 node = build_node(NULL, NULL, NULL);
789 name_node(node, xstrdup(name));
790 add_child(parent, node);
792 return node;
795 static struct node *build_root_node(struct node *dt, char *name)
797 struct node *an;
804 die("Could not build root node /%s\n", name);
809 static bool any_label_tree(struct dt_info *dti, struct node *node)
811 struct node *c;
813 if (node->labels)
816 for_each_child(node, c)
824 struct node *an, struct node *node,
827 struct node *dt = dti->dt;
828 struct node *c;
833 if (node->labels) {
835 /* now add the label in the node */
836 for_each_label(node->labels, l) {
849 data_copy_escape_string(node->fullpath,
850 strlen(node->fullpath)),
855 /* force allocation of a phandle for this node */
857 (void)get_node_phandle(dt, node);
860 for_each_child(node, c)
864 static bool any_fixup_tree(struct dt_info *dti, struct node *node)
866 struct node *c;
870 for_each_property(node, prop) {
878 for_each_child(node, c) {
886 static void add_fixup_entry(struct dt_info *dti, struct node *fn,
887 struct node *node, struct property *prop,
896 if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
900 node->fullpath, prop->name, m->offset);
907 struct node *fn,
908 struct node *node)
910 struct node *dt = dti->dt;
911 struct node *c;
914 struct node *refnode;
916 for_each_property(node, prop) {
921 add_fixup_entry(dti, fn, node, prop, m);
925 for_each_child(node, c)
929 static bool any_local_fixup_tree(struct dt_info *dti, struct node *node)
931 struct node *c;
935 for_each_property(node, prop) {
943 for_each_child(node, c) {
952 struct node *lfn, struct node *node,
954 struct node *refnode)
956 struct node *wn, *nwn; /* local fixup node, walk node, new */
963 for (wn = node; wn; wn = wn->parent)
970 for (wn = node, i = depth - 1; wn; wn = wn->parent, i--)
975 /* if no node exists, create it */
988 struct node *lfn,
989 struct node *node)
991 struct node *dt = dti->dt;
992 struct node *c;
995 struct node *refnode;
997 for_each_property(node, prop) {
1002 add_local_fixup_entry(dti, lfn, node, prop, m, refnode);
1006 for_each_child(node, c)