summaryrefslogtreecommitdiffstats
path: root/utils/regtools/qeditor/backend.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 11:28:04 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-05-01 19:34:18 +0200
commit4356666101e0e7985e65a19f86bc4a74519e93f9 (patch)
treebf8de8057d93d0fab0a30cae92a90f5a4edc79dc /utils/regtools/qeditor/backend.h
parent3754624edc48539c5cc5acbf426ce909477e87d8 (diff)
downloadrockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.gz
rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.bz2
rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.zip
regtools: completely rework qeditor, improve soc desc library and tools
The graphical editor can now display and editor description files. The library has been improved to provide more useful function. The XML format has been slightly changed: only one soc is allowed per file (this is was already de facto the case since <soc> was the root tag). Also introduce a DTD to validate the files. Change-Id: If70ba35b6dc0242bdb87411cf4baee9597798aac
Diffstat (limited to 'utils/regtools/qeditor/backend.h')
-rw-r--r--utils/regtools/qeditor/backend.h79
1 files changed, 56 insertions, 23 deletions
diff --git a/utils/regtools/qeditor/backend.h b/utils/regtools/qeditor/backend.h
index 939ed9529f..a813f5929f 100644
--- a/utils/regtools/qeditor/backend.h
+++ b/utils/regtools/qeditor/backend.h
@@ -5,10 +5,11 @@
#include <QStringList>
#include <QMap>
#include <QVector>
-#include "soc_desc.hpp"
+#include <QMetaType>
#ifdef HAVE_HWSTUB
#include "hwstub.h"
#endif
+#include "soc.h"
class IoBackend : public QObject
{
@@ -62,18 +63,18 @@ class DummyIoBackend : public IoBackend
public:
DummyIoBackend() {}
- virtual bool SupportAccess(AccessType type) { (void) type; return false; }
+ virtual bool SupportAccess(AccessType type) { Q_UNUSED(type); return false; }
virtual QString GetSocName() { return ""; }
virtual bool ReadRegister(const QString& name, soc_word_t& value)
- { (void) name; (void) value; return false; }
+ { Q_UNUSED(name); Q_UNUSED(value); return false; }
virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value)
- { (void) addr; (void) value; return false; }
+ { Q_UNUSED(addr); Q_UNUSED(value); return false; }
virtual bool Reload() { return false; }
virtual bool IsReadOnly() { return true; }
virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode)
- { (void) name; (void) value; (void) mode; return false; }
+ { Q_UNUSED(name); Q_UNUSED(value); Q_UNUSED(mode); return false; }
virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode)
- { (void) addr; (void) value; (void) mode; return false; }
+ { Q_UNUSED(addr); Q_UNUSED(value); Q_UNUSED(mode); return false; }
virtual bool IsDirty() { return false; }
virtual bool Commit() { return false; }
};
@@ -90,12 +91,12 @@ public:
virtual QString GetSocName();
virtual bool ReadRegister(const QString& name, soc_word_t& value);
virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value)
- { (void) addr; (void) value; return false; }
+ { Q_UNUSED(addr); Q_UNUSED(value); return false; }
virtual bool Reload();
virtual bool IsReadOnly() { return m_readonly; }
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; }
+ { Q_UNUSED(addr); Q_UNUSED(value); Q_UNUSED(mode); return false; }
virtual bool IsDirty() { return m_dirty; }
virtual bool Commit();
@@ -149,12 +150,12 @@ public:
virtual bool SupportAccess(AccessType type) { return type == ByAddress; }
virtual QString GetSocName();
virtual bool ReadRegister(const QString& name, soc_word_t& value)
- { (void) name; (void) value; return false; }
+ { Q_UNUSED(name); Q_UNUSED(value); return false; }
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, WriteMode mode)
- { (void) name; (void) value; (void) mode; return false; }
+ { Q_UNUSED(name); Q_UNUSED(value); Q_UNUSED(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; }
@@ -191,16 +192,48 @@ protected:
};
#endif
-class SocRef
+class SocRef;
+
+class SocFile
+{
+public:
+ SocFile();
+ SocFile(const QString& filename);
+ bool IsValid();
+
+ SocRef GetSocRef();
+ QString GetFilename();
+ soc_t& GetSoc() { return m_soc; }
+
+protected:
+ bool m_valid;
+ QString m_filename;
+ soc_t m_soc;
+};
+
+class SocFileRef
{
public:
- SocRef():m_soc(0) {}
- SocRef(const soc_t *soc):m_soc(soc) {}
- const soc_t& GetSoc() const { return *m_soc; }
+ SocFileRef():m_socfile(0) {}
+ SocFileRef(SocFile *file):m_socfile(file) {}
+ SocFile *GetSocFile() const { return m_socfile; }
+
protected:
- const soc_t *m_soc;
+ SocFile *m_socfile;
};
+Q_DECLARE_METATYPE(SocFileRef)
+
+class SocRef : public SocFileRef
+{
+public:
+ SocRef() {}
+ SocRef(SocFile *file):SocFileRef(file) {}
+ soc_t& GetSoc() const { return GetSocFile()->GetSoc(); }
+};
+
+Q_DECLARE_METATYPE(SocRef)
+
class SocDevRef : public SocRef
{
public:
@@ -208,9 +241,9 @@ public:
SocDevRef(const SocRef& soc, int dev_idx, int dev_addr_idx)
:SocRef(soc), m_dev_idx(dev_idx), m_dev_addr_idx(dev_addr_idx) {}
int GetDevIndex() const { return m_dev_idx; }
- const soc_dev_t& GetDev() const { return GetSoc().dev[GetDevIndex()]; }
+ soc_dev_t& GetDev() const { return GetSoc().dev[GetDevIndex()]; }
int GetDevAddrIndex() const { return m_dev_addr_idx; }
- const soc_dev_addr_t& GetDevAddr() const { return GetDev().addr[GetDevAddrIndex()]; }
+ soc_dev_addr_t& GetDevAddr() const { return GetDev().addr[GetDevAddrIndex()]; }
protected:
int m_dev_idx, m_dev_addr_idx;
};
@@ -222,9 +255,9 @@ public:
SocRegRef(const SocDevRef& dev, int reg_idx, int reg_addr_idx)
:SocDevRef(dev), m_reg_idx(reg_idx), m_reg_addr_idx(reg_addr_idx) {}
int GetRegIndex() const { return m_reg_idx; }
- const soc_reg_t& GetReg() const { return GetDev().reg[GetRegIndex()]; }
+ soc_reg_t& GetReg() const { return GetDev().reg[GetRegIndex()]; }
int GetRegAddrIndex() const { return m_reg_addr_idx; }
- const soc_reg_addr_t& GetRegAddr() const { return GetReg().addr[GetRegAddrIndex()]; }
+ soc_reg_addr_t& GetRegAddr() const { return GetReg().addr[GetRegAddrIndex()]; }
protected:
int m_reg_idx, m_reg_addr_idx;
};
@@ -236,7 +269,7 @@ public:
SocFieldRef(const SocRegRef& reg, int field_idx)
:SocRegRef(reg), m_field_idx(field_idx) {}
int GetFieldIndex() const { return m_field_idx; }
- const soc_reg_field_t& GetField() const { return GetReg().field[GetFieldIndex()]; }
+ soc_reg_field_t& GetField() const { return GetReg().field[GetFieldIndex()]; }
protected:
int m_field_idx;
};
@@ -247,9 +280,9 @@ class Backend : public QObject
public:
Backend();
- QStringList GetSocNameList();
+ QList< SocFileRef > GetSocFileList();
+ QList< SocRef > GetSocList();
bool LoadSocDesc(const QString& filename);
- bool GetSocByName(const QString& name, SocRef& s);
IoBackend *CreateDummyIoBackend();
IoBackend *CreateFileIoBackend(const QString& filename);
#ifdef HAVE_HWSTUB
@@ -259,7 +292,7 @@ public:
signals:
void OnSocListChanged();
private:
- std::list< soc_t > m_socs;
+ std::list< SocFile > m_socs;
};
class BackendHelper