1 /* Target description support for GDB.
3 Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5 Contributed by CodeSourcery.
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/>. */
22 #ifndef TARGET_DESCRIPTIONS_H
23 #define TARGET_DESCRIPTIONS_H 1
26 struct tdesc_arch_data;
32 /* Fetch the current target's description, and switch the current
33 architecture to one which incorporates that description. */
35 void target_find_description (void);
37 /* Discard any description fetched from the current target, and switch
38 the current architecture to one with no target description. */
40 void target_clear_description (void);
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. */
46 const struct target_desc *target_current_description (void);
48 /* Record architecture-specific functions to call for pseudo-register
49 support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs
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. */
54 void set_tdesc_pseudo_register_name
55 (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name);
57 void set_tdesc_pseudo_register_type
58 (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type);
60 void set_tdesc_pseudo_register_reggroup_p
61 (struct gdbarch *gdbarch,
62 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p);
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.
69 Fixed register assignments are taken from EARLY_DATA, which is freed.
70 All registers which have not been assigned fixed numbers are given
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
75 successfully validating the required registers. */
77 void tdesc_use_registers (struct gdbarch *gdbarch,
78 const struct target_desc *target_desc,
79 struct tdesc_arch_data *early_data);
81 /* Allocate initial data for validation of a target description during
82 gdbarch initialization. */
84 struct tdesc_arch_data *tdesc_data_alloc (void);
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. */
90 void tdesc_data_cleanup (void *data_untyped);
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,
97 int tdesc_numbered_register (const struct tdesc_feature *feature,
98 struct tdesc_arch_data *data,
99 int regno, const char *name);
101 /* Search FEATURE for a register named NAME, and return its size in
102 bits. The register must exist. */
104 int tdesc_register_size (const struct tdesc_feature *feature,
107 /* Search FEATURE for a register with any of the names from NAMES
108 (NULL-terminated). Record REGNO and the register in DATA; when
109 tdesc_use_registers is called, REGNO will be assigned to the
110 register. 1 is returned if the register was found, 0 if it was
113 int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
114 struct tdesc_arch_data *data,
115 int regno, const char *const names[]);
118 /* Accessors for target descriptions. */
120 /* Return the BFD architecture associated with this target
121 description, or NULL if no architecture was specified. */
123 const struct bfd_arch_info *tdesc_architecture
124 (const struct target_desc *);
126 /* Return the OSABI associated with this target description, or
127 GDB_OSABI_UNKNOWN if no osabi was specified. */
129 enum gdb_osabi tdesc_osabi (const struct target_desc *);
131 /* Return the string value of a property named KEY, or NULL if the
132 property was not specified. */
134 const char *tdesc_property (const struct target_desc *,
137 /* Return 1 if this target description describes any registers. */
139 int tdesc_has_registers (const struct target_desc *);
141 /* Return the feature with the given name, if present, or NULL if
142 the named feature is not found. */
144 const struct tdesc_feature *tdesc_find_feature (const struct target_desc *,
147 /* Return the name of FEATURE. */
149 const char *tdesc_feature_name (const struct tdesc_feature *feature);
151 /* Return the type associated with ID in the context of FEATURE, or
154 struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
157 /* Return the name of register REGNO, from the target description or
158 from an architecture-provided pseudo_register_name method. */
160 const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);
162 /* Check whether REGNUM is a member of REGGROUP using the target
163 description. Return -1 if the target description does not
166 int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
167 struct reggroup *reggroup);
169 /* Methods for constructing a target description. */
171 struct target_desc *allocate_target_description (void);
172 struct cleanup *make_cleanup_free_target_description (struct target_desc *);
173 void set_tdesc_architecture (struct target_desc *,
174 const struct bfd_arch_info *);
175 void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
176 void set_tdesc_property (struct target_desc *,
177 const char *key, const char *value);
179 struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
181 struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
183 struct tdesc_type *field_type,
185 struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature,
187 void tdesc_add_field (struct tdesc_type *type, const char *field_name,
188 struct tdesc_type *field_type);
189 void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
190 int regnum, int save_restore, const char *group,
191 int bitsize, const char *type);
193 #endif /* TARGET_DESCRIPTIONS_H */