xref: /netbsd-src/external/gpl3/gdb/dist/sim/common/hw-tree.h (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1 /* The common simulator framework for GDB, the GNU Debugger.
2 
3    Copyright 2002-2019 Free Software Foundation, Inc.
4 
5    Contributed by Andrew Cagney and Red Hat.
6 
7    This file is part of GDB.
8 
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21 
22 
23 #ifndef HW_TREE
24 #define HW_TREE
25 
26 
27 struct hw *hw_tree_create
28 (SIM_DESC sd,
29  const char *device);
30 
31 void hw_tree_delete
32 (struct hw *root);
33 
34 struct hw *hw_tree_parse
35 (struct hw *root,
36  const char *fmt,
37  ...) __attribute__ ((format (printf, 2, 3)));
38 
39 struct hw *hw_tree_vparse
40 (struct hw *root,
41  const char *fmt,
42  va_list ap);
43 
44 
45 void hw_tree_finish
46 (struct hw *root);
47 
48 typedef void (hw_tree_print_callback)
49      (void *,
50       const char *fmt,
51       ...);
52 
53 void hw_tree_print
54 (struct hw *root,
55  hw_tree_print_callback *print,
56  void *file);
57 
58 
59 /* Tree traversal::
60 
61    The entire device tree can be traversed using the
62    <<device_tree_traverse()>> function.  The traversal can be in
63    either prefix or postfix order.
64 
65    */
66 
67 typedef void (hw_tree_traverse_function)
68      (struct hw *device,
69       void *data);
70 
71 void hw_tree_traverse
72 (struct hw *root,
73  hw_tree_traverse_function *prefix,
74  hw_tree_traverse_function *postfix,
75  void *data);
76 
77 
78 /* Tree lookup::
79 
80    The function <<hw_tree_find_device()>> will attempt to locate the
81    specified device within the tree.  If the device is not found a
82    NULL device is returned.
83 
84    */
85 
86 struct hw * hw_tree_find_device
87 (struct hw *root,
88  const char *path);
89 
90 
91 const struct hw_property *hw_tree_find_property
92 (struct hw *root,
93  const char *path_to_property);
94 
95 int hw_tree_find_boolean_property
96 (struct hw *root,
97  const char *path_to_property);
98 
99 signed_cell hw_tree_find_integer_property
100 (struct hw *root,
101  const char *path_to_property);
102 
103 #if NOT_YET
104 device_instance *hw_tree_find_ihandle_property
105 (struct hw *root,
106  const char *path_to_property);
107 #endif
108 
109 const char *hw_tree_find_string_property
110 (struct hw *root,
111  const char *path_to_property);
112 
113 
114 /* Perform a soft reset on the created tree. */
115 
116 void hw_tree_reset
117 (struct hw *root);
118 
119 
120 #endif
121