Lines Matching defs:node

100 struct node *build_node(struct property *proplist, struct node *children)
102 struct node *new = xmalloc(sizeof(*new));
103 struct node *child;
117 struct node *build_node_delete(void)
119 struct node *new = xmalloc(sizeof(*new));
128 struct node *name_node(struct node *node, char *name)
130 assert(node->name == NULL);
132 node->name = name;
134 return node;
137 struct node *merge_nodes(struct node *old_node, struct node *new_node)
140 struct node *new_child, *old_child;
145 /* Add new node labels to old node */
149 /* Move properties from the new node to the old node. If there
178 /* if no collision occurred, add property to the old node. */
183 /* Move the override child nodes into the primary node. If
186 /* Pop the child node off the list */
207 /* if no collision occurred, add child to the old node. */
212 /* The new node contents are now merged into the old node. Free
213 * the new node. */
219 struct node *chain_node(struct node *first, struct node *list)
227 void add_property(struct node *node, struct property *prop)
233 p = &node->proplist;
240 void delete_property_by_name(struct node *node, char *name)
242 struct property *prop = node->proplist;
259 void add_child(struct node *parent, struct node *child)
261 struct node **p;
273 void delete_node_by_name(struct node *parent, char *name)
275 struct node *node = parent->children;
277 while (node) {
278 if (streq(node->name, name)) {
279 delete_node(node);
282 node = node->next_sibling;
286 void delete_node(struct node *node)
289 struct node *child;
291 node->deleted = 1;
292 for_each_child(node, child)
294 for_each_property(node, prop)
296 delete_labels(&node->labels);
299 void append_to_property(struct node *node,
305 p = get_property(node, name);
312 add_property(node, p);
357 struct node *tree, uint32_t boot_cpuid_phys)
374 const char *get_unitname(struct node *node)
376 if (node->name[node->basenamelen] == '\0')
379 return node->name + node->basenamelen + 1;
382 struct property *get_property(struct node *node, const char *propname)
386 for_each_property(node, prop)
399 struct property *get_property_by_label(struct node *tree, const char *label,
400 struct node **node)
403 struct node *c;
405 *node = tree;
416 prop = get_property_by_label(c, label, node);
421 *node = NULL;
425 struct marker *get_marker_label(struct node *tree, const char *label,
426 struct node **node, struct property **prop)
430 struct node *c;
432 *node = tree;
443 m = get_marker_label(c, label, node, prop);
449 *node = NULL;
453 struct node *get_subnode(struct node *node, const char *nodename)
455 struct node *child;
457 for_each_child(node, child)
464 struct node *get_node_by_path(struct node *tree, const char *path)
467 struct node *child;
490 struct node *get_node_by_label(struct node *tree, const char *label)
492 struct node *child, *node;
502 node = get_node_by_label(child, label);
503 if (node)
504 return node;
510 struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
512 struct node *child, *node;
523 node = get_node_by_phandle(child, phandle);
524 if (node)
525 return node;
531 struct node *get_node_by_ref(struct node *tree, const char *ref)
541 cell_t get_node_phandle(struct node *root, struct node *node)
545 if ((node->phandle != 0) && (node->phandle != -1))
546 return node->phandle;
551 node->phandle = phandle;
553 if (!get_property(node, "linux,phandle")
555 add_property(node,
559 if (!get_property(node, "phandle")
561 add_property(node,
565 /* If the node *does* have a phandle property, we must
569 return node->phandle;
572 uint32_t guess_boot_cpuid(struct node *tree)
574 struct node *cpus, *bootcpu;
590 /* FIXME: Sanity check node? */
654 static void sort_properties(struct node *node)
659 for_each_property_withdel(node, prop)
667 for_each_property_withdel(node, prop)
672 node->proplist = tbl[0];
682 const struct node *a, *b;
684 a = *((const struct node * const *)ax);
685 b = *((const struct node * const *)bx);
690 static void sort_subnodes(struct node *node)
693 struct node *subnode, **tbl;
695 for_each_child_withdel(node, subnode)
703 for_each_child_withdel(node, subnode)
708 node->children = tbl[0];
716 static void sort_node(struct node *node)
718 struct node *c;
720 sort_properties(node);
721 sort_subnodes(node);
722 for_each_child_withdel(node, c)
733 static struct node *build_and_name_child_node(struct node *parent, char *name)
735 struct node *node;
737 node = build_node(NULL, NULL);
738 name_node(node, xstrdup(name));
739 add_child(parent, node);
741 return node;
744 static struct node *build_root_node(struct node *dt, char *name)
746 struct node *an;
753 die("Could not build root node /%s\n", name);
758 static bool any_label_tree(struct dt_info *dti, struct node *node)
760 struct node *c;
762 if (node->labels)
765 for_each_child(node, c)
773 struct node *an, struct node *node,
776 struct node *dt = dti->dt;
777 struct node *c;
782 if (node->labels) {
784 /* now add the label in the node */
785 for_each_label(node->labels, l) {
798 data_copy_mem(node->fullpath,
799 strlen(node->fullpath) + 1));
803 /* force allocation of a phandle for this node */
805 (void)get_node_phandle(dt, node);
808 for_each_child(node, c)
812 static bool any_fixup_tree(struct dt_info *dti, struct node *node)
814 struct node *c;
818 for_each_property(node, prop) {
826 for_each_child(node, c) {
834 static void add_fixup_entry(struct dt_info *dti, struct node *fn,
835 struct node *node, struct property *prop,
844 if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
848 node->fullpath, prop->name, m->offset);
855 struct node *fn,
856 struct node *node)
858 struct node *dt = dti->dt;
859 struct node *c;
862 struct node *refnode;
864 for_each_property(node, prop) {
869 add_fixup_entry(dti, fn, node, prop, m);
873 for_each_child(node, c)
877 static bool any_local_fixup_tree(struct dt_info *dti, struct node *node)
879 struct node *c;
883 for_each_property(node, prop) {
891 for_each_child(node, c) {
900 struct node *lfn, struct node *node,
902 struct node *refnode)
904 struct node *wn, *nwn; /* local fixup node, walk node, new */
911 for (wn = node; wn; wn = wn->parent)
918 for (wn = node, i = depth - 1; wn; wn = wn->parent, i--)
923 /* if no node exists, create it */
936 struct node *lfn,
937 struct node *node)
939 struct node *dt = dti->dt;
940 struct node *c;
943 struct node *refnode;
945 for_each_property(node, prop) {
950 add_local_fixup_entry(dti, lfn, node, prop, m, refnode);
954 for_each_child(node, c)