Lines Matching +full:- +full:- +full:valid +full:- +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
8 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
296 input.parse_error("reference only permitted in 32-bit arrays"); in parse_cells()
297 valid = false; in parse_cells()
314 valid = false; in parse_cells()
341 valid = false; in parse_cells()
347 // permit anything that looks like a sign-extended in parse_cells()
350 (val | ((1ull << (cell_size - 1)) - 1)) != in parse_cells()
354 std::to_string(cell_size) + "-bit cell"; in parse_cells()
356 valid = false; in parse_cells()
403 valid = false; in parse_bytes()
424 valid = false; in parse_reference()
435 valid = structs.consume_binary(length) && in property()
437 if (!valid) in property()
449 valid = false; in property()
463 if (!(valid = structs.consume_binary(byte))) in property()
479 valid = false; in parse_define()
485 ((found = defines->find(name)) == defines->end())) in parse_define()
488 valid = false; in parse_define()
491 values.push_back((*found).second->values[0]); in parse_define()
498 define_map *defines) : key(k), labels(l), valid(true) in property()
507 if (valid) in property()
515 valid = false; in property()
523 if (!(valid = input.consume('"'))) in property()
529 if (!(valid = input.read_binary_file(filename, v.byte_data))) in property()
534 if (!(valid &= input.consume(')'))) in property()
543 valid = input.consume("/bits/"); in property()
545 valid &= input.consume_integer(bits); in property()
551 valid = false; in property()
553 if (!valid) return; in property()
557 input.parse_error("/bits/ directive is only valid on arrays"); in property()
558 valid = false; in property()
586 valid = false; in property()
594 if (!p->valid) in parse_dtb()
610 if (!p->valid) in parse()
624 i->push_to_buffer(value_buffer); in write()
698 for (auto i=vals->begin(), e=vals->end() ; i!=e ; ++i) in write_dts()
700 i->write_dts(file); in write_dts()
723 return -1; in offset_of_value()
729 if (!valid) in parse_name()
744 valid = false; in parse_name()
763 behavior = c->visit(fn, this); in visit()
778 node::node(input_buffer &structs, input_buffer &strings) : valid(true) in node()
807 valid = false; in node()
815 valid = false; in node()
830 valid = false; in node()
841 valid = false; in node()
849 valid = false; in node()
882 : labels(l), name(n), unit_address(a), valid(true) in node()
889 while (valid && !input.consume('}')) in node()
894 // flag set if our node is marked as /omit-if-no-ref/ to be in node()
904 valid = false; in node()
916 valid = false; in node()
921 if (input.consume("/delete-node/")) in node()
926 if (valid) in node()
932 if (input.consume("/delete-property/")) in node()
937 if (valid) in node()
943 if (input.consume("/omit-if-no-ref/")) in node()
963 if (!valid) in node()
975 valid = false; in node()
988 child->omit_if_no_ref = marked_omit_if_no_ref; in node()
993 valid = false; in node()
1003 valid = false; in node()
1014 return p1->get_key() < p2->get_key(); in cmp_properties()
1020 if (c1->name == c2->name) in cmp_children()
1022 return c1->unit_address < c2->unit_address; in cmp_children()
1024 return c1->name < c2->name; in cmp_children()
1034 c->sort(); in sort()
1071 if (!n->valid) in parse()
1082 if (!n->valid) in parse_dtb()
1094 if (i->get_key() == key) in get_property()
1105 for (auto &l : other->labels) in merge_node()
1111 string full_name = p->name; in merge_node()
1112 if (p->unit_address != string()) in merge_node()
1115 full_name += p->unit_address; in merge_node()
1117 if (other->deleted_children.count(full_name) > 0) in merge_node()
1119 other->deleted_children.erase(full_name); in merge_node()
1126 if (other->deleted_props.count(p->get_key()) > 0) in merge_node()
1128 other->deleted_props.erase(p->get_key()); in merge_node()
1138 for (auto &p : other->properties()) in merge_node()
1143 if (mp->get_key() == p->get_key()) in merge_node()
1155 for (auto &c : other->children) in merge_node()
1160 if (i->name == c->name && i->unit_address == c->unit_address) in merge_node()
1162 i->merge_node(c); in merge_node()
1190 p->write(writer, strings); in write()
1194 c->write(writer, strings); in write()
1224 p->write_dts(file, indent+1); in write_dts()
1228 c->write_dts(file, indent+1); in write_dts()
1240 path.push_back(std::make_pair(n->name, n->unit_address)); in collect_names_recursive()
1241 for (const string &name : n->labels) in collect_names_recursive()
1268 for (auto &c : n->child_nodes()) in collect_names_recursive()
1274 for (auto &p : n->properties()) in collect_names_recursive()
1287 if ((p->get_key() == "phandle") || in collect_names_recursive()
1288 (p->get_key() == "linux,phandle")) in collect_names_recursive()
1290 if (p->begin()->byte_data.size() != 4) in collect_names_recursive()
1292 …fprintf(stderr, "Invalid phandle value for node %s. Should be a 4-byte value.\n", n->name.c_str()… in collect_names_recursive()
1293 valid = false; in collect_names_recursive()
1297 uint32_t phandle = p->begin()->get_as_uint32(); in collect_names_recursive()
1321 property_ptr p = n->get_property("phandle"); in assign_phandle()
1324 p = n->get_property("linux,phandle"); in assign_phandle()
1339 // any 32-bit system and we've done in assign_phandle()
1348 p->add_value(v); in assign_phandle()
1349 n->add_property(p); in assign_phandle()
1354 p->add_value(v); in assign_phandle()
1355 n->add_property(p); in assign_phandle()
1365 if (!n->labels.empty()) in assign_phandles()
1370 for (auto &c : n->child_nodes()) in assign_phandles()
1381 node_path path = node_paths[pv->string_data]; in resolve_cross_references()
1389 pv->byte_data.push_back('/'); in resolve_cross_references()
1390 push_string(pv->byte_data, p->first); in resolve_cross_references()
1391 if (!(p->second.empty())) in resolve_cross_references()
1393 pv->byte_data.push_back('@'); in resolve_cross_references()
1394 push_string(pv->byte_data, p->second); in resolve_cross_references()
1397 pv->byte_data.push_back(0); in resolve_cross_references()
1406 root->visit([&](node &n, node *) { in resolve_cross_references()
1414 sorted_phandles.push_back(i->second); in resolve_cross_references()
1447 for (auto &c : target->child_nodes()) in resolve_cross_references()
1449 if (c->name == node_name) in resolve_cross_references()
1451 if (c->unit_address == node_address) in resolve_cross_references()
1458 possible = path + c->name; in resolve_cross_references()
1459 if (c->unit_address != string()) in resolve_cross_references()
1462 possible += c->unit_address; in resolve_cross_references()
1498 valid = 0; in resolve_cross_references()
1504 p->begin()->push_to_buffer(i.get().val.byte_data); in resolve_cross_references()
1542 if (!nx->used) in garbage_collect_marked_nodes()
1544 nx->used = 1; in garbage_collect_marked_nodes()
1557 root->visit([&](node &n, node *) { in garbage_collect_marked_nodes()
1580 root->visit([&](node &n, node *) { in garbage_collect_marked_nodes()
1585 if (cn->omit_if_no_ref && !cn->used) in garbage_collect_marked_nodes()
1596 return (nx->omit_if_no_ref && !nx->used); in garbage_collect_marked_nodes()
1615 while (input.consume("/dts-v1/;")) in parse_file()
1627 input.parse_error("Expected /dts-v1/; version string"); in parse_file()
1649 while (valid && !input.finished()) in parse_file()
1652 if (input.consume("/delete-node/")) in parse_file()
1654 // Top-level /delete-node/ directives refer to references that must in parse_file()
1662 valid = false; in parse_file()
1665 return valid; in parse_file()
1667 if (expect('&', "Expected reference after top-level /delete-node/.")) in parse_file()
1672 input.parse_error("Expected label name for top-level /delete-node/."); in parse_file()
1673 valid = false; in parse_file()
1694 // While it may make sense in a non-plugin context, we don't support such in parse_file()
1710 n->name_is_path_reference = name_is_path_reference; in parse_file()
1723 valid = false; in parse_file()
1759 root->write(struct_writer, st); in write()
1828 fputs("/dts-v1/;\n\n", file); in write_dts()
1834 fwrite(msg, sizeof(msg) - 1, 1, file); in write_dts()
1843 root->write_dts(file, 0); in write_dts()
1853 valid = false; in parse_dtb()
1858 valid = h.read_dtb(input); in parse_dtb()
1863 valid = false; in parse_dtb()
1865 if (!valid) in parse_dtb()
1878 valid = false; in parse_dtb()
1895 valid = false; in parse_dtb()
1902 valid = false; in parse_dtb()
1905 valid = (root != 0); in parse_dtb()
1922 path += p->first; in to_string()
1923 if (!(p->second.empty())) in to_string()
1926 path += p->second; in to_string()
1935 // In a plugin, we can massage these non-/ root nodes into into a fragment in create_fragment_wrapper()
1948 v.string_data = node->name; in create_fragment_wrapper()
1949 if (!node->name_is_path_reference) in create_fragment_wrapper()
1956 propname = "target-path"; in create_fragment_wrapper()
1960 prop->add_value(v); in create_fragment_wrapper()
1965 wrapper->merge_node(node); in create_fragment_wrapper()
1966 fragment->add_child(std::move(wrapper)); in create_fragment_wrapper()
1967 newroot->add_child(std::move(fragment)); in create_fragment_wrapper()
1975 string name = node->name; in generate_root()
1992 for (auto &c : node->child_nodes()) in reassign_fragment_numbers()
1994 if (c->name == std::string("fragment")) in reassign_fragment_numbers()
1996 int current_address = std::stoi(c->unit_address, nullptr, 16); in reassign_fragment_numbers()
2003 c->unit_address = new_address.str(); in reassign_fragment_numbers()
2014 valid = false; in parse_dts()
2034 valid = false; in parse_dts()
2041 valid = false; in parse_dts()
2051 valid = false; in parse_dts()
2058 string name = node->name; in parse_dts()
2063 // Re-assign any fragment numbers based on a delta of in parse_dts()
2067 root->merge_node(node); in parse_dts()
2082 root->merge_node(fragment); in parse_dts()
2091 existing->second->merge_node(node); in parse_dts()
2104 …fprintf(stderr, "Top-level /delete-node/ directive refers to label %s, which is not found.\n", ref… in parse_dts()
2108 parent->delete_children_if([&](node_ptr &child) { return child == node; }); in parse_dts()
2120 // order semi-predictable and stable. in parse_dts()
2146 prop->add_value(v); in parse_dts()
2149 root->add_child(node::create_special_node("__symbols__", symbols)); in parse_dts()
2153 // already-loaded nodes and external references will need to be in parse_dts()
2164 value += i.prop->get_key(); in parse_dts()
2166 value += std::to_string(i.prop->offset_of_value(i.val)); in parse_dts()
2171 prop->add_value(v); in parse_dts()
2190 root->add_child(node::create_special_node("__fixups__", symbols)); in parse_dts()
2215 for (auto &c : n->child_nodes()) in parse_dts()
2217 if (c->name == p.first) in parse_dts()
2219 if (c->unit_address == p.second) in parse_dts()
2235 n->add_child(node::create_special_node(path, symbols)); in parse_dts()
2236 n = *(--(n->child_end())); in parse_dts()
2241 push_big_endian(pv.byte_data, static_cast<uint32_t>(i.prop->offset_of_value(i.val))); in parse_dts()
2243 auto key = i.prop->get_key(); in parse_dts()
2244 property_ptr prop = n->get_property(key); in parse_dts()
2250 n->add_property(prop); in parse_dts()
2251 prop->add_value(pv); in parse_dts()
2257 property_value &old_val = *(--prop->end()); in parse_dts()
2260 prop->add_value(pv); in parse_dts()
2266 if (local_fixups->child_begin() != local_fixups->child_end()) in parse_dts()
2268 root->add_child(std::move(local_fixups)); in parse_dts()
2286 string name(def, val-def); in parse_define()