diff options
Diffstat (limited to 'utils/regtools/qeditor/backend.h')
-rw-r--r-- | utils/regtools/qeditor/backend.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/regtools/qeditor/backend.h b/utils/regtools/qeditor/backend.h index 879b88c42c..72a19b6ec1 100644 --- a/utils/regtools/qeditor/backend.h +++ b/utils/regtools/qeditor/backend.h | |||
@@ -32,6 +32,17 @@ public: | |||
32 | 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) */ | 33 | /* reload content (if it makes sense) */ |
34 | virtual bool Reload() = 0; | 34 | virtual bool Reload() = 0; |
35 | /* check whether backend supports writing */ | ||
36 | virtual bool IsReadOnly() = 0; | ||
37 | /* write a register by name or address | ||
38 | * NOTE: even on a read-only backend, a write is allowed be successful as long | ||
39 | * as commit fails */ | ||
40 | virtual bool WriteRegister(const QString& name, soc_word_t value) = 0; | ||
41 | virtual bool WriteRegister(soc_addr_t addr, soc_word_t value) = 0; | ||
42 | /* check whether backend contains uncommitted (ie cached) writes */ | ||
43 | virtual bool IsDirty() = 0; | ||
44 | /* commit all writes */ | ||
45 | virtual bool Commit() = 0; | ||
35 | }; | 46 | }; |
36 | 47 | ||
37 | class DummyIoBackend : public IoBackend | 48 | class DummyIoBackend : public IoBackend |
@@ -47,8 +58,17 @@ public: | |||
47 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) | 58 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) |
48 | { (void) addr; (void) value; return false; } | 59 | { (void) addr; (void) value; return false; } |
49 | virtual bool Reload() { return false; } | 60 | virtual bool Reload() { return false; } |
61 | virtual bool IsReadOnly() { return true; } | ||
62 | virtual bool WriteRegister(const QString& name, soc_word_t value) | ||
63 | { (void) name; (void) value; return false; } | ||
64 | virtual bool WriteRegister(soc_addr_t addr, soc_word_t value) | ||
65 | { (void) addr; (void) value; return false; } | ||
66 | virtual bool IsDirty() { return false; } | ||
67 | virtual bool Commit() { return false; } | ||
50 | }; | 68 | }; |
51 | 69 | ||
70 | /** NOTE the File backend makes a difference between writes and commits: | ||
71 | * a write will *never* touch the underlying file unless it was committed. */ | ||
52 | class FileIoBackend : public IoBackend | 72 | class FileIoBackend : public IoBackend |
53 | { | 73 | { |
54 | Q_OBJECT | 74 | Q_OBJECT |
@@ -61,10 +81,18 @@ public: | |||
61 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) | 81 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value) |
62 | { (void) addr; (void) value; return false; } | 82 | { (void) addr; (void) value; return false; } |
63 | virtual bool Reload(); | 83 | virtual bool Reload(); |
84 | virtual bool IsReadOnly() { return m_readonly; } | ||
85 | virtual bool WriteRegister(const QString& name, soc_word_t value); | ||
86 | virtual bool WriteRegister(soc_addr_t addr, soc_word_t value) | ||
87 | { (void) addr; (void) value; return false; } | ||
88 | virtual bool IsDirty() { return m_dirty; } | ||
89 | virtual bool Commit(); | ||
64 | 90 | ||
65 | protected: | 91 | protected: |
66 | QString m_filename; | 92 | QString m_filename; |
67 | QString m_soc; | 93 | QString m_soc; |
94 | bool m_readonly; | ||
95 | bool m_dirty; | ||
68 | QMap< QString, soc_word_t > m_map; | 96 | QMap< QString, soc_word_t > m_map; |
69 | }; | 97 | }; |
70 | 98 | ||
@@ -85,6 +113,7 @@ public: | |||
85 | inline struct hwstub_stmp_desc_t GetSTMPInfo() { return m_hwdev_stmp; } | 113 | inline struct hwstub_stmp_desc_t GetSTMPInfo() { return m_hwdev_stmp; } |
86 | /* Calls below require the device to be opened */ | 114 | /* Calls below require the device to be opened */ |
87 | bool ReadMem(soc_addr_t addr, size_t length, void *buffer); | 115 | bool ReadMem(soc_addr_t addr, size_t length, void *buffer); |
116 | bool WriteMem(soc_addr_t addr, size_t length, void *buffer); | ||
88 | 117 | ||
89 | protected: | 118 | protected: |
90 | bool Probe(); | 119 | bool Probe(); |
@@ -98,6 +127,7 @@ protected: | |||
98 | struct hwstub_stmp_desc_t m_hwdev_stmp; | 127 | struct hwstub_stmp_desc_t m_hwdev_stmp; |
99 | }; | 128 | }; |
100 | 129 | ||
130 | /** NOTE the HWStub backend is never dirty: all writes are immediately committed */ | ||
101 | class HWStubIoBackend : public IoBackend | 131 | class HWStubIoBackend : public IoBackend |
102 | { | 132 | { |
103 | Q_OBJECT | 133 | Q_OBJECT |
@@ -111,6 +141,12 @@ public: | |||
111 | { (void) name; (void) value; return false; } | 141 | { (void) name; (void) value; return false; } |
112 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value); | 142 | virtual bool ReadRegister(soc_addr_t addr, soc_word_t& value); |
113 | virtual bool Reload(); | 143 | virtual bool Reload(); |
144 | virtual bool IsReadOnly() { return false; } | ||
145 | virtual bool WriteRegister(const QString& name, soc_word_t value) | ||
146 | { (void) name; (void) value; return false; } | ||
147 | virtual bool WriteRegister(soc_addr_t addr, soc_word_t value); | ||
148 | virtual bool IsDirty() { return false; } | ||
149 | virtual bool Commit() { return true; } | ||
114 | 150 | ||
115 | protected: | 151 | protected: |
116 | QString m_soc; | 152 | QString m_soc; |