summaryrefslogtreecommitdiffstats
path: root/utils/regtools/qeditor/backend.cpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-02-09 02:16:43 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-02-10 23:14:26 +0100
commita66a5af4db8249b5b86a8126e0fe7a60a6f6338a (patch)
tree2b9507b56b72da61ffdf90ef44ec44a862fcd0c1 /utils/regtools/qeditor/backend.cpp
parent3d07706c05c46878533f55f26bbe02d7904efd75 (diff)
downloadrockbox-a66a5af4db8249b5b86a8126e0fe7a60a6f6338a.tar.gz
rockbox-a66a5af4db8249b5b86a8126e0fe7a60a6f6338a.tar.bz2
rockbox-a66a5af4db8249b5b86a8126e0fe7a60a6f6338a.zip
regtools/qeditor: prepare support for register writing
Change-Id: Ifef36a3ddb1604db63ec974da2d6a77a5540ff42
Diffstat (limited to 'utils/regtools/qeditor/backend.cpp')
-rw-r--r--utils/regtools/qeditor/backend.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/utils/regtools/qeditor/backend.cpp b/utils/regtools/qeditor/backend.cpp
index 75c504a6f6..fa107ec26c 100644
--- a/utils/regtools/qeditor/backend.cpp
+++ b/utils/regtools/qeditor/backend.cpp
@@ -1,6 +1,7 @@
#include <QFile>
#include <QTextStream>
#include <QDebug>
+#include <QFileInfo>
#include "backend.h"
/**
@@ -99,9 +100,38 @@ bool FileIoBackend::Reload()
else if(ok)
m_map[key] = val;
}
+
+ m_readonly = !QFileInfo(file).isWritable();
+ m_dirty = false;
+ return true;
+}
+
+bool FileIoBackend::WriteRegister(const QString& name, soc_word_t value)
+{
+ m_dirty = true;
+ m_map[name] = value;
return true;
}
+bool FileIoBackend::Commit()
+{
+ if(!m_dirty)
+ return true;
+ QFile file(m_filename);
+ if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
+ return false;
+ QTextStream out(&file);
+ out << "HW = " << m_soc << "\n";
+ QMapIterator< QString, soc_word_t > it(m_map);
+ while(it.hasNext())
+ {
+ it.next();
+ out << it.key() << " = " << it.value() << "\n";
+ }
+ out.flush();
+ return file.flush();
+}
+
#ifdef HAVE_HWSTUB
/**
* HWStubDevice
@@ -195,6 +225,14 @@ bool HWStubDevice::ReadMem(soc_addr_t addr, size_t length, void *buffer)
return ret >= 0 && (size_t)ret == length;
}
+bool HWStubDevice::WriteMem(soc_addr_t addr, size_t length, void *buffer)
+{
+ if(!m_hwdev)
+ return false;
+ int ret = hwstub_rw_mem(m_hwdev, 0, addr, buffer, length);
+ return ret >= 0 && (size_t)ret == length;
+}
+
bool HWStubDevice::IsValid()
{
return m_valid;
@@ -243,6 +281,11 @@ 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)
+{
+ return m_dev->WriteMem(addr, sizeof(value), &value);
+}
+
bool HWStubIoBackend::Reload()
{
return true;