diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-02-10 23:10:21 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-02-10 23:14:27 +0100 |
commit | 6e132b48d52ad285728529f982bb6421b100ba8a (patch) | |
tree | 84e60834306d6409fc5abf73f1ae4a70febb541a /utils/regtools | |
parent | 68163e8f4974545a33de236139b5995883df7a17 (diff) |
regtools/qeditor: enhance backend write with write mode (SCT)
Change-Id: I723bce7a60fb08c1d1d5f894a225c36bc1ba4394
Diffstat (limited to 'utils/regtools')
-rw-r--r-- | utils/regtools/qeditor/backend.cpp | 36 | ||||
-rw-r--r-- | utils/regtools/qeditor/backend.h | 37 |
2 files changed, 56 insertions, 17 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 +} diff --git a/utils/regtools/qeditor/backend.h b/utils/regtools/qeditor/backend.h index 72a19b6ec1..939ed9529f 100644 --- a/utils/regtools/qeditor/backend.h +++ b/utils/regtools/qeditor/backend.h @@ -17,12 +17,21 @@ public: IoBackend() {} virtual ~IoBackend() {} + enum WriteMode + { + Write, Set, Clear, Toggle + }; + enum AccessType { ByName, ByAddress, }; + /** Register naming convention: name based access are of the form: + * HW.dev.reg + * where <dev> is the device name (including index like APPUART1) + * and <reg> is the register name (including index like PRIORITY29) */ /* report whether backend supports register access type */ virtual bool SupportAccess(AccessType type) = 0; /* get SoC name */ @@ -37,8 +46,10 @@ public: /* write a register by name or address * NOTE: even on a read-only backend, a write is allowed be successful as long * as commit fails */ - virtual bool WriteRegister(const QString& name, soc_word_t value) = 0; - virtual bool WriteRegister(soc_addr_t addr, soc_word_t value) = 0; + virtual bool WriteRegister(const QString& name, soc_word_t value, + WriteMode mode = Write) = 0; + virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, + WriteMode mode = Write) = 0; /* check whether backend contains uncommitted (ie cached) writes */ virtual bool IsDirty() = 0; /* commit all writes */ @@ -59,10 +70,10 @@ public: { (void) addr; (void) value; return false; } virtual bool Reload() { return false; } virtual bool IsReadOnly() { return true; } - virtual bool WriteRegister(const QString& name, soc_word_t value) - { (void) name; (void) value; return false; } - virtual bool WriteRegister(soc_addr_t addr, soc_word_t value) - { (void) addr; (void) value; return false; } + virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode) + { (void) name; (void) value; (void) mode; return false; } + virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode) + { (void) addr; (void) value; (void) mode; return false; } virtual bool IsDirty() { return false; } virtual bool Commit() { return false; } }; @@ -82,9 +93,9 @@ public: { (void) addr; (void) value; return false; } virtual bool Reload(); virtual bool IsReadOnly() { return m_readonly; } - virtual bool WriteRegister(const QString& name, soc_word_t value); - virtual bool WriteRegister(soc_addr_t addr, soc_word_t value) - { (void) addr; (void) value; return false; } + virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode); + virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode) + { (void) addr; (void) value; (void) mode; return false; } virtual bool IsDirty() { return m_dirty; } virtual bool Commit(); @@ -142,9 +153,9 @@ public: virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value); virtual bool Reload(); virtual bool IsReadOnly() { return false; } - virtual bool WriteRegister(const QString& name, soc_word_t value) - { (void) name; (void) value; return false; } - virtual bool WriteRegister(soc_addr_t addr, soc_word_t value); + virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode) + { (void) name; (void) value; (void) mode; return false; } + virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode); virtual bool IsDirty() { return false; } virtual bool Commit() { return true; } @@ -258,6 +269,8 @@ public: bool ReadRegister(const QString& dev, const QString& reg, soc_word_t& v); bool ReadRegisterField(const QString& dev, const QString& reg, const QString& field, soc_word_t& v); + bool WriteRegister(const QString& dev, const QString& reg, soc_word_t v, + IoBackend::WriteMode mode = IoBackend::Write); bool GetDevRef(const QString& dev, SocDevRef& ref); bool GetRegRef(const SocDevRef& dev, const QString& reg, SocRegRef& ref); bool GetFieldRef(const SocRegRef& reg, const QString& field, SocFieldRef& ref); |