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