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