##// END OF EJS Templates
Étiquette socexplorer-plugins-0.7-5 ajoutée à la révision 7f21c0e03b63
Étiquette socexplorer-plugins-0.7-5 ajoutée à la révision 7f21c0e03b63

File last commit:

r88:f17adb028d26 default
r93:50d45b307e37 default
Show More
dsu3plugin.cpp
342 lines | 11.2 KiB | text/x-c | CppLexer
First init /!\ outdated spwplugin!
r0 /*------------------------------------------------------------------------------
Jeandet Alexis
updated plugin headers and win32/Apbuart fix tentative.
r4 -- This file is a part of the SocExplorer Software
Jeandet Alexis
Added disconnection auto-detection to the spacewire plugin.
r11 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
First init /!\ outdated spwplugin!
r0 --
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@lpp.polytechnique.fr
----------------------------------------------------------------------------*/
#include "dsu3plugin.h"
#include <QFileDialog>
#include <QDir>
#include <socexplorerengine.h>
Added cache enable/disable on dsu3plugin....
r44
struct acceptedMemctrlr_str
{
Fixed mistake on dsu3plugin.
r45 int vid;
int pid;
const char* name;
Added cache enable/disable on dsu3plugin....
r44 };
const struct acceptedMemctrlr_str acceptedMemctrlr[]=
{
paul
fixed bug on dsu3plugin r45 not valid!
r48 {0x04,0x0f,"MCTRL"},
Added cache enable/disable on dsu3plugin....
r44 {0x01,0x51,"FTSRCTRL"},
{0x20,0x01,"SRCTRLE_0WS" },
{0x20,0x02,"SRCTRLE_1WS" }
};
paul
fixed bug on dsu3plugin r45 not valid!
r48 #define acceptedMemctrlrCnt 4
Added cache enable/disable on dsu3plugin....
r44
First init /!\ outdated spwplugin!
r0 dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false)
{
Fixed mistake on dsu3plugin.
r45 this->UI = new dsu3pluginui();
this->setWidget((QWidget*)this->UI);
dsu3plugin:...
r60 this->elfFile = new ElfFile();
Fixed mistake on dsu3plugin.
r45 connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile()));
connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget()));
connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun()));
dsu3plugin:...
r60 connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*)));
Fixed mistake on dsu3plugin.
r45 this->running = false;
First init /!\ outdated spwplugin!
r0 }
dsu3plugin::~dsu3plugin()
{
}
void dsu3plugin::openFile()
{
Fixed mistake on dsu3plugin.
r45 QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)"));
if(filename!="")
First init /!\ outdated spwplugin!
r0 {
Fixed mistake on dsu3plugin.
r45 this->openFile(filename);
First init /!\ outdated spwplugin!
r0 }
}
void dsu3plugin::openFile(QString fileName)
{
dsu3plugin:...
r60 this->elfFile->openFile(fileName);
emit this->updateInfo(this->elfFile);
First init /!\ outdated spwplugin!
r0 }
bool dsu3plugin::configureTarget()
{
dsu3plugin now support SRCTRLE_0WS and SRCTRLE_1WS....
r49 int detectedMctrlr=-1;
Fixed mistake on dsu3plugin.
r45 if(parent==NULL)
return false;
unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
if(DSUBASEADDRESS == (unsigned int)-1)
DSUBASEADDRESS = 0x90000000;
unsigned int MCTRLBASEADDRESS =-1;
for(int i=0; i<acceptedMemctrlrCnt;i++)
dsu3 wip
r37 {
Fixed mistake on dsu3plugin.
r45 MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0);
if(MCTRLBASEADDRESS != (unsigned int)-1)
{
SocExplorerEngine::message(this,QString("Found %1 @%2").arg(acceptedMemctrlr[i].name).arg(MCTRLBASEADDRESS,8,16),1);
dsu3plugin now support SRCTRLE_0WS and SRCTRLE_1WS....
r49 detectedMctrlr=i;
Fixed mistake on dsu3plugin.
r45 break;
}
Added cache enable/disable on dsu3plugin....
r44 }
Fixed mistake on dsu3plugin.
r45 if(MCTRLBASEADDRESS == (unsigned int)-1)
Added cache enable/disable on dsu3plugin....
r44 {
Jeandet Alexis
dsu3plugin:...
r88 SocExplorerEngine::message(this,"Can't find any compatible memory controller",1);
// return false;
dsu3 wip
r37 }
First init /!\ outdated spwplugin!
r0
Added cache enable/disable on dsu3plugin....
r44
Fixed mistake on dsu3plugin.
r45 //Force a debug break
WriteRegs(uIntlist()<<0x0000002f,(unsigned int)DSUBASEADDRESS);
WriteRegs(uIntlist()<<0x0000ffff,(unsigned int)DSUBASEADDRESS+0x20);
//Clear time tag counter
WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x8);
First init /!\ outdated spwplugin!
r0
Fixed mistake on dsu3plugin.
r45 //Clear ASR registers
WriteRegs(uIntlist()<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400040);
WriteRegs(uIntlist()<<0x2,(unsigned int)DSUBASEADDRESS+0x400024);
WriteRegs(uIntlist()<<0<<0<<0<<0<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x48);
WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x000004C);
WriteRegs(uIntlist()<<0,(unsigned int)DSUBASEADDRESS+0x400040);
First init /!\ outdated spwplugin!
r0
dsu3plugin now support SRCTRLE_0WS and SRCTRLE_1WS....
r49 // {0x04,0x0f,"MCTRL"},
// {0x01,0x51,"FTSRCTRL"},
// {0x20,0x01,"SRCTRLE_0WS" },
// {0x20,0x02,"SRCTRLE_1WS" }
if(QString(acceptedMemctrlr[detectedMctrlr].name)=="MCTRL" || QString(acceptedMemctrlr[detectedMctrlr].name)=="FTSRCTRL" )
{
WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS);
}
if(QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_0WS" || QString(acceptedMemctrlr[detectedMctrlr].name)=="SRCTRLE_1WS" )
{
//let's perform a mem Wash
unsigned int val = ReadReg(MCTRLBASEADDRESS);
val |=1<<31;
WriteRegs(uIntlist()<<val,(unsigned int)MCTRLBASEADDRESS);
usleep(1000*1000);
}
First init /!\ outdated spwplugin!
r0
Fixed mistake on dsu3plugin.
r45 WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060);
WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24);
Added cache enable/disable on dsu3plugin....
r44
Jeandet Alexis
dsu3plugin:...
r88 unsigned int ramSize=SocExplorerEngine::self()->memMeasureSize(this->parentPlugin(),0x40000000);
SocExplorerEngine::message(this,QString("Measured memory size=%1").arg(ramSize),0);
Fixed mistake on dsu3plugin.
r45 memSet(DSUBASEADDRESS+0x300000,0,1567);
WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000);
Jeandet Alexis
dsu3plugin:...
r88 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);
Fixed mistake on dsu3plugin.
r45 WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS);
First init /!\ outdated spwplugin!
r0
Fixed mistake on dsu3plugin.
r45 //Disable interrupts
unsigned int APBIRQCTRLRBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x0d,0);
if(APBIRQCTRLRBASEADD == (unsigned int)-1)
return false;
WriteRegs(uIntlist()<<0x00000000,APBIRQCTRLRBASEADD+0x040);
WriteRegs(uIntlist()<<0xFFFE0000,APBIRQCTRLRBASEADD+0x080);
WriteRegs(uIntlist()<<0<<0,APBIRQCTRLRBASEADD);
Added cache enable/disable on dsu3plugin....
r44
Fixed mistake on dsu3plugin.
r45 //Set up timer
unsigned int APBTIMERBASEADD = (unsigned int)SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,1,0x11,0);
if(APBTIMERBASEADD == (unsigned int)-1)
return false;
WriteRegs(uIntlist()<<0xffffffff,APBTIMERBASEADD+0x014);
WriteRegs(uIntlist()<<0x00000018,APBTIMERBASEADD+0x04);
WriteRegs(uIntlist()<<0x00000007,APBTIMERBASEADD+0x018);
return true;
Added cache enable/disable on dsu3plugin....
r44 }
First init /!\ outdated spwplugin!
r0
Added cache enable/disable on dsu3plugin....
r44 bool dsu3plugin::cacheDisable()
{
Fixed mistake on dsu3plugin.
r45 return setCacheEnable(false);
Added cache enable/disable on dsu3plugin....
r44 }
bool dsu3plugin::cacheEnable()
{
Fixed mistake on dsu3plugin.
r45 return setCacheEnable(true);
Added cache enable/disable on dsu3plugin....
r44 }
First init /!\ outdated spwplugin!
r0
Jeandet Alexis
dsu3plugin: added cacheIsEnable function.
r70 bool dsu3plugin::cacheIsEnable()
{
if(parent==NULL)
return false;
unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
if(DSUBASEADDRESS == (unsigned int)-1)
DSUBASEADDRESS = 0x90000000;
WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
return ((reg&0x0F)==0x0F);
}
Added cache enable/disable on dsu3plugin....
r44 bool dsu3plugin::setCacheEnable(bool enabled)
{
Fixed mistake on dsu3plugin.
r45 if(parent==NULL)
return false;
unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
if(DSUBASEADDRESS == (unsigned int)-1)
DSUBASEADDRESS = 0x90000000;
WriteRegs(uIntlist()<<2,DSUBASEADDRESS+0x400024);
unsigned int reg = ReadReg(DSUBASEADDRESS+0x700000);
if(enabled)
Added cache enable/disable on dsu3plugin....
r44 {
Fixed mistake on dsu3plugin.
r45 WriteRegs(uIntlist()<<(0x0001000F|reg),DSUBASEADDRESS+0x700000);
//flushes cache.
WriteRegs(uIntlist()<<(0x0061000F|reg),DSUBASEADDRESS+0x700000);
Added cache enable/disable on dsu3plugin....
r44 }
Fixed mistake on dsu3plugin.
r45 else
Added cache enable/disable on dsu3plugin....
r44 {
Fixed mistake on dsu3plugin.
r45 WriteRegs(uIntlist()<<((!0x0001000F)&reg),DSUBASEADDRESS+0x700000);
WriteRegs(uIntlist()<<(0x00600000|reg),DSUBASEADDRESS+0x700000);
Added cache enable/disable on dsu3plugin....
r44 }
Fixed mistake on dsu3plugin.
r45 return true;
First init /!\ outdated spwplugin!
r0 }
bool dsu3plugin::flashTarget()
{
Fixed mistake on dsu3plugin.
r45 stop();
cacheDisable();
configureTarget();
/*Write .text*/
this->writeSection(".text");
/*Write .data*/
this->writeSection(".data");
return true;
First init /!\ outdated spwplugin!
r0 }
void dsu3plugin::run()
{
Fixed mistake on dsu3plugin.
r45 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
if(DSUBASEADDRESS == (unsigned int)-1)
DSUBASEADDRESS = 0x90000000;
WriteRegs(uIntlist()<<0,DSUBASEADDRESS+0x020);
this->running = true;
this->UI->setRunning(true);
Added stop function to dsu3plugin...
r14 }
void dsu3plugin::stop()
{
Fixed mistake on dsu3plugin.
r45 unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0);
if(DSUBASEADDRESS == (unsigned int)-1)
DSUBASEADDRESS = 0x90000000;
WriteRegs(uIntlist()<<0xFFFF,DSUBASEADDRESS+0x020);
this->running = false;
this->UI->setRunning(false);
Added stop function to dsu3plugin...
r14 }
void dsu3plugin::toggleRun()
{
Fixed mistake on dsu3plugin.
r45 if(this->running)
this->stop();
else
this->run();
First init /!\ outdated spwplugin!
r0 }
dsu3plugin:...
r60 bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format)
{
if(this->elfFile->isopened())
{
int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
if(symbolIndex!=-1)
return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format);
}
return false;
}
Added wrapper to use StarDundee driver as a plugin, since they don't respect...
r63 QVariantList dsu3plugin::readSymbol(const QString &symbolName)
{
if(this->elfFile->isopened())
{
int symbolIndex=this->elfFile->getSymbolIndex(symbolName);
if(symbolIndex!=-1)
return socexplorerplugin::Read((unsigned int)this->elfFile->getSymbolAddress(symbolIndex),(unsigned int)this->elfFile->getSymbolSize(symbolIndex)/4);
}
return QVariantList();
}
First init /!\ outdated spwplugin!
r0 void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address)
{
Fixed mistake on dsu3plugin.
r45 unsigned int* buff;
buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int));
for(int i=0;i<Values.count();i++)
First init /!\ outdated spwplugin!
r0 {
Fixed mistake on dsu3plugin.
r45 buff[i]=Values.at(i);
First init /!\ outdated spwplugin!
r0 }
Fixed mistake on dsu3plugin.
r45 parent->Write(buff,(unsigned int)Values.count(),address);
free(buff);
}
unsigned int dsu3plugin::ReadReg(unsigned int address)
{
unsigned int buff;
parent->Read(&buff,1,address);
return buff;
First init /!\ outdated spwplugin!
r0 }
void dsu3plugin::writeSection(int index)
{
Fixed mistake on dsu3plugin.
r45 char* buffch=NULL;
unsigned int* buff;
dsu3plugin:...
r60 int size = this->elfFile->getSectionDatasz(index);
Fixed mistake on dsu3plugin.
r45 int sizeInt = size/4;
if(parent==NULL)
return;
dsu3plugin:...
r60 this->elfFile->getSectionData(index,&buffch);
Fixed mistake on dsu3plugin.
r45 buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int));
for(int i=0;i<sizeInt;i++)
First init /!\ outdated spwplugin!
r0 {
Fixed mistake on dsu3plugin.
r45 buff[i] = 0x0FF & ((unsigned int)buffch[4*i]);
buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+1]));
buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+2]));
buff[i] = (buff[i]<<8) + (0x0FF & ((unsigned int)buffch[(4*i)+3]));
First init /!\ outdated spwplugin!
r0 }
Fixed mistake on dsu3plugin.
r45 if(size%4)
First init /!\ outdated spwplugin!
r0 {
Fixed mistake on dsu3plugin.
r45 buff[sizeInt]=0;
for(int i=(size%4);i>0;i--)
First init /!\ outdated spwplugin!
r0 {
Fixed mistake on dsu3plugin.
r45 buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i]));
First init /!\ outdated spwplugin!
r0 }
Fixed mistake on dsu3plugin.
r45 sizeInt++;
First init /!\ outdated spwplugin!
r0 }
dsu3plugin:...
r60 parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index));
Fixed mistake on dsu3plugin.
r45 free(buff);
First init /!\ outdated spwplugin!
r0 }
void dsu3plugin::writeSection(const QString &name)
{
dsu3plugin:...
r60 if(elfFile->isopened())
First init /!\ outdated spwplugin!
r0 {
dsu3plugin:...
r60 writeSection(this->elfFile->getSectionIndex(name));
First init /!\ outdated spwplugin!
r0 }
}
bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count)
{
Fixed mistake on dsu3plugin.
r45 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
if(buffer!=NULL)
First init /!\ outdated spwplugin!
r0 {
Fixed mistake on dsu3plugin.
r45 memset((void*)buffer,value,count*sizeof(unsigned int));
parent->Write(buffer,count,address);
free(buffer );
return true;
First init /!\ outdated spwplugin!
r0 }
Fixed mistake on dsu3plugin.
r45 return false;
First init /!\ outdated spwplugin!
r0 }