xref: /netbsd/external/gpl3/gdb/dist/gdb/memattr.h (revision 1424dfb3)
166e63ce3Schristos /* Memory attributes support, for GDB.
266e63ce3Schristos 
3*1424dfb3Schristos    Copyright (C) 2001-2020 Free Software Foundation, Inc.
466e63ce3Schristos 
566e63ce3Schristos    This file is part of GDB.
666e63ce3Schristos 
766e63ce3Schristos    This program is free software; you can redistribute it and/or modify
866e63ce3Schristos    it under the terms of the GNU General Public License as published by
966e63ce3Schristos    the Free Software Foundation; either version 3 of the License, or
1066e63ce3Schristos    (at your option) any later version.
1166e63ce3Schristos 
1266e63ce3Schristos    This program is distributed in the hope that it will be useful,
1366e63ce3Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1466e63ce3Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1566e63ce3Schristos    GNU General Public License for more details.
1666e63ce3Schristos 
1766e63ce3Schristos    You should have received a copy of the GNU General Public License
1866e63ce3Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
1966e63ce3Schristos 
2066e63ce3Schristos #ifndef MEMATTR_H
2166e63ce3Schristos #define MEMATTR_H
2266e63ce3Schristos 
2366e63ce3Schristos enum mem_access_mode
2466e63ce3Schristos {
2566e63ce3Schristos   MEM_NONE,                     /* Memory that is not physically present.  */
2666e63ce3Schristos   MEM_RW,			/* read/write */
2766e63ce3Schristos   MEM_RO,			/* read only */
2866e63ce3Schristos   MEM_WO,			/* write only */
2966e63ce3Schristos 
3066e63ce3Schristos   /* Read/write, but special steps are required to write to it.  */
3166e63ce3Schristos   MEM_FLASH
3266e63ce3Schristos };
3366e63ce3Schristos 
3466e63ce3Schristos enum mem_access_width
3566e63ce3Schristos {
3666e63ce3Schristos   MEM_WIDTH_UNSPECIFIED,
3766e63ce3Schristos   MEM_WIDTH_8,			/*  8 bit accesses */
3866e63ce3Schristos   MEM_WIDTH_16,			/* 16  "      "    */
3966e63ce3Schristos   MEM_WIDTH_32,			/* 32  "      "    */
4066e63ce3Schristos   MEM_WIDTH_64			/* 64  "      "    */
4166e63ce3Schristos };
4266e63ce3Schristos 
4366e63ce3Schristos /* The set of all attributes that can be set for a memory region.
4466e63ce3Schristos 
4566e63ce3Schristos    This structure was created so that memory attributes can be passed
4666e63ce3Schristos    to target_ functions without exposing the details of memory region
4766e63ce3Schristos    list, which would be necessary if these fields were simply added to
4866e63ce3Schristos    the mem_region structure.
4966e63ce3Schristos 
5066e63ce3Schristos    FIXME: It would be useful if there was a mechanism for targets to
5166e63ce3Schristos    add their own attributes.  For example, the number of wait states.  */
5266e63ce3Schristos 
5366e63ce3Schristos struct mem_attrib
5466e63ce3Schristos {
unknownmem_attrib5507163879Schristos   static mem_attrib unknown ()
5607163879Schristos   {
5707163879Schristos     mem_attrib attrib;
5866e63ce3Schristos 
5907163879Schristos     attrib.mode = MEM_NONE;
6007163879Schristos 
6107163879Schristos     return attrib;
6207163879Schristos   }
6307163879Schristos 
6407163879Schristos   /* read/write, read-only, or write-only */
6507163879Schristos   enum mem_access_mode mode = MEM_RW;
6607163879Schristos 
6707163879Schristos   enum mem_access_width width = MEM_WIDTH_UNSPECIFIED;
6866e63ce3Schristos 
6966e63ce3Schristos   /* enables hardware breakpoints */
7007163879Schristos   int hwbreak = 0;
7166e63ce3Schristos 
7266e63ce3Schristos   /* enables host-side caching of memory region data */
7307163879Schristos   int cache = 0;
7466e63ce3Schristos 
7566e63ce3Schristos   /* Enables memory verification.  After a write, memory is re-read
7666e63ce3Schristos      to verify that the write was successful.  */
7707163879Schristos   int verify = 0;
7866e63ce3Schristos 
7966e63ce3Schristos   /* Block size.  Only valid if mode == MEM_FLASH.  */
8007163879Schristos   int blocksize = -1;
8166e63ce3Schristos };
8266e63ce3Schristos 
8366e63ce3Schristos struct mem_region
8466e63ce3Schristos {
8507163879Schristos   /* Create a mem_region with default attributes.  */
8607163879Schristos 
mem_regionmem_region8707163879Schristos   mem_region (CORE_ADDR lo_, CORE_ADDR hi_)
8807163879Schristos     : lo (lo_), hi (hi_)
8907163879Schristos   {}
9007163879Schristos 
9107163879Schristos   /* Create a mem_region with access mode MODE_, but otherwise default
9207163879Schristos      attributes.  */
9307163879Schristos 
mem_regionmem_region9407163879Schristos   mem_region (CORE_ADDR lo_, CORE_ADDR hi_, mem_access_mode mode_)
9507163879Schristos     : lo (lo_), hi (hi_)
9607163879Schristos   {
9707163879Schristos     attrib.mode = mode_;
9807163879Schristos   }
9907163879Schristos 
10007163879Schristos   /* Create a mem_region with attributes ATTRIB_.  */
10107163879Schristos 
mem_regionmem_region10207163879Schristos   mem_region (CORE_ADDR lo_, CORE_ADDR hi_, const mem_attrib &attrib_)
10307163879Schristos     : lo (lo_), hi (hi_), attrib (attrib_)
10407163879Schristos   {}
10507163879Schristos 
10607163879Schristos   bool operator< (const mem_region &other) const
10707163879Schristos   {
10807163879Schristos     return this->lo < other.lo;
10907163879Schristos   }
11007163879Schristos 
11166e63ce3Schristos   /* Lowest address in the region.  */
11266e63ce3Schristos   CORE_ADDR lo;
11366e63ce3Schristos   /* Address past the highest address of the region.
11466e63ce3Schristos      If 0, upper bound is "infinity".  */
11566e63ce3Schristos   CORE_ADDR hi;
11666e63ce3Schristos 
11766e63ce3Schristos   /* Item number of this memory region.  */
11807163879Schristos   int number = 0;
11966e63ce3Schristos 
12007163879Schristos   /* Status of this memory region (enabled if true, otherwise
12166e63ce3Schristos      disabled).  */
12207163879Schristos   bool enabled_p = true;
12366e63ce3Schristos 
12466e63ce3Schristos   /* Attributes for this region.  */
12507163879Schristos   mem_attrib attrib;
12666e63ce3Schristos };
12766e63ce3Schristos 
12866e63ce3Schristos extern struct mem_region *lookup_mem_region (CORE_ADDR);
12966e63ce3Schristos 
13066e63ce3Schristos void invalidate_target_mem_regions (void);
13166e63ce3Schristos 
13266e63ce3Schristos #endif	/* MEMATTR_H */
133