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