15796c8dcSSimon Schubert /* Memory attributes support, for GDB. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 2001-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #ifndef MEMATTR_H 215796c8dcSSimon Schubert #define MEMATTR_H 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #include "vec.h" 245796c8dcSSimon Schubert 255796c8dcSSimon Schubert enum mem_access_mode 265796c8dcSSimon Schubert { 275796c8dcSSimon Schubert MEM_NONE, /* Memory that is not physically present. */ 285796c8dcSSimon Schubert MEM_RW, /* read/write */ 295796c8dcSSimon Schubert MEM_RO, /* read only */ 305796c8dcSSimon Schubert MEM_WO, /* write only */ 315796c8dcSSimon Schubert 325796c8dcSSimon Schubert /* Read/write, but special steps are required to write to it. */ 335796c8dcSSimon Schubert MEM_FLASH 345796c8dcSSimon Schubert }; 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert enum mem_access_width 375796c8dcSSimon Schubert { 385796c8dcSSimon Schubert MEM_WIDTH_UNSPECIFIED, 395796c8dcSSimon Schubert MEM_WIDTH_8, /* 8 bit accesses */ 405796c8dcSSimon Schubert MEM_WIDTH_16, /* 16 " " */ 415796c8dcSSimon Schubert MEM_WIDTH_32, /* 32 " " */ 425796c8dcSSimon Schubert MEM_WIDTH_64 /* 64 " " */ 435796c8dcSSimon Schubert }; 445796c8dcSSimon Schubert 455796c8dcSSimon Schubert /* The set of all attributes that can be set for a memory region. 465796c8dcSSimon Schubert 475796c8dcSSimon Schubert This structure was created so that memory attributes can be passed 485796c8dcSSimon Schubert to target_ functions without exposing the details of memory region 495796c8dcSSimon Schubert list, which would be necessary if these fields were simply added to 505796c8dcSSimon Schubert the mem_region structure. 515796c8dcSSimon Schubert 525796c8dcSSimon Schubert FIXME: It would be useful if there was a mechanism for targets to 535796c8dcSSimon Schubert add their own attributes. For example, the number of wait states. */ 545796c8dcSSimon Schubert 555796c8dcSSimon Schubert struct mem_attrib 565796c8dcSSimon Schubert { 575796c8dcSSimon Schubert /* read/write, read-only, or write-only */ 585796c8dcSSimon Schubert enum mem_access_mode mode; 595796c8dcSSimon Schubert 605796c8dcSSimon Schubert enum mem_access_width width; 615796c8dcSSimon Schubert 625796c8dcSSimon Schubert /* enables hardware breakpoints */ 635796c8dcSSimon Schubert int hwbreak; 645796c8dcSSimon Schubert 655796c8dcSSimon Schubert /* enables host-side caching of memory region data */ 665796c8dcSSimon Schubert int cache; 675796c8dcSSimon Schubert 68c50c785cSJohn Marino /* Enables memory verification. After a write, memory is re-read 695796c8dcSSimon Schubert to verify that the write was successful. */ 705796c8dcSSimon Schubert int verify; 715796c8dcSSimon Schubert 725796c8dcSSimon Schubert /* Block size. Only valid if mode == MEM_FLASH. */ 735796c8dcSSimon Schubert int blocksize; 745796c8dcSSimon Schubert }; 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert struct mem_region 775796c8dcSSimon Schubert { 785796c8dcSSimon Schubert /* Lowest address in the region. */ 795796c8dcSSimon Schubert CORE_ADDR lo; 805796c8dcSSimon Schubert /* Address past the highest address of the region. 815796c8dcSSimon Schubert If 0, upper bound is "infinity". */ 825796c8dcSSimon Schubert CORE_ADDR hi; 835796c8dcSSimon Schubert 845796c8dcSSimon Schubert /* Item number of this memory region. */ 855796c8dcSSimon Schubert int number; 865796c8dcSSimon Schubert 87c50c785cSJohn Marino /* Status of this memory region (enabled if non-zero, otherwise 88c50c785cSJohn Marino disabled). */ 895796c8dcSSimon Schubert int enabled_p; 905796c8dcSSimon Schubert 91c50c785cSJohn Marino /* Attributes for this region. */ 925796c8dcSSimon Schubert struct mem_attrib attrib; 935796c8dcSSimon Schubert }; 945796c8dcSSimon Schubert 955796c8dcSSimon Schubert /* Declare a vector type for a group of mem_region structures. The 965796c8dcSSimon Schubert typedef is necessary because vec.h can not handle a struct tag. 975796c8dcSSimon Schubert Except during construction, these vectors are kept sorted. */ 985796c8dcSSimon Schubert typedef struct mem_region mem_region_s; 995796c8dcSSimon Schubert DEF_VEC_O(mem_region_s); 1005796c8dcSSimon Schubert 1015796c8dcSSimon Schubert extern struct mem_region *lookup_mem_region(CORE_ADDR); 1025796c8dcSSimon Schubert 1035796c8dcSSimon Schubert void invalidate_target_mem_regions (void); 1045796c8dcSSimon Schubert 1055796c8dcSSimon Schubert void mem_region_init (struct mem_region *); 1065796c8dcSSimon Schubert 1075796c8dcSSimon Schubert int mem_region_cmp (const void *, const void *); 1085796c8dcSSimon Schubert 1095796c8dcSSimon Schubert #endif /* MEMATTR_H */ 110