OpenOCD
register.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2005 by Dominic Rath *
5  * Dominic.Rath@gmx.de *
6  * *
7  * Copyright (C) 2007,2008 Øyvind Harboe *
8  * oyvind.harboe@zylin.com *
9  ***************************************************************************/
10 
11 #ifndef OPENOCD_TARGET_REGISTER_H
12 #define OPENOCD_TARGET_REGISTER_H
13 
14 #include "helper/replacements.h"
15 #include "helper/types.h"
16 
17 struct target;
18 
19 enum reg_type {
39 };
40 
41 struct reg_feature {
42  const char *name;
43 };
44 
47  uint32_t count;
48 };
49 
51  const char *name;
54 };
55 
58 };
59 
61  uint32_t start;
62  uint32_t end;
63  enum reg_type type;
64 };
65 
67  const char *name;
69  union {
72  };
74 };
75 
77  uint32_t size;
79 };
80 
82  const char *name;
85 };
86 
88  uint32_t size;
90 };
91 
97 };
98 
99 struct reg_data_type {
100  enum reg_type type;
101  const char *id;
103  union {
108  };
109 };
110 
111 struct reg {
112  /* Canonical name of the register. */
113  const char *name;
114  /* Number that gdb uses to access this register. */
115  uint32_t number;
116  /* TODO. This should probably be const. */
118  /* TODO: When true, the caller will save this register before running any algorithm. */
120  /* Pointer to place where the value is stored, in the format understood by
121  * the binarybuffer.h functions. */
122  uint8_t *value;
123  /* The stored value needs to be written to the target. */
124  bool dirty;
125  /* When true, value is valid. */
126  bool valid;
127  /* When false, the register doesn't actually exist in the target. */
128  bool exist;
129  /* Hide the register from gdb and omit it in 'reg' cmd output */
130  bool hidden;
131  /* Size of the register in bits. */
132  uint32_t size;
133  /* Used for generating XML description of registers. Can be set to NULL for
134  * targets that don't use that. */
136  /* Used for generating XML description of registers. Can be set to NULL for
137  * targets that don't use that. */
138  const char *group;
139  /* Pointer to architecture-specific info for this register. */
140  void *arch_info;
141  const struct reg_arch_type *type;
142 };
143 
144 struct reg_cache {
145  const char *name;
146  struct reg_cache *next;
147  struct reg *reg_list;
148  unsigned num_regs;
149 };
150 
152  int (*get)(struct reg *reg);
153  int (*set)(struct reg *reg, uint8_t *buf);
154 };
155 
156 struct reg *register_get_by_number(struct reg_cache *first,
157  uint32_t reg_num, bool search_all);
158 struct reg *register_get_by_name(struct reg_cache *first,
159  const char *name, bool search_all);
160 struct reg_cache **register_get_last_cache_p(struct reg_cache **first);
161 void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache);
162 void register_cache_invalidate(struct reg_cache *cache);
163 
164 void register_init_dummy(struct reg *reg);
165 
166 #endif /* OPENOCD_TARGET_REGISTER_H */
const char * name
Definition: armv4_5.c:76
void register_init_dummy(struct reg *reg)
Definition: register.c:124
reg_type
Definition: register.h:19
@ REG_TYPE_INT
Definition: register.h:21
@ REG_TYPE_UINT16
Definition: register.h:29
@ REG_TYPE_BOOL
Definition: register.h:20
@ REG_TYPE_IEEE_DOUBLE
Definition: register.h:37
@ REG_TYPE_INT64
Definition: register.h:25
@ REG_TYPE_INT16
Definition: register.h:23
@ REG_TYPE_UINT32
Definition: register.h:30
@ REG_TYPE_CODE_PTR
Definition: register.h:33
@ REG_TYPE_DATA_PTR
Definition: register.h:34
@ REG_TYPE_INT32
Definition: register.h:24
@ REG_TYPE_INT128
Definition: register.h:26
@ REG_TYPE_UINT128
Definition: register.h:32
@ REG_TYPE_UINT
Definition: register.h:27
@ REG_TYPE_FLOAT
Definition: register.h:35
@ REG_TYPE_UINT64
Definition: register.h:31
@ REG_TYPE_INT8
Definition: register.h:22
@ REG_TYPE_ARCH_DEFINED
Definition: register.h:38
@ REG_TYPE_IEEE_SINGLE
Definition: register.h:36
@ REG_TYPE_UINT8
Definition: register.h:28
struct reg * register_get_by_name(struct reg_cache *first, const char *name, bool search_all)
Definition: register.c:50
reg_data_type_class
Definition: register.h:92
@ REG_TYPE_CLASS_VECTOR
Definition: register.h:93
@ REG_TYPE_CLASS_FLAGS
Definition: register.h:96
@ REG_TYPE_CLASS_UNION
Definition: register.h:94
@ REG_TYPE_CLASS_STRUCT
Definition: register.h:95
struct reg_cache ** register_get_last_cache_p(struct reg_cache **first)
Definition: register.c:72
void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache)
Definition: register.c:85
void register_cache_invalidate(struct reg_cache *cache)
Marks the contents of the register cache as invalid (and clean).
Definition: register.c:94
struct reg * register_get_by_number(struct reg_cache *first, uint32_t reg_num, bool search_all)
Definition: register.c:28
int(* get)(struct reg *reg)
Definition: register.h:152
int(* set)(struct reg *reg, uint8_t *buf)
Definition: register.h:153
const char * name
Definition: register.h:145
unsigned num_regs
Definition: register.h:148
struct reg * reg_list
Definition: register.h:147
struct reg_cache * next
Definition: register.h:146
enum reg_type type
Definition: register.h:63
struct reg_data_type_flags_field * next
Definition: register.h:84
struct reg_data_type_bitfield * bitfield
Definition: register.h:83
struct reg_data_type_flags_field * fields
Definition: register.h:89
struct reg_data_type * type
Definition: register.h:71
struct reg_data_type_bitfield * bitfield
Definition: register.h:70
struct reg_data_type_struct_field * next
Definition: register.h:73
struct reg_data_type_struct_field * fields
Definition: register.h:78
struct reg_data_type * type
Definition: register.h:52
struct reg_data_type_union_field * next
Definition: register.h:53
struct reg_data_type_union_field * fields
Definition: register.h:57
struct reg_data_type * type
Definition: register.h:46
struct reg_data_type_union * reg_type_union
Definition: register.h:105
enum reg_type type
Definition: register.h:100
struct reg_data_type_vector * reg_type_vector
Definition: register.h:104
enum reg_data_type_class type_class
Definition: register.h:102
const char * id
Definition: register.h:101
struct reg_data_type_flags * reg_type_flags
Definition: register.h:107
struct reg_data_type_struct * reg_type_struct
Definition: register.h:106
const char * name
Definition: register.h:42
Definition: register.h:111
bool caller_save
Definition: register.h:119
bool valid
Definition: register.h:126
bool exist
Definition: register.h:128
uint32_t size
Definition: register.h:132
const char * group
Definition: register.h:138
uint8_t * value
Definition: register.h:122
struct reg_feature * feature
Definition: register.h:117
struct reg_data_type * reg_data_type
Definition: register.h:135
uint32_t number
Definition: register.h:115
bool hidden
Definition: register.h:130
void * arch_info
Definition: register.h:140
bool dirty
Definition: register.h:124
const struct reg_arch_type * type
Definition: register.h:141
const char * name
Definition: register.h:113
Definition: target.h:120