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