1 /* This file is part of the program psim.
3 Copyright (C) 1994-1998, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifndef HW_PROPERTIES_H
23 #define HW_PROPERTIES_H
25 /* The following are valid property types. The property `array' is
26 for generic untyped data. */
32 ihandle_property, /*runtime*/
38 string_array_property,
44 hw_property_type type;
45 unsigned sizeof_array;
47 const struct hw_property *original;
48 object_disposition disposition;
51 #define hw_property_owner(p) ((p)->owner + 0)
52 #define hw_property_name(p) ((p)->name + 0)
53 #define hw_property_type(p) ((p)->type + 0)
54 #define hw_property_array(p) ((p)->array + 0)
55 #define hw_property_sizeof_array(p) ((p)->sizeof_array + 0)
56 #define hw_property_original(p) ((p)->original + 0)
57 #define hw_property_disposition(p) ((p)->disposition + 0)
60 /* Find/iterate over properites attached to a device.
62 To iterate over all properties attached to a device, call
63 hw_find_property (.., NULL) and then hw_property_next. */
65 const struct hw_property *hw_find_property
67 const char *property);
69 const struct hw_property *hw_next_property
70 (const struct hw_property *previous);
73 /* Manipulate the properties belonging to a given device.
75 HW_ADD_* will, if the property is not already present, add a
76 property to the device. Adding a property to a device after it has
77 been created is a checked run-time error (use HW_SET_*).
79 HW_SET_* will always update (or create) the property so that it has
80 the specified value. Changing the type of a property is a checked
83 FIND returns the specified properties value. It is a checked
84 runtime error to either request a nonexistant property or to
85 request a property using the wrong type. Code locating a property
86 should first check its type (using hw_find_property above) and then
87 obtain its value using the below.
91 void hw_add_<type>_property(struct hw *, const char *, <type>)
92 void hw_add_*_array_property(struct hw *, const char *, const <type>*, int)
93 void hw_set_*_property(struct hw *, const char *, <type>)
94 void hw_set_*_array_property(struct hw *, const char *, const <type>*, int)
95 <type> hw_find_*_property(struct hw *, const char *)
96 int hw_find_*_array_property(struct hw *, const char *, int, <type>*)
101 void hw_add_array_property
103 const char *property,
107 void hw_set_array_property
109 const char *property,
113 const struct hw_property *hw_find_array_property
115 const char *property);
119 void hw_add_boolean_property
121 const char *property,
124 int hw_find_boolean_property
126 const char *property);
131 typedef struct _ihandle_runtime_property_spec {
132 const char *full_path;
133 } ihandle_runtime_property_spec;
135 void hw_add_ihandle_runtime_property
137 const char *property,
138 const ihandle_runtime_property_spec *ihandle);
140 void hw_find_ihandle_runtime_property
142 const char *property,
143 ihandle_runtime_property_spec *ihandle);
145 void hw_set_ihandle_property
147 const char *property,
148 hw_instance *ihandle);
150 hw_instance * hw_find_ihandle_property
152 const char *property);
156 void hw_add_integer_property
158 const char *property,
159 signed_cell integer);
161 signed_cell hw_find_integer_property
163 const char *property);
165 int hw_find_integer_array_property
167 const char *property,
169 signed_word *integer);
173 typedef struct _range_property_spec {
174 hw_unit child_address;
175 hw_unit parent_address;
177 } range_property_spec;
179 void hw_add_range_array_property
181 const char *property,
182 const range_property_spec *ranges,
185 int hw_find_range_array_property
187 const char *property,
189 range_property_spec *range);
193 typedef struct _reg_property_spec {
198 void hw_add_reg_array_property
200 const char *property,
201 const reg_property_spec *reg,
204 int hw_find_reg_array_property
206 const char *property,
208 reg_property_spec *reg);
212 void hw_add_string_property
214 const char *property,
217 const char *hw_find_string_property
219 const char *property);
223 typedef const char *string_property_spec;
225 void hw_add_string_array_property
227 const char *property,
228 const string_property_spec *strings,
229 unsigned nr_strings);
231 int hw_find_string_array_property
233 const char *property,
235 string_property_spec *string);
239 void hw_add_duplicate_property
241 const char *property,
242 const struct hw_property *original);