summaryrefslogtreecommitdiffstats
path: root/utils/regtools/qeditor/backend.cpp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-05-11 19:51:55 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-05-11 19:56:56 +0200
commit7b590a953639714cf8ea4b550dd7f6558698e23f (patch)
tree4d37890770d45b29237fb671aa66ac446dff7684 /utils/regtools/qeditor/backend.cpp
parent4c1eafc208426d4457660313314289a570287cb8 (diff)
downloadrockbox-7b590a953639714cf8ea4b550dd7f6558698e23f.tar.gz
rockbox-7b590a953639714cf8ea4b550dd7f6558698e23f.tar.bz2
rockbox-7b590a953639714cf8ea4b550dd7f6558698e23f.zip
qeditor: many enhancement
Qeditor has been improved in many ways: - it can now dump all registers, just like the lua DUMPER.dump_all() command - several crash were fixed - when connected to a hwstub command, one can correctly edit individual fields - the code was simplified in several places Change-Id: I092b99ce3a12ff6417552de61d62c65f706bcff0
Diffstat (limited to 'utils/regtools/qeditor/backend.cpp')
-rw-r--r--utils/regtools/qeditor/backend.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/utils/regtools/qeditor/backend.cpp b/utils/regtools/qeditor/backend.cpp
index 10ef84c6a0..423b0bb520 100644
--- a/utils/regtools/qeditor/backend.cpp
+++ b/utils/regtools/qeditor/backend.cpp
@@ -90,9 +90,10 @@ IoBackend *Backend::CreateHWStubIoBackend(HWStubDevice *dev)
* FileIoBackend
*/
-FileIoBackend::FileIoBackend(const QString& filename)
+FileIoBackend::FileIoBackend(const QString& filename, const QString& soc_name)
{
m_filename = filename;
+ m_soc = soc_name;
Reload();
}
@@ -163,7 +164,7 @@ bool FileIoBackend::Commit()
while(it.hasNext())
{
it.next();
- out << it.key() << " = " << it.value() << "\n";
+ out << it.key() << " = " << hex << showbase << it.value() << "\n";
}
out.flush();
return file.flush();
@@ -175,6 +176,16 @@ bool FileIoBackend::Commit()
*/
HWStubDevice::HWStubDevice(struct libusb_device *dev)
{
+ Init(dev);
+}
+
+HWStubDevice::HWStubDevice(const HWStubDevice *dev)
+{
+ Init(dev->m_dev);
+}
+
+void HWStubDevice::Init(struct libusb_device *dev)
+{
libusb_ref_device(dev);
m_dev = dev;
m_handle = 0;
@@ -325,7 +336,7 @@ QString HWStubIoBackend::GetSocName()
HWStubIoBackend::~HWStubIoBackend()
{
- m_dev->Close();
+ delete m_dev;
}
bool HWStubIoBackend::ReadRegister(soc_addr_t addr, soc_word_t& value)
@@ -530,3 +541,31 @@ bool BackendHelper::ReadRegisterField(const QString& dev, const QString& reg,
v = (v & field_ref.GetField().bitmask()) >> field_ref.GetField().first_bit;
return true;
}
+
+bool BackendHelper::DumpAllRegisters(const QString& filename)
+{
+ FileIoBackend b(filename, QString::fromStdString(m_soc.GetSoc().name));
+ BackendHelper bh(&b, m_soc);
+ for(size_t i = 0; i < m_soc.GetSoc().dev.size(); i++)
+ {
+ const soc_dev_t& dev = m_soc.GetSoc().dev[i];
+ for(size_t j = 0; j < dev.addr.size(); j++)
+ {
+ QString devname = QString::fromStdString(dev.addr[j].name);
+ for(size_t k = 0; k < dev.reg.size(); k++)
+ {
+ const soc_reg_t& reg = dev.reg[k];
+ for(size_t l = 0; l < reg.addr.size(); l++)
+ {
+ QString regname = QString::fromStdString(reg.addr[l].name);
+ soc_word_t val;
+ if(!ReadRegister(devname, regname, val))
+ return false;
+ if(!bh.WriteRegister(devname, regname, val))
+ return false;
+ }
+ }
+ }
+ }
+ return b.Commit();
+}