summaryrefslogtreecommitdiff
path: root/utils/regtools/qeditor/backend.cpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-02-10 23:10:21 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-02-10 23:14:27 +0100
commit6e132b48d52ad285728529f982bb6421b100ba8a (patch)
tree84e60834306d6409fc5abf73f1ae4a70febb541a /utils/regtools/qeditor/backend.cpp
parent68163e8f4974545a33de236139b5995883df7a17 (diff)
regtools/qeditor: enhance backend write with write mode (SCT)
Change-Id: I723bce7a60fb08c1d1d5f894a225c36bc1ba4394
Diffstat (limited to 'utils/regtools/qeditor/backend.cpp')
-rw-r--r--utils/regtools/qeditor/backend.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/utils/regtools/qeditor/backend.cpp b/utils/regtools/qeditor/backend.cpp
index fa107ec26c..44430c25da 100644
--- a/utils/regtools/qeditor/backend.cpp
+++ b/utils/regtools/qeditor/backend.cpp
@@ -106,11 +106,17 @@ bool FileIoBackend::Reload()
return true;
}
-bool FileIoBackend::WriteRegister(const QString& name, soc_word_t value)
+bool FileIoBackend::WriteRegister(const QString& name, soc_word_t value, WriteMode mode)
{
m_dirty = true;
- m_map[name] = value;
- return true;
+ switch(mode)
+ {
+ case Write: m_map[name] = value; return true;
+ case Set: m_map[name] |= value; return true;
+ case Clear: m_map[name] &= ~value; return true;
+ case Toggle: m_map[name] ^= value; return true;
+ default: return false;
+ }
}
bool FileIoBackend::Commit()
@@ -281,8 +287,15 @@ bool HWStubIoBackend::ReadRegister(soc_addr_t addr, soc_word_t& value)
return m_dev->ReadMem(addr, sizeof(value), &value);
}
-bool HWStubIoBackend:: WriteRegister(soc_addr_t addr, soc_word_t value)
+bool HWStubIoBackend::WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode)
{
+ switch(mode)
+ {
+ case Set: addr += 4; break;
+ case Clear: addr += 8; break;
+ case Toggle: addr += 12; break;
+ default: break;
+ }
return m_dev->WriteMem(addr, sizeof(value), &value);
}
@@ -387,6 +400,19 @@ bool BackendHelper::ReadRegister(const QString& dev, const QString& reg, soc_wor
return false;
}
+bool BackendHelper::WriteRegister(const QString& dev, const QString& reg,
+ soc_word_t v, IoBackend::WriteMode mode)
+{
+ if(m_io_backend->SupportAccess(IoBackend::ByName))
+ return m_io_backend->WriteRegister("HW." + dev + "." + reg, v, mode);
+ if(m_io_backend->SupportAccess(IoBackend::ByAddress))
+ {
+ soc_addr_t addr;
+ if(GetRegisterAddress(dev, reg, addr))
+ return m_io_backend->WriteRegister(addr, v, mode);
+ }
+ return false;
+}
bool BackendHelper::GetDevRef(const QString& sdev, SocDevRef& ref)
{
@@ -456,4 +482,4 @@ bool BackendHelper::ReadRegisterField(const QString& dev, const QString& reg,
return false;
v = (v & field_ref.GetField().bitmask()) >> field_ref.GetField().first_bit;
return true;
-} \ No newline at end of file
+}