]>
Commit | Line | Data |
---|---|---|
b85e4829 AC |
1 | /* The common simulator framework for GDB, the GNU Debugger. |
2 | ||
e2882c85 | 3 | Copyright 2002-2018 Free Software Foundation, Inc. |
b85e4829 AC |
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 | |
4744ac1b | 11 | the Free Software Foundation; either version 3 of the License, or |
b85e4829 AC |
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 | |
4744ac1b | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
21 | |
22 | ||
23 | #ifndef HW_PROPERTIES_H | |
24 | #define HW_PROPERTIES_H | |
25 | ||
26 | /* The following are valid property types. The property `array' is | |
27 | for generic untyped data. */ | |
28 | ||
12c4cbd5 MF |
29 | typedef enum |
30 | { | |
c906108c SS |
31 | array_property, |
32 | boolean_property, | |
33 | #if 0 | |
34 | ihandle_property, /*runtime*/ | |
35 | #endif | |
36 | integer_property, | |
37 | range_array_property, | |
38 | reg_array_property, | |
39 | string_property, | |
40 | string_array_property, | |
41 | } hw_property_type; | |
42 | ||
12c4cbd5 MF |
43 | struct hw_property |
44 | { | |
c906108c SS |
45 | struct hw *owner; |
46 | const char *name; | |
47 | hw_property_type type; | |
48 | unsigned sizeof_array; | |
49 | const void *array; | |
50 | const struct hw_property *original; | |
51 | object_disposition disposition; | |
52 | }; | |
53 | ||
54 | #define hw_property_owner(p) ((p)->owner + 0) | |
55 | #define hw_property_name(p) ((p)->name + 0) | |
56 | #define hw_property_type(p) ((p)->type + 0) | |
57 | #define hw_property_array(p) ((p)->array + 0) | |
58 | #define hw_property_sizeof_array(p) ((p)->sizeof_array + 0) | |
59 | #define hw_property_original(p) ((p)->original + 0) | |
60 | #define hw_property_disposition(p) ((p)->disposition + 0) | |
61 | ||
62 | ||
63 | /* Find/iterate over properites attached to a device. | |
64 | ||
65 | To iterate over all properties attached to a device, call | |
66 | hw_find_property (.., NULL) and then hw_property_next. */ | |
67 | ||
68 | const struct hw_property *hw_find_property | |
69 | (struct hw *me, | |
70 | const char *property); | |
71 | ||
72 | const struct hw_property *hw_next_property | |
73 | (const struct hw_property *previous); | |
74 | ||
75 | ||
76 | /* Manipulate the properties belonging to a given device. | |
77 | ||
78 | HW_ADD_* will, if the property is not already present, add a | |
79 | property to the device. Adding a property to a device after it has | |
80 | been created is a checked run-time error (use HW_SET_*). | |
81 | ||
82 | HW_SET_* will always update (or create) the property so that it has | |
83 | the specified value. Changing the type of a property is a checked | |
84 | run-time error. | |
85 | ||
86 | FIND returns the specified properties value. It is a checked | |
87 | runtime error to either request a nonexistant property or to | |
88 | request a property using the wrong type. Code locating a property | |
89 | should first check its type (using hw_find_property above) and then | |
90 | obtain its value using the below. | |
91 | ||
92 | Naming convention: | |
93 | ||
94 | void hw_add_<type>_property(struct hw *, const char *, <type>) | |
95 | void hw_add_*_array_property(struct hw *, const char *, const <type>*, int) | |
96 | void hw_set_*_property(struct hw *, const char *, <type>) | |
97 | void hw_set_*_array_property(struct hw *, const char *, const <type>*, int) | |
98 | <type> hw_find_*_property(struct hw *, const char *) | |
99 | int hw_find_*_array_property(struct hw *, const char *, int, <type>*) | |
100 | ||
101 | */ | |
102 | ||
103 | ||
104 | void hw_add_array_property | |
105 | (struct hw *me, | |
106 | const char *property, | |
107 | const void *array, | |
108 | int sizeof_array); | |
109 | ||
110 | void hw_set_array_property | |
111 | (struct hw *me, | |
112 | const char *property, | |
113 | const void *array, | |
114 | int sizeof_array); | |
115 | ||
116 | const struct hw_property *hw_find_array_property | |
117 | (struct hw *me, | |
118 | const char *property); | |
119 | ||
120 | ||
121 | ||
122 | void hw_add_boolean_property | |
123 | (struct hw *me, | |
124 | const char *property, | |
799026a7 | 125 | int boolean); |
c906108c SS |
126 | |
127 | int hw_find_boolean_property | |
128 | (struct hw *me, | |
129 | const char *property); | |
130 | ||
131 | ||
132 | ||
133 | #if 0 | |
12c4cbd5 MF |
134 | typedef struct _ihandle_runtime_property_spec |
135 | { | |
c906108c SS |
136 | const char *full_path; |
137 | } ihandle_runtime_property_spec; | |
138 | ||
139 | void hw_add_ihandle_runtime_property | |
140 | (struct hw *me, | |
141 | const char *property, | |
142 | const ihandle_runtime_property_spec *ihandle); | |
143 | ||
144 | void hw_find_ihandle_runtime_property | |
145 | (struct hw *me, | |
146 | const char *property, | |
147 | ihandle_runtime_property_spec *ihandle); | |
148 | ||
149 | void hw_set_ihandle_property | |
150 | (struct hw *me, | |
151 | const char *property, | |
152 | hw_instance *ihandle); | |
153 | ||
154 | hw_instance * hw_find_ihandle_property | |
155 | (struct hw *me, | |
156 | const char *property); | |
157 | #endif | |
158 | ||
159 | ||
160 | void hw_add_integer_property | |
161 | (struct hw *me, | |
162 | const char *property, | |
163 | signed_cell integer); | |
164 | ||
165 | signed_cell hw_find_integer_property | |
166 | (struct hw *me, | |
167 | const char *property); | |
168 | ||
169 | int hw_find_integer_array_property | |
170 | (struct hw *me, | |
171 | const char *property, | |
172 | unsigned index, | |
f9cbceb6 | 173 | signed_cell *integer); |
c906108c SS |
174 | |
175 | ||
176 | ||
12c4cbd5 MF |
177 | typedef struct _range_property_spec |
178 | { | |
c906108c SS |
179 | hw_unit child_address; |
180 | hw_unit parent_address; | |
181 | hw_unit size; | |
182 | } range_property_spec; | |
183 | ||
184 | void hw_add_range_array_property | |
185 | (struct hw *me, | |
186 | const char *property, | |
187 | const range_property_spec *ranges, | |
188 | unsigned nr_ranges); | |
189 | ||
190 | int hw_find_range_array_property | |
191 | (struct hw *me, | |
192 | const char *property, | |
193 | unsigned index, | |
194 | range_property_spec *range); | |
195 | ||
196 | ||
197 | ||
12c4cbd5 MF |
198 | typedef struct _reg_property_spec |
199 | { | |
c906108c SS |
200 | hw_unit address; |
201 | hw_unit size; | |
202 | } reg_property_spec; | |
203 | ||
204 | void hw_add_reg_array_property | |
205 | (struct hw *me, | |
206 | const char *property, | |
207 | const reg_property_spec *reg, | |
208 | unsigned nr_regs); | |
209 | ||
210 | int hw_find_reg_array_property | |
211 | (struct hw *me, | |
212 | const char *property, | |
213 | unsigned index, | |
214 | reg_property_spec *reg); | |
215 | ||
216 | ||
217 | ||
218 | void hw_add_string_property | |
219 | (struct hw *me, | |
220 | const char *property, | |
221 | const char *string); | |
222 | ||
223 | const char *hw_find_string_property | |
224 | (struct hw *me, | |
225 | const char *property); | |
226 | ||
227 | ||
228 | ||
229 | typedef const char *string_property_spec; | |
230 | ||
231 | void hw_add_string_array_property | |
232 | (struct hw *me, | |
233 | const char *property, | |
234 | const string_property_spec *strings, | |
235 | unsigned nr_strings); | |
236 | ||
237 | int hw_find_string_array_property | |
238 | (struct hw *me, | |
239 | const char *property, | |
240 | unsigned index, | |
241 | string_property_spec *string); | |
242 | ||
243 | ||
244 | ||
245 | void hw_add_duplicate_property | |
246 | (struct hw *me, | |
247 | const char *property, | |
248 | const struct hw_property *original); | |
249 | ||
250 | #endif |