Home | History | Annotate | Line # | Download | only in gdb
memattr.h revision 1.1.1.5
      1      1.1  christos /* Memory attributes support, for GDB.
      2      1.1  christos 
      3  1.1.1.5  christos    Copyright (C) 2001-2019 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 enum mem_access_mode
     24      1.1  christos {
     25      1.1  christos   MEM_NONE,                     /* Memory that is not physically present.  */
     26      1.1  christos   MEM_RW,			/* read/write */
     27      1.1  christos   MEM_RO,			/* read only */
     28      1.1  christos   MEM_WO,			/* write only */
     29      1.1  christos 
     30      1.1  christos   /* Read/write, but special steps are required to write to it.  */
     31      1.1  christos   MEM_FLASH
     32      1.1  christos };
     33      1.1  christos 
     34      1.1  christos enum mem_access_width
     35      1.1  christos {
     36      1.1  christos   MEM_WIDTH_UNSPECIFIED,
     37      1.1  christos   MEM_WIDTH_8,			/*  8 bit accesses */
     38      1.1  christos   MEM_WIDTH_16,			/* 16  "      "    */
     39      1.1  christos   MEM_WIDTH_32,			/* 32  "      "    */
     40      1.1  christos   MEM_WIDTH_64			/* 64  "      "    */
     41      1.1  christos };
     42      1.1  christos 
     43      1.1  christos /* The set of all attributes that can be set for a memory region.
     44      1.1  christos 
     45      1.1  christos    This structure was created so that memory attributes can be passed
     46      1.1  christos    to target_ functions without exposing the details of memory region
     47      1.1  christos    list, which would be necessary if these fields were simply added to
     48      1.1  christos    the mem_region structure.
     49      1.1  christos 
     50      1.1  christos    FIXME: It would be useful if there was a mechanism for targets to
     51      1.1  christos    add their own attributes.  For example, the number of wait states.  */
     52      1.1  christos 
     53      1.1  christos struct mem_attrib
     54      1.1  christos {
     55  1.1.1.5  christos   static mem_attrib unknown ()
     56  1.1.1.5  christos   {
     57  1.1.1.5  christos     mem_attrib attrib;
     58  1.1.1.5  christos 
     59  1.1.1.5  christos     attrib.mode = MEM_NONE;
     60  1.1.1.5  christos 
     61  1.1.1.5  christos     return attrib;
     62  1.1.1.5  christos   }
     63  1.1.1.5  christos 
     64      1.1  christos   /* read/write, read-only, or write-only */
     65  1.1.1.5  christos   enum mem_access_mode mode = MEM_RW;
     66      1.1  christos 
     67  1.1.1.5  christos   enum mem_access_width width = MEM_WIDTH_UNSPECIFIED;
     68      1.1  christos 
     69      1.1  christos   /* enables hardware breakpoints */
     70  1.1.1.5  christos   int hwbreak = 0;
     71      1.1  christos 
     72      1.1  christos   /* enables host-side caching of memory region data */
     73  1.1.1.5  christos   int cache = 0;
     74      1.1  christos 
     75      1.1  christos   /* Enables memory verification.  After a write, memory is re-read
     76      1.1  christos      to verify that the write was successful.  */
     77  1.1.1.5  christos   int verify = 0;
     78      1.1  christos 
     79      1.1  christos   /* Block size.  Only valid if mode == MEM_FLASH.  */
     80  1.1.1.5  christos   int blocksize = -1;
     81      1.1  christos };
     82      1.1  christos 
     83      1.1  christos struct mem_region
     84      1.1  christos {
     85  1.1.1.5  christos   /* Create a mem_region with default attributes.  */
     86  1.1.1.5  christos 
     87  1.1.1.5  christos   mem_region (CORE_ADDR lo_, CORE_ADDR hi_)
     88  1.1.1.5  christos     : lo (lo_), hi (hi_)
     89  1.1.1.5  christos   {}
     90  1.1.1.5  christos 
     91  1.1.1.5  christos   /* Create a mem_region with access mode MODE_, but otherwise default
     92  1.1.1.5  christos      attributes.  */
     93  1.1.1.5  christos 
     94  1.1.1.5  christos   mem_region (CORE_ADDR lo_, CORE_ADDR hi_, mem_access_mode mode_)
     95  1.1.1.5  christos     : lo (lo_), hi (hi_)
     96  1.1.1.5  christos   {
     97  1.1.1.5  christos     attrib.mode = mode_;
     98  1.1.1.5  christos   }
     99  1.1.1.5  christos 
    100  1.1.1.5  christos   /* Create a mem_region with attributes ATTRIB_.  */
    101  1.1.1.5  christos 
    102  1.1.1.5  christos   mem_region (CORE_ADDR lo_, CORE_ADDR hi_, const mem_attrib &attrib_)
    103  1.1.1.5  christos     : lo (lo_), hi (hi_), attrib (attrib_)
    104  1.1.1.5  christos   {}
    105  1.1.1.5  christos 
    106  1.1.1.5  christos   bool operator< (const mem_region &other) const
    107  1.1.1.5  christos   {
    108  1.1.1.5  christos     return this->lo < other.lo;
    109  1.1.1.5  christos   }
    110  1.1.1.5  christos 
    111      1.1  christos   /* Lowest address in the region.  */
    112      1.1  christos   CORE_ADDR lo;
    113      1.1  christos   /* Address past the highest address of the region.
    114      1.1  christos      If 0, upper bound is "infinity".  */
    115      1.1  christos   CORE_ADDR hi;
    116      1.1  christos 
    117      1.1  christos   /* Item number of this memory region.  */
    118  1.1.1.5  christos   int number = 0;
    119      1.1  christos 
    120  1.1.1.5  christos   /* Status of this memory region (enabled if true, otherwise
    121      1.1  christos      disabled).  */
    122  1.1.1.5  christos   bool enabled_p = true;
    123      1.1  christos 
    124      1.1  christos   /* Attributes for this region.  */
    125  1.1.1.5  christos   mem_attrib attrib;
    126      1.1  christos };
    127      1.1  christos 
    128  1.1.1.5  christos extern struct mem_region *lookup_mem_region (CORE_ADDR);
    129      1.1  christos 
    130      1.1  christos void invalidate_target_mem_regions (void);
    131      1.1  christos 
    132      1.1  christos #endif	/* MEMATTR_H */
    133