|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the LPPMON 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 "ahbpluginui.h"
|
|
|
#include <socexplorerengine.h>
|
|
|
|
|
|
ahbPluginUi::ahbPluginUi(socexplorerplugin *plugin, QWidget *parent) :
|
|
|
QWidget(parent)
|
|
|
{
|
|
|
this->mainlayout = new QHBoxLayout;
|
|
|
this->scanBp = new QPushButton(tr("Scan AHB"));
|
|
|
this->deviceslst = new ahbdevicelist;
|
|
|
this->mainlayout->addWidget(this->deviceslst);
|
|
|
this->mainlayout->addWidget(this->scanBp);
|
|
|
this->setLayout(this->mainlayout);
|
|
|
this->_plugin = plugin;
|
|
|
connect(this,SIGNAL(addAHBdevice(ahbdeviceInfo*)),this->deviceslst,SLOT(addAHBdevice(ahbdeviceInfo*)));
|
|
|
connect(this,SIGNAL(clearAHBdevicesList()),this->deviceslst,SLOT(clearAHBdevicesList()));
|
|
|
connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAHB()));
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ahbdeviceInfo* ahbPluginUi::extractInfos(int *pnpregs)
|
|
|
{
|
|
|
AHBbarreg BAR[4];
|
|
|
|
|
|
int VID;
|
|
|
int PID;
|
|
|
for(int i=0;i<4;i++)
|
|
|
{
|
|
|
BAR[i].address = pnpregs[i+4] & 0xfff00000;
|
|
|
BAR[i].size = (pnpregs[i+4] & 0x0000fff0)<<16;
|
|
|
if(BAR[i].size!=0)
|
|
|
BAR[i].size = (((-1^BAR[i].size)|BAR[i].address)-BAR[i].address)+1;
|
|
|
BAR[i].cacheable = (bool)((pnpregs[i+4]&0x00010000)>>16);
|
|
|
BAR[i].prefectchable = (bool)((pnpregs[i+4]&0x00020000)>>17);
|
|
|
BAR[i].type = (unsigned char)(pnpregs[i+4]&0xf);
|
|
|
}
|
|
|
|
|
|
VID = (pnpregs[0]>>24)&0xff;
|
|
|
PID = (pnpregs[0]>>12)&0xfff;
|
|
|
QString devname = SocExplorerEngine::getDevName(VID,PID);
|
|
|
return new ahbdeviceInfo(devname,BAR[0],BAR[1],BAR[2],BAR[3],VID,PID);
|
|
|
}
|
|
|
|
|
|
|
|
|
void ahbPluginUi::scanAHB()
|
|
|
{
|
|
|
unsigned int size = AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START;
|
|
|
int j=0;
|
|
|
unsigned long long i = AHB_PLUGNPLAY_MASTER_START;
|
|
|
int pnpregs[AHB_PLUGNPLAY_SLAVE_STOP- AHB_PLUGNPLAY_MASTER_START];
|
|
|
emit this->clearAHBdevicesList();
|
|
|
if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size)
|
|
|
{
|
|
|
while(i<AHB_PLUGNPLAY_SLAVE_STOP)
|
|
|
{
|
|
|
if(pnpregs[j]!=0)
|
|
|
{
|
|
|
ahbdeviceInfo* devinfo=this->extractInfos(pnpregs+j);
|
|
|
if(!devinfo->deviceName->compare("DSU3"))
|
|
|
SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[0].address,*devinfo->deviceName);
|
|
|
emit this->addAHBdevice(devinfo);
|
|
|
}
|
|
|
i+=32;
|
|
|
j+=8;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|