summaryrefslogtreecommitdiff
path: root/src/target/register.c
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-11-19 19:02:10 -0800
committerDavid Brownell <dbrownell@users.sourceforge.net>2009-11-19 19:02:10 -0800
commit71cde5e359f273585880ea8986709b950ba85b08 (patch)
treeb04f841ddfe6c0900f48b676cbb6c84d12eea7a3 /src/target/register.c
parent31fb7788a605fe1c0c405444b5bab51a7e42d481 (diff)
downloadopenocd+libswd-71cde5e359f273585880ea8986709b950ba85b08.tar.gz
openocd+libswd-71cde5e359f273585880ea8986709b950ba85b08.tar.bz2
openocd+libswd-71cde5e359f273585880ea8986709b950ba85b08.tar.xz
openocd+libswd-71cde5e359f273585880ea8986709b950ba85b08.zip
target: create/use register_cache_invalidate()
Create a generic register_cache_invalidate(), and use it to replace three all-but-identical core-specific routines: - armv4_5_invalidate_core_regs() - armv7m_invalidate_core_regs - mips32_invalidate_core_regs() too. Make cache->num_regs be unsigned, avoiding various errors. Net code shrink and simplification. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'src/target/register.c')
-rw-r--r--src/target/register.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/target/register.c b/src/target/register.c
index d9ef53e3..392455d0 100644
--- a/src/target/register.c
+++ b/src/target/register.c
@@ -28,11 +28,20 @@
#include "register.h"
#include "log.h"
+/**
+ * @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,
const char *name, bool search_all)
{
- int i;
+ unsigned i;
struct reg_cache *cache = first;
while (cache)
@@ -65,6 +74,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;