Commit | Line | Data |
---|---|---|
424163ea DJ |
1 | /* Target description support for GDB. |
2 | ||
7b6bb8da JB |
3 | Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 |
4 | Free Software Foundation, Inc. | |
424163ea DJ |
5 | |
6 | Contributed by CodeSourcery. | |
7 | ||
8 | This file is part of GDB. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 12 | the Free Software Foundation; either version 3 of the License, or |
424163ea DJ |
13 | (at your option) any later version. |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
424163ea DJ |
22 | |
23 | #ifndef TARGET_DESCRIPTIONS_H | |
24 | #define TARGET_DESCRIPTIONS_H 1 | |
25 | ||
123dc839 DJ |
26 | struct tdesc_feature; |
27 | struct tdesc_arch_data; | |
ad068eab | 28 | struct tdesc_type; |
123dc839 | 29 | struct tdesc_reg; |
424163ea | 30 | struct target_desc; |
123dc839 | 31 | struct target_ops; |
424163ea DJ |
32 | |
33 | /* Fetch the current target's description, and switch the current | |
34 | architecture to one which incorporates that description. */ | |
35 | ||
36 | void target_find_description (void); | |
37 | ||
38 | /* Discard any description fetched from the current target, and switch | |
39 | the current architecture to one with no target description. */ | |
40 | ||
41 | void target_clear_description (void); | |
42 | ||
43 | /* Return the global current target description. This should only be | |
44 | used by gdbarch initialization code; most access should be through | |
45 | an existing gdbarch. */ | |
46 | ||
47 | const struct target_desc *target_current_description (void); | |
48 | ||
123dc839 | 49 | /* Record architecture-specific functions to call for pseudo-register |
f57d151a | 50 | support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs |
123dc839 DJ |
51 | is greater than zero, then these should be called as well. |
52 | They are equivalent to the gdbarch methods with similar names, | |
53 | except that they will only be called for pseudo registers. */ | |
54 | ||
55 | void set_tdesc_pseudo_register_name | |
56 | (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name); | |
57 | ||
58 | void set_tdesc_pseudo_register_type | |
59 | (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type); | |
60 | ||
61 | void set_tdesc_pseudo_register_reggroup_p | |
62 | (struct gdbarch *gdbarch, | |
63 | gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p); | |
64 | ||
7cc46491 DJ |
65 | /* Update GDBARCH to use the TARGET_DESC for registers. TARGET_DESC |
66 | may be GDBARCH's target description or (if GDBARCH does not have | |
67 | one which describes registers) another target description | |
68 | constructed by the gdbarch initialization routine. | |
69 | ||
70 | Fixed register assignments are taken from EARLY_DATA, which is freed. | |
123dc839 | 71 | All registers which have not been assigned fixed numbers are given |
f57d151a UW |
72 | numbers above the current value of gdbarch_num_regs. |
73 | gdbarch_num_regs and various register-related predicates are updated to | |
74 | refer to the target description. This function should only be called from | |
75 | the architecture's gdbarch initialization routine, and only after | |
123dc839 DJ |
76 | successfully validating the required registers. */ |
77 | ||
78 | void tdesc_use_registers (struct gdbarch *gdbarch, | |
7cc46491 | 79 | const struct target_desc *target_desc, |
123dc839 DJ |
80 | struct tdesc_arch_data *early_data); |
81 | ||
82 | /* Allocate initial data for validation of a target description during | |
83 | gdbarch initialization. */ | |
84 | ||
85 | struct tdesc_arch_data *tdesc_data_alloc (void); | |
86 | ||
87 | /* Clean up data allocated by tdesc_data_alloc. This should only | |
88 | be called to discard the data; tdesc_use_registers takes ownership | |
89 | of its EARLY_DATA argument. */ | |
90 | ||
91 | void tdesc_data_cleanup (void *data_untyped); | |
92 | ||
93 | /* Search FEATURE for a register named NAME. Record REGNO and the | |
94 | register in DATA; when tdesc_use_registers is called, REGNO will be | |
95 | assigned to the register. 1 is returned if the register was found, | |
96 | 0 if it was not. */ | |
97 | ||
98 | int tdesc_numbered_register (const struct tdesc_feature *feature, | |
99 | struct tdesc_arch_data *data, | |
100 | int regno, const char *name); | |
101 | ||
58d6951d DJ |
102 | /* Search FEATURE for a register named NAME, but do not assign a fixed |
103 | register number to it. */ | |
104 | ||
105 | int tdesc_unnumbered_register (const struct tdesc_feature *feature, | |
106 | const char *name); | |
107 | ||
7cc46491 DJ |
108 | /* Search FEATURE for a register named NAME, and return its size in |
109 | bits. The register must exist. */ | |
110 | ||
111 | int tdesc_register_size (const struct tdesc_feature *feature, | |
112 | const char *name); | |
113 | ||
123dc839 DJ |
114 | /* Search FEATURE for a register with any of the names from NAMES |
115 | (NULL-terminated). Record REGNO and the register in DATA; when | |
116 | tdesc_use_registers is called, REGNO will be assigned to the | |
117 | register. 1 is returned if the register was found, 0 if it was | |
118 | not. */ | |
119 | ||
120 | int tdesc_numbered_register_choices (const struct tdesc_feature *feature, | |
121 | struct tdesc_arch_data *data, | |
122 | int regno, const char *const names[]); | |
123 | ||
124 | ||
424163ea DJ |
125 | /* Accessors for target descriptions. */ |
126 | ||
23181151 DJ |
127 | /* Return the BFD architecture associated with this target |
128 | description, or NULL if no architecture was specified. */ | |
129 | ||
130 | const struct bfd_arch_info *tdesc_architecture | |
131 | (const struct target_desc *); | |
132 | ||
08d16641 PA |
133 | /* Return the OSABI associated with this target description, or |
134 | GDB_OSABI_UNKNOWN if no osabi was specified. */ | |
135 | ||
136 | enum gdb_osabi tdesc_osabi (const struct target_desc *); | |
137 | ||
e35359c5 UW |
138 | /* Return non-zero if this target description is compatible |
139 | with the given BFD architecture. */ | |
140 | ||
141 | int tdesc_compatible_p (const struct target_desc *, | |
142 | const struct bfd_arch_info *); | |
143 | ||
29709017 DJ |
144 | /* Return the string value of a property named KEY, or NULL if the |
145 | property was not specified. */ | |
146 | ||
147 | const char *tdesc_property (const struct target_desc *, | |
148 | const char *key); | |
149 | ||
123dc839 DJ |
150 | /* Return 1 if this target description describes any registers. */ |
151 | ||
152 | int tdesc_has_registers (const struct target_desc *); | |
153 | ||
154 | /* Return the feature with the given name, if present, or NULL if | |
155 | the named feature is not found. */ | |
156 | ||
157 | const struct tdesc_feature *tdesc_find_feature (const struct target_desc *, | |
158 | const char *name); | |
159 | ||
160 | /* Return the name of FEATURE. */ | |
161 | ||
162 | const char *tdesc_feature_name (const struct tdesc_feature *feature); | |
163 | ||
164 | /* Return the type associated with ID in the context of FEATURE, or | |
165 | NULL if none. */ | |
166 | ||
ad068eab UW |
167 | struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature, |
168 | const char *id); | |
123dc839 | 169 | |
f8b73d13 DJ |
170 | /* Return the name of register REGNO, from the target description or |
171 | from an architecture-provided pseudo_register_name method. */ | |
172 | ||
d93859e2 | 173 | const char *tdesc_register_name (struct gdbarch *gdbarch, int regno); |
f8b73d13 | 174 | |
58d6951d DJ |
175 | /* Return the type of register REGNO, from the target description or |
176 | from an architecture-provided pseudo_register_type method. */ | |
177 | ||
178 | struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno); | |
179 | ||
c378eb4e | 180 | /* Return the type associated with ID, from the target description. */ |
9fd3625f L |
181 | |
182 | struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id); | |
183 | ||
f8b73d13 DJ |
184 | /* Check whether REGNUM is a member of REGGROUP using the target |
185 | description. Return -1 if the target description does not | |
186 | specify a group. */ | |
187 | ||
188 | int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno, | |
189 | struct reggroup *reggroup); | |
190 | ||
424163ea DJ |
191 | /* Methods for constructing a target description. */ |
192 | ||
193 | struct target_desc *allocate_target_description (void); | |
23181151 DJ |
194 | struct cleanup *make_cleanup_free_target_description (struct target_desc *); |
195 | void set_tdesc_architecture (struct target_desc *, | |
196 | const struct bfd_arch_info *); | |
08d16641 | 197 | void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi); |
29709017 DJ |
198 | void set_tdesc_property (struct target_desc *, |
199 | const char *key, const char *value); | |
e35359c5 UW |
200 | void tdesc_add_compatible (struct target_desc *, |
201 | const struct bfd_arch_info *); | |
29709017 | 202 | |
123dc839 DJ |
203 | struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc, |
204 | const char *name); | |
ad068eab UW |
205 | struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature, |
206 | const char *name, | |
207 | struct tdesc_type *field_type, | |
208 | int count); | |
f5dff777 DJ |
209 | struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature, |
210 | const char *name); | |
211 | void tdesc_set_struct_size (struct tdesc_type *type, LONGEST size); | |
ad068eab UW |
212 | struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature, |
213 | const char *name); | |
f5dff777 DJ |
214 | struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature, |
215 | const char *name, | |
216 | LONGEST size); | |
ad068eab UW |
217 | void tdesc_add_field (struct tdesc_type *type, const char *field_name, |
218 | struct tdesc_type *field_type); | |
f5dff777 DJ |
219 | void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name, |
220 | int start, int end); | |
221 | void tdesc_add_flag (struct tdesc_type *type, int start, | |
222 | const char *flag_name); | |
123dc839 DJ |
223 | void tdesc_create_reg (struct tdesc_feature *feature, const char *name, |
224 | int regnum, int save_restore, const char *group, | |
225 | int bitsize, const char *type); | |
226 | ||
424163ea | 227 | #endif /* TARGET_DESCRIPTIONS_H */ |