summaryrefslogtreecommitdiff
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.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 @@
5#include <QStringList> 5#include <QStringList>
6#include <QMap> 6#include <QMap>
7#include <QVector> 7#include <QVector>
8#include "soc_desc.hpp" 8#include <QMetaType>
9#ifdef HAVE_HWSTUB 9#ifdef HAVE_HWSTUB
10#include "hwstub.h" 10#include "hwstub.h"
11#endif 11#endif
12#include "soc.h"
12 13
13class IoBackend : public QObject 14class IoBackend : public QObject
14{ 15{
@@ -62,18 +63,18 @@ class DummyIoBackend : public IoBackend
62public: 63public:
63 DummyIoBackend() {} 64 DummyIoBackend() {}
64 65
65 virtual bool SupportAccess(AccessType type) { (void) type; return false; } 66 virtual bool SupportAccess(AccessType type) { Q_UNUSED(type); return false; }
66 virtual QString GetSocName() { return ""; } 67 virtual QString GetSocName() { return ""; }
67 virtual bool ReadRegister(const QString& name, soc_word_t& value) 68 virtual bool ReadRegister(const QString& name, soc_word_t& value)
68 { (void) name; (void) value; return false; } 69 { Q_UNUSED(name); Q_UNUSED(value); return false; }
69 virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) 70 virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value)
70 { (void) addr; (void) value; return false; } 71 { Q_UNUSED(addr); Q_UNUSED(value); return false; }
71 virtual bool Reload() { return false; } 72 virtual bool Reload() { return false; }
72 virtual bool IsReadOnly() { return true; } 73 virtual bool IsReadOnly() { return true; }
73 virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode) 74 virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode)
74 { (void) name; (void) value; (void) mode; return false; } 75 { Q_UNUSED(name); Q_UNUSED(value); Q_UNUSED(mode); return false; }
75 virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode) 76 virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode)
76 { (void) addr; (void) value; (void) mode; return false; } 77 { Q_UNUSED(addr); Q_UNUSED(value); Q_UNUSED(mode); return false; }
77 virtual bool IsDirty() { return false; } 78 virtual bool IsDirty() { return false; }
78 virtual bool Commit() { return false; } 79 virtual bool Commit() { return false; }
79}; 80};
@@ -90,12 +91,12 @@ public:
90 virtual QString GetSocName(); 91 virtual QString GetSocName();
91 virtual bool ReadRegister(const QString& name, soc_word_t& value); 92 virtual bool ReadRegister(const QString& name, soc_word_t& value);
92 virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) 93 virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value)
93 { (void) addr; (void) value; return false; } 94 { Q_UNUSED(addr); Q_UNUSED(value); return false; }
94 virtual bool Reload(); 95 virtual bool Reload();
95 virtual bool IsReadOnly() { return m_readonly; } 96 virtual bool IsReadOnly() { return m_readonly; }
96 virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode); 97 virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode);
97 virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode) 98 virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode)
98 { (void) addr; (void) value; (void) mode; return false; } 99 { Q_UNUSED(addr); Q_UNUSED(value); Q_UNUSED(mode); return false; }
99 virtual bool IsDirty() { return m_dirty; } 100 virtual bool IsDirty() { return m_dirty; }
100 virtual bool Commit(); 101 virtual bool Commit();
101 102
@@ -149,12 +150,12 @@ public:
149 virtual bool SupportAccess(AccessType type) { return type == ByAddress; } 150 virtual bool SupportAccess(AccessType type) { return type == ByAddress; }
150 virtual QString GetSocName(); 151 virtual QString GetSocName();
151 virtual bool ReadRegister(const QString& name, soc_word_t& value) 152 virtual bool ReadRegister(const QString& name, soc_word_t& value)
152 { (void) name; (void) value; return false; } 153 { Q_UNUSED(name); Q_UNUSED(value); return false; }
153 virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value); 154 virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value);
154 virtual bool Reload(); 155 virtual bool Reload();
155 virtual bool IsReadOnly() { return false; } 156 virtual bool IsReadOnly() { return false; }
156 virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode) 157 virtual bool WriteRegister(const QString& name, soc_word_t value, WriteMode mode)
157 { (void) name; (void) value; (void) mode; return false; } 158 { Q_UNUSED(name); Q_UNUSED(value); Q_UNUSED(mode); return false; }
158 virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode); 159 virtual bool WriteRegister(soc_addr_t addr, soc_word_t value, WriteMode mode);
159 virtual bool IsDirty() { return false; } 160 virtual bool IsDirty() { return false; }
160 virtual bool Commit() { return true; } 161 virtual bool Commit() { return true; }
@@ -191,16 +192,48 @@ protected:
191}; 192};
192#endif 193#endif
193 194
194class SocRef 195class SocRef;
196
197class SocFile
198{
199public:
200 SocFile();
201 SocFile(const QString& filename);
202 bool IsValid();
203
204 SocRef GetSocRef();
205 QString GetFilename();
206 soc_t& GetSoc() { return m_soc; }
207
208protected:
209 bool m_valid;
210 QString m_filename;
211 soc_t m_soc;
212};
213
214class SocFileRef
195{ 215{
196public: 216public:
197 SocRef():m_soc(0) {} 217 SocFileRef():m_socfile(0) {}
198 SocRef(const soc_t *soc):m_soc(soc) {} 218 SocFileRef(SocFile *file):m_socfile(file) {}
199 const soc_t& GetSoc() const { return *m_soc; } 219 SocFile *GetSocFile() const { return m_socfile; }
220
200protected: 221protected:
201 const soc_t *m_soc; 222 SocFile *m_socfile;
202}; 223};
203 224
225Q_DECLARE_METATYPE(SocFileRef)
226
227class SocRef : public SocFileRef
228{
229public:
230 SocRef() {}
231 SocRef(SocFile *file):SocFileRef(file) {}
232 soc_t& GetSoc() const { return GetSocFile()->GetSoc(); }
233};
234
235Q_DECLARE_METATYPE(SocRef)
236
204class SocDevRef : public SocRef 237class SocDevRef : public SocRef
205{ 238{
206public: 239public:
@@ -208,9 +241,9 @@ public:
208 SocDevRef(const SocRef& soc, int dev_idx, int dev_addr_idx) 241 SocDevRef(const SocRef& soc, int dev_idx, int dev_addr_idx)
209 :SocRef(soc), m_dev_idx(dev_idx), m_dev_addr_idx(dev_addr_idx) {} 242 :SocRef(soc), m_dev_idx(dev_idx), m_dev_addr_idx(dev_addr_idx) {}
210 int GetDevIndex() const { return m_dev_idx; } 243 int GetDevIndex() const { return m_dev_idx; }
211 const soc_dev_t& GetDev() const { return GetSoc().dev[GetDevIndex()]; } 244 soc_dev_t& GetDev() const { return GetSoc().dev[GetDevIndex()]; }
212 int GetDevAddrIndex() const { return m_dev_addr_idx; } 245 int GetDevAddrIndex() const { return m_dev_addr_idx; }
213 const soc_dev_addr_t& GetDevAddr() const { return GetDev().addr[GetDevAddrIndex()]; } 246 soc_dev_addr_t& GetDevAddr() const { return GetDev().addr[GetDevAddrIndex()]; }
214protected: 247protected:
215 int m_dev_idx, m_dev_addr_idx; 248 int m_dev_idx, m_dev_addr_idx;
216}; 249};
@@ -222,9 +255,9 @@ public:
222 SocRegRef(const SocDevRef& dev, int reg_idx, int reg_addr_idx) 255 SocRegRef(const SocDevRef& dev, int reg_idx, int reg_addr_idx)
223 :SocDevRef(dev), m_reg_idx(reg_idx), m_reg_addr_idx(reg_addr_idx) {} 256 :SocDevRef(dev), m_reg_idx(reg_idx), m_reg_addr_idx(reg_addr_idx) {}
224 int GetRegIndex() const { return m_reg_idx; } 257 int GetRegIndex() const { return m_reg_idx; }
225 const soc_reg_t& GetReg() const { return GetDev().reg[GetRegIndex()]; } 258 soc_reg_t& GetReg() const { return GetDev().reg[GetRegIndex()]; }
226 int GetRegAddrIndex() const { return m_reg_addr_idx; } 259 int GetRegAddrIndex() const { return m_reg_addr_idx; }
227 const soc_reg_addr_t& GetRegAddr() const { return GetReg().addr[GetRegAddrIndex()]; } 260 soc_reg_addr_t& GetRegAddr() const { return GetReg().addr[GetRegAddrIndex()]; }
228protected: 261protected:
229 int m_reg_idx, m_reg_addr_idx; 262 int m_reg_idx, m_reg_addr_idx;
230}; 263};
@@ -236,7 +269,7 @@ public:
236 SocFieldRef(const SocRegRef& reg, int field_idx) 269 SocFieldRef(const SocRegRef& reg, int field_idx)
237 :SocRegRef(reg), m_field_idx(field_idx) {} 270 :SocRegRef(reg), m_field_idx(field_idx) {}
238 int GetFieldIndex() const { return m_field_idx; } 271 int GetFieldIndex() const { return m_field_idx; }
239 const soc_reg_field_t& GetField() const { return GetReg().field[GetFieldIndex()]; } 272 soc_reg_field_t& GetField() const { return GetReg().field[GetFieldIndex()]; }
240protected: 273protected:
241 int m_field_idx; 274 int m_field_idx;
242}; 275};
@@ -247,9 +280,9 @@ class Backend : public QObject
247public: 280public:
248 Backend(); 281 Backend();
249 282
250 QStringList GetSocNameList(); 283 QList< SocFileRef > GetSocFileList();
284 QList< SocRef > GetSocList();
251 bool LoadSocDesc(const QString& filename); 285 bool LoadSocDesc(const QString& filename);
252 bool GetSocByName(const QString& name, SocRef& s);
253 IoBackend *CreateDummyIoBackend(); 286 IoBackend *CreateDummyIoBackend();
254 IoBackend *CreateFileIoBackend(const QString& filename); 287 IoBackend *CreateFileIoBackend(const QString& filename);
255#ifdef HAVE_HWSTUB 288#ifdef HAVE_HWSTUB
@@ -259,7 +292,7 @@ public:
259signals: 292signals:
260 void OnSocListChanged(); 293 void OnSocListChanged();
261private: 294private:
262 std::list< soc_t > m_socs; 295 std::list< SocFile > m_socs;
263}; 296};
264 297
265class BackendHelper 298class BackendHelper