tree.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _TREE_H_
  15. #define _TREE_H_
  16. #ifndef INLINE_TREE
  17. #define INLINE_TREE
  18. #endif
  19. /* Constructing the device tree:
  20. The initial device tree populated with devices and basic properties
  21. is created using the function <<device_tree_add_parsed()>>. This
  22. function parses a PSIM device specification and uses it to populate
  23. the tree accordingly.
  24. This function accepts a printf style formatted string as the
  25. argument that describes the entry. Any properties or interrupt
  26. connections added to a device tree using this function are marked
  27. as having a permenant disposition. When the tree is (re)
  28. initialized they will be restored to their initial value.
  29. */
  30. EXTERN_TREE\
  31. (char*) tree_quote_property
  32. (const char *property_value);
  33. EXTERN_TREE\
  34. (device *) tree_parse
  35. (device *root,
  36. const char *fmt,
  37. ...) ATTRIBUTE_PRINTF_2;
  38. INLINE_TREE\
  39. (void) tree_usage
  40. (int verbose);
  41. INLINE_TREE\
  42. (void) tree_print
  43. (device *root);
  44. INLINE_TREE\
  45. (device_instance*) tree_instance
  46. (device *root,
  47. const char *device_specifier);
  48. /* Tree traversal::
  49. The entire device tree can be traversed using the
  50. <<device_tree_traverse()>> function. The traversal can be in
  51. either pre- or postfix order.
  52. */
  53. typedef void (tree_traverse_function)
  54. (device *device,
  55. void *data);
  56. INLINE_DEVICE\
  57. (void) tree_traverse
  58. (device *root,
  59. tree_traverse_function *prefix,
  60. tree_traverse_function *postfix,
  61. void *data);
  62. /* Tree lookup::
  63. The function <<tree_find_device()>> will attempt to locate
  64. the specified device within the tree. If the device is not found a
  65. NULL device is returned.
  66. */
  67. INLINE_TREE\
  68. (device *) tree_find_device
  69. (device *root,
  70. const char *path);
  71. INLINE_TREE\
  72. (const device_property *) tree_find_property
  73. (device *root,
  74. const char *path_to_property);
  75. INLINE_TREE\
  76. (int) tree_find_boolean_property
  77. (device *root,
  78. const char *path_to_property);
  79. INLINE_TREE\
  80. (signed_cell) tree_find_integer_property
  81. (device *root,
  82. const char *path_to_property);
  83. INLINE_TREE\
  84. (device_instance *) tree_find_ihandle_property
  85. (device *root,
  86. const char *path_to_property);
  87. INLINE_TREE\
  88. (const char *) tree_find_string_property
  89. (device *root,
  90. const char *path_to_property);
  91. /* Initializing the created tree:
  92. Once a device tree has been created the <<device_tree_init()>>
  93. function is used to initialize it. The exact sequence of events
  94. that occure during initialization are described separatly.
  95. */
  96. INLINE_TREE\
  97. (void) tree_init
  98. (device *root,
  99. psim *system);
  100. #endif /* _TREE_H_ */