1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney and Red Hat.
7 This file is part of GDB.
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.
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.
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/>. */
23 #ifndef HW_PROPERTIES_H
24 #define HW_PROPERTIES_H
26 /* The following are valid property types. The property `array' is
27 for generic untyped data. */
33 ihandle_property
, /*runtime*/
39 string_array_property
,
45 hw_property_type type
;
46 unsigned sizeof_array
;
48 const struct hw_property
*original
;
49 object_disposition disposition
;
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)
61 /* Find/iterate over properites attached to a device.
63 To iterate over all properties attached to a device, call
64 hw_find_property (.., NULL) and then hw_property_next. */
66 const struct hw_property
*hw_find_property
68 const char *property
);
70 const struct hw_property
*hw_next_property
71 (const struct hw_property
*previous
);
74 /* Manipulate the properties belonging to a given device.
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_*).
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
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.
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>*)
102 void hw_add_array_property
104 const char *property
,
108 void hw_set_array_property
110 const char *property
,
114 const struct hw_property
*hw_find_array_property
116 const char *property
);
120 void hw_add_boolean_property
122 const char *property
,
125 int hw_find_boolean_property
127 const char *property
);
132 typedef struct _ihandle_runtime_property_spec
{
133 const char *full_path
;
134 } ihandle_runtime_property_spec
;
136 void hw_add_ihandle_runtime_property
138 const char *property
,
139 const ihandle_runtime_property_spec
*ihandle
);
141 void hw_find_ihandle_runtime_property
143 const char *property
,
144 ihandle_runtime_property_spec
*ihandle
);
146 void hw_set_ihandle_property
148 const char *property
,
149 hw_instance
*ihandle
);
151 hw_instance
* hw_find_ihandle_property
153 const char *property
);
157 void hw_add_integer_property
159 const char *property
,
160 signed_cell integer
);
162 signed_cell hw_find_integer_property
164 const char *property
);
166 int hw_find_integer_array_property
168 const char *property
,
170 signed_cell
*integer
);
174 typedef struct _range_property_spec
{
175 hw_unit child_address
;
176 hw_unit parent_address
;
178 } range_property_spec
;
180 void hw_add_range_array_property
182 const char *property
,
183 const range_property_spec
*ranges
,
186 int hw_find_range_array_property
188 const char *property
,
190 range_property_spec
*range
);
194 typedef struct _reg_property_spec
{
199 void hw_add_reg_array_property
201 const char *property
,
202 const reg_property_spec
*reg
,
205 int hw_find_reg_array_property
207 const char *property
,
209 reg_property_spec
*reg
);
213 void hw_add_string_property
215 const char *property
,
218 const char *hw_find_string_property
220 const char *property
);
224 typedef const char *string_property_spec
;
226 void hw_add_string_array_property
228 const char *property
,
229 const string_property_spec
*strings
,
230 unsigned nr_strings
);
232 int hw_find_string_array_property
234 const char *property
,
236 string_property_spec
*string
);
240 void hw_add_duplicate_property
242 const char *property
,
243 const struct hw_property
*original
);