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