@@ -8,13 +8,13 CONFIG += socexplorerplugin | |||
|
8 | 8 | win32:CONFIG += dll |
|
9 | 9 | win32:CONFIG -= static |
|
10 | 10 | |
|
11 | CONFIG(debug, debug|release) { | |
|
12 | DEBUG_EXT = _d | |
|
13 | } else { | |
|
14 | DEBUG_EXT = | |
|
15 | } | |
|
11 | #CONFIG(debug, debug|release) { | |
|
12 | # DEBUG_EXT = _d | |
|
13 | #} else { | |
|
14 | # DEBUG_EXT = | |
|
15 | #} | |
|
16 | 16 | |
|
17 | TARGET = ApbUartPlugin$${DEBUG_EXT} | |
|
17 | TARGET = ApbUartPlugin #$${DEBUG_EXT} | |
|
18 | 18 | |
|
19 | 19 | DEFINES += PLUGIN=ApbUartPlugin |
|
20 | 20 | DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" |
@@ -7,12 +7,12 CONFIG += socexplorerplugin | |||
|
7 | 7 | TEMPLATE = lib |
|
8 | 8 | CONFIG += dll |
|
9 | 9 | CONFIG -= static |
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | TARGET = ahbuartplugin$${DEBUG_EXT} | |
|
10 | #CONFIG(debug, debug|release) { | |
|
11 | # DEBUG_EXT = _d | |
|
12 | #} else { | |
|
13 | # DEBUG_EXT = | |
|
14 | #} | |
|
15 | TARGET = ahbuartplugin #$${DEBUG_EXT} | |
|
16 | 16 | DEFINES += PLUGIN=ahbuartplugin |
|
17 | 17 | DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\" |
|
18 | 18 | DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\" |
@@ -6,12 +6,12 | |||
|
6 | 6 | CONFIG += socexplorerplugin |
|
7 | 7 | CONFIG += dll |
|
8 | 8 | CONFIG -= static |
|
9 | CONFIG(debug, debug|release) { | |
|
10 | DEBUG_EXT = _d | |
|
11 | } else { | |
|
12 | DEBUG_EXT = | |
|
13 | } | |
|
14 | TARGET = ambaplugin$${DEBUG_EXT} | |
|
9 | #CONFIG(debug, debug|release) { | |
|
10 | # DEBUG_EXT = _d | |
|
11 | #} else { | |
|
12 | # DEBUG_EXT = | |
|
13 | #} | |
|
14 | TARGET = ambaplugin #$${DEBUG_EXT} | |
|
15 | 15 | DEFINES += PLUGIN=ambaplugin |
|
16 | 16 | DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\" |
|
17 | 17 | DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\" |
@@ -25,21 +25,43 | |||
|
25 | 25 | #include "dsu3pluginpywrapper.h" |
|
26 | 26 | #include <socexplorerengine.h> |
|
27 | 27 | |
|
28 | ||
|
29 | struct acceptedMemctrlr_str | |
|
30 | { | |
|
31 | int vid; | |
|
32 | int pid; | |
|
33 | const char* name; | |
|
34 | }; | |
|
35 | ||
|
36 | const struct acceptedMemctrlr_str acceptedMemctrlr[]= | |
|
37 | { | |
|
38 | {0x01,0x04,"MCTRL"}, | |
|
39 | {0x01,0x51,"FTSRCTRL"}, | |
|
40 | {0x20,0x01,"SRCTRLE_0WS" }, | |
|
41 | {0x20,0x02,"SRCTRLE_1WS" } | |
|
42 | }; | |
|
43 | ||
|
44 | #define acceptedMemctrlrCnt sizeof acceptedMemctrlr | |
|
45 | ||
|
28 | 46 | dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false) |
|
29 | 47 | { |
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 | connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); | |
|
40 | connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); | |
|
41 | connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); | |
|
42 | this->running = false; | |
|
48 | this->UI = new dsu3pluginui(); | |
|
49 | this->setWidget((QWidget*)this->UI); | |
|
50 | this->elfparserInst = new elfparser(); | |
|
51 | this->pyObject = new dsu3pluginPywrapper(this); | |
|
52 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString))); | |
|
53 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget())); | |
|
54 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run())); | |
|
55 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop())); | |
|
56 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable())); | |
|
57 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable())); | |
|
58 | QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool))); | |
|
59 | ||
|
60 | connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); | |
|
61 | connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); | |
|
62 | connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); | |
|
63 | connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); | |
|
64 | this->running = false; | |
|
43 | 65 | } |
|
44 | 66 | |
|
45 | 67 | |
@@ -51,177 +73,211 dsu3plugin::~dsu3plugin() | |||
|
51 | 73 | |
|
52 | 74 | void dsu3plugin::openFile() |
|
53 | 75 | { |
|
54 |
|
|
|
55 |
|
|
|
76 | QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); | |
|
77 | if(filename!="") | |
|
56 | 78 | { |
|
57 |
|
|
|
79 | this->openFile(filename); | |
|
58 | 80 | } |
|
59 | 81 | } |
|
60 | 82 | |
|
61 | 83 | void dsu3plugin::openFile(QString fileName) |
|
62 | 84 | { |
|
63 |
|
|
|
64 |
|
|
|
85 | this->elfparserInst->setFilename(fileName); | |
|
86 | emit this->updateInfo(this->elfparserInst); | |
|
65 | 87 | } |
|
66 | 88 | |
|
67 | 89 | bool dsu3plugin::configureTarget() |
|
68 | 90 | { |
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 | unsigned int MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x04 , 0x00F,0); | |
|
75 | if(MCTRLBASEADDRESS == (unsigned int)-1) | |
|
91 | if(parent==NULL) | |
|
92 | return false; | |
|
93 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
|
94 | if(DSUBASEADDRESS == (unsigned int)-1) | |
|
95 | DSUBASEADDRESS = 0x90000000; | |
|
96 | unsigned int MCTRLBASEADDRESS =-1; | |
|
97 | for(int i=0; i<acceptedMemctrlrCnt;i++) | |
|
76 | 98 | { |
|
77 | SocExplorerEngine::message(this,"Can't find MemCtrlr",1); | |
|
78 | MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x051,0); | |
|
79 | if(MCTRLBASEADDRESS == (unsigned int)-1) | |
|
80 | { | |
|
81 | SocExplorerEngine::message(this,"Can't find FTMemCtrlr",1); | |
|
82 | return false; | |
|
83 | } | |
|
99 | MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0); | |
|
100 | if(MCTRLBASEADDRESS != (unsigned int)-1) break; | |
|
101 | } | |
|
102 | if(MCTRLBASEADDRESS == (unsigned int)-1) | |
|
103 | { | |
|
104 | //SocExplorerEngine::message(this,"Can't find FTMemCtrlr",1); | |
|
105 | return false; | |
|
84 | 106 | } |
|
85 | 107 | |
|
86 | //Force a debug break | |
|
87 | WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS); | |
|
88 |
|
|
|
89 | //Clear time tag counter | |
|
90 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8); | |
|
108 | ||
|
109 | //Force a debug break | |
|
110 | WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS); | |
|
111 | WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20); | |
|
112 | //Clear time tag counter | |
|
113 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8); | |
|
91 | 114 | |
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
115 | //Clear ASR registers | |
|
116 | WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040); | |
|
117 | WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024); | |
|
118 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); | |
|
119 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48); | |
|
120 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C); | |
|
121 | WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040); | |
|
99 | 122 | |
|
100 | 123 | |
|
101 | 124 | |
|
102 |
|
|
|
125 | WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS); | |
|
103 | 126 | |
|
104 | 127 | |
|
105 |
|
|
|
106 |
|
|
|
128 | WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); | |
|
129 | WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24); | |
|
130 | ||
|
131 | unsigned int buff=0; | |
|
132 | // for(int i=0;i<1567;i++) | |
|
133 | // { | |
|
134 | // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i)); | |
|
135 | // } | |
|
136 | memSet(DSUBASEADDRESS+0x300000,0,1567); | |
|
137 | WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); | |
|
138 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x403ffff0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020); | |
|
139 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); | |
|
107 | 140 | |
|
108 | unsigned int buff=0; | |
|
109 | // for(int i=0;i<1567;i++) | |
|
110 | // { | |
|
111 | // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i)); | |
|
112 | // } | |
|
113 | memSet(DSUBASEADDRESS+0x300000,0,1567); | |
|
114 | WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); | |
|
115 | WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x403ffff0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020); | |
|
116 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); | |
|
141 | //Disable interrupts | |
|
142 | unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0); | |
|
143 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) | |
|
144 | return false; | |
|
145 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); | |
|
146 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); | |
|
147 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); | |
|
148 | ||
|
149 | //Set up timer | |
|
150 | unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0); | |
|
151 | if(APBTIMERBASEADD == (unsigned int)-1) | |
|
152 | return false; | |
|
153 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); | |
|
154 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); | |
|
155 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); | |
|
156 | return true; | |
|
157 | } | |
|
117 | 158 | |
|
118 | //Disable interrupts | |
|
119 | unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0); | |
|
120 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) | |
|
121 | return false; | |
|
122 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); | |
|
123 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); | |
|
124 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); | |
|
159 | bool dsu3plugin::cacheDisable() | |
|
160 | { | |
|
161 | return setCacheEnable(false); | |
|
162 | } | |
|
163 | ||
|
164 | bool dsu3plugin::cacheEnable() | |
|
165 | { | |
|
166 | return setCacheEnable(true); | |
|
167 | } | |
|
125 | 168 | |
|
126 | //Set up timer | |
|
127 | unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0); | |
|
128 | if(APBTIMERBASEADD == (unsigned int)-1) | |
|
129 |
|
|
|
130 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); | |
|
131 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); | |
|
132 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); | |
|
133 | return true; | |
|
169 | bool dsu3plugin::setCacheEnable(bool enabled) | |
|
170 | { | |
|
171 | if(parent==NULL) | |
|
172 | return false; | |
|
173 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
|
174 | if(DSUBASEADDRESS == (unsigned int)-1) | |
|
175 | DSUBASEADDRESS = 0x90000000; | |
|
176 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); | |
|
177 | if(enabled) | |
|
178 | { | |
|
179 | WriteRegs(uIntlist()<<0x0001000F,DSUBASEADDRESS+0x700000); | |
|
180 | //flushes cache. | |
|
181 | WriteRegs(uIntlist()<<0x0061000F,DSUBASEADDRESS+0x700000); | |
|
182 | } | |
|
183 | else | |
|
184 | { | |
|
185 | WriteRegs(uIntlist()<<0x00000000,DSUBASEADDRESS+0x700000); | |
|
186 | WriteRegs(uIntlist()<<0x00600000,DSUBASEADDRESS+0x700000); | |
|
187 | } | |
|
188 | return true; | |
|
134 | 189 | } |
|
135 | 190 | |
|
136 | 191 | bool dsu3plugin::flashTarget() |
|
137 | 192 | { |
|
138 | configureTarget(); | |
|
139 | ||
|
140 | /*Write .text*/ | |
|
141 | this->writeSection(".text"); | |
|
142 | /*Write .data*/ | |
|
143 | this->writeSection(".data"); | |
|
144 | return true; | |
|
193 | stop(); | |
|
194 | cacheDisable(); | |
|
195 | configureTarget(); | |
|
196 | /*Write .text*/ | |
|
197 | this->writeSection(".text"); | |
|
198 | /*Write .data*/ | |
|
199 | this->writeSection(".data"); | |
|
200 | return true; | |
|
145 | 201 | } |
|
146 | 202 | |
|
147 | 203 | void dsu3plugin::run() |
|
148 | 204 | { |
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
205 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
|
206 | if(DSUBASEADDRESS == (unsigned int)-1) | |
|
207 | DSUBASEADDRESS = 0x90000000; | |
|
208 | WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020); | |
|
209 | this->running = true; | |
|
210 | this->UI->setRunning(true); | |
|
155 | 211 | } |
|
156 | 212 | |
|
157 | 213 | void dsu3plugin::stop() |
|
158 | 214 | { |
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
215 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
|
216 | if(DSUBASEADDRESS == (unsigned int)-1) | |
|
217 | DSUBASEADDRESS = 0x90000000; | |
|
218 | WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020); | |
|
219 | this->running = false; | |
|
220 | this->UI->setRunning(false); | |
|
165 | 221 | } |
|
166 | 222 | |
|
167 | 223 | void dsu3plugin::toggleRun() |
|
168 | 224 | { |
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
225 | if(this->running) | |
|
226 | this->stop(); | |
|
227 | else | |
|
228 | this->run(); | |
|
173 | 229 | } |
|
174 | 230 | |
|
175 | 231 | void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) |
|
176 | 232 | { |
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
233 | unsigned int* buff; | |
|
234 | buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); | |
|
235 | for(int i=0;i<Values.count();i++) | |
|
180 | 236 | { |
|
181 |
|
|
|
237 | buff[i]=Values.at(i); | |
|
182 | 238 | } |
|
183 |
|
|
|
184 |
|
|
|
239 | parent->Write(buff,(unsigned int)Values.count(),address); | |
|
240 | free(buff); | |
|
185 | 241 | } |
|
186 | 242 | |
|
187 | 243 | void dsu3plugin::writeSection(int index) |
|
188 | 244 | { |
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
245 | char* buffch=NULL; | |
|
246 | unsigned int* buff; | |
|
247 | int size = this->elfparserInst->getSectionDatasz(index); | |
|
248 | int sizeInt = size/4; | |
|
249 | if(parent==NULL) | |
|
250 | return; | |
|
251 | this->elfparserInst->getSectionData(index,&buffch); | |
|
252 | buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); | |
|
253 | for(int i=0;i<sizeInt;i++) | |
|
198 | 254 | { |
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
255 | buff[i] = 0x0FF & ((unsigned int)buffch[4*i]); | |
|
256 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1])); | |
|
257 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2])); | |
|
258 | buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3])); | |
|
203 | 259 | } |
|
204 |
|
|
|
260 | if(size%4) | |
|
205 | 261 | { |
|
206 |
|
|
|
207 |
|
|
|
262 | buff[sizeInt]=0; | |
|
263 | for(int i=(size%4);i>0;i--) | |
|
208 | 264 | { |
|
209 |
|
|
|
265 | buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); | |
|
210 | 266 | } |
|
211 |
|
|
|
267 | sizeInt++; | |
|
212 | 268 | } |
|
213 |
|
|
|
214 |
|
|
|
269 | parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index)); | |
|
270 | free(buff); | |
|
215 | 271 | } |
|
216 | 272 | |
|
217 | 273 | void dsu3plugin::writeSection(const QString &name) |
|
218 | 274 | { |
|
219 |
|
|
|
275 | for(int i=0;i<this->elfparserInst->getSectioncount();i++) | |
|
220 | 276 | { |
|
221 |
|
|
|
277 | if(!this->elfparserInst->getSectionName(i).compare(name)) | |
|
222 | 278 | { |
|
223 |
|
|
|
224 |
|
|
|
279 | printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i)); | |
|
280 | writeSection(i); | |
|
225 | 281 | } |
|
226 | 282 | } |
|
227 | 283 | } |
@@ -229,27 +285,27 void dsu3plugin::writeSection(const QStr | |||
|
229 | 285 | |
|
230 | 286 | unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address) |
|
231 | 287 | { |
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
288 | if(parent!=NULL) | |
|
289 | return parent->Write(Value,count,address); | |
|
290 | return 0; | |
|
235 | 291 | } |
|
236 | 292 | |
|
237 | 293 | bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) |
|
238 | 294 | { |
|
239 |
|
|
|
240 |
|
|
|
295 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
|
296 | if(buffer!=NULL) | |
|
241 | 297 | { |
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
298 | memset((void*)buffer,value,count*sizeof(unsigned int)); | |
|
299 | parent->Write(buffer,count,address); | |
|
300 | free(buffer ); | |
|
301 | return true; | |
|
246 | 302 | } |
|
247 |
|
|
|
303 | return false; | |
|
248 | 304 | } |
|
249 | 305 | |
|
250 | 306 | unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address) |
|
251 | 307 | { |
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
308 | if(parent!=NULL) | |
|
309 | return parent->Read(Value,count,address); | |
|
310 | return 0; | |
|
255 | 311 | } |
@@ -46,6 +46,9 public slots: | |||
|
46 | 46 | void openFile(); |
|
47 | 47 | void openFile(QString fileName); |
|
48 | 48 | bool configureTarget(); |
|
49 | bool cacheDisable(); | |
|
50 | bool cacheEnable(); | |
|
51 | bool setCacheEnable(bool enabled); | |
|
49 | 52 | bool flashTarget(); |
|
50 | 53 | void run(); |
|
51 | 54 | void stop(); |
@@ -7,17 +7,17 CONFIG += socexplorerplugin | |||
|
7 | 7 | |
|
8 | 8 | TEMPLATE = lib |
|
9 | 9 | |
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
10 | #CONFIG(debug, debug|release) { | |
|
11 | # DEBUG_EXT = _d | |
|
12 | #} else { | |
|
13 | # DEBUG_EXT = | |
|
14 | #} | |
|
15 | 15 | |
|
16 | 16 | QMAKE_LFLAGS_RELEASE += --enable-auto-import -mstackrealign |
|
17 | 17 | QMAKE_LFLAGS_DEBUG += --enable-auto-import -mstackrealign |
|
18 | 18 | |
|
19 | 19 | |
|
20 | TARGET = dsu3plugin$${DEBUG_EXT} | |
|
20 | TARGET = dsu3plugin #$${DEBUG_EXT} | |
|
21 | 21 | |
|
22 | 22 | DEFINES += PLUGIN=dsu3plugin |
|
23 | 23 | DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\" |
@@ -13,6 +13,9 signals: | |||
|
13 | 13 | bool loadFile(); |
|
14 | 14 | bool run(); |
|
15 | 15 | bool stop(); |
|
16 | bool cacheDisable(); | |
|
17 | bool cacheEnable(); | |
|
18 | bool setCacheEnable(bool enabled); | |
|
16 | 19 | public slots: |
|
17 | 20 | |
|
18 | 21 | }; |
@@ -7,12 +7,12 CONFIG += socexplorerplugin | |||
|
7 | 7 | CONFIG += dll |
|
8 | 8 | CONFIG -= static |
|
9 | 9 | |
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
15 | TARGET = genericrwplugin$${DEBUG_EXT} | |
|
10 | #CONFIG(debug, debug|release) { | |
|
11 | # DEBUG_EXT = _d | |
|
12 | #} else { | |
|
13 | # DEBUG_EXT = | |
|
14 | #} | |
|
15 | TARGET = genericrwplugin #$${DEBUG_EXT} | |
|
16 | 16 | DEFINES += PLUGIN=genericrwplugin |
|
17 | 17 | DEFINES += PLUGINHEADER="\"\\\"genericrwplugin.h"\\\"\" |
|
18 | 18 | DEFINES += driver_Name="\"\\\"GenericRWplugin"\\\"\" |
@@ -23,36 +23,91 | |||
|
23 | 23 | |
|
24 | 24 | memchecker::memchecker(socexplorerplugin* plugin) |
|
25 | 25 | { |
|
26 |
|
|
|
26 | this->plugin = plugin; | |
|
27 | 27 | } |
|
28 | 28 | |
|
29 | 29 | QString memchecker::checkmemory(unsigned int address, unsigned int size, bool *success) |
|
30 | 30 | { |
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
31 | *success = true; | |
|
32 | QString repport; | |
|
33 | unsigned int* dataLocal = (unsigned int*)malloc(size); | |
|
34 | unsigned int* dataOnBoard = (unsigned int*)malloc(size); | |
|
35 | for(int i=0;(unsigned int)i<(size>>2);i++) | |
|
36 | 36 | { |
|
37 |
|
|
|
37 | dataLocal[i]= (0xFFFF&rand())+(rand()<<16); | |
|
38 | 38 | } |
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
39 | plugin->Write(dataLocal,size>>2,address); | |
|
40 | plugin->Read(dataOnBoard,size>>2,address); | |
|
41 | for(int i=0;(unsigned int)i<(size>>2);i++) | |
|
42 | 42 | { |
|
43 |
|
|
|
44 |
|
|
|
43 | if(dataLocal[i]!=dataOnBoard[i]) | |
|
44 | *success=false; | |
|
45 | 45 | } |
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
46 | free(dataLocal); | |
|
47 | free(dataOnBoard); | |
|
48 | return repport; | |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | QString memchecker::checkdatabits(unsigned int address,unsigned int size,bool* success) |
|
52 | 52 | { |
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
53 | *success = true; | |
|
54 | QString repport; | |
|
55 | return repport; | |
|
56 | } | |
|
57 | ||
|
58 | ||
|
59 | unsigned int p_pow2(unsigned int v) | |
|
60 | { | |
|
61 | static const char LogTable256[256] = | |
|
62 | { | |
|
63 | #define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n | |
|
64 | -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, | |
|
65 | LT(4), LT(5), LT(5), LT(6), LT(6), LT(6), LT(6), | |
|
66 | LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7) | |
|
67 | }; | |
|
68 | ||
|
69 | unsigned int r; // r will be lg(v) | |
|
70 | register unsigned int t, tt; // temporaries | |
|
71 | ||
|
72 | if (tt = v >> 16) | |
|
73 | { | |
|
74 | r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt]; | |
|
75 | } | |
|
76 | else | |
|
77 | { | |
|
78 | r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v]; | |
|
79 | } | |
|
80 | return r; | |
|
56 | 81 | } |
|
57 | 82 | |
|
58 | 83 | |
|
84 | unsigned int memchecker::measureMemSize(unsigned int address, unsigned int maxSize) | |
|
85 | { | |
|
86 | unsigned int curVal=1,testAddress=address; | |
|
87 | unsigned int size=0; | |
|
88 | this->plugin->Write(&curVal,1,testAddress); | |
|
89 | this->plugin->Read(&curVal,1,testAddress); | |
|
90 | if(curVal!=1) | |
|
91 | return size; | |
|
92 | unsigned int max= p_pow2((0xFFFFFFFFFFFFFFFF - address))+1; | |
|
93 | register unsigned int maxSizeLg=p_pow2(maxSize)-1; | |
|
94 | if(max>maxSizeLg) | |
|
95 | max=maxSizeLg; | |
|
96 | if(max>32)max=32; | |
|
97 | for(size=2;size<max;size++) //check each address bit | |
|
98 | { | |
|
99 | testAddress = (unsigned int)(address+(1<<size)); | |
|
100 | curVal = (unsigned int)(1<<size); | |
|
101 | this->plugin->Write(&curVal,1,testAddress); | |
|
102 | this->plugin->Read(&curVal,1,testAddress); | |
|
103 | if((unsigned int)curVal!=(unsigned int)(1<<size)) | |
|
104 | return (1<<(size)); | |
|
105 | this->plugin->Read(&curVal,1,address); | |
|
106 | if((curVal==(unsigned int)(1<<size)) && (size!=0)) | |
|
107 | return (1<<(size)); | |
|
108 | } | |
|
109 | return (1<<(size+1)); | |
|
110 | } | |
|
111 | ||
|
112 | ||
|
113 |
@@ -31,6 +31,7 public: | |||
|
31 | 31 | QString checkmemory(unsigned int address,unsigned int size,bool* success); |
|
32 | 32 | QString checkdatabits(unsigned int address,unsigned int size,bool* success); |
|
33 | 33 | |
|
34 | unsigned int measureMemSize(unsigned int address,unsigned int maxSize=0xFFFFFFFF); | |
|
34 | 35 | private: |
|
35 | 36 | socexplorerplugin* plugin; |
|
36 | 37 | }; |
@@ -28,6 +28,7 memcheckplugin::memcheckplugin(QWidget * | |||
|
28 | 28 | this->checker = new memchecker(this); |
|
29 | 29 | QObject::connect(this->UI,SIGNAL(checkdatabits(uint,uint)),this,SLOT(checkdatabits(uint,uint))); |
|
30 | 30 | QObject::connect(this->UI,SIGNAL(checkmemory(uint,uint)),this,SLOT(checkmemory(uint,uint))); |
|
31 | QObject::connect(this->UI,SIGNAL(checkmemorySize(uint,uint)),this,SLOT(checkmemorySize(uint,uint))); | |
|
31 | 32 | } |
|
32 | 33 | |
|
33 | 34 | memcheckplugin::~memcheckplugin() |
@@ -42,6 +43,22 void memcheckplugin::checkmemory(unsigne | |||
|
42 | 43 | |
|
43 | 44 | } |
|
44 | 45 | |
|
46 | void memcheckplugin::checkmemorySize(unsigned int address, unsigned int size) | |
|
47 | { | |
|
48 | bool success=true; | |
|
49 | unsigned int _size = this->checker->measureMemSize(address,size); | |
|
50 | int prefix=0; | |
|
51 | QStringList list; | |
|
52 | list <<"B" << "KB" << "MB" << "GB"; | |
|
53 | while (_size>=(unsigned int)1024) | |
|
54 | { | |
|
55 | _size/=1024; | |
|
56 | prefix++; | |
|
57 | } | |
|
58 | QString repport=QString::number(_size)+list.at(prefix); | |
|
59 | this->UI->setResult(success,repport); | |
|
60 | } | |
|
61 | ||
|
45 | 62 | void memcheckplugin::checkdatabits(unsigned int address, unsigned int size) |
|
46 | 63 | { |
|
47 | 64 | bool success; |
@@ -59,6 +59,7 public: | |||
|
59 | 59 | ~memcheckplugin(); |
|
60 | 60 | public slots: |
|
61 | 61 | void checkmemory(unsigned int address,unsigned int size); |
|
62 | void checkmemorySize(unsigned int address,unsigned int size); | |
|
62 | 63 | void checkdatabits(unsigned int address,unsigned int size); |
|
63 | 64 | signals: |
|
64 | 65 |
@@ -7,13 +7,14 CONFIG += socexplorerplugin | |||
|
7 | 7 | CONFIG += dll |
|
8 | 8 | CONFIG -= static |
|
9 | 9 | |
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
10 | #CONFIG(debug, debug|release) { | |
|
11 | # DEBUG_EXT = _d | |
|
12 | #} else { | |
|
13 | # DEBUG_EXT = | |
|
14 | #} | |
|
15 | 15 | |
|
16 | TARGET = memcheckplugin$${DEBUG_EXT} | |
|
16 | ||
|
17 | TARGET = memcheckplugin #$${DEBUG_EXT} | |
|
17 | 18 | DEFINES += PLUGIN=memcheckplugin |
|
18 | 19 | DEFINES += PLUGINHEADER="\"\\\"memcheckplugin.h"\\\"\" |
|
19 | 20 | DEFINES += driver_Name="\"\\\"MemChecker"\\\"\" |
@@ -45,7 +45,8 void memcheckplugin_ui::startCheck() | |||
|
45 | 45 | } |
|
46 | 46 | if(this->ui->testTypeQchkBx->currentText()=="Check memory size") |
|
47 | 47 | { |
|
48 | emit checkmemory(this->ui->StartAddress->value(),this->ui->MemSize->getsize()); | |
|
48 | //emit checkmemory(this->ui->StartAddress->value(),this->ui->MemSize->getsize()); | |
|
49 | emit checkmemorySize(this->ui->StartAddress->value(),this->ui->MemSize->getsize()); | |
|
49 | 50 | } |
|
50 | 51 | if(this->ui->testTypeQchkBx->currentText()=="Full test") |
|
51 | 52 | { |
@@ -40,6 +40,7 public slots: | |||
|
40 | 40 | void setResult(bool success,QString repport); |
|
41 | 41 | signals: |
|
42 | 42 | void checkmemory(unsigned int address,unsigned int size); |
|
43 | void checkmemorySize(unsigned int address,unsigned int size); | |
|
43 | 44 | void checkdatabits(unsigned int address,unsigned int size); |
|
44 | 45 | private: |
|
45 | 46 | Ui::memcheckplugin_ui *ui; |
@@ -7,13 +7,13 CONFIG += socexplorerplugin | |||
|
7 | 7 | CONFIG += dll |
|
8 | 8 | CONFIG -= static |
|
9 | 9 | |
|
10 | CONFIG(debug, debug|release) { | |
|
11 | DEBUG_EXT = _d | |
|
12 | } else { | |
|
13 | DEBUG_EXT = | |
|
14 | } | |
|
10 | #CONFIG(debug, debug|release) { | |
|
11 | # DEBUG_EXT = _d | |
|
12 | #} else { | |
|
13 | # DEBUG_EXT = | |
|
14 | #} | |
|
15 | 15 | |
|
16 | TARGET = memctrlrplugin$${DEBUG_EXT} | |
|
16 | TARGET = memctrlrplugin #$${DEBUG_EXT} | |
|
17 | 17 | DEFINES += PLUGIN=memctrlrplugin |
|
18 | 18 | DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\" |
|
19 | 19 | DEFINES += driver_Name="\"\\\"MemControler"\\\"\" |
General Comments 0
You need to be logged in to leave comments.
Login now