fdt.hh (009e81b16465ea457c0e63fd49fe77f47cc27a5a) | fdt.hh (bbe31b709a653884e18995a1c97cdafd7392999a) |
---|---|
1/*- 2 * Copyright (c) 2013 David Chisnall 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 25 unchanged lines hidden (view full) --- 34#define _FDT_HH_ 35#include <unordered_map> 36#include <unordered_set> 37#include <memory> 38#include <string> 39#include <functional> 40 41#include "util.hh" | 1/*- 2 * Copyright (c) 2013 David Chisnall 3 * All rights reserved. 4 * 5 * This software was developed by SRI International and the University of 6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 7 * ("CTSRD"), as part of the DARPA CRASH research programme. 8 * --- 25 unchanged lines hidden (view full) --- 34#define _FDT_HH_ 35#include <unordered_map> 36#include <unordered_set> 37#include <memory> 38#include <string> 39#include <functional> 40 41#include "util.hh" |
42#include "string.hh" | 42#include "input_buffer.hh" |
43 44namespace dtc 45{ 46 47namespace dtb 48{ 49struct output_writer; 50class string_table; --- 9 unchanged lines hidden (view full) --- 60typedef std::shared_ptr<property> property_ptr; 61/** 62 * Owning pointer to a node. 63 */ 64typedef std::unique_ptr<node> node_ptr; 65/** 66 * Map from macros to property pointers. 67 */ | 43 44namespace dtc 45{ 46 47namespace dtb 48{ 49struct output_writer; 50class string_table; --- 9 unchanged lines hidden (view full) --- 60typedef std::shared_ptr<property> property_ptr; 61/** 62 * Owning pointer to a node. 63 */ 64typedef std::unique_ptr<node> node_ptr; 65/** 66 * Map from macros to property pointers. 67 */ |
68typedef std::unordered_map<string, property_ptr> define_map; | 68typedef std::unordered_map<std::string, property_ptr> define_map; |
69/** | 69/** |
70 * Set of strings used for label names. 71 */ 72typedef std::unordered_set<std::string> string_set; 73/** |
|
70 * Properties may contain a number of different value, each with a different 71 * label. This class encapsulates a single value. 72 */ 73struct property_value 74{ 75 /** 76 * The label for this data. This is usually empty. 77 */ | 74 * Properties may contain a number of different value, each with a different 75 * label. This class encapsulates a single value. 76 */ 77struct property_value 78{ 79 /** 80 * The label for this data. This is usually empty. 81 */ |
78 string label; | 82 std::string label; |
79 /** 80 * If this value is a string, or something resolved from a string (a 81 * reference) then this contains the source string. 82 */ | 83 /** 84 * If this value is a string, or something resolved from a string (a 85 * reference) then this contains the source string. 86 */ |
83 string string_data; | 87 std::string string_data; |
84 /** 85 * The data that should be written to the final output. 86 */ 87 byte_buffer byte_data; 88 /** 89 * Enumeration describing the possible types of a value. Note that 90 * property-coded arrays will appear simply as binary (or possibly 91 * string, if they happen to be nul-terminated and printable), and must --- 89 unchanged lines hidden (view full) --- 181 * property value is not 32 bits long. The bytes in the property value 182 * are assumed to be in big-endian format, but the return value is in 183 * the host native endian. 184 */ 185 uint32_t get_as_uint32(); 186 /** 187 * Default constructor, specifying the label of the value. 188 */ | 88 /** 89 * The data that should be written to the final output. 90 */ 91 byte_buffer byte_data; 92 /** 93 * Enumeration describing the possible types of a value. Note that 94 * property-coded arrays will appear simply as binary (or possibly 95 * string, if they happen to be nul-terminated and printable), and must --- 89 unchanged lines hidden (view full) --- 185 * property value is not 32 bits long. The bytes in the property value 186 * are assumed to be in big-endian format, but the return value is in 187 * the host native endian. 188 */ 189 uint32_t get_as_uint32(); 190 /** 191 * Default constructor, specifying the label of the value. 192 */ |
189 property_value(string l=string()) : label(l), type(UNKNOWN) {} | 193 property_value(std::string l=std::string()) : label(l), type(UNKNOWN) {} |
190 /** 191 * Writes the data for this value into an output buffer. 192 */ 193 void push_to_buffer(byte_buffer &buffer); 194 195 /** 196 * Writes the property value to the standard output. This uses the 197 * following heuristics for deciding how to print the output: --- 47 unchanged lines hidden (view full) --- 245 * A value encapsulating a single property. This contains a key, optionally a 246 * label, and optionally one or more values. 247 */ 248class property 249{ 250 /** 251 * The name of this property. 252 */ | 194 /** 195 * Writes the data for this value into an output buffer. 196 */ 197 void push_to_buffer(byte_buffer &buffer); 198 199 /** 200 * Writes the property value to the standard output. This uses the 201 * following heuristics for deciding how to print the output: --- 47 unchanged lines hidden (view full) --- 249 * A value encapsulating a single property. This contains a key, optionally a 250 * label, and optionally one or more values. 251 */ 252class property 253{ 254 /** 255 * The name of this property. 256 */ |
253 string key; | 257 std::string key; |
254 /** | 258 /** |
255 * An optional label. | 259 * Zero or more labels. |
256 */ | 260 */ |
257 string label; | 261 string_set labels; |
258 /** 259 * The values in this property. 260 */ 261 std::vector<property_value> values; 262 /** 263 * Value indicating that this is a valid property. If a parse error 264 * occurs, then this value is false. 265 */ 266 bool valid; 267 /** 268 * Parses a string property value, i.e. a value enclosed in double quotes. 269 */ | 262 /** 263 * The values in this property. 264 */ 265 std::vector<property_value> values; 266 /** 267 * Value indicating that this is a valid property. If a parse error 268 * occurs, then this value is false. 269 */ 270 bool valid; 271 /** 272 * Parses a string property value, i.e. a value enclosed in double quotes. 273 */ |
270 void parse_string(input_buffer &input); | 274 void parse_string(text_input_buffer &input); |
271 /** 272 * Parses one or more 32-bit values enclosed in angle brackets. 273 */ | 275 /** 276 * Parses one or more 32-bit values enclosed in angle brackets. 277 */ |
274 void parse_cells(input_buffer &input, int cell_size); | 278 void parse_cells(text_input_buffer &input, int cell_size); |
275 /** 276 * Parses an array of bytes, contained within square brackets. 277 */ | 279 /** 280 * Parses an array of bytes, contained within square brackets. 281 */ |
278 void parse_bytes(input_buffer &input); | 282 void parse_bytes(text_input_buffer &input); |
279 /** 280 * Parses a reference. This is a node label preceded by an ampersand 281 * symbol, which should expand to the full path to that node. 282 * 283 * Note: The specification says that the target of such a reference is 284 * a node name, however dtc assumes that it is a label, and so we 285 * follow their interpretation for compatibility. 286 */ | 283 /** 284 * Parses a reference. This is a node label preceded by an ampersand 285 * symbol, which should expand to the full path to that node. 286 * 287 * Note: The specification says that the target of such a reference is 288 * a node name, however dtc assumes that it is a label, and so we 289 * follow their interpretation for compatibility. 290 */ |
287 void parse_reference(input_buffer &input); | 291 void parse_reference(text_input_buffer &input); |
288 /** 289 * Parse a predefined macro definition for a property. 290 */ | 292 /** 293 * Parse a predefined macro definition for a property. 294 */ |
291 void parse_define(input_buffer &input, define_map *defines); | 295 void parse_define(text_input_buffer &input, define_map *defines); |
292 /** 293 * Constructs a new property from two input buffers, pointing to the 294 * struct and strings tables in the device tree blob, respectively. 295 * The structs input buffer is assumed to have just consumed the 296 * FDT_PROP token. 297 */ 298 property(input_buffer &structs, input_buffer &strings); 299 /** 300 * Parses a new property from the input buffer. 301 */ | 296 /** 297 * Constructs a new property from two input buffers, pointing to the 298 * struct and strings tables in the device tree blob, respectively. 299 * The structs input buffer is assumed to have just consumed the 300 * FDT_PROP token. 301 */ 302 property(input_buffer &structs, input_buffer &strings); 303 /** 304 * Parses a new property from the input buffer. 305 */ |
302 property(input_buffer &input, 303 string k, 304 string l, | 306 property(text_input_buffer &input, 307 std::string &&k, 308 string_set &&l, |
305 bool terminated, 306 define_map *defines); 307 public: 308 /** 309 * Creates an empty property. 310 */ | 309 bool terminated, 310 define_map *defines); 311 public: 312 /** 313 * Creates an empty property. 314 */ |
311 property(string k, string l=string()) : key(k), label(l), valid(true) 312 {} | 315 property(std::string &&k, string_set &&l=string_set()) 316 : key(k), labels(l), valid(true) {} |
313 /** 314 * Copy constructor. 315 */ | 317 /** 318 * Copy constructor. 319 */ |
316 property(property &p) : key(p.key), label(p.label), values(p.values), | 320 property(property &p) : key(p.key), labels(p.labels), values(p.values), |
317 valid(p.valid) {} 318 /** 319 * Factory method for constructing a new property. Attempts to parse a 320 * property from the input, and returns it on success. On any parse 321 * error, this will return 0. 322 */ 323 static property_ptr parse_dtb(input_buffer &structs, | 321 valid(p.valid) {} 322 /** 323 * Factory method for constructing a new property. Attempts to parse a 324 * property from the input, and returns it on success. On any parse 325 * error, this will return 0. 326 */ 327 static property_ptr parse_dtb(input_buffer &structs, |
324 input_buffer &strings); | 328 input_buffer &strings); |
325 /** 326 * Factory method for constructing a new property. Attempts to parse a 327 * property from the input, and returns it on success. On any parse 328 * error, this will return 0. 329 */ | 329 /** 330 * Factory method for constructing a new property. Attempts to parse a 331 * property from the input, and returns it on success. On any parse 332 * error, this will return 0. 333 */ |
330 static property_ptr parse(input_buffer &input, 331 string key, 332 string label=string(), | 334 static property_ptr parse(text_input_buffer &input, 335 std::string &&key, 336 string_set &&labels=string_set(), |
333 bool semicolonTerminated=true, 334 define_map *defines=0); 335 /** 336 * Iterator type used for accessing the values of a property. 337 */ 338 typedef std::vector<property_value>::iterator value_iterator; 339 /** 340 * Returns an iterator referring to the first value in this property. --- 14 unchanged lines hidden (view full) --- 355 */ 356 inline void add_value(property_value v) 357 { 358 values.push_back(v); 359 } 360 /** 361 * Returns the key for this property. 362 */ | 337 bool semicolonTerminated=true, 338 define_map *defines=0); 339 /** 340 * Iterator type used for accessing the values of a property. 341 */ 342 typedef std::vector<property_value>::iterator value_iterator; 343 /** 344 * Returns an iterator referring to the first value in this property. --- 14 unchanged lines hidden (view full) --- 359 */ 360 inline void add_value(property_value v) 361 { 362 values.push_back(v); 363 } 364 /** 365 * Returns the key for this property. 366 */ |
363 inline string get_key() | 367 inline std::string get_key() |
364 { 365 return key; 366 } 367 /** 368 * Writes the property to the specified writer. The property name is a 369 * reference into the strings table. 370 */ 371 void write(dtb::output_writer &writer, dtb::string_table &strings); --- 9 unchanged lines hidden (view full) --- 381/** 382 * Class encapsulating a device tree node. Nodes may contain properties and 383 * other nodes. 384 */ 385class node 386{ 387 public: 388 /** | 368 { 369 return key; 370 } 371 /** 372 * Writes the property to the specified writer. The property name is a 373 * reference into the strings table. 374 */ 375 void write(dtb::output_writer &writer, dtb::string_table &strings); --- 9 unchanged lines hidden (view full) --- 385/** 386 * Class encapsulating a device tree node. Nodes may contain properties and 387 * other nodes. 388 */ 389class node 390{ 391 public: 392 /** |
389 * The label for this node, if any. Node labels are used as the | 393 * The labels for this node, if any. Node labels are used as the |
390 * targets for cross references. 391 */ | 394 * targets for cross references. 395 */ |
392 string label; | 396 std::unordered_set<std::string> labels; |
393 /** 394 * The name of the node. 395 */ | 397 /** 398 * The name of the node. 399 */ |
396 string name; | 400 std::string name; |
397 /** 398 * The unit address of the node, which is optionally written after the 399 * name followed by an at symbol. 400 */ | 401 /** 402 * The unit address of the node, which is optionally written after the 403 * name followed by an at symbol. 404 */ |
401 string unit_address; | 405 std::string unit_address; |
402 /** 403 * The type for the property vector. 404 */ 405 typedef std::vector<property_ptr> property_vector; 406 /** 407 * Iterator type for child nodes. 408 */ 409 typedef std::vector<node_ptr>::iterator child_iterator; --- 24 unchanged lines hidden (view full) --- 434 * The properties contained within this node. 435 */ 436 property_vector props; 437 /** 438 * The children of this node. 439 */ 440 std::vector<node_ptr> children; 441 /** | 406 /** 407 * The type for the property vector. 408 */ 409 typedef std::vector<property_ptr> property_vector; 410 /** 411 * Iterator type for child nodes. 412 */ 413 typedef std::vector<node_ptr>::iterator child_iterator; --- 24 unchanged lines hidden (view full) --- 438 * The properties contained within this node. 439 */ 440 property_vector props; 441 /** 442 * The children of this node. 443 */ 444 std::vector<node_ptr> children; 445 /** |
446 * Children that should be deleted from this node when merging. 447 */ 448 std::unordered_set<std::string> deleted_children; 449 /** 450 * Properties that should be deleted from this node when merging. 451 */ 452 std::unordered_set<std::string> deleted_props; 453 /** |
|
442 * A flag indicating whether this node is valid. This is set to false 443 * if an error occurs during parsing. 444 */ 445 bool valid; 446 /** 447 * Parses a name inside a node, writing the string passed as the last 448 * argument as an error if it fails. 449 */ | 454 * A flag indicating whether this node is valid. This is set to false 455 * if an error occurs during parsing. 456 */ 457 bool valid; 458 /** 459 * Parses a name inside a node, writing the string passed as the last 460 * argument as an error if it fails. 461 */ |
450 string parse_name(input_buffer &input, 451 bool &is_property, 452 const char *error); | 462 std::string parse_name(text_input_buffer &input, 463 bool &is_property, 464 const char *error); |
453 /** 454 * Constructs a new node from two input buffers, pointing to the struct 455 * and strings tables in the device tree blob, respectively. 456 */ 457 node(input_buffer &structs, input_buffer &strings); 458 /** 459 * Parses a new node from the specified input buffer. This is called 460 * when the input cursor is on the open brace for the start of the 461 * node. The name, and optionally label and unit address, should have 462 * already been parsed. 463 */ | 465 /** 466 * Constructs a new node from two input buffers, pointing to the struct 467 * and strings tables in the device tree blob, respectively. 468 */ 469 node(input_buffer &structs, input_buffer &strings); 470 /** 471 * Parses a new node from the specified input buffer. This is called 472 * when the input cursor is on the open brace for the start of the 473 * node. The name, and optionally label and unit address, should have 474 * already been parsed. 475 */ |
464 node(input_buffer &input, string n, string l, string a, define_map*); | 476 node(text_input_buffer &input, 477 std::string &&n, 478 std::unordered_set<std::string> &&l, 479 std::string &&a, 480 define_map*); |
465 /** 466 * Comparison function for properties, used when sorting the properties 467 * vector. Orders the properties based on their names. 468 */ 469 static inline bool cmp_properties(property_ptr &p1, property_ptr &p2); 470 /* 471 { 472 return p1->get_key() < p2->get_key(); --- 20 unchanged lines hidden (view full) --- 493 } 494 /** 495 * Returns an iterator after the last child of this node. 496 */ 497 inline child_iterator child_end() 498 { 499 return children.end(); 500 } | 481 /** 482 * Comparison function for properties, used when sorting the properties 483 * vector. Orders the properties based on their names. 484 */ 485 static inline bool cmp_properties(property_ptr &p1, property_ptr &p2); 486 /* 487 { 488 return p1->get_key() < p2->get_key(); --- 20 unchanged lines hidden (view full) --- 509 } 510 /** 511 * Returns an iterator after the last child of this node. 512 */ 513 inline child_iterator child_end() 514 { 515 return children.end(); 516 } |
517 /** 518 * Returns a range suitable for use in a range-based for loop describing 519 * the children of this node. 520 */ |
|
501 inline child_range child_nodes() 502 { 503 return child_range(*this); 504 } | 521 inline child_range child_nodes() 522 { 523 return child_range(*this); 524 } |
525 /** 526 * Accessor for the deleted children. 527 */ 528 inline const std::unordered_set<std::string> &deleted_child_nodes() 529 { 530 return deleted_children; 531 } 532 /** 533 * Accessor for the deleted properties 534 */ 535 inline const std::unordered_set<std::string> &deleted_properties() 536 { 537 return deleted_props; 538 } 539 /** 540 * Returns a range suitable for use in a range-based for loop describing 541 * the properties of this node. 542 */ |
|
505 inline property_range properties() 506 { 507 return property_range(*this); 508 } 509 /** 510 * Returns an iterator after the last property of this node. 511 */ 512 inline property_vector::iterator property_begin() --- 9 unchanged lines hidden (view full) --- 522 } 523 /** 524 * Factory method for constructing a new node. Attempts to parse a 525 * node in DTS format from the input, and returns it on success. On 526 * any parse error, this will return 0. This should be called with the 527 * cursor on the open brace of the property, after the name and so on 528 * have been parsed. 529 */ | 543 inline property_range properties() 544 { 545 return property_range(*this); 546 } 547 /** 548 * Returns an iterator after the last property of this node. 549 */ 550 inline property_vector::iterator property_begin() --- 9 unchanged lines hidden (view full) --- 560 } 561 /** 562 * Factory method for constructing a new node. Attempts to parse a 563 * node in DTS format from the input, and returns it on success. On 564 * any parse error, this will return 0. This should be called with the 565 * cursor on the open brace of the property, after the name and so on 566 * have been parsed. 567 */ |
530 static node_ptr parse(input_buffer &input, 531 string name, 532 string label=string(), 533 string address=string(), | 568 static node_ptr parse(text_input_buffer &input, 569 std::string &&name, 570 std::unordered_set<std::string> &&label=std::unordered_set<std::string>(), 571 std::string &&address=std::string(), |
534 define_map *defines=0); 535 /** 536 * Factory method for constructing a new node. Attempts to parse a 537 * node in DTB format from the input, and returns it on success. On 538 * any parse error, this will return 0. This should be called with the 539 * cursor on the open brace of the property, after the name and so on 540 * have been parsed. 541 */ 542 static node_ptr parse_dtb(input_buffer &structs, input_buffer &strings); 543 /** 544 * Returns a property corresponding to the specified key, or 0 if this 545 * node does not contain a property of that name. 546 */ | 572 define_map *defines=0); 573 /** 574 * Factory method for constructing a new node. Attempts to parse a 575 * node in DTB format from the input, and returns it on success. On 576 * any parse error, this will return 0. This should be called with the 577 * cursor on the open brace of the property, after the name and so on 578 * have been parsed. 579 */ 580 static node_ptr parse_dtb(input_buffer &structs, input_buffer &strings); 581 /** 582 * Returns a property corresponding to the specified key, or 0 if this 583 * node does not contain a property of that name. 584 */ |
547 property_ptr get_property(string key); | 585 property_ptr get_property(const std::string &key); |
548 /** 549 * Adds a new property to this node. 550 */ 551 inline void add_property(property_ptr &p) 552 { 553 props.push_back(p); 554 } 555 /** --- 27 unchanged lines hidden (view full) --- 583 */ 584class device_tree 585{ 586 public: 587 /** 588 * Type used for node paths. A node path is sequence of names and unit 589 * addresses. 590 */ | 586 /** 587 * Adds a new property to this node. 588 */ 589 inline void add_property(property_ptr &p) 590 { 591 props.push_back(p); 592 } 593 /** --- 27 unchanged lines hidden (view full) --- 621 */ 622class device_tree 623{ 624 public: 625 /** 626 * Type used for node paths. A node path is sequence of names and unit 627 * addresses. 628 */ |
591 typedef std::vector<std::pair<string,string> > node_path; | 629 typedef std::vector<std::pair<std::string,std::string> > node_path; |
592 /** 593 * Name that we should use for phandle nodes. 594 */ 595 enum phandle_format 596 { 597 /** linux,phandle */ 598 LINUX, 599 /** phandle */ --- 25 unchanged lines hidden (view full) --- 625 /** 626 * Root node. All other nodes are children of this node. 627 */ 628 node_ptr root; 629 /** 630 * Mapping from names to nodes. Only unambiguous names are recorded, 631 * duplicate names are stored as (node*)-1. 632 */ | 630 /** 631 * Name that we should use for phandle nodes. 632 */ 633 enum phandle_format 634 { 635 /** linux,phandle */ 636 LINUX, 637 /** phandle */ --- 25 unchanged lines hidden (view full) --- 663 /** 664 * Root node. All other nodes are children of this node. 665 */ 666 node_ptr root; 667 /** 668 * Mapping from names to nodes. Only unambiguous names are recorded, 669 * duplicate names are stored as (node*)-1. 670 */ |
633 std::unordered_map<string, node*> node_names; | 671 std::unordered_map<std::string, node*> node_names; |
634 /** 635 * A map from labels to node paths. When resolving cross references, 636 * we look up referenced nodes in this and replace the cross reference 637 * with the full path to its target. 638 */ | 672 /** 673 * A map from labels to node paths. When resolving cross references, 674 * we look up referenced nodes in this and replace the cross reference 675 * with the full path to its target. 676 */ |
639 std::unordered_map<string, node_path> node_paths; | 677 std::unordered_map<std::string, node_path> node_paths; |
640 /** 641 * A collection of property values that are references to other nodes. 642 * These should be expanded to the full path of their targets. 643 */ 644 std::vector<property_value*> cross_references; 645 /** 646 * A collection of property values that refer to phandles. These will 647 * be replaced by the value of the phandle property in their 648 * destination. 649 */ 650 std::vector<property_value*> phandles; 651 /** 652 * The names of nodes that target phandles. 653 */ | 678 /** 679 * A collection of property values that are references to other nodes. 680 * These should be expanded to the full path of their targets. 681 */ 682 std::vector<property_value*> cross_references; 683 /** 684 * A collection of property values that refer to phandles. These will 685 * be replaced by the value of the phandle property in their 686 * destination. 687 */ 688 std::vector<property_value*> phandles; 689 /** 690 * The names of nodes that target phandles. 691 */ |
654 std::unordered_set<string> phandle_targets; | 692 std::unordered_set<std::string> phandle_targets; |
655 /** 656 * A collection of input buffers that we are using. These input 657 * buffers are the ones that own their memory, and so we must preserve 658 * them for the lifetime of the device tree. 659 */ 660 std::vector<std::unique_ptr<input_buffer>> buffers; 661 /** 662 * A map of used phandle values to nodes. All phandles must be unique, --- 50 unchanged lines hidden (view full) --- 713 void collect_names(); 714 /** 715 * Resolves all cross references. Any properties that refer to another 716 * node must have their values replaced by either the node path or 717 * phandle value. 718 */ 719 void resolve_cross_references(); 720 /** | 693 /** 694 * A collection of input buffers that we are using. These input 695 * buffers are the ones that own their memory, and so we must preserve 696 * them for the lifetime of the device tree. 697 */ 698 std::vector<std::unique_ptr<input_buffer>> buffers; 699 /** 700 * A map of used phandle values to nodes. All phandles must be unique, --- 50 unchanged lines hidden (view full) --- 751 void collect_names(); 752 /** 753 * Resolves all cross references. Any properties that refer to another 754 * node must have their values replaced by either the node path or 755 * phandle value. 756 */ 757 void resolve_cross_references(); 758 /** |
721 * Parse a top-level include directive. 722 */ 723 bool parse_include(input_buffer &input, 724 const std::string &dir, 725 std::vector<node_ptr> &roots, 726 FILE *depfile, 727 bool &read_header); 728 /** | |
729 * Parses a dts file in the given buffer and adds the roots to the parsed 730 * set. The `read_header` argument indicates whether the header has 731 * already been read. Some dts files place the header in an include, 732 * rather than in the top-level file. 733 */ | 759 * Parses a dts file in the given buffer and adds the roots to the parsed 760 * set. The `read_header` argument indicates whether the header has 761 * already been read. Some dts files place the header in an include, 762 * rather than in the top-level file. 763 */ |
734 void parse_file(input_buffer &input, 735 const std::string &dir, | 764 void parse_file(text_input_buffer &input, |
736 std::vector<node_ptr> &roots, | 765 std::vector<node_ptr> &roots, |
737 FILE *depfile, | |
738 bool &read_header); 739 /** | 766 bool &read_header); 767 /** |
740 * Allocates a new mmap()'d input buffer for use in parsing. This 741 * object then keeps a reference to it, ensuring that it is not 742 * deallocated until the device tree is destroyed. 743 */ 744 input_buffer *buffer_for_file(const char *path, bool warn=true); 745 /** | |
746 * Template function that writes a dtb blob using the specified writer. 747 * The writer defines the output format (assembly, blob). 748 */ 749 template<class writer> 750 void write(int fd); 751 public: 752 /** 753 * Returns the node referenced by the property. If this is a tree that --- 20 unchanged lines hidden (view full) --- 774 */ 775 device_tree() : phandle_node_name(EPAPR), valid(true), 776 boot_cpu(0), spare_reserve_map_entries(0), 777 minimum_blob_size(0), blob_padding(0) {} 778 /** 779 * Constructs a device tree from the specified file name, referring to 780 * a file that contains a device tree blob. 781 */ | 768 * Template function that writes a dtb blob using the specified writer. 769 * The writer defines the output format (assembly, blob). 770 */ 771 template<class writer> 772 void write(int fd); 773 public: 774 /** 775 * Returns the node referenced by the property. If this is a tree that --- 20 unchanged lines hidden (view full) --- 796 */ 797 device_tree() : phandle_node_name(EPAPR), valid(true), 798 boot_cpu(0), spare_reserve_map_entries(0), 799 minimum_blob_size(0), blob_padding(0) {} 800 /** 801 * Constructs a device tree from the specified file name, referring to 802 * a file that contains a device tree blob. 803 */ |
782 void parse_dtb(const char *fn, FILE *depfile); | 804 void parse_dtb(const std::string &fn, FILE *depfile); |
783 /** 784 * Constructs a device tree from the specified file name, referring to 785 * a file that contains device tree source. 786 */ | 805 /** 806 * Constructs a device tree from the specified file name, referring to 807 * a file that contains device tree source. 808 */ |
787 void parse_dts(const char *fn, FILE *depfile); | 809 void parse_dts(const std::string &fn, FILE *depfile); |
788 /** 789 * Returns whether this tree is valid. 790 */ 791 inline bool is_valid() 792 { 793 return valid; 794 } 795 /** --- 71 unchanged lines hidden --- | 810 /** 811 * Returns whether this tree is valid. 812 */ 813 inline bool is_valid() 814 { 815 return valid; 816 } 817 /** --- 71 unchanged lines hidden --- |