X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Fregister.c;h=42b3b8b64e2fa7e2dcba049f025ba8e8907b0731;hp=d9ef53e31f0e43a2929bf8fd6aa22bffb57b51dd;hb=08d4411b59dd8bd0e7d8009003b71d23acbf6eee;hpb=f4788652e45662d1e43933dc0620561bc4cddae0 diff --git a/src/target/register.c b/src/target/register.c index d9ef53e31f..42b3b8b64e 100644 --- a/src/target/register.c +++ b/src/target/register.c @@ -18,27 +18,34 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * ***************************************************************************/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "types.h" #include "register.h" -#include "log.h" +#include +/** + * @file + * Holds utilities to work with register caches. + * + * OpenOCD uses machine registers internally, and exposes them by name + * to Tcl scripts. Sets of related registers are grouped into caches. + * For example, a CPU core will expose a set of registers, and there + * may be separate registers associated with debug or trace modules. + */ -struct reg* register_get_by_name(struct reg_cache *first, +struct reg *register_get_by_name(struct reg_cache *first, const char *name, bool search_all) { - int i; + unsigned i; struct reg_cache *cache = first; - while (cache) - { - for (i = 0; i < cache->num_regs; i++) - { + while (cache) { + for (i = 0; i < cache->num_regs; i++) { if (strcmp(cache->reg_list[i].name, name) == 0) return &(cache->reg_list[i]); } @@ -52,7 +59,7 @@ struct reg* register_get_by_name(struct reg_cache *first, return NULL; } -struct reg_cache** register_get_last_cache_p(struct reg_cache **first) +struct reg_cache **register_get_last_cache_p(struct reg_cache **first) { struct reg_cache **cache_p = first; @@ -65,6 +72,17 @@ struct reg_cache** register_get_last_cache_p(struct reg_cache **first) return cache_p; } +/** Marks the contents of the register cache as invalid (and clean). */ +void register_cache_invalidate(struct reg_cache *cache) +{ + struct reg *reg = cache->reg_list; + + for (unsigned n = cache->num_regs; n != 0; n--, reg++) { + reg->valid = 0; + reg->dirty = 0; + } +} + static int register_get_dummy_core_reg(struct reg *reg) { return ERROR_OK;