apbpluginui.cpp
104 lines
| 3.8 KiB
| text/x-c
|
CppLexer
r0 | /*------------------------------------------------------------------------------ | |||
Jeandet Alexis
|
r4 | -- This file is a part of the SocExplorer Software | ||
Jeandet Alexis
|
r11 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS | ||
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 "apbpluginui.h" | ||||
#include <stdint.h> | ||||
#include <socexplorerengine.h> | ||||
apbPluginUi::apbPluginUi(socexplorerplugin *plugin, QWidget *parent) : | ||||
QWidget(parent) | ||||
{ | ||||
this->setWindowTitle(tr("APB Driver")); | ||||
this->mainlayout = new QHBoxLayout; | ||||
this->scanBp = new QPushButton(tr("Scan APB")); | ||||
this->deviceslst = new apbdevicelist; | ||||
this->mainlayout->addWidget(this->deviceslst); | ||||
this->mainlayout->addWidget(this->scanBp); | ||||
this->setLayout(this->mainlayout); | ||||
this->_plugin = plugin; | ||||
connect(this,SIGNAL(addAPBdevice(apbdeviceInfo*)),this->deviceslst,SLOT(addAPBdevice(apbdeviceInfo*))); | ||||
connect(this,SIGNAL(clearAPBdevicesList()),this->deviceslst,SLOT(clearAPBdevicesList())); | ||||
connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAPB())); | ||||
} | ||||
void apbPluginUi::lockScanBp() | ||||
{ | ||||
this->scanBp->setEnabled(false); | ||||
} | ||||
void apbPluginUi::unlockScanBp() | ||||
{ | ||||
this->scanBp->setEnabled(true); | ||||
} | ||||
apbdeviceInfo* apbPluginUi::extractInfos(int *pnpregs) | ||||
{ | ||||
APBbarreg BAR[1]; | ||||
int VID; | ||||
int PID; | ||||
for(int i=0;i<1;i++) | ||||
{ | ||||
BAR[i].address = ((uint32_t)(pnpregs[i+1] & 0xfff00000)>>12)+ APB_BUS_START; | ||||
BAR[i].size = ((pnpregs[i+1] & 0x00000ff0)>>4 )+1; | ||||
BAR[i].type = (unsigned char)(pnpregs[i+1]&0xf); | ||||
} | ||||
VID = (pnpregs[0]>>24)&0xff; | ||||
PID = (pnpregs[0]>>12)&0xfff; | ||||
QString devname = SocExplorerEngine::getDevName(VID,PID); | ||||
return new apbdeviceInfo(devname,BAR[0],VID,PID); | ||||
} | ||||
void apbPluginUi::scanAPB() | ||||
{ | ||||
this->lockScanBp(); | ||||
paul
|
r50 | unsigned int size = (APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START)/4; | ||
r0 | int j=0; | |||
unsigned long long i = APB_PLUGNPLAY_START; | ||||
paul
|
r50 | int pnpregs[size]; | ||
r0 | emit this->clearAPBdevicesList(); | |||
r64 | this->devList.clear(); | |||
paul
|
r50 | if(this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)APB_PLUGNPLAY_START)==size) | ||
r0 | { | |||
while(i<APB_PLUGNPLAY_STOP) | ||||
{ | ||||
if(pnpregs[j]!=0) | ||||
{ | ||||
apbdeviceInfo* devinfos=this->extractInfos(pnpregs+j); | ||||
SocExplorerEngine::addEnumDevice(this->_plugin,devinfos->VID,devinfos->PID,devinfos->BAR[0].address,devinfos->deviceName); | ||||
r64 | if(!this->devList.contains(devinfos->BAR[0].address)) | |||
{ | ||||
this->devList.append(devinfos->BAR[0].address); | ||||
emit this->addAPBdevice(devinfos); | ||||
} | ||||
r0 | } | |||
i+=8; | ||||
j+=2; | ||||
r64 | // if(pnpregs[0]!=0&&pnpregs[0]==pnpregs[j]&&pnpregs[1]==pnpregs[j+1])break; | |||
r0 | } | |||
} | ||||
this->unlockScanBp(); | ||||
} | ||||