gdb_server: support gdb target description
[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_INT8,
31 REG_TYPE_INT16,
32 REG_TYPE_INT32,
33 REG_TYPE_INT64,
34 REG_TYPE_INT128,
35 REG_TYPE_UINT8,
36 REG_TYPE_UINT16,
37 REG_TYPE_UINT32,
38 REG_TYPE_UINT64,
39 REG_TYPE_UINT128,
40 REG_TYPE_CODE_PTR,
41 REG_TYPE_DATA_PTR,
42 REG_TYPE_IEEE_SINGLE,
43 REG_TYPE_IEEE_DOUBLE,
44 REG_TYPE_ARCH_DEFINED,
45 };
46
47 struct reg_feature {
48 const char *name;
49 };
50
51 struct reg_data_type_vector {
52 struct reg_data_type *type;
53 uint32_t count;
54 };
55
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;
60 };
61
62 struct reg_data_type_union {
63 struct reg_data_type_union_field *fields;
64 };
65
66 struct reg_data_type_bitfield {
67 uint32_t start;
68 uint32_t end;
69 };
70
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;
77 };
78 struct reg_data_type_struct_field *next;
79 };
80
81 struct reg_data_type_struct {
82 uint32_t size;
83 struct reg_data_type_struct_field *fields;
84 };
85
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;
90 };
91
92 struct reg_data_type_flags {
93 uint32_t size;
94 struct reg_data_type_flags_field *fields;
95 };
96
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,
102 };
103
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;
113 };
114 };
115
116 struct reg {
117 const char *name;
118 uint32_t number;
119 struct reg_feature *feature;
120 bool caller_save;
121 void *value;
122 bool dirty;
123 bool valid;
124 bool exist;
125 uint32_t size;
126 struct reg_data_type *reg_data_type;
127 const char *group;
128 void *arch_info;
129 const struct reg_arch_type *type;
130 };
131
132 struct reg_cache {
133 const char *name;
134 struct reg_cache *next;
135 struct reg *reg_list;
136 unsigned num_regs;
137 };
138
139 struct reg_arch_type {
140 int (*get)(struct reg *reg);
141 int (*set)(struct reg *reg, uint8_t *buf);
142 };
143
144 struct reg *register_get_by_name(struct reg_cache *first,
145 const char *name, bool search_all);
146 struct reg_cache **register_get_last_cache_p(struct reg_cache **first);
147 void register_cache_invalidate(struct reg_cache *cache);
148
149 void register_init_dummy(struct reg *reg);
150
151 #endif /* REGISTER_H */