diff options
Diffstat (limited to 'utils/regtools/qeditor/backend.h')
-rw-r--r-- | utils/regtools/qeditor/backend.h | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/utils/regtools/qeditor/backend.h b/utils/regtools/qeditor/backend.h index 55f31cce52..879b88c42c 100644 --- a/utils/regtools/qeditor/backend.h +++ b/utils/regtools/qeditor/backend.h | |||
@@ -23,10 +23,14 @@ public: | |||
23 | ByAddress, | 23 | ByAddress, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | /* report whether backend supports register access type */ | ||
26 | virtual bool SupportAccess(AccessType type) = 0; | 27 | virtual bool SupportAccess(AccessType type) = 0; |
28 | /* get SoC name */ | ||
27 | virtual QString GetSocName() = 0; | 29 | virtual QString GetSocName() = 0; |
30 | /* read a register by name or address */ | ||
28 | virtual bool ReadRegister(const QString& name, soc_word_t& value) = 0; | 31 | virtual bool ReadRegister(const QString& name, soc_word_t& value) = 0; |
29 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) = 0; | 32 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) = 0; |
33 | /* reload content (if it makes sense) */ | ||
30 | virtual bool Reload() = 0; | 34 | virtual bool Reload() = 0; |
31 | }; | 35 | }; |
32 | 36 | ||
@@ -140,6 +144,56 @@ protected: | |||
140 | }; | 144 | }; |
141 | #endif | 145 | #endif |
142 | 146 | ||
147 | class SocRef | ||
148 | { | ||
149 | public: | ||
150 | SocRef():m_soc(0) {} | ||
151 | SocRef(const soc_t *soc):m_soc(soc) {} | ||
152 | const soc_t& GetSoc() const { return *m_soc; } | ||
153 | protected: | ||
154 | const soc_t *m_soc; | ||
155 | }; | ||
156 | |||
157 | class SocDevRef : public SocRef | ||
158 | { | ||
159 | public: | ||
160 | SocDevRef() {} | ||
161 | SocDevRef(const SocRef& soc, int dev_idx, int dev_addr_idx) | ||
162 | :SocRef(soc), m_dev_idx(dev_idx), m_dev_addr_idx(dev_addr_idx) {} | ||
163 | int GetDevIndex() const { return m_dev_idx; } | ||
164 | const soc_dev_t& GetDev() const { return GetSoc().dev[GetDevIndex()]; } | ||
165 | int GetDevAddrIndex() const { return m_dev_addr_idx; } | ||
166 | const soc_dev_addr_t& GetDevAddr() const { return GetDev().addr[GetDevAddrIndex()]; } | ||
167 | protected: | ||
168 | int m_dev_idx, m_dev_addr_idx; | ||
169 | }; | ||
170 | |||
171 | class SocRegRef : public SocDevRef | ||
172 | { | ||
173 | public: | ||
174 | SocRegRef() {} | ||
175 | SocRegRef(const SocDevRef& dev, int reg_idx, int reg_addr_idx) | ||
176 | :SocDevRef(dev), m_reg_idx(reg_idx), m_reg_addr_idx(reg_addr_idx) {} | ||
177 | int GetRegIndex() const { return m_reg_idx; } | ||
178 | const soc_reg_t& GetReg() const { return GetDev().reg[GetRegIndex()]; } | ||
179 | int GetRegAddrIndex() const { return m_reg_addr_idx; } | ||
180 | const soc_reg_addr_t& GetRegAddr() const { return GetReg().addr[GetRegAddrIndex()]; } | ||
181 | protected: | ||
182 | int m_reg_idx, m_reg_addr_idx; | ||
183 | }; | ||
184 | |||
185 | class SocFieldRef : public SocRegRef | ||
186 | { | ||
187 | public: | ||
188 | SocFieldRef(){} | ||
189 | SocFieldRef(const SocRegRef& reg, int field_idx) | ||
190 | :SocRegRef(reg), m_field_idx(field_idx) {} | ||
191 | int GetFieldIndex() const { return m_field_idx; } | ||
192 | const soc_reg_field_t& GetField() const { return GetReg().field[GetFieldIndex()]; } | ||
193 | protected: | ||
194 | int m_field_idx; | ||
195 | }; | ||
196 | |||
143 | class Backend : public QObject | 197 | class Backend : public QObject |
144 | { | 198 | { |
145 | Q_OBJECT | 199 | Q_OBJECT |
@@ -148,7 +202,7 @@ public: | |||
148 | 202 | ||
149 | QStringList GetSocNameList(); | 203 | QStringList GetSocNameList(); |
150 | bool LoadSocDesc(const QString& filename); | 204 | bool LoadSocDesc(const QString& filename); |
151 | bool GetSocByName(const QString& name, soc_t& s); | 205 | bool GetSocByName(const QString& name, SocRef& s); |
152 | IoBackend *CreateDummyIoBackend(); | 206 | IoBackend *CreateDummyIoBackend(); |
153 | IoBackend *CreateFileIoBackend(const QString& filename); | 207 | IoBackend *CreateFileIoBackend(const QString& filename); |
154 | #ifdef HAVE_HWSTUB | 208 | #ifdef HAVE_HWSTUB |
@@ -158,23 +212,23 @@ public: | |||
158 | signals: | 212 | signals: |
159 | void OnSocListChanged(); | 213 | void OnSocListChanged(); |
160 | private: | 214 | private: |
161 | std::vector< soc_t > m_socs; | 215 | std::list< soc_t > m_socs; |
162 | }; | 216 | }; |
163 | 217 | ||
164 | class BackendHelper | 218 | class BackendHelper |
165 | { | 219 | { |
166 | public: | 220 | public: |
167 | BackendHelper(IoBackend *io_backend, const soc_t& soc); | 221 | BackendHelper(IoBackend *io_backend, const SocRef& soc); |
168 | bool ReadRegister(const QString& dev, const QString& reg, soc_word_t& v); | 222 | bool ReadRegister(const QString& dev, const QString& reg, soc_word_t& v); |
169 | bool ReadRegisterField(const QString& dev, const QString& reg, | 223 | bool ReadRegisterField(const QString& dev, const QString& reg, |
170 | const QString& field, soc_word_t& v); | 224 | const QString& field, soc_word_t& v); |
171 | bool GetDeviceDesc(const QString& dev, soc_dev_t& dev_desc, size_t& index); | 225 | bool GetDevRef(const QString& dev, SocDevRef& ref); |
172 | bool GetRegisterDesc(const soc_dev_t& dev, const QString& reg, soc_reg_t& reg_desc, size_t& index); | 226 | bool GetRegRef(const SocDevRef& dev, const QString& reg, SocRegRef& ref); |
173 | bool GetFieldDesc(const soc_reg_t& reg_desc, const QString& field, soc_reg_field_t& field_desc); | 227 | bool GetFieldRef(const SocRegRef& reg, const QString& field, SocFieldRef& ref); |
174 | bool GetRegisterAddress(const QString& dev, const QString& reg, soc_addr_t& addr); | 228 | bool GetRegisterAddress(const QString& dev, const QString& reg, soc_addr_t& addr); |
175 | private: | 229 | private: |
176 | IoBackend *m_io_backend; | 230 | IoBackend *m_io_backend; |
177 | soc_t m_soc; | 231 | const SocRef& m_soc; |
178 | }; | 232 | }; |
179 | 233 | ||
180 | #endif /* __BACKEND_H__ */ | 234 | #endif /* __BACKEND_H__ */ |