You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

178 lines
5.2 KiB

  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. ***************************************************************************/
  21. #ifndef OPENOCD_TARGET_REGISTER_H
  22. #define OPENOCD_TARGET_REGISTER_H
  23. #include "helper/replacements.h"
  24. #include "helper/types.h"
  25. struct target;
  26. enum reg_type {
  27. REG_TYPE_BOOL,
  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_UINT,
  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_FLOAT,
  43. REG_TYPE_IEEE_SINGLE,
  44. REG_TYPE_IEEE_DOUBLE,
  45. REG_TYPE_ARCH_DEFINED,
  46. };
  47. struct reg_feature {
  48. const char *name;
  49. };
  50. struct reg_data_type_vector {
  51. struct reg_data_type *type;
  52. uint32_t count;
  53. };
  54. struct reg_data_type_union_field {
  55. const char *name;
  56. struct reg_data_type *type;
  57. struct reg_data_type_union_field *next;
  58. };
  59. struct reg_data_type_union {
  60. struct reg_data_type_union_field *fields;
  61. };
  62. struct reg_data_type_bitfield {
  63. uint32_t start;
  64. uint32_t end;
  65. enum reg_type type;
  66. };
  67. struct reg_data_type_struct_field {
  68. const char *name;
  69. bool use_bitfields;
  70. union {
  71. struct reg_data_type_bitfield *bitfield;
  72. struct reg_data_type *type;
  73. };
  74. struct reg_data_type_struct_field *next;
  75. };
  76. struct reg_data_type_struct {
  77. uint32_t size;
  78. struct reg_data_type_struct_field *fields;
  79. };
  80. struct reg_data_type_flags_field {
  81. const char *name;
  82. struct reg_data_type_bitfield *bitfield;
  83. struct reg_data_type_flags_field *next;
  84. };
  85. struct reg_data_type_flags {
  86. uint32_t size;
  87. struct reg_data_type_flags_field *fields;
  88. };
  89. enum reg_data_type_class {
  90. REG_TYPE_CLASS_VECTOR,
  91. REG_TYPE_CLASS_UNION,
  92. REG_TYPE_CLASS_STRUCT,
  93. REG_TYPE_CLASS_FLAGS,
  94. };
  95. struct reg_data_type {
  96. enum reg_type type;
  97. const char *id;
  98. enum reg_data_type_class type_class;
  99. union {
  100. struct reg_data_type_vector *reg_type_vector;
  101. struct reg_data_type_union *reg_type_union;
  102. struct reg_data_type_struct *reg_type_struct;
  103. struct reg_data_type_flags *reg_type_flags;
  104. };
  105. };
  106. struct reg {
  107. /* Canonical name of the register. */
  108. const char *name;
  109. /* Number that gdb uses to access this register. */
  110. uint32_t number;
  111. /* TODO. This should probably be const. */
  112. struct reg_feature *feature;
  113. /* TODO: When true, the caller will save this register before running any algorithm. */
  114. bool caller_save;
  115. /* Pointer to place where the value is stored, in the format understood by
  116. * the binarybuffer.h functions. */
  117. uint8_t *value;
  118. /* The stored value needs to be written to the target. */
  119. bool dirty;
  120. /* When true, value is valid. */
  121. bool valid;
  122. /* When false, the register doesn't actually exist in the target. */
  123. bool exist;
  124. /* Hide the register from gdb and omit it in 'reg' cmd output */
  125. bool hidden;
  126. /* Size of the register in bits. */
  127. uint32_t size;
  128. /* Used for generating XML description of registers. Can be set to NULL for
  129. * targets that don't use that. */
  130. struct reg_data_type *reg_data_type;
  131. /* Used for generating XML description of registers. Can be set to NULL for
  132. * targets that don't use that. */
  133. const char *group;
  134. /* Pointer to architecture-specific info for this register. */
  135. void *arch_info;
  136. const struct reg_arch_type *type;
  137. };
  138. struct reg_cache {
  139. const char *name;
  140. struct reg_cache *next;
  141. struct reg *reg_list;
  142. unsigned num_regs;
  143. };
  144. struct reg_arch_type {
  145. int (*get)(struct reg *reg);
  146. int (*set)(struct reg *reg, uint8_t *buf);
  147. };
  148. struct reg *register_get_by_number(struct reg_cache *first,
  149. uint32_t reg_num, bool search_all);
  150. struct reg *register_get_by_name(struct reg_cache *first,
  151. const char *name, bool search_all);
  152. struct reg_cache **register_get_last_cache_p(struct reg_cache **first);
  153. void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache);
  154. void register_cache_invalidate(struct reg_cache *cache);
  155. void register_init_dummy(struct reg *reg);
  156. #endif /* OPENOCD_TARGET_REGISTER_H */