##// END OF EJS Templates
dsu3plugin:...
Jeandet Alexis -
r94:8ff48a64ef09 default draft
parent child
Show More
@@ -1,342 +1,342
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->elfFile = new ElfFile();
49 this->elfFile = new ElfFile();
50 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
50 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
51 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
51 connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
52 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
52 connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
53 connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*)));
53 connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*)));
54 this->running = false;
54 this->running = false;
55 }
55 }
56
56
57
57
58 dsu3plugin::~dsu3plugin()
58 dsu3plugin::~dsu3plugin()
59 {
59 {
60
60
61 }
61 }
62
62
63
63
64 void dsu3plugin::openFile()
64 void dsu3plugin::openFile()
65 {
65 {
66 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 (*)"));
67 if(filename!="")
67 if(filename!="")
68 {
68 {
69 this->openFile(filename);
69 this->openFile(filename);
70 }
70 }
71 }
71 }
72
72
73 void dsu3plugin::openFile(QString fileName)
73 void dsu3plugin::openFile(QString fileName)
74 {
74 {
75 this->elfFile->openFile(fileName);
75 this->elfFile->openFile(fileName);
76 emit this->updateInfo(this->elfFile);
76 emit this->updateInfo(this->elfFile);
77 }
77 }
78
78
79 bool dsu3plugin::configureTarget()
79 bool dsu3plugin::configureTarget()
80 {
80 {
81 int detectedMctrlr=-1;
81 int detectedMctrlr=-1;
82 if(parent==NULL)
82 if(parent==NULL)
83 return false;
83 return false;
84 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
84 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
85 if(DSUBASEADDRESS == (unsigned int)-1)
85 if(DSUBASEADDRESS == (unsigned int)-1)
86 DSUBASEADDRESS = 0x90000000;
86 DSUBASEADDRESS = 0x90000000;
87 unsigned int MCTRLBASEADDRESS =-1;
87 unsigned int MCTRLBASEADDRESS =-1;
88 for(int i=0; i<acceptedMemctrlrCnt;i++)
88 for(int i=0; i<acceptedMemctrlrCnt;i++)
89 {
89 {
90 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);
91 if(MCTRLBASEADDRESS != (unsigned int)-1)
91 if(MCTRLBASEADDRESS != (unsigned int)-1)
92 {
92 {
93 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);
94 detectedMctrlr=i;
94 detectedMctrlr=i;
95 break;
95 break;
96 }
96 }
97 }
97 }
98 if(MCTRLBASEADDRESS == (unsigned int)-1)
98 if(MCTRLBASEADDRESS == (unsigned int)-1)
99 {
99 {
100 SocExplorerEngine::message(this,"Can't find any compatible memory controller",1);
100 SocExplorerEngine::message(this,"Can't find any compatible memory controller",1);
101 // return false;
101 // return false;
102 }
102 }
103
103
104
104
105 //Force a debug break
105 //Force a debug break
106 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
106 WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
107 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
107 WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
108 //Clear time tag counter
108 //Clear time tag counter
109 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
109 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
110
110
111 //Clear ASR registers
111 //Clear ASR registers
112 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
112 WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
113 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
113 WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
114 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);
115 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
115 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
116 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
116 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
117 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
117 WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
118
118
119 // {0x04,0x0f,"MCTRL"},
119 // {0x04,0x0f,"MCTRL"},
120 // {0x01,0x51,"FTSRCTRL"},
120 // {0x01,0x51,"FTSRCTRL"},
121 // {0x20,0x01,"SRCTRLE_0WS" },
121 // {0x20,0x01,"SRCTRLE_0WS" },
122 // {0x20,0x02,"SRCTRLE_1WS" }
122 // {0x20,0x02,"SRCTRLE_1WS" }
123 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" )
123 if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" )
124 {
124 {
125 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
125 WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
126 }
126 }
127 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" )
128 {
128 {
129 //let's perform a mem Wash
129 //let's perform a mem Wash
130 unsigned int val = ReadReg(MCTRLBASEADDRESS);
130 unsigned int val = ReadReg(MCTRLBASEADDRESS);
131 val |=1<<31;
131 val |=1<<31;
132 WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS);
132 WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS);
133 usleep(1000*1000);
133 usleep(2000*1000);
134 }
134 }
135
135
136
136
137 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
137 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
138 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
138 WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
139
139
140 unsigned int ramSize=SocExplorerEngine::self()->memMeasureSize(this->parentPlugin(),0x40000000);
140 unsigned int ramSize=SocExplorerEngine::self()->memMeasureSize(this->parentPlugin(),0x40000000);
141 SocExplorerEngine::message(this,QString("Measured memory size=%1").arg(ramSize),0);
141 SocExplorerEngine::message(this,QString("Measured memory size=%1").arg(ramSize),0);
142
142
143 memSet(DSUBASEADDRESS+0x300000,0,1567);
143 memSet(DSUBASEADDRESS+0x300000,0,1567);
144 WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
144 WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
145 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x40000000+ramSize-16<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020);
145 WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x40000000+ramSize-16<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x300020);
146 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
146 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
147
147
148 //Disable interrupts
148 //Disable interrupts
149 unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
149 unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
150 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
150 if(APBIRQCTRLRBASEADD == (unsigned int)-1)
151 return false;
151 return false;
152 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
152 WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
153 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
153 WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
154 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
154 WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
155
155
156 //Set up timer
156 //Set up timer
157 unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
157 unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
158 if(APBTIMERBASEADD == (unsigned int)-1)
158 if(APBTIMERBASEADD == (unsigned int)-1)
159 return false;
159 return false;
160 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
160 WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
161 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
161 WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
162 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
162 WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
163 return true;
163 return true;
164 }
164 }
165
165
166 bool dsu3plugin::cacheDisable()
166 bool dsu3plugin::cacheDisable()
167 {
167 {
168 return setCacheEnable(false);
168 return setCacheEnable(false);
169 }
169 }
170
170
171 bool dsu3plugin::cacheEnable()
171 bool dsu3plugin::cacheEnable()
172 {
172 {
173 return setCacheEnable(true);
173 return setCacheEnable(true);
174 }
174 }
175
175
176 bool dsu3plugin::cacheIsEnable()
176 bool dsu3plugin::cacheIsEnable()
177 {
177 {
178 if(parent==NULL)
178 if(parent==NULL)
179 return false;
179 return false;
180 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
180 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
181 if(DSUBASEADDRESS == (unsigned int)-1)
181 if(DSUBASEADDRESS == (unsigned int)-1)
182 DSUBASEADDRESS = 0x90000000;
182 DSUBASEADDRESS = 0x90000000;
183 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
183 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
184 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
184 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
185 return ((reg&0x0F)==0x0F);
185 return ((reg&0x0F)==0x0F);
186 }
186 }
187
187
188 bool dsu3plugin::setCacheEnable(bool enabled)
188 bool dsu3plugin::setCacheEnable(bool enabled)
189 {
189 {
190 if(parent==NULL)
190 if(parent==NULL)
191 return false;
191 return false;
192 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
192 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
193 if(DSUBASEADDRESS == (unsigned int)-1)
193 if(DSUBASEADDRESS == (unsigned int)-1)
194 DSUBASEADDRESS = 0x90000000;
194 DSUBASEADDRESS = 0x90000000;
195 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
195 WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
196 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
196 unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
197 if(enabled)
197 if(enabled)
198 {
198 {
199 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
199 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
200 //flushes cache.
200 //flushes cache.
201 WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
201 WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
202 }
202 }
203 else
203 else
204 {
204 {
205 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
205 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
206 WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
206 WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
207 }
207 }
208 return true;
208 return true;
209 }
209 }
210
210
211 bool dsu3plugin::flashTarget()
211 bool dsu3plugin::flashTarget()
212 {
212 {
213 stop();
213 stop();
214 cacheDisable();
214 cacheDisable();
215 configureTarget();
215 configureTarget();
216 /*Write .text*/
216 /*Write .text*/
217 this->writeSection(".text");
217 this->writeSection(".text");
218 /*Write .data*/
218 /*Write .data*/
219 this->writeSection(".data");
219 this->writeSection(".data");
220 return true;
220 return true;
221 }
221 }
222
222
223 void dsu3plugin::run()
223 void dsu3plugin::run()
224 {
224 {
225 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
225 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
226 if(DSUBASEADDRESS == (unsigned int)-1)
226 if(DSUBASEADDRESS == (unsigned int)-1)
227 DSUBASEADDRESS = 0x90000000;
227 DSUBASEADDRESS = 0x90000000;
228 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
228 WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
229 this->running = true;
229 this->running = true;
230 this->UI->setRunning(true);
230 this->UI->setRunning(true);
231 }
231 }
232
232
233 void dsu3plugin::stop()
233 void dsu3plugin::stop()
234 {
234 {
235 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
235 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
236 if(DSUBASEADDRESS == (unsigned int)-1)
236 if(DSUBASEADDRESS == (unsigned int)-1)
237 DSUBASEADDRESS = 0x90000000;
237 DSUBASEADDRESS = 0x90000000;
238 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
238 WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
239 this->running = false;
239 this->running = false;
240 this->UI->setRunning(false);
240 this->UI->setRunning(false);
241 }
241 }
242
242
243 void dsu3plugin::toggleRun()
243 void dsu3plugin::toggleRun()
244 {
244 {
245 if(this->running)
245 if(this->running)
246 this->stop();
246 this->stop();
247 else
247 else
248 this->run();
248 this->run();
249 }
249 }
250
250
251 bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format)
251 bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format)
252 {
252 {
253 if(this->elfFile->isopened())
253 if(this->elfFile->isopened())
254 {
254 {
255 int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
255 int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
256 if(symbolIndex!=-1)
256 if(symbolIndex!=-1)
257 return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format);
257 return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format);
258 }
258 }
259 return false;
259 return false;
260 }
260 }
261
261
262 QVariantList dsu3plugin::readSymbol(const QString &symbolName)
262 QVariantList dsu3plugin::readSymbol(const QString &symbolName)
263 {
263 {
264 if(this->elfFile->isopened())
264 if(this->elfFile->isopened())
265 {
265 {
266 int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
266 int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
267 if(symbolIndex!=-1)
267 if(symbolIndex!=-1)
268 return socexplorerplugin::Read((unsigned int)this->elfFile->getSymbolAddress(symbolIndex),(unsigned int)this->elfFile->getSymbolSize(symbolIndex)/4);
268 return socexplorerplugin::Read((unsigned int)this->elfFile->getSymbolAddress(symbolIndex),(unsigned int)this->elfFile->getSymbolSize(symbolIndex)/4);
269 }
269 }
270 return QVariantList();
270 return QVariantList();
271 }
271 }
272
272
273 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
273 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
274 {
274 {
275 unsigned int* buff;
275 unsigned int* buff;
276 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
276 buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
277 for(int i=0;i<Values.count();i++)
277 for(int i=0;i<Values.count();i++)
278 {
278 {
279 buff[i]=Values.at(i);
279 buff[i]=Values.at(i);
280 }
280 }
281 parent->Write(buff,(unsigned int)Values.count(),address);
281 parent->Write(buff,(unsigned int)Values.count(),address);
282 free(buff);
282 free(buff);
283 }
283 }
284
284
285 unsigned int dsu3plugin::ReadReg(unsigned int address)
285 unsigned int dsu3plugin::ReadReg(unsigned int address)
286 {
286 {
287 unsigned int buff;
287 unsigned int buff;
288 parent->Read(&buff,1,address);
288 parent->Read(&buff,1,address);
289 return buff;
289 return buff;
290 }
290 }
291
291
292 void dsu3plugin::writeSection(int index)
292 void dsu3plugin::writeSection(int index)
293 {
293 {
294 char* buffch=NULL;
294 char* buffch=NULL;
295 unsigned int* buff;
295 unsigned int* buff;
296 int size = this->elfFile->getSectionDatasz(index);
296 int size = this->elfFile->getSectionDatasz(index);
297 int sizeInt = size/4;
297 int sizeInt = size/4;
298 if(parent==NULL)
298 if(parent==NULL)
299 return;
299 return;
300 this->elfFile->getSectionData(index,&buffch);
300 this->elfFile->getSectionData(index,&buffch);
301 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
301 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
302 for(int i=0;i<sizeInt;i++)
302 for(int i=0;i<sizeInt;i++)
303 {
303 {
304 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
304 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
305 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
305 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
306 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
306 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
307 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
307 buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
308 }
308 }
309 if(size%4)
309 if(size%4)
310 {
310 {
311 buff[sizeInt]=0;
311 buff[sizeInt]=0;
312 for(int i=(size%4);i>0;i--)
312 for(int i=(size%4);i>0;i--)
313 {
313 {
314 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
314 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
315 }
315 }
316 sizeInt++;
316 sizeInt++;
317 }
317 }
318 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index));
318 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index));
319 free(buff);
319 free(buff);
320 }
320 }
321
321
322 void dsu3plugin::writeSection(const QString &name)
322 void dsu3plugin::writeSection(const QString &name)
323 {
323 {
324 if(elfFile->isopened())
324 if(elfFile->isopened())
325 {
325 {
326 writeSection(this->elfFile->getSectionIndex(name));
326 writeSection(this->elfFile->getSectionIndex(name));
327 }
327 }
328 }
328 }
329
329
330
330
331 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
331 bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
332 {
332 {
333 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
333 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
334 if(buffer!=NULL)
334 if(buffer!=NULL)
335 {
335 {
336 memset((void*)buffer,value,count*sizeof(unsigned int));
336 memset((void*)buffer,value,count*sizeof(unsigned int));
337 parent->Write(buffer,count,address);
337 parent->Write(buffer,count,address);
338 free(buffer );
338 free(buffer );
339 return true;
339 return true;
340 }
340 }
341 return false;
341 return false;
342 }
342 }
General Comments 0
You need to be logged in to leave comments. Login now