@@ -1,339 +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 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(1000*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); | |||
|
141 | SocExplorerEngine::message(this,QString("Measured memory size=%1").arg(ramSize),0); | |||
|
142 | ||||
140 | memSet(DSUBASEADDRESS+0x300000,0,1567); |
|
143 | memSet(DSUBASEADDRESS+0x300000,0,1567); | |
141 | 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); | |
142 |
WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0x40 |
|
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); | |
143 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); |
|
146 | WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); | |
144 |
|
147 | |||
145 | //Disable interrupts |
|
148 | //Disable interrupts | |
146 | 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); | |
147 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) |
|
150 | if(APBIRQCTRLRBASEADD == (unsigned int)-1) | |
148 | return false; |
|
151 | return false; | |
149 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); |
|
152 | WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040); | |
150 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); |
|
153 | WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080); | |
151 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); |
|
154 | WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD); | |
152 |
|
155 | |||
153 | //Set up timer |
|
156 | //Set up timer | |
154 | 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); | |
155 | if(APBTIMERBASEADD == (unsigned int)-1) |
|
158 | if(APBTIMERBASEADD == (unsigned int)-1) | |
156 | return false; |
|
159 | return false; | |
157 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); |
|
160 | WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014); | |
158 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); |
|
161 | WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04); | |
159 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); |
|
162 | WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018); | |
160 | return true; |
|
163 | return true; | |
161 | } |
|
164 | } | |
162 |
|
165 | |||
163 | bool dsu3plugin::cacheDisable() |
|
166 | bool dsu3plugin::cacheDisable() | |
164 | { |
|
167 | { | |
165 | return setCacheEnable(false); |
|
168 | return setCacheEnable(false); | |
166 | } |
|
169 | } | |
167 |
|
170 | |||
168 | bool dsu3plugin::cacheEnable() |
|
171 | bool dsu3plugin::cacheEnable() | |
169 | { |
|
172 | { | |
170 | return setCacheEnable(true); |
|
173 | return setCacheEnable(true); | |
171 | } |
|
174 | } | |
172 |
|
175 | |||
173 | bool dsu3plugin::cacheIsEnable() |
|
176 | bool dsu3plugin::cacheIsEnable() | |
174 | { |
|
177 | { | |
175 | if(parent==NULL) |
|
178 | if(parent==NULL) | |
176 | return false; |
|
179 | return false; | |
177 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
180 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
178 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
181 | if(DSUBASEADDRESS == (unsigned int)-1) | |
179 | DSUBASEADDRESS = 0x90000000; |
|
182 | DSUBASEADDRESS = 0x90000000; | |
180 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); |
|
183 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); | |
181 | unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000); |
|
184 | unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000); | |
182 | return ((reg&0x0F)==0x0F); |
|
185 | return ((reg&0x0F)==0x0F); | |
183 | } |
|
186 | } | |
184 |
|
187 | |||
185 | bool dsu3plugin::setCacheEnable(bool enabled) |
|
188 | bool dsu3plugin::setCacheEnable(bool enabled) | |
186 | { |
|
189 | { | |
187 | if(parent==NULL) |
|
190 | if(parent==NULL) | |
188 | return false; |
|
191 | return false; | |
189 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
192 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
190 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
193 | if(DSUBASEADDRESS == (unsigned int)-1) | |
191 | DSUBASEADDRESS = 0x90000000; |
|
194 | DSUBASEADDRESS = 0x90000000; | |
192 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); |
|
195 | WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024); | |
193 | unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000); |
|
196 | unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000); | |
194 | if(enabled) |
|
197 | if(enabled) | |
195 | { |
|
198 | { | |
196 | WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000); |
|
199 | WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000); | |
197 | //flushes cache. |
|
200 | //flushes cache. | |
198 | WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000); |
|
201 | WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000); | |
199 | } |
|
202 | } | |
200 | else |
|
203 | else | |
201 | { |
|
204 | { | |
202 | WriteRegs(uIntlist()<<((!0x0001000F)®),DSUBASEADDRESS+0x700000); |
|
205 | WriteRegs(uIntlist()<<((!0x0001000F)®),DSUBASEADDRESS+0x700000); | |
203 | WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000); |
|
206 | WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000); | |
204 | } |
|
207 | } | |
205 | return true; |
|
208 | return true; | |
206 | } |
|
209 | } | |
207 |
|
210 | |||
208 | bool dsu3plugin::flashTarget() |
|
211 | bool dsu3plugin::flashTarget() | |
209 | { |
|
212 | { | |
210 | stop(); |
|
213 | stop(); | |
211 | cacheDisable(); |
|
214 | cacheDisable(); | |
212 | configureTarget(); |
|
215 | configureTarget(); | |
213 | /*Write .text*/ |
|
216 | /*Write .text*/ | |
214 | this->writeSection(".text"); |
|
217 | this->writeSection(".text"); | |
215 | /*Write .data*/ |
|
218 | /*Write .data*/ | |
216 | this->writeSection(".data"); |
|
219 | this->writeSection(".data"); | |
217 | return true; |
|
220 | return true; | |
218 | } |
|
221 | } | |
219 |
|
222 | |||
220 | void dsu3plugin::run() |
|
223 | void dsu3plugin::run() | |
221 | { |
|
224 | { | |
222 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
225 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
223 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
226 | if(DSUBASEADDRESS == (unsigned int)-1) | |
224 | DSUBASEADDRESS = 0x90000000; |
|
227 | DSUBASEADDRESS = 0x90000000; | |
225 | WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020); |
|
228 | WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020); | |
226 | this->running = true; |
|
229 | this->running = true; | |
227 | this->UI->setRunning(true); |
|
230 | this->UI->setRunning(true); | |
228 | } |
|
231 | } | |
229 |
|
232 | |||
230 | void dsu3plugin::stop() |
|
233 | void dsu3plugin::stop() | |
231 | { |
|
234 | { | |
232 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); |
|
235 | unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); | |
233 | if(DSUBASEADDRESS == (unsigned int)-1) |
|
236 | if(DSUBASEADDRESS == (unsigned int)-1) | |
234 | DSUBASEADDRESS = 0x90000000; |
|
237 | DSUBASEADDRESS = 0x90000000; | |
235 | WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020); |
|
238 | WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020); | |
236 | this->running = false; |
|
239 | this->running = false; | |
237 | this->UI->setRunning(false); |
|
240 | this->UI->setRunning(false); | |
238 | } |
|
241 | } | |
239 |
|
242 | |||
240 | void dsu3plugin::toggleRun() |
|
243 | void dsu3plugin::toggleRun() | |
241 | { |
|
244 | { | |
242 | if(this->running) |
|
245 | if(this->running) | |
243 | this->stop(); |
|
246 | this->stop(); | |
244 | else |
|
247 | else | |
245 | this->run(); |
|
248 | this->run(); | |
246 | } |
|
249 | } | |
247 |
|
250 | |||
248 | bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format) |
|
251 | bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format) | |
249 | { |
|
252 | { | |
250 | if(this->elfFile->isopened()) |
|
253 | if(this->elfFile->isopened()) | |
251 | { |
|
254 | { | |
252 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); |
|
255 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); | |
253 | if(symbolIndex!=-1) |
|
256 | if(symbolIndex!=-1) | |
254 | 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); | |
255 | } |
|
258 | } | |
256 | return false; |
|
259 | return false; | |
257 | } |
|
260 | } | |
258 |
|
261 | |||
259 | QVariantList dsu3plugin::readSymbol(const QString &symbolName) |
|
262 | QVariantList dsu3plugin::readSymbol(const QString &symbolName) | |
260 | { |
|
263 | { | |
261 | if(this->elfFile->isopened()) |
|
264 | if(this->elfFile->isopened()) | |
262 | { |
|
265 | { | |
263 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); |
|
266 | int symbolIndex=this->elfFile->getSymbolIndex(symbolName); | |
264 | if(symbolIndex!=-1) |
|
267 | if(symbolIndex!=-1) | |
265 | 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); | |
266 | } |
|
269 | } | |
267 | return QVariantList(); |
|
270 | return QVariantList(); | |
268 | } |
|
271 | } | |
269 |
|
272 | |||
270 | void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) |
|
273 | void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) | |
271 | { |
|
274 | { | |
272 | unsigned int* buff; |
|
275 | unsigned int* buff; | |
273 | buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); |
|
276 | buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); | |
274 | for(int i=0;i<Values.count();i++) |
|
277 | for(int i=0;i<Values.count();i++) | |
275 | { |
|
278 | { | |
276 | buff[i]=Values.at(i); |
|
279 | buff[i]=Values.at(i); | |
277 | } |
|
280 | } | |
278 | parent->Write(buff,(unsigned int)Values.count(),address); |
|
281 | parent->Write(buff,(unsigned int)Values.count(),address); | |
279 | free(buff); |
|
282 | free(buff); | |
280 | } |
|
283 | } | |
281 |
|
284 | |||
282 | unsigned int dsu3plugin::ReadReg(unsigned int address) |
|
285 | unsigned int dsu3plugin::ReadReg(unsigned int address) | |
283 | { |
|
286 | { | |
284 | unsigned int buff; |
|
287 | unsigned int buff; | |
285 | parent->Read(&buff,1,address); |
|
288 | parent->Read(&buff,1,address); | |
286 | return buff; |
|
289 | return buff; | |
287 | } |
|
290 | } | |
288 |
|
291 | |||
289 | void dsu3plugin::writeSection(int index) |
|
292 | void dsu3plugin::writeSection(int index) | |
290 | { |
|
293 | { | |
291 | char* buffch=NULL; |
|
294 | char* buffch=NULL; | |
292 | unsigned int* buff; |
|
295 | unsigned int* buff; | |
293 | int size = this->elfFile->getSectionDatasz(index); |
|
296 | int size = this->elfFile->getSectionDatasz(index); | |
294 | int sizeInt = size/4; |
|
297 | int sizeInt = size/4; | |
295 | if(parent==NULL) |
|
298 | if(parent==NULL) | |
296 | return; |
|
299 | return; | |
297 | this->elfFile->getSectionData(index,&buffch); |
|
300 | this->elfFile->getSectionData(index,&buffch); | |
298 | buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); |
|
301 | buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); | |
299 | for(int i=0;i<sizeInt;i++) |
|
302 | for(int i=0;i<sizeInt;i++) | |
300 | { |
|
303 | { | |
301 | buff[i] = 0x0FF & ((unsigned int)buffch[4*i]); |
|
304 | buff[i] = 0x0FF & ((unsigned int)buffch[4*i]); | |
302 | 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])); | |
303 | 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])); | |
304 | 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])); | |
305 | } |
|
308 | } | |
306 | if(size%4) |
|
309 | if(size%4) | |
307 | { |
|
310 | { | |
308 | buff[sizeInt]=0; |
|
311 | buff[sizeInt]=0; | |
309 | for(int i=(size%4);i>0;i--) |
|
312 | for(int i=(size%4);i>0;i--) | |
310 | { |
|
313 | { | |
311 | buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); |
|
314 | buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); | |
312 | } |
|
315 | } | |
313 | sizeInt++; |
|
316 | sizeInt++; | |
314 | } |
|
317 | } | |
315 | 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)); | |
316 | free(buff); |
|
319 | free(buff); | |
317 | } |
|
320 | } | |
318 |
|
321 | |||
319 | void dsu3plugin::writeSection(const QString &name) |
|
322 | void dsu3plugin::writeSection(const QString &name) | |
320 | { |
|
323 | { | |
321 | if(elfFile->isopened()) |
|
324 | if(elfFile->isopened()) | |
322 | { |
|
325 | { | |
323 | writeSection(this->elfFile->getSectionIndex(name)); |
|
326 | writeSection(this->elfFile->getSectionIndex(name)); | |
324 | } |
|
327 | } | |
325 | } |
|
328 | } | |
326 |
|
329 | |||
327 |
|
330 | |||
328 | bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) |
|
331 | bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) | |
329 | { |
|
332 | { | |
330 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); |
|
333 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
331 | if(buffer!=NULL) |
|
334 | if(buffer!=NULL) | |
332 | { |
|
335 | { | |
333 | memset((void*)buffer,value,count*sizeof(unsigned int)); |
|
336 | memset((void*)buffer,value,count*sizeof(unsigned int)); | |
334 | parent->Write(buffer,count,address); |
|
337 | parent->Write(buffer,count,address); | |
335 | free(buffer ); |
|
338 | free(buffer ); | |
336 | return true; |
|
339 | return true; | |
337 | } |
|
340 | } | |
338 | return false; |
|
341 | return false; | |
339 | } |
|
342 | } |
General Comments 0
You need to be logged in to leave comments.
Login now