# HG changeset patch # User Alexis Jeandet # Date 2015-02-10 12:01:40 # Node ID 0935da2bcc7f0fd3288512a64c0290b371b981d9 # Parent 1fcab95903ab3f80fcda62c44917cd75d5c7e2e3 Added cache enable/disable on dsu3plugin. Improved memchecker, memory size measurement added. diff --git a/APBUARTPLUGIN/APBUARTPLUGIN.pro b/APBUARTPLUGIN/APBUARTPLUGIN.pro --- a/APBUARTPLUGIN/APBUARTPLUGIN.pro +++ b/APBUARTPLUGIN/APBUARTPLUGIN.pro @@ -8,13 +8,13 @@ CONFIG += socexplorerplugin win32:CONFIG += dll win32:CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} -TARGET = ApbUartPlugin$${DEBUG_EXT} +TARGET = ApbUartPlugin #$${DEBUG_EXT} DEFINES += PLUGIN=ApbUartPlugin DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" diff --git a/ahbuartplugin/ahbuartplugin.pro b/ahbuartplugin/ahbuartplugin.pro --- a/ahbuartplugin/ahbuartplugin.pro +++ b/ahbuartplugin/ahbuartplugin.pro @@ -7,12 +7,12 @@ CONFIG += socexplorerplugin TEMPLATE = lib CONFIG += dll CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} -TARGET = ahbuartplugin$${DEBUG_EXT} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} +TARGET = ahbuartplugin #$${DEBUG_EXT} DEFINES += PLUGIN=ahbuartplugin DEFINES += PLUGINHEADER="\"\\\"ahbuartplugin.h"\\\"\" DEFINES += driver_Name="\"\\\"AHBUARTplugin"\\\"\" diff --git a/ambaplugin/ambaplugin.pro b/ambaplugin/ambaplugin.pro --- a/ambaplugin/ambaplugin.pro +++ b/ambaplugin/ambaplugin.pro @@ -6,12 +6,12 @@ CONFIG += socexplorerplugin CONFIG += dll CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} -TARGET = ambaplugin$${DEBUG_EXT} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} +TARGET = ambaplugin #$${DEBUG_EXT} DEFINES += PLUGIN=ambaplugin DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\" DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\" diff --git a/dsu3plugin/dsu3plugin.cpp b/dsu3plugin/dsu3plugin.cpp --- a/dsu3plugin/dsu3plugin.cpp +++ b/dsu3plugin/dsu3plugin.cpp @@ -25,21 +25,43 @@ #include "dsu3pluginpywrapper.h" #include + +struct acceptedMemctrlr_str +{ + int vid; + int pid; + const char* name; +}; + +const struct acceptedMemctrlr_str acceptedMemctrlr[]= +{ +{0x01,0x04,"MCTRL"}, +{0x01,0x51,"FTSRCTRL"}, +{0x20,0x01,"SRCTRLE_0WS" }, +{0x20,0x02,"SRCTRLE_1WS" } +}; + +#define acceptedMemctrlrCnt sizeof acceptedMemctrlr + dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false) { - this->UI = new dsu3pluginui(); - this->setWidget((QWidget*)this->UI); - this->elfparserInst = new elfparser(); - this->pyObject = new dsu3pluginPywrapper(this); - QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString))); - QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget())); - QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run())); - QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop())); - connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); - connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); - connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); - connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); - this->running = false; + this->UI = new dsu3pluginui(); + this->setWidget((QWidget*)this->UI); + this->elfparserInst = new elfparser(); + this->pyObject = new dsu3pluginPywrapper(this); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString))); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget())); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run())); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop())); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable())); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable())); + QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool))); + + connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); + connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); + connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); + connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); + this->running = false; } @@ -51,177 +73,211 @@ dsu3plugin::~dsu3plugin() void dsu3plugin::openFile() { - QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); - if(filename!="") + QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); + if(filename!="") { - this->openFile(filename); + this->openFile(filename); } } void dsu3plugin::openFile(QString fileName) { - this->elfparserInst->setFilename(fileName); - emit this->updateInfo(this->elfparserInst); + this->elfparserInst->setFilename(fileName); + emit this->updateInfo(this->elfparserInst); } bool dsu3plugin::configureTarget() { - 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 = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x04 , 0x00F,0); - if(MCTRLBASEADDRESS == (unsigned int)-1) + 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; igetEnumDeviceBaseAddress(this,0x01 , 0x051,0); - if(MCTRLBASEADDRESS == (unsigned int)-1) - { - SocExplorerEngine::message(this,"Can't find FTMemCtrlr",1); - return false; - } + MCTRLBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,acceptedMemctrlr[i].vid , acceptedMemctrlr[i].pid,0); + if(MCTRLBASEADDRESS != (unsigned int)-1) break; + } + if(MCTRLBASEADDRESS == (unsigned int)-1) + { + //SocExplorerEngine::message(this,"Can't find FTMemCtrlr",1); + return false; } - //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); + + //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); - //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); + //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); - WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS); + WriteRegs(uIntlist()<<0x2FF<<0xE60<<0,(unsigned int)MCTRLBASEADDRESS); - WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); - WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24); + WriteRegs(uIntlist()<<0<<0<<0<<0,(unsigned int)DSUBASEADDRESS+0x400060); + WriteRegs(uIntlist()<<0x0000FFFF,(unsigned int)DSUBASEADDRESS+0x24); + + unsigned int buff=0; + // for(int i=0;i<1567;i++) + // { + // parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i)); + // } + memSet(DSUBASEADDRESS+0x300000,0,1567); + WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); + 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); + WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); - unsigned int buff=0; -// for(int i=0;i<1567;i++) -// { -// parent->Write(&buff,(unsigned int)1,DSUBASEADDRESS+0x300000+(4*i)); -// } - memSet(DSUBASEADDRESS+0x300000,0,1567); - WriteRegs(uIntlist()<<0<<0xF30000E0<<0x00000002<<0x40000000<<0x40000000<<0x40000004<<0x1000000,(unsigned int)DSUBASEADDRESS+0x400000); - 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); - WriteRegs(uIntlist()<<0x000002EF,(unsigned int)DSUBASEADDRESS); + //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); + + //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; +} - //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); +bool dsu3plugin::cacheDisable() +{ + return setCacheEnable(false); +} + +bool dsu3plugin::cacheEnable() +{ + return setCacheEnable(true); +} - //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; +bool dsu3plugin::setCacheEnable(bool enabled) +{ + 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); + if(enabled) + { + WriteRegs(uIntlist()<<0x0001000F,DSUBASEADDRESS+0x700000); + //flushes cache. + WriteRegs(uIntlist()<<0x0061000F,DSUBASEADDRESS+0x700000); + } + else + { + WriteRegs(uIntlist()<<0x00000000,DSUBASEADDRESS+0x700000); + WriteRegs(uIntlist()<<0x00600000,DSUBASEADDRESS+0x700000); + } + return true; } bool dsu3plugin::flashTarget() { - configureTarget(); - - /*Write .text*/ - this->writeSection(".text"); - /*Write .data*/ - this->writeSection(".data"); - return true; + stop(); + cacheDisable(); + configureTarget(); + /*Write .text*/ + this->writeSection(".text"); + /*Write .data*/ + this->writeSection(".data"); + return true; } void dsu3plugin::run() { - 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); + 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); } void dsu3plugin::stop() { - 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); + 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); } void dsu3plugin::toggleRun() { - if(this->running) - this->stop(); - else - this->run(); + if(this->running) + this->stop(); + else + this->run(); } void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) { - unsigned int* buff; - buff = (unsigned int*)malloc(Values.count()*sizeof(unsigned int)); - for(int i=0;iWrite(buff,(unsigned int)Values.count(),address); - free(buff); + parent->Write(buff,(unsigned int)Values.count(),address); + free(buff); } void dsu3plugin::writeSection(int index) { - char* buffch=NULL; - unsigned int* buff; - int size = this->elfparserInst->getSectionDatasz(index); - int sizeInt = size/4; - if(parent==NULL) - return; - this->elfparserInst->getSectionData(index,&buffch); - buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); - for(int i=0;ielfparserInst->getSectionDatasz(index); + int sizeInt = size/4; + if(parent==NULL) + return; + this->elfparserInst->getSectionData(index,&buffch); + buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); + for(int i=0;i0;i--) + buff[sizeInt]=0; + for(int i=(size%4);i>0;i--) { - buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); + buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); } - sizeInt++; + sizeInt++; } - parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index)); - free(buff); + parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index)); + free(buff); } void dsu3plugin::writeSection(const QString &name) { - for(int i=0;ielfparserInst->getSectioncount();i++) + for(int i=0;ielfparserInst->getSectioncount();i++) { - if(!this->elfparserInst->getSectionName(i).compare(name)) + if(!this->elfparserInst->getSectionName(i).compare(name)) { - printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i)); - writeSection(i); + printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i)); + writeSection(i); } } } @@ -229,27 +285,27 @@ void dsu3plugin::writeSection(const QStr unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address) { - if(parent!=NULL) - return parent->Write(Value,count,address); - return 0; + if(parent!=NULL) + return parent->Write(Value,count,address); + return 0; } bool dsu3plugin::memSet(unsigned int address,int value, unsigned int count) { - unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); - if(buffer!=NULL) + unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); + if(buffer!=NULL) { - memset((void*)buffer,value,count*sizeof(unsigned int)); - parent->Write(buffer,count,address); - free(buffer ); - return true; + memset((void*)buffer,value,count*sizeof(unsigned int)); + parent->Write(buffer,count,address); + free(buffer ); + return true; } - return false; + return false; } unsigned int dsu3plugin::Read(unsigned int *Value,unsigned int count, unsigned int address) { - if(parent!=NULL) - return parent->Read(Value,count,address); - return 0; + if(parent!=NULL) + return parent->Read(Value,count,address); + return 0; } diff --git a/dsu3plugin/dsu3plugin.h b/dsu3plugin/dsu3plugin.h --- a/dsu3plugin/dsu3plugin.h +++ b/dsu3plugin/dsu3plugin.h @@ -46,6 +46,9 @@ public slots: void openFile(); void openFile(QString fileName); bool configureTarget(); + bool cacheDisable(); + bool cacheEnable(); + bool setCacheEnable(bool enabled); bool flashTarget(); void run(); void stop(); diff --git a/dsu3plugin/dsu3plugin.pro b/dsu3plugin/dsu3plugin.pro --- a/dsu3plugin/dsu3plugin.pro +++ b/dsu3plugin/dsu3plugin.pro @@ -7,17 +7,17 @@ CONFIG += socexplorerplugin TEMPLATE = lib -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} QMAKE_LFLAGS_RELEASE += --enable-auto-import -mstackrealign QMAKE_LFLAGS_DEBUG += --enable-auto-import -mstackrealign -TARGET = dsu3plugin$${DEBUG_EXT} +TARGET = dsu3plugin #$${DEBUG_EXT} DEFINES += PLUGIN=dsu3plugin DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\" diff --git a/dsu3plugin/dsu3pluginpywrapper.h b/dsu3plugin/dsu3pluginpywrapper.h --- a/dsu3plugin/dsu3pluginpywrapper.h +++ b/dsu3plugin/dsu3pluginpywrapper.h @@ -13,6 +13,9 @@ signals: bool loadFile(); bool run(); bool stop(); + bool cacheDisable(); + bool cacheEnable(); + bool setCacheEnable(bool enabled); public slots: }; diff --git a/genericrwplugin/genericrwplugin.pro b/genericrwplugin/genericrwplugin.pro --- a/genericrwplugin/genericrwplugin.pro +++ b/genericrwplugin/genericrwplugin.pro @@ -7,12 +7,12 @@ CONFIG += socexplorerplugin CONFIG += dll CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} -TARGET = genericrwplugin$${DEBUG_EXT} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} +TARGET = genericrwplugin #$${DEBUG_EXT} DEFINES += PLUGIN=genericrwplugin DEFINES += PLUGINHEADER="\"\\\"genericrwplugin.h"\\\"\" DEFINES += driver_Name="\"\\\"GenericRWplugin"\\\"\" diff --git a/memcheckplugin/memchecker.cpp b/memcheckplugin/memchecker.cpp --- a/memcheckplugin/memchecker.cpp +++ b/memcheckplugin/memchecker.cpp @@ -23,36 +23,91 @@ memchecker::memchecker(socexplorerplugin* plugin) { - this->plugin = plugin; + this->plugin = plugin; } QString memchecker::checkmemory(unsigned int address, unsigned int size, bool *success) { - *success = true; - QString repport; - unsigned int* dataLocal = (unsigned int*)malloc(size); - unsigned int* dataOnBoard = (unsigned int*)malloc(size); - for(int i=0;(unsigned int)i<(size>>2);i++) + *success = true; + QString repport; + unsigned int* dataLocal = (unsigned int*)malloc(size); + unsigned int* dataOnBoard = (unsigned int*)malloc(size); + for(int i=0;(unsigned int)i<(size>>2);i++) { - dataLocal[i]= (0xFFFF&rand())+(rand()<<16); + dataLocal[i]= (0xFFFF&rand())+(rand()<<16); } - plugin->Write(dataLocal,size>>2,address); - plugin->Read(dataOnBoard,size>>2,address); - for(int i=0;(unsigned int)i<(size>>2);i++) + plugin->Write(dataLocal,size>>2,address); + plugin->Read(dataOnBoard,size>>2,address); + for(int i=0;(unsigned int)i<(size>>2);i++) { - if(dataLocal[i]!=dataOnBoard[i]) - *success=false; + if(dataLocal[i]!=dataOnBoard[i]) + *success=false; } - free(dataLocal); - free(dataOnBoard); - return repport; + free(dataLocal); + free(dataOnBoard); + return repport; } QString memchecker::checkdatabits(unsigned int address,unsigned int size,bool* success) { - *success = true; - QString repport; - return repport; + *success = true; + QString repport; + return repport; +} + + +unsigned int p_pow2(unsigned int v) +{ + static const char LogTable256[256] = + { + #define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n + -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + LT(4), LT(5), LT(5), LT(6), LT(6), LT(6), LT(6), + LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7) + }; + + unsigned int r; // r will be lg(v) + register unsigned int t, tt; // temporaries + + if (tt = v >> 16) + { + r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt]; + } + else + { + r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v]; + } + return r; } +unsigned int memchecker::measureMemSize(unsigned int address, unsigned int maxSize) +{ + unsigned int curVal=1,testAddress=address; + unsigned int size=0; + this->plugin->Write(&curVal,1,testAddress); + this->plugin->Read(&curVal,1,testAddress); + if(curVal!=1) + return size; + unsigned int max= p_pow2((0xFFFFFFFFFFFFFFFF - address))+1; + register unsigned int maxSizeLg=p_pow2(maxSize)-1; + if(max>maxSizeLg) + max=maxSizeLg; + if(max>32)max=32; + for(size=2;sizeplugin->Write(&curVal,1,testAddress); + this->plugin->Read(&curVal,1,testAddress); + if((unsigned int)curVal!=(unsigned int)(1<plugin->Read(&curVal,1,address); + if((curVal==(unsigned int)(1<checker = new memchecker(this); QObject::connect(this->UI,SIGNAL(checkdatabits(uint,uint)),this,SLOT(checkdatabits(uint,uint))); QObject::connect(this->UI,SIGNAL(checkmemory(uint,uint)),this,SLOT(checkmemory(uint,uint))); + QObject::connect(this->UI,SIGNAL(checkmemorySize(uint,uint)),this,SLOT(checkmemorySize(uint,uint))); } memcheckplugin::~memcheckplugin() @@ -42,6 +43,22 @@ void memcheckplugin::checkmemory(unsigne } +void memcheckplugin::checkmemorySize(unsigned int address, unsigned int size) +{ + bool success=true; + unsigned int _size = this->checker->measureMemSize(address,size); + int prefix=0; + QStringList list; + list <<"B" << "KB" << "MB" << "GB"; + while (_size>=(unsigned int)1024) + { + _size/=1024; + prefix++; + } + QString repport=QString::number(_size)+list.at(prefix); + this->UI->setResult(success,repport); +} + void memcheckplugin::checkdatabits(unsigned int address, unsigned int size) { bool success; diff --git a/memcheckplugin/memcheckplugin.h b/memcheckplugin/memcheckplugin.h --- a/memcheckplugin/memcheckplugin.h +++ b/memcheckplugin/memcheckplugin.h @@ -59,6 +59,7 @@ public: ~memcheckplugin(); public slots: void checkmemory(unsigned int address,unsigned int size); + void checkmemorySize(unsigned int address,unsigned int size); void checkdatabits(unsigned int address,unsigned int size); signals: diff --git a/memcheckplugin/memcheckplugin.pro b/memcheckplugin/memcheckplugin.pro --- a/memcheckplugin/memcheckplugin.pro +++ b/memcheckplugin/memcheckplugin.pro @@ -7,13 +7,14 @@ CONFIG += socexplorerplugin CONFIG += dll CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} -TARGET = memcheckplugin$${DEBUG_EXT} + +TARGET = memcheckplugin #$${DEBUG_EXT} DEFINES += PLUGIN=memcheckplugin DEFINES += PLUGINHEADER="\"\\\"memcheckplugin.h"\\\"\" DEFINES += driver_Name="\"\\\"MemChecker"\\\"\" diff --git a/memcheckplugin/memcheckplugin_ui.cpp b/memcheckplugin/memcheckplugin_ui.cpp --- a/memcheckplugin/memcheckplugin_ui.cpp +++ b/memcheckplugin/memcheckplugin_ui.cpp @@ -45,7 +45,8 @@ void memcheckplugin_ui::startCheck() } if(this->ui->testTypeQchkBx->currentText()=="Check memory size") { - emit checkmemory(this->ui->StartAddress->value(),this->ui->MemSize->getsize()); + //emit checkmemory(this->ui->StartAddress->value(),this->ui->MemSize->getsize()); + emit checkmemorySize(this->ui->StartAddress->value(),this->ui->MemSize->getsize()); } if(this->ui->testTypeQchkBx->currentText()=="Full test") { diff --git a/memcheckplugin/memcheckplugin_ui.h b/memcheckplugin/memcheckplugin_ui.h --- a/memcheckplugin/memcheckplugin_ui.h +++ b/memcheckplugin/memcheckplugin_ui.h @@ -40,6 +40,7 @@ public slots: void setResult(bool success,QString repport); signals: void checkmemory(unsigned int address,unsigned int size); + void checkmemorySize(unsigned int address,unsigned int size); void checkdatabits(unsigned int address,unsigned int size); private: Ui::memcheckplugin_ui *ui; diff --git a/memctrlrplugin/memctrlrplugin.pro b/memctrlrplugin/memctrlrplugin.pro --- a/memctrlrplugin/memctrlrplugin.pro +++ b/memctrlrplugin/memctrlrplugin.pro @@ -7,13 +7,13 @@ CONFIG += socexplorerplugin CONFIG += dll CONFIG -= static -CONFIG(debug, debug|release) { - DEBUG_EXT = _d -} else { - DEBUG_EXT = -} +#CONFIG(debug, debug|release) { +# DEBUG_EXT = _d +#} else { +# DEBUG_EXT = +#} -TARGET = memctrlrplugin$${DEBUG_EXT} +TARGET = memctrlrplugin #$${DEBUG_EXT} DEFINES += PLUGIN=memctrlrplugin DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\" DEFINES += driver_Name="\"\\\"MemControler"\\\"\"