gdb: add default description reg types
[openocd.git] / src / target / register.h
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, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
22 ***************************************************************************/
23
24 #ifndef REGISTER_H
25 #define REGISTER_H
26
27 struct target;
28
29 enum reg_type {
30 REG_TYPE_INT,
31 REG_TYPE_INT8,
32 REG_TYPE_INT16,
33 REG_TYPE_INT32,
34 REG_TYPE_INT64,
35 REG_TYPE_INT128,
36 REG_TYPE_UINT8,
37 REG_TYPE_UINT16,
38 REG_TYPE_UINT32,
39 REG_TYPE_UINT64,
40 REG_TYPE_UINT128,
41 REG_TYPE_CODE_PTR,
42 REG_TYPE_DATA_PTR,
43 REG_TYPE_FLOAT,
44 REG_TYPE_IEEE_SINGLE,
45 REG_TYPE_IEEE_DOUBLE,
46 REG_TYPE_ARCH_DEFINED,
47 };
48
49 struct reg_feature {
50 const char *name;
51 };
52
53 struct reg_data_type_vector {
54 struct reg_data_type *type;
55 uint32_t count;
56 };
57
58 struct reg_data_type_union_field {
59 const char *name;
60 struct reg_data_type *type;
61 struct reg_data_type_union_field *next;
62 };
63
64 struct reg_data_type_union {
65 struct reg_data_type_union_field *fields;
66 };
67
68 struct reg_data_type_bitfield {
69 uint32_t start;
70 uint32_t end;
71 };
72
73 struct reg_data_type_struct_field {
74 const char *name;
75 bool use_bitfields;
76 union {
77 struct reg_data_type_bitfield *bitfield;
78 struct reg_data_type *type;
79 };
80 struct reg_data_type_struct_field *next;
81 };
82
83 struct reg_data_type_struct {
84 uint32_t size;
85 struct reg_data_type_struct_field *fields;
86 };
87
88 struct reg_data_type_flags_field {
89 const char *name;
90 struct reg_data_type_bitfield *bitfield;
91 struct reg_data_type_flags_field *next;
92 };
93
94 struct reg_data_type_flags {
95 uint32_t size;
96 struct reg_data_type_flags_field *fields;
97 };
98
99 enum reg_data_type_class {
100 REG_TYPE_CLASS_VECTOR,
101 REG_TYPE_CLASS_UNION,
102 REG_TYPE_CLASS_STRUCT,
103 REG_TYPE_CLASS_FLAGS,
104 };
105
106 struct reg_data_type {
107 enum reg_type type;
108 const char *id;
109 enum reg_data_type_class type_class;
110 union {
111 struct reg_data_type_vector *reg_type_vector;
112 struct reg_data_type_union *reg_type_union;
113 struct reg_data_type_struct *reg_type_struct;
114 struct reg_data_type_flags *reg_type_flags;
115 };
116 };
117
118 struct reg {
119 const char *name;
120 uint32_t number;
121 struct reg_feature *feature;
122 bool caller_save;
123 void *value;
124 bool dirty;
125 bool valid;
126 bool exist;
127 uint32_t size;
128 struct reg_data_type *reg_data_type;
129 const char *group;
130 void *arch_info;
131 const struct reg_arch_type *type;
132 };
133
134 struct reg_cache {
135 const char *name;
136 struct reg_cache *next;
137 struct reg *reg_list;
138 unsigned num_regs;
139 };
140
141 struct reg_arch_type {
142 int (*get)(struct reg *reg);
143 int (*set)(struct reg *reg, uint8_t *buf);
144 };
145
146 struct reg *register_get_by_name(struct reg_cache *first,
147 const char *name, bool search_all);
148 struct reg_cache **register_get_last_cache_p(struct reg_cache **first);
149 void register_cache_invalidate(struct reg_cache *cache);
150
151 void register_init_dummy(struct reg *reg);
152
153 #endif /* REGISTER_H */