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