Document `struct reg` fields.
[openocd.git] / src / target / register.h
blobdc18e9a89935cf9038791303c1f14801c2eb9218
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20 ***************************************************************************/
22 #ifndef OPENOCD_TARGET_REGISTER_H
23 #define OPENOCD_TARGET_REGISTER_H
25 struct target;
27 enum reg_type {
28 REG_TYPE_INT,
29 REG_TYPE_INT8,
30 REG_TYPE_INT16,
31 REG_TYPE_INT32,
32 REG_TYPE_INT64,
33 REG_TYPE_INT128,
34 REG_TYPE_UINT8,
35 REG_TYPE_UINT16,
36 REG_TYPE_UINT32,
37 REG_TYPE_UINT64,
38 REG_TYPE_UINT128,
39 REG_TYPE_CODE_PTR,
40 REG_TYPE_DATA_PTR,
41 REG_TYPE_FLOAT,
42 REG_TYPE_IEEE_SINGLE,
43 REG_TYPE_IEEE_DOUBLE,
44 REG_TYPE_ARCH_DEFINED,
47 struct reg_feature {
48 const char *name;
51 struct reg_data_type_vector {
52 struct reg_data_type *type;
53 uint32_t count;
56 struct reg_data_type_union_field {
57 const char *name;
58 struct reg_data_type *type;
59 struct reg_data_type_union_field *next;
62 struct reg_data_type_union {
63 struct reg_data_type_union_field *fields;
66 struct reg_data_type_bitfield {
67 uint32_t start;
68 uint32_t end;
71 struct reg_data_type_struct_field {
72 const char *name;
73 bool use_bitfields;
74 union {
75 struct reg_data_type_bitfield *bitfield;
76 struct reg_data_type *type;
78 struct reg_data_type_struct_field *next;
81 struct reg_data_type_struct {
82 uint32_t size;
83 struct reg_data_type_struct_field *fields;
86 struct reg_data_type_flags_field {
87 const char *name;
88 struct reg_data_type_bitfield *bitfield;
89 struct reg_data_type_flags_field *next;
92 struct reg_data_type_flags {
93 uint32_t size;
94 struct reg_data_type_flags_field *fields;
97 enum reg_data_type_class {
98 REG_TYPE_CLASS_VECTOR,
99 REG_TYPE_CLASS_UNION,
100 REG_TYPE_CLASS_STRUCT,
101 REG_TYPE_CLASS_FLAGS,
104 struct reg_data_type {
105 enum reg_type type;
106 const char *id;
107 enum reg_data_type_class type_class;
108 union {
109 struct reg_data_type_vector *reg_type_vector;
110 struct reg_data_type_union *reg_type_union;
111 struct reg_data_type_struct *reg_type_struct;
112 struct reg_data_type_flags *reg_type_flags;
116 struct reg {
117 /* Canonical name of the register. */
118 const char *name;
119 /* Number that gdb uses to access this register. */
120 uint32_t number;
121 /* TODO. This should probably be const. */
122 struct reg_feature *feature;
123 /* TODO: When true, the caller will save this register before running any algorithm. */
124 bool caller_save;
125 /* Pointer to place where the value is stored, in the format understood by
126 * the binarybuffer.h functions. */
127 void *value;
128 /* The stored value needs to be written to the target. */
129 bool dirty;
130 /* When true, value is valid. */
131 bool valid;
132 /* When false, the register doesn't actually exist in the target. */
133 bool exist;
134 /* Size of the register in bits. */
135 uint32_t size;
136 /* Used for generating XML description of registers. Can be set to NULL for
137 * targets that don't use that. */
138 struct reg_data_type *reg_data_type;
139 /* Used for generating XML description of registers. Can be set to NULL for
140 * targets that don't use that. */
141 const char *group;
142 /* Pointer to architecture-specific info for this register. */
143 void *arch_info;
144 const struct reg_arch_type *type;
147 struct reg_cache {
148 const char *name;
149 struct reg_cache *next;
150 struct reg *reg_list;
151 unsigned num_regs;
154 struct reg_arch_type {
155 int (*get)(struct reg *reg);
156 int (*set)(struct reg *reg, uint8_t *buf);
159 struct reg *register_get_by_name(struct reg_cache *first,
160 const char *name, bool search_all);
161 struct reg_cache **register_get_last_cache_p(struct reg_cache **first);
162 void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache);
163 void register_cache_invalidate(struct reg_cache *cache);
165 void register_init_dummy(struct reg *reg);
167 #endif /* OPENOCD_TARGET_REGISTER_H */