##// END OF EJS Templates
dsu3plugin:...
jeandet -
r60:dbbb04783771 default
parent child
Show More
@@ -1,332 +1,330
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "dsu3plugin.h"
22 #include "dsu3plugin.h"
23 #include <QFileDialog>
23 #include <QFileDialog>
24 #include <QDir>
24 #include <QDir>
25 #include <socexplorerengine.h>
25 #include <socexplorerengine.h>
26
26
27
27
28 struct acceptedMemctrlr_str
28 struct acceptedMemctrlr_str
29 {
29 {
30 int vid;
30 int vid;
31 int pid;
31 int pid;
32 const char* name;
32 const char* name;
33 };
33 };
34
34
35 const struct acceptedMemctrlr_str acceptedMemctrlr[]=
35 const struct acceptedMemctrlr_str acceptedMemctrlr[]=
36 {
36 {
37 {0x04,0x0f,"MCTRL"},
37 {0x04,0x0f,"MCTRL"},
38 {0x01,0x51,"FTSRCTRL"},
38 {0x01,0x51,"FTSRCTRL"},
39 {0x20,0x01,"SRCTRLE_0WS" },
39 {0x20,0x01,"SRCTRLE_0WS" },
40 {0x20,0x02,"SRCTRLE_1WS" }
40 {0x20,0x02,"SRCTRLE_1WS" }
41 };
41 };
42
42
43 #define acceptedMemctrlrCnt 4
43 #define acceptedMemctrlrCnt 4
44
44
45 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
45 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
46 {
46 {
47 this->UI = new dsu3pluginui();
47 this->UI = new dsu3pluginui();
48 this->setWidget((QWidget*)this->UI);
48 this->setWidget((QWidget*)this->UI);
49 this->elfparserInst = new elfparser();
49 this->elfFile = new ElfFile();
50 // this->pyObject = new dsu3pluginPywrapper(this);
51 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString)));
52 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget()));
53 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run()));
54 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop()));
55 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable()));
56 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable()));
57 // QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool)));
58
59 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
50 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
60 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
51 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
61 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
52 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
62 connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*)));
53 connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*)));
63 this->running = false;
54 this->running = false;
64 }
55 }
65
56
66
57
67 dsu3plugin::~dsu3plugin()
58 dsu3plugin::~dsu3plugin()
68 {
59 {
69
60
70 }
61 }
71
62
72
63
73 void dsu3plugin::openFile()
64 void dsu3plugin::openFile()
74 {
65 {
75 QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)"));
66 QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)"));
76 if(filename!="")
67 if(filename!="")
77 {
68 {
78 this->openFile(filename);
69 this->openFile(filename);
79 }
70 }
80 }
71 }
81
72
82 void dsu3plugin::openFile(QString fileName)
73 void dsu3plugin::openFile(QString fileName)
83 {
74 {
84 this->elfparserInst->setFilename(fileName);
75 this->elfFile->openFile(fileName);
85 emit this->updateInfo(this->elfparserInst);
76 emit this->updateInfo(this->elfFile);
86 }
77 }
87
78
88 bool dsu3plugin::configureTarget()
79 bool dsu3plugin::configureTarget()
89 {
80 {
90 int detectedMctrlr=-1;
81 int detectedMctrlr=-1;
91 if(parent==NULL)
82 if(parent==NULL)
92 return false;
83 return false;
93 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
84 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
94 if(DSUBASEADDRESS == (unsigned int)-1)
85 if(DSUBASEADDRESS == (unsigned int)-1)
95 DSUBASEADDRESS = 0x90000000;
86 DSUBASEADDRESS = 0x90000000;
96 unsigned int MCTRLBASEADDRESS =-1;
87 unsigned int MCTRLBASEADDRESS =-1;
97 for(int i=0; i<acceptedMemctrlrCnt;i++)
88 for(int i=0; i<acceptedMemctrlrCnt;i++)
98 {
89 {
99 MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0);
90 MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0);
100 if(MCTRLBASEADDRESS != (unsigned int)-1)
91 if(MCTRLBASEADDRESS != (unsigned int)-1)
101 {
92 {
102 SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1);
93 SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1);
103 detectedMctrlr=i;
94 detectedMctrlr=i;
104 break;
95 break;
105 }
96 }
106 }
97 }
107 if(MCTRLBASEADDRESS == (unsigned int)-1)
98 if(MCTRLBASEADDRESS == (unsigned int)-1)
108 {
99 {
109 SocExplorerEngine::message(this,"Can't any compatible memory controller",1);
100 SocExplorerEngine::message(this,"Can't any compatible memory controller",1);
110 return false;
101 return false;
111 }
102 }
112
103
113
104
114 //Force a debug break
105 //Force a debug break
115 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
106 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
116 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
107 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
117 //Clear time tag counter
108 //Clear time tag counter
118 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
109 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
119
110
120 //Clear ASR registers
111 //Clear ASR registers
121 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
112 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
122 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
113 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
123 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
114 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
124 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
115 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
125 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
116 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
126 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
117 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
127
118
128 // {0x04,0x0f,"MCTRL"},
119 // {0x04,0x0f,"MCTRL"},
129 // {0x01,0x51,"FTSRCTRL"},
120 // {0x01,0x51,"FTSRCTRL"},
130 // {0x20,0x01,"SRCTRLE_0WS" },
121 // {0x20,0x01,"SRCTRLE_0WS" },
131 // {0x20,0x02,"SRCTRLE_1WS" }
122 // {0x20,0x02,"SRCTRLE_1WS" }
132 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" )
123 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" )
133 {
124 {
134 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
125 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
135 }
126 }
136 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_0WS" || QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_1WS" )
127 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_0WS" || QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_1WS" )
137 {
128 {
138 //let's perform a mem Wash
129 //let's perform a mem Wash
139 unsigned int val = ReadReg(MCTRLBASEADDRESS);
130 unsigned int val = ReadReg(MCTRLBASEADDRESS);
140 val |=1<<31;
131 val |=1<<31;
141 WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS);
132 WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS);
142 usleep(1000*1000);
133 usleep(1000*1000);
143 }
134 }
144
135
145
136
146 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
137 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
147 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
138 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
148
139
149 memSet(DSUBASEADDRESS+0x300000,0,1567);
140 memSet(DSUBASEADDRESS+0x300000,0,1567);
150 WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
141 WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
151 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);
142 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);
152 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
143 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
153
144
154 //Disable interrupts
145 //Disable interrupts
155 unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
146 unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
156 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
147 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
157 return false;
148 return false;
158 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
149 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
159 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
150 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
160 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
151 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
161
152
162 //Set up timer
153 //Set up timer
163 unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
154 unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
164 if(APBTIMERBASEADD == (unsigned int)-1)
155 if(APBTIMERBASEADD == (unsigned int)-1)
165 return false;
156 return false;
166 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
157 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
167 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
158 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
168 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
159 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
169 return true;
160 return true;
170 }
161 }
171
162
172 bool dsu3plugin::cacheDisable()
163 bool dsu3plugin::cacheDisable()
173 {
164 {
174 return setCacheEnable(false);
165 return setCacheEnable(false);
175 }
166 }
176
167
177 bool dsu3plugin::cacheEnable()
168 bool dsu3plugin::cacheEnable()
178 {
169 {
179 return setCacheEnable(true);
170 return setCacheEnable(true);
180 }
171 }
181
172
182 bool dsu3plugin::setCacheEnable(bool enabled)
173 bool dsu3plugin::setCacheEnable(bool enabled)
183 {
174 {
184 if(parent==NULL)
175 if(parent==NULL)
185 return false;
176 return false;
186 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
177 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
187 if(DSUBASEADDRESS == (unsigned int)-1)
178 if(DSUBASEADDRESS == (unsigned int)-1)
188 DSUBASEADDRESS = 0x90000000;
179 DSUBASEADDRESS = 0x90000000;
189 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
180 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
190 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
181 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
191 if(enabled)
182 if(enabled)
192 {
183 {
193 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
184 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
194 //flushes cache.
185 //flushes cache.
195 WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
186 WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
196 }
187 }
197 else
188 else
198 {
189 {
199 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
190 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
200 WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
191 WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
201 }
192 }
202 return true;
193 return true;
203 }
194 }
204
195
205 bool dsu3plugin::flashTarget()
196 bool dsu3plugin::flashTarget()
206 {
197 {
207 stop();
198 stop();
208 cacheDisable();
199 cacheDisable();
209 configureTarget();
200 configureTarget();
210 /*Write .text*/
201 /*Write .text*/
211 this->writeSection(".text");
202 this->writeSection(".text");
212 /*Write .data*/
203 /*Write .data*/
213 this->writeSection(".data");
204 this->writeSection(".data");
214 return true;
205 return true;
215 }
206 }
216
207
217 void dsu3plugin::run()
208 void dsu3plugin::run()
218 {
209 {
219 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
210 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
220 if(DSUBASEADDRESS == (unsigned int)-1)
211 if(DSUBASEADDRESS == (unsigned int)-1)
221 DSUBASEADDRESS = 0x90000000;
212 DSUBASEADDRESS = 0x90000000;
222 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
213 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
223 this->running = true;
214 this->running = true;
224 this->UI->setRunning(true);
215 this->UI->setRunning(true);
225 }
216 }
226
217
227 void dsu3plugin::stop()
218 void dsu3plugin::stop()
228 {
219 {
229 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
220 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
230 if(DSUBASEADDRESS == (unsigned int)-1)
221 if(DSUBASEADDRESS == (unsigned int)-1)
231 DSUBASEADDRESS = 0x90000000;
222 DSUBASEADDRESS = 0x90000000;
232 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
223 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
233 this->running = false;
224 this->running = false;
234 this->UI->setRunning(false);
225 this->UI->setRunning(false);
235 }
226 }
236
227
237 void dsu3plugin::toggleRun()
228 void dsu3plugin::toggleRun()
238 {
229 {
239 if(this->running)
230 if(this->running)
240 this->stop();
231 this->stop();
241 else
232 else
242 this->run();
233 this->run();
243 }
234 }
244
235
236 bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format)
237 {
238 if(this->elfFile->isopened())
239 {
240 int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
241 if(symbolIndex!=-1)
242 return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format);
243 }
244 return false;
245 }
246
245 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
247 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
246 {
248 {
247 unsigned int* buff;
249 unsigned int* buff;
248 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
250 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
249 for(int i=0;i<Values.count();i++)
251 for(int i=0;i<Values.count();i++)
250 {
252 {
251 buff[i]=Values.at(i);
253 buff[i]=Values.at(i);
252 }
254 }
253 parent->Write(buff,(unsigned int)Values.count(),address);
255 parent->Write(buff,(unsigned int)Values.count(),address);
254 free(buff);
256 free(buff);
255 }
257 }
256
258
257 unsigned int dsu3plugin::ReadReg(unsigned int address)
259 unsigned int dsu3plugin::ReadReg(unsigned int address)
258 {
260 {
259 unsigned int buff;
261 unsigned int buff;
260 parent->Read(&buff,1,address);
262 parent->Read(&buff,1,address);
261 return buff;
263 return buff;
262 }
264 }
263
265
264 void dsu3plugin::writeSection(int index)
266 void dsu3plugin::writeSection(int index)
265 {
267 {
266 char* buffch=NULL;
268 char* buffch=NULL;
267 unsigned int* buff;
269 unsigned int* buff;
268 int size = this->elfparserInst->getSectionDatasz(index);
270 int size = this->elfFile->getSectionDatasz(index);
269 int sizeInt = size/4;
271 int sizeInt = size/4;
270 if(parent==NULL)
272 if(parent==NULL)
271 return;
273 return;
272 this->elfparserInst->getSectionData(index,&buffch);
274 this->elfFile->getSectionData(index,&buffch);
273 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
275 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
274 for(int i=0;i<sizeInt;i++)
276 for(int i=0;i<sizeInt;i++)
275 {
277 {
276 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
278 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
277 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
279 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
278 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
280 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
279 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
281 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
280 }
282 }
281 if(size%4)
283 if(size%4)
282 {
284 {
283 buff[sizeInt]=0;
285 buff[sizeInt]=0;
284 for(int i=(size%4);i>0;i--)
286 for(int i=(size%4);i>0;i--)
285 {
287 {
286 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
288 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
287 }
289 }
288 sizeInt++;
290 sizeInt++;
289 }
291 }
290 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index));
292 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index));
291 free(buff);
293 free(buff);
292 }
294 }
293
295
294 void dsu3plugin::writeSection(const QString &name)
296 void dsu3plugin::writeSection(const QString &name)
295 {
297 {
296 for(int i=0;i<this->elfparserInst->getSectioncount();i++)
298 if(elfFile->isopened())
297 {
299 {
298 if(!this->elfparserInst->getSectionName(i).compare(name))
300 writeSection(this->elfFile->getSectionIndex(name));
299 {
300 printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i));
301 writeSection(i);
302 }
303 }
301 }
304 }
302 }
305
303
306
304
307 unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
305 unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
308 {
306 {
309 if(parent!=NULL)
307 if(parent!=NULL)
310 return parent->Write(Value,count,address);
308 return parent->Write(Value,count,address);
311 return 0;
309 return 0;
312 }
310 }
313
311
314 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
312 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
315 {
313 {
316 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
314 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
317 if(buffer!=NULL)
315 if(buffer!=NULL)
318 {
316 {
319 memset((void*)buffer,value,count*sizeof(unsigned int));
317 memset((void*)buffer,value,count*sizeof(unsigned int));
320 parent->Write(buffer,count,address);
318 parent->Write(buffer,count,address);
321 free(buffer );
319 free(buffer );
322 return true;
320 return true;
323 }
321 }
324 return false;
322 return false;
325 }
323 }
326
324
327 unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address)
325 unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address)
328 {
326 {
329 if(parent!=NULL)
327 if(parent!=NULL)
330 return parent->Read(Value,count,address);
328 return parent->Read(Value,count,address);
331 return 0;
329 return 0;
332 }
330 }
@@ -1,70 +1,73
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef DSU3PLUGIN_H
22 #ifndef DSU3PLUGIN_H
23 #define DSU3PLUGIN_H
23 #define DSU3PLUGIN_H
24 #include "dsu3pluginui.h"
24 #include "dsu3pluginui.h"
25 #include <QMenuBar>
25 #include <QMenuBar>
26 #include <QMenu>
26 #include <QMenu>
27 #include <QAction>
27 #include <QAction>
28 #include <QMainWindow>
28 #include <QMainWindow>
29 #include <QList>
29 #include <QList>
30 #include "elfparser.h"
30 #include "elfparser.h"
31 #include <elffile.h>
31 #include <socexplorerplugin.h>
32 #include <socexplorerplugin.h>
32 #include <socexplorerengine.h>
33 #include <socexplorerengine.h>
33
34
34 typedef QList<unsigned int> uIntlist;
35 typedef QList<unsigned int> uIntlist;
35
36
36 class dsu3plugin : public socexplorerplugin
37 class dsu3plugin : public socexplorerplugin
37 {
38 {
38 Q_OBJECT
39 Q_OBJECT
39 public:
40 public:
40 explicit dsu3plugin(QWidget *parent = 0);
41 explicit dsu3plugin(QWidget *parent = 0);
41 ~dsu3plugin();
42 ~dsu3plugin();
42 bool memSet(unsigned int address, int value, unsigned int count);
43 bool memSet(unsigned int address, int value, unsigned int count);
43 public slots:
44 public slots:
44 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
45 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
45 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
46 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
46 void openFile();
47 void openFile();
47 void openFile(QString fileName);
48 void openFile(QString fileName);
48 bool configureTarget();
49 bool configureTarget();
49 bool cacheDisable();
50 bool cacheDisable();
50 bool cacheEnable();
51 bool cacheEnable();
51 bool setCacheEnable(bool enabled);
52 bool setCacheEnable(bool enabled);
52 bool flashTarget();
53 bool flashTarget();
53 void run();
54 void run();
54 void stop();
55 void stop();
55 void toggleRun();
56 void toggleRun();
56 //added for python backward compatibility
57 //added for python backward compatibility
57 void loadFile(){this->flashTarget();}
58 void loadFile(){this->flashTarget();}
59 bool dumpSymbol(const QString& symbolName,QString file,const QString& format);
60
58 signals:
61 signals:
59 void updateInfo(elfparser* parser);
62 void updateInfo(ElfFile* elfFile);
60 private:
63 private:
61 void WriteRegs(uIntlist Values, unsigned int address);
64 void WriteRegs(uIntlist Values, unsigned int address);
62 unsigned int ReadReg(unsigned int address);
65 unsigned int ReadReg(unsigned int address);
63 void writeSection(int index);
66 void writeSection(int index);
64 void writeSection(const QString& name);
67 void writeSection(const QString& name);
65 dsu3pluginui* UI;
68 dsu3pluginui* UI;
66 elfparser* elfparserInst;
69 ElfFile* elfFile;
67 bool running;
70 bool running;
68 };
71 };
69
72
70 #endif // DSU3PLUGIN_H
73 #endif // DSU3PLUGIN_H
@@ -1,62 +1,66
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22
22
23 #include <dsu3pluginui.h>
23 #include <dsu3pluginui.h>
24
24
25 dsu3pluginui::dsu3pluginui(QWidget *parent)
25 dsu3pluginui::dsu3pluginui(QWidget *parent)
26 :QWidget(parent)
26 :QWidget(parent)
27 {
27 {
28 this->openFileQpb = new QPushButton(tr("Open File"));
28 this->openFileQpb = new QPushButton(tr("Open File"));
29 this->flashTargetQpb = new QPushButton(tr("Flash Target"));
29 this->flashTargetQpb = new QPushButton(tr("Flash Target"));
30 this->runQpb = new QPushButton(tr("Run"));
30 this->runQpb = new QPushButton(tr("Run"));
31 this->mainLayout = new QGridLayout();
31 this->mainLayout = new QGridLayout();
32 this->elfInfoWdgtInst = new elfInfoWdgt;
32 this->elfFileWidgetInst = new elfFileWidget();
33 this->mainLayout->addWidget(this->openFileQpb,0,0,1,1);
33 this->mainLayout->addWidget(this->openFileQpb,0,0,1,1);
34 this->mainLayout->addWidget(this->flashTargetQpb,0,1,1,1);
34 this->mainLayout->addWidget(this->flashTargetQpb,0,1,1,1);
35 this->mainLayout->addWidget(this->runQpb,0,2,1,1);
35 this->mainLayout->addWidget(this->runQpb,0,2,1,1);
36 this->mainLayout->addWidget(this->elfInfoWdgtInst,1,0,1,-1);
36 this->mainLayout->addWidget(this->elfFileWidgetInst,1,0,1,-1);
37 this->setLayout(this->mainLayout);
37 this->setLayout(this->mainLayout);
38 connect(this->openFileQpb,SIGNAL(clicked()),this,SIGNAL(openFile()));
38 connect(this->openFileQpb,SIGNAL(clicked()),this,SIGNAL(openFile()));
39 connect(this->flashTargetQpb,SIGNAL(clicked()),this,SIGNAL(flashTarget()));
39 connect(this->flashTargetQpb,SIGNAL(clicked()),this,SIGNAL(flashTarget()));
40 connect(this->runQpb,SIGNAL(clicked()),this,SIGNAL(run()));
40 connect(this->runQpb,SIGNAL(clicked()),this,SIGNAL(run()));
41 connect(this,SIGNAL(updateInfo(elfparser*)),this->elfInfoWdgtInst,SLOT(updateInfo(elfparser*)));
42
41
43 }
42 }
44
43
45 void dsu3pluginui::setRunning(bool running)
44 void dsu3pluginui::setRunning(bool running)
46 {
45 {
47 if(running)
46 if(running)
48 this->runQpb->setText("Stop");
47 this->runQpb->setText("Stop");
49 else
48 else
50 this->runQpb->setText("Run");
49 this->runQpb->setText("Run");
51 }
50 }
52
51
52 void dsu3pluginui::updateInfo(ElfFile *file)
53 {
54 this->elfFileWidgetInst->setFile(file);
55 }
56
53
57
54
58
55
59
56
60
57
61
58
62
59
63
60
64
61
65
62
66
@@ -1,57 +1,59
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef DSU3PLUGINUI_H
22 #ifndef DSU3PLUGINUI_H
23 #define DSU3PLUGINUI_H
23 #define DSU3PLUGINUI_H
24
24
25 #include <QWidget>
25 #include <QWidget>
26 #include <QHBoxLayout>
26 #include <QHBoxLayout>
27 #include <QPushButton>
27 #include <QPushButton>
28 #include <qhexedit.h>
28 #include <qhexedit.h>
29 #include <QSplitter>
29 #include <QSplitter>
30 #include <QVBoxLayout>
30 #include <QVBoxLayout>
31 #include <QGridLayout>
31 #include <QGridLayout>
32 #include "elfinfowdgt.h"
32 #include "elfinfowdgt.h"
33 #include <elffile.h>
34 #include <elffilewidget.h>
33
35
34 class dsu3pluginui : public QWidget
36 class dsu3pluginui : public QWidget
35 {
37 {
36 Q_OBJECT
38 Q_OBJECT
37 public:
39 public:
38 explicit dsu3pluginui(QWidget *parent = 0);
40 explicit dsu3pluginui(QWidget *parent = 0);
39
41
40 public slots:
42 public slots:
41 void setRunning(bool running);
43 void setRunning(bool running);
44 void updateInfo(ElfFile* file);
42 signals:
45 signals:
43 void openFile();
46 void openFile();
44 void updateInfo(elfparser* parser);
45 bool flashTarget();
47 bool flashTarget();
46 void run();
48 void run();
47 private:
49 private:
48 QGridLayout* mainLayout;
50 QGridLayout* mainLayout;
49 QPushButton* openFileQpb;
51 QPushButton* openFileQpb;
50 QPushButton* flashTargetQpb;
52 QPushButton* flashTargetQpb;
51 QPushButton* runQpb;
53 QPushButton* runQpb;
52 elfInfoWdgt* elfInfoWdgtInst;
54 elfFileWidget* elfFileWidgetInst;
53 };
55 };
54
56
55 #endif // DSU3PLUGINUI_H
57 #endif // DSU3PLUGINUI_H
56
58
57
59
General Comments 0
You need to be logged in to leave comments. Login now