*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / target-descriptions.h
1 /* Target description support for GDB.
2
3 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
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
11 the Free Software Foundation; either version 2 of the License, or
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
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
23
24 #ifndef TARGET_DESCRIPTIONS_H
25 #define TARGET_DESCRIPTIONS_H 1
26
27 struct tdesc_feature;
28 struct tdesc_arch_data;
29 struct tdesc_reg;
30 struct target_desc;
31 struct target_ops;
32 struct type;
33
34 /* Fetch the current target's description, and switch the current
35 architecture to one which incorporates that description. */
36
37 void target_find_description (void);
38
39 /* Discard any description fetched from the current target, and switch
40 the current architecture to one with no target description. */
41
42 void target_clear_description (void);
43
44 /* Return the global current target description. This should only be
45 used by gdbarch initialization code; most access should be through
46 an existing gdbarch. */
47
48 const struct target_desc *target_current_description (void);
49
50 /* Record architecture-specific functions to call for pseudo-register
51 support. If tdesc_use_registers is called and gdbarch_num_pseudo_regs
52 is greater than zero, then these should be called as well.
53 They are equivalent to the gdbarch methods with similar names,
54 except that they will only be called for pseudo registers. */
55
56 void set_tdesc_pseudo_register_name
57 (struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name);
58
59 void set_tdesc_pseudo_register_type
60 (struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type);
61
62 void set_tdesc_pseudo_register_reggroup_p
63 (struct gdbarch *gdbarch,
64 gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p);
65
66 /* Update GDBARCH to use the target description for registers. Fixed
67 register assignments are taken from EARLY_DATA, which is freed.
68 All registers which have not been assigned fixed numbers are given
69 numbers above the current value of gdbarch_num_regs.
70 gdbarch_num_regs and various register-related predicates are updated to
71 refer to the target description. This function should only be called from
72 the architecture's gdbarch initialization routine, and only after
73 successfully validating the required registers. */
74
75 void tdesc_use_registers (struct gdbarch *gdbarch,
76 struct tdesc_arch_data *early_data);
77
78 /* Allocate initial data for validation of a target description during
79 gdbarch initialization. */
80
81 struct tdesc_arch_data *tdesc_data_alloc (void);
82
83 /* Clean up data allocated by tdesc_data_alloc. This should only
84 be called to discard the data; tdesc_use_registers takes ownership
85 of its EARLY_DATA argument. */
86
87 void tdesc_data_cleanup (void *data_untyped);
88
89 /* Search FEATURE for a register named NAME. Record REGNO and the
90 register in DATA; when tdesc_use_registers is called, REGNO will be
91 assigned to the register. 1 is returned if the register was found,
92 0 if it was not. */
93
94 int tdesc_numbered_register (const struct tdesc_feature *feature,
95 struct tdesc_arch_data *data,
96 int regno, const char *name);
97
98 /* Search FEATURE for a register with any of the names from NAMES
99 (NULL-terminated). Record REGNO and the register in DATA; when
100 tdesc_use_registers is called, REGNO will be assigned to the
101 register. 1 is returned if the register was found, 0 if it was
102 not. */
103
104 int tdesc_numbered_register_choices (const struct tdesc_feature *feature,
105 struct tdesc_arch_data *data,
106 int regno, const char *const names[]);
107
108
109 /* Accessors for target descriptions. */
110
111 /* Return the BFD architecture associated with this target
112 description, or NULL if no architecture was specified. */
113
114 const struct bfd_arch_info *tdesc_architecture
115 (const struct target_desc *);
116
117 /* Return the string value of a property named KEY, or NULL if the
118 property was not specified. */
119
120 const char *tdesc_property (const struct target_desc *,
121 const char *key);
122
123 /* Return 1 if this target description describes any registers. */
124
125 int tdesc_has_registers (const struct target_desc *);
126
127 /* Return the feature with the given name, if present, or NULL if
128 the named feature is not found. */
129
130 const struct tdesc_feature *tdesc_find_feature (const struct target_desc *,
131 const char *name);
132
133 /* Return the name of FEATURE. */
134
135 const char *tdesc_feature_name (const struct tdesc_feature *feature);
136
137 /* Return the type associated with ID in the context of FEATURE, or
138 NULL if none. */
139
140 struct type *tdesc_named_type (const struct tdesc_feature *feature,
141 const char *id);
142
143 /* Return the name of register REGNO, from the target description or
144 from an architecture-provided pseudo_register_name method. */
145
146 const char *tdesc_register_name (int regno);
147
148 /* Check whether REGNUM is a member of REGGROUP using the target
149 description. Return -1 if the target description does not
150 specify a group. */
151
152 int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
153 struct reggroup *reggroup);
154
155 /* Methods for constructing a target description. */
156
157 struct target_desc *allocate_target_description (void);
158 struct cleanup *make_cleanup_free_target_description (struct target_desc *);
159 void set_tdesc_architecture (struct target_desc *,
160 const struct bfd_arch_info *);
161 void set_tdesc_property (struct target_desc *,
162 const char *key, const char *value);
163
164 struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
165 const char *name);
166 void tdesc_record_type (struct tdesc_feature *feature, struct type *type);
167
168 void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
169 int regnum, int save_restore, const char *group,
170 int bitsize, const char *type);
171
172 #endif /* TARGET_DESCRIPTIONS_H */
This page took 0.041739 seconds and 4 git commands to generate.