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