##// END OF EJS Templates
Fixed mistake on dsu3plugin.
jeandet -
r45:33514237ed3a default
parent child
Show More
@@ -1,311 +1,323
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 "dsu3pluginpywrapper.h"
25 #include "dsu3pluginpywrapper.h"
26 #include <socexplorerengine.h>
26 #include <socexplorerengine.h>
27
27
28
28
29 struct acceptedMemctrlr_str
29 struct acceptedMemctrlr_str
30 {
30 {
31 int vid;
31 int vid;
32 int pid;
32 int pid;
33 const char* name;
33 const char* name;
34 };
34 };
35
35
36 const struct acceptedMemctrlr_str acceptedMemctrlr[]=
36 const struct acceptedMemctrlr_str acceptedMemctrlr[]=
37 {
37 {
38 {0x01,0x04,"MCTRL"},
38 {0x0f,0x04,"MCTRL"},
39 {0x01,0x51,"FTSRCTRL"},
39 {0x01,0x51,"FTSRCTRL"},
40 {0x20,0x01,"SRCTRLE_0WS" },
40 {0x20,0x01,"SRCTRLE_0WS" },
41 {0x20,0x02,"SRCTRLE_1WS" }
41 {0x20,0x02,"SRCTRLE_1WS" }
42 };
42 };
43
43
44 #define acceptedMemctrlrCnt sizeof acceptedMemctrlr
44 #define acceptedMemctrlrCnt sizeof acceptedMemctrlr
45
45
46 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
46 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
47 {
47 {
48 this->UI = new dsu3pluginui();
48 this->UI = new dsu3pluginui();
49 this->setWidget((QWidget*)this->UI);
49 this->setWidget((QWidget*)this->UI);
50 this->elfparserInst = new elfparser();
50 this->elfparserInst = new elfparser();
51 this->pyObject = new dsu3pluginPywrapper(this);
51 this->pyObject = new dsu3pluginPywrapper(this);
52 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)));
53 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget()));
53 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget()));
54 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run()));
54 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run()));
55 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop()));
55 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop()));
56 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable()));
56 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable()));
57 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable()));
57 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable()));
58 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool)));
58 QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool)));
59
59
60 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
60 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
61 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
61 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
62 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
62 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
63 connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*)));
63 connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*)));
64 this->running = false;
64 this->running = false;
65 }
65 }
66
66
67
67
68 dsu3plugin::~dsu3plugin()
68 dsu3plugin::~dsu3plugin()
69 {
69 {
70
70
71 }
71 }
72
72
73
73
74 void dsu3plugin::openFile()
74 void dsu3plugin::openFile()
75 {
75 {
76 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 (*)"));
77 if(filename!="")
77 if(filename!="")
78 {
78 {
79 this->openFile(filename);
79 this->openFile(filename);
80 }
80 }
81 }
81 }
82
82
83 void dsu3plugin::openFile(QString fileName)
83 void dsu3plugin::openFile(QString fileName)
84 {
84 {
85 this->elfparserInst->setFilename(fileName);
85 this->elfparserInst->setFilename(fileName);
86 emit this->updateInfo(this->elfparserInst);
86 emit this->updateInfo(this->elfparserInst);
87 }
87 }
88
88
89 bool dsu3plugin::configureTarget()
89 bool dsu3plugin::configureTarget()
90 {
90 {
91 if(parent==NULL)
91 if(parent==NULL)
92 return false;
92 return false;
93 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
93 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
94 if(DSUBASEADDRESS == (unsigned int)-1)
94 if(DSUBASEADDRESS == (unsigned int)-1)
95 DSUBASEADDRESS = 0x90000000;
95 DSUBASEADDRESS = 0x90000000;
96 unsigned int MCTRLBASEADDRESS =-1;
96 unsigned int MCTRLBASEADDRESS =-1;
97 for(int i=0; i<acceptedMemctrlrCnt;i++)
97 for(int i=0; i<acceptedMemctrlrCnt;i++)
98 {
98 {
99 MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0);
99 MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0);
100 if(MCTRLBASEADDRESS != (unsigned int)-1) break;
100 if(MCTRLBASEADDRESS != (unsigned int)-1)
101 {
102 SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1);
103 break;
104 }
101 }
105 }
102 if(MCTRLBASEADDRESS == (unsigned int)-1)
106 if(MCTRLBASEADDRESS == (unsigned int)-1)
103 {
107 {
104 //SocExplorerEngine::message(this,"Can't find FTMemCtrlr",1);
108 SocExplorerEngine::message(this,"Can't any compatible memory controller",1);
105 return false;
109 return false;
106 }
110 }
107
111
108
112
109 //Force a debug break
113 //Force a debug break
110 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
114 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
111 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
115 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
112 //Clear time tag counter
116 //Clear time tag counter
113 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
117 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
114
118
115 //Clear ASR registers
119 //Clear ASR registers
116 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
120 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
117 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
121 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
118 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
122 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
119 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
123 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
120 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
124 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
121 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
125 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
122
126
123
127
124
128
125 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
129 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
126
130
127
131
128 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
132 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
129 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
133 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
130
134
131 unsigned int buff=0;
135 unsigned int buff=0;
132 // for(int i=0;i<1567;i++)
136 // for(int i=0;i<1567;i++)
133 // {
137 // {
134 // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i));
138 // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i));
135 // }
139 // }
136 memSet(DSUBASEADDRESS+0x300000,0,1567);
140 memSet(DSUBASEADDRESS+0x300000,0,1567);
137 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);
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);
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);
139 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
143 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
140
144
141 //Disable interrupts
145 //Disable interrupts
142 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);
143 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
147 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
144 return false;
148 return false;
145 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
149 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
146 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
150 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
147 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
151 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
148
152
149 //Set up timer
153 //Set up timer
150 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);
151 if(APBTIMERBASEADD == (unsigned int)-1)
155 if(APBTIMERBASEADD == (unsigned int)-1)
152 return false;
156 return false;
153 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
157 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
154 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
158 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
155 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
159 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
156 return true;
160 return true;
157 }
161 }
158
162
159 bool dsu3plugin::cacheDisable()
163 bool dsu3plugin::cacheDisable()
160 {
164 {
161 return setCacheEnable(false);
165 return setCacheEnable(false);
162 }
166 }
163
167
164 bool dsu3plugin::cacheEnable()
168 bool dsu3plugin::cacheEnable()
165 {
169 {
166 return setCacheEnable(true);
170 return setCacheEnable(true);
167 }
171 }
168
172
169 bool dsu3plugin::setCacheEnable(bool enabled)
173 bool dsu3plugin::setCacheEnable(bool enabled)
170 {
174 {
171 if(parent==NULL)
175 if(parent==NULL)
172 return false;
176 return false;
173 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
177 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
174 if(DSUBASEADDRESS == (unsigned int)-1)
178 if(DSUBASEADDRESS == (unsigned int)-1)
175 DSUBASEADDRESS = 0x90000000;
179 DSUBASEADDRESS = 0x90000000;
176 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
180 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
177 if(enabled)
181 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
182 if(enabled)
178 {
183 {
179 WriteRegs(uIntlist()<<0x0001000F,DSUBASEADDRESS+0x700000);
184 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
180 //flushes cache.
185 //flushes cache.
181 WriteRegs(uIntlist()<<0x0061000F,DSUBASEADDRESS+0x700000);
186 WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
182 }
187 }
183 else
188 else
184 {
189 {
185 WriteRegs(uIntlist()<<0x00000000,DSUBASEADDRESS+0x700000);
190 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
186 WriteRegs(uIntlist()<<0x00600000,DSUBASEADDRESS+0x700000);
191 WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
187 }
192 }
188 return true;
193 return true;
189 }
194 }
190
195
191 bool dsu3plugin::flashTarget()
196 bool dsu3plugin::flashTarget()
192 {
197 {
193 stop();
198 stop();
194 cacheDisable();
199 cacheDisable();
195 configureTarget();
200 configureTarget();
196 /*Write .text*/
201 /*Write .text*/
197 this->writeSection(".text");
202 this->writeSection(".text");
198 /*Write .data*/
203 /*Write .data*/
199 this->writeSection(".data");
204 this->writeSection(".data");
200 return true;
205 return true;
201 }
206 }
202
207
203 void dsu3plugin::run()
208 void dsu3plugin::run()
204 {
209 {
205 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
210 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
206 if(DSUBASEADDRESS == (unsigned int)-1)
211 if(DSUBASEADDRESS == (unsigned int)-1)
207 DSUBASEADDRESS = 0x90000000;
212 DSUBASEADDRESS = 0x90000000;
208 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
213 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
209 this->running = true;
214 this->running = true;
210 this->UI->setRunning(true);
215 this->UI->setRunning(true);
211 }
216 }
212
217
213 void dsu3plugin::stop()
218 void dsu3plugin::stop()
214 {
219 {
215 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
220 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
216 if(DSUBASEADDRESS == (unsigned int)-1)
221 if(DSUBASEADDRESS == (unsigned int)-1)
217 DSUBASEADDRESS = 0x90000000;
222 DSUBASEADDRESS = 0x90000000;
218 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
223 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
219 this->running = false;
224 this->running = false;
220 this->UI->setRunning(false);
225 this->UI->setRunning(false);
221 }
226 }
222
227
223 void dsu3plugin::toggleRun()
228 void dsu3plugin::toggleRun()
224 {
229 {
225 if(this->running)
230 if(this->running)
226 this->stop();
231 this->stop();
227 else
232 else
228 this->run();
233 this->run();
229 }
234 }
230
235
231 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
236 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
232 {
237 {
233 unsigned int* buff;
238 unsigned int* buff;
234 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
239 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
235 for(int i=0;i<Values.count();i++)
240 for(int i=0;i<Values.count();i++)
236 {
241 {
237 buff[i]=Values.at(i);
242 buff[i]=Values.at(i);
238 }
243 }
239 parent->Write(buff,(unsigned int)Values.count(),address);
244 parent->Write(buff,(unsigned int)Values.count(),address);
240 free(buff);
245 free(buff);
246 }
247
248 unsigned int dsu3plugin::ReadReg(unsigned int address)
249 {
250 unsigned int buff;
251 parent->Read(&buff,1,address);
252 return buff;
241 }
253 }
242
254
243 void dsu3plugin::writeSection(int index)
255 void dsu3plugin::writeSection(int index)
244 {
256 {
245 char* buffch=NULL;
257 char* buffch=NULL;
246 unsigned int* buff;
258 unsigned int* buff;
247 int size = this->elfparserInst->getSectionDatasz(index);
259 int size = this->elfparserInst->getSectionDatasz(index);
248 int sizeInt = size/4;
260 int sizeInt = size/4;
249 if(parent==NULL)
261 if(parent==NULL)
250 return;
262 return;
251 this->elfparserInst->getSectionData(index,&buffch);
263 this->elfparserInst->getSectionData(index,&buffch);
252 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
264 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
253 for(int i=0;i<sizeInt;i++)
265 for(int i=0;i<sizeInt;i++)
254 {
266 {
255 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
267 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
256 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
268 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]));
269 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]));
270 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
259 }
271 }
260 if(size%4)
272 if(size%4)
261 {
273 {
262 buff[sizeInt]=0;
274 buff[sizeInt]=0;
263 for(int i=(size%4);i>0;i--)
275 for(int i=(size%4);i>0;i--)
264 {
276 {
265 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
277 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
266 }
278 }
267 sizeInt++;
279 sizeInt++;
268 }
280 }
269 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index));
281 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index));
270 free(buff);
282 free(buff);
271 }
283 }
272
284
273 void dsu3plugin::writeSection(const QString &name)
285 void dsu3plugin::writeSection(const QString &name)
274 {
286 {
275 for(int i=0;i<this->elfparserInst->getSectioncount();i++)
287 for(int i=0;i<this->elfparserInst->getSectioncount();i++)
276 {
288 {
277 if(!this->elfparserInst->getSectionName(i).compare(name))
289 if(!this->elfparserInst->getSectionName(i).compare(name))
278 {
290 {
279 printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i));
291 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);
292 writeSection(i);
281 }
293 }
282 }
294 }
283 }
295 }
284
296
285
297
286 unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
298 unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address)
287 {
299 {
288 if(parent!=NULL)
300 if(parent!=NULL)
289 return parent->Write(Value,count,address);
301 return parent->Write(Value,count,address);
290 return 0;
302 return 0;
291 }
303 }
292
304
293 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
305 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
294 {
306 {
295 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
307 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
296 if(buffer!=NULL)
308 if(buffer!=NULL)
297 {
309 {
298 memset((void*)buffer,value,count*sizeof(unsigned int));
310 memset((void*)buffer,value,count*sizeof(unsigned int));
299 parent->Write(buffer,count,address);
311 parent->Write(buffer,count,address);
300 free(buffer );
312 free(buffer );
301 return true;
313 return true;
302 }
314 }
303 return false;
315 return false;
304 }
316 }
305
317
306 unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address)
318 unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address)
307 {
319 {
308 if(parent!=NULL)
320 if(parent!=NULL)
309 return parent->Read(Value,count,address);
321 return parent->Read(Value,count,address);
310 return 0;
322 return 0;
311 }
323 }
@@ -1,67 +1,68
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 <socexplorerplugin.h>
31 #include <socexplorerplugin.h>
32 #include <socexplorerengine.h>
32 #include <socexplorerengine.h>
33
33
34 typedef QList<unsigned int> uIntlist;
34 typedef QList<unsigned int> uIntlist;
35
35
36 class dsu3plugin : public socexplorerplugin
36 class dsu3plugin : public socexplorerplugin
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 public:
39 public:
40 explicit dsu3plugin(QWidget *parent = 0);
40 explicit dsu3plugin(QWidget *parent = 0);
41 ~dsu3plugin();
41 ~dsu3plugin();
42 bool memSet(unsigned int address, int value, unsigned int count);
42 bool memSet(unsigned int address, int value, unsigned int count);
43 public slots:
43 public slots:
44 unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0);
44 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);
45 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
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();
49 bool cacheDisable();
50 bool cacheEnable();
50 bool cacheEnable();
51 bool setCacheEnable(bool enabled);
51 bool setCacheEnable(bool enabled);
52 bool flashTarget();
52 bool flashTarget();
53 void run();
53 void run();
54 void stop();
54 void stop();
55 void toggleRun();
55 void toggleRun();
56 signals:
56 signals:
57 void updateInfo(elfparser* parser);
57 void updateInfo(elfparser* parser);
58 private:
58 private:
59 void WriteRegs(uIntlist Values, unsigned int address);
59 void WriteRegs(uIntlist Values, unsigned int address);
60 unsigned int ReadReg(unsigned int address);
60 void writeSection(int index);
61 void writeSection(int index);
61 void writeSection(const QString& name);
62 void writeSection(const QString& name);
62 dsu3pluginui* UI;
63 dsu3pluginui* UI;
63 elfparser* elfparserInst;
64 elfparser* elfparserInst;
64 bool running;
65 bool running;
65 };
66 };
66
67
67 #endif // DSU3PLUGIN_H
68 #endif // DSU3PLUGIN_H
General Comments 0
You need to be logged in to leave comments. Login now