memattr.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* Memory attributes support, for GDB.
  2. Copyright (C) 2001-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef MEMATTR_H
  15. #define MEMATTR_H
  16. enum mem_access_mode
  17. {
  18. MEM_NONE, /* Memory that is not physically present. */
  19. MEM_RW, /* read/write */
  20. MEM_RO, /* read only */
  21. MEM_WO, /* write only */
  22. /* Read/write, but special steps are required to write to it. */
  23. MEM_FLASH
  24. };
  25. enum mem_access_width
  26. {
  27. MEM_WIDTH_UNSPECIFIED,
  28. MEM_WIDTH_8, /* 8 bit accesses */
  29. MEM_WIDTH_16, /* 16 " " */
  30. MEM_WIDTH_32, /* 32 " " */
  31. MEM_WIDTH_64 /* 64 " " */
  32. };
  33. /* The set of all attributes that can be set for a memory region.
  34. This structure was created so that memory attributes can be passed
  35. to target_ functions without exposing the details of memory region
  36. list, which would be necessary if these fields were simply added to
  37. the mem_region structure.
  38. FIXME: It would be useful if there was a mechanism for targets to
  39. add their own attributes. For example, the number of wait states. */
  40. struct mem_attrib
  41. {
  42. static mem_attrib unknown ()
  43. {
  44. mem_attrib attrib;
  45. attrib.mode = MEM_NONE;
  46. return attrib;
  47. }
  48. /* read/write, read-only, or write-only */
  49. enum mem_access_mode mode = MEM_RW;
  50. enum mem_access_width width = MEM_WIDTH_UNSPECIFIED;
  51. /* enables hardware breakpoints */
  52. int hwbreak = 0;
  53. /* enables host-side caching of memory region data */
  54. int cache = 0;
  55. /* Enables memory verification. After a write, memory is re-read
  56. to verify that the write was successful. */
  57. int verify = 0;
  58. /* Block size. Only valid if mode == MEM_FLASH. */
  59. int blocksize = -1;
  60. };
  61. struct mem_region
  62. {
  63. /* Create a mem_region with default attributes. */
  64. mem_region (CORE_ADDR lo_, CORE_ADDR hi_)
  65. : lo (lo_), hi (hi_)
  66. {}
  67. /* Create a mem_region with access mode MODE_, but otherwise default
  68. attributes. */
  69. mem_region (CORE_ADDR lo_, CORE_ADDR hi_, mem_access_mode mode_)
  70. : lo (lo_), hi (hi_)
  71. {
  72. attrib.mode = mode_;
  73. }
  74. /* Create a mem_region with attributes ATTRIB_. */
  75. mem_region (CORE_ADDR lo_, CORE_ADDR hi_, const mem_attrib &attrib_)
  76. : lo (lo_), hi (hi_), attrib (attrib_)
  77. {}
  78. bool operator< (const mem_region &other) const
  79. {
  80. return this->lo < other.lo;
  81. }
  82. /* Lowest address in the region. */
  83. CORE_ADDR lo;
  84. /* Address past the highest address of the region.
  85. If 0, upper bound is "infinity". */
  86. CORE_ADDR hi;
  87. /* Item number of this memory region. */
  88. int number = 0;
  89. /* Status of this memory region (enabled if true, otherwise
  90. disabled). */
  91. bool enabled_p = true;
  92. /* Attributes for this region. */
  93. mem_attrib attrib;
  94. };
  95. extern struct mem_region *lookup_mem_region (CORE_ADDR);
  96. void invalidate_target_mem_regions (void);
  97. #endif /* MEMATTR_H */