GDB (xrefs)

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