/*------------------------------------------------------------------------------ -- This file is a part of the SocExplorer Software -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS -- -- 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 #include 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(); unsigned int size = APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START; int j=0; unsigned long long i = APB_PLUGNPLAY_START; int pnpregs[APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START]; emit this->clearAPBdevicesList(); if(this->_plugin->Read((unsigned int*)pnpregs,size/4,(unsigned int)APB_PLUGNPLAY_START)==(size/4)) { while(iextractInfos(pnpregs+j); SocExplorerEngine::addEnumDevice(this->_plugin,devinfos->VID,devinfos->PID,devinfos->BAR[0].address,devinfos->deviceName); emit this->addAPBdevice(devinfos); } i+=8; j+=2; if(pnpregs[0]==pnpregs[j]&&pnpregs[1]==pnpregs[j+1])break; } } this->unlockScanBp(); }