/*------------------------------------------------------------------------------ -- This file is a part of the SocExplorer Software -- Copyright (C) 2011, Plasma Physics Laboratory - 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 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(unsigned int *pnpregs) { AHBbarreg BAR[4]; int VID; int PID; for(int i=0;i<4;i++) { unsigned int addr=(pnpregs[i+4] & 0xfff00000)>>20; unsigned int mask=(pnpregs[i+4] & 0x0FFF0)>>4; BAR[i].type = (unsigned char)(pnpregs[i+4]&0x0f); printf("%x\n",addr); BAR[i].size = 0; BAR[i].address = 0; switch ((int)(BAR[i].type)) { case AHB_PLUGNPLAY_APB_IO_SPACE: break; case AHB_PLUGNPLAY_MEMORY_SPACE: BAR[i].address = addr<<20; BAR[i].size = (mask)<<20; break; case AHB_PLUGNPLAY_AHB_IO_SPACE: BAR[i].address = 0xfff00000 + (addr<<8); BAR[i].size = (mask)<<8; break; default: break; } 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); } 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)/4; int j=0; unsigned long long i = AHB_PLUGNPLAY_MASTER_START; int pnpregs[size]; emit this->clearAHBdevicesList(); if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size) { while(iextractInfos((unsigned int*)(pnpregs+j)); if(!devinfo->deviceName->compare("DSU3")) SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[0].address,*devinfo->deviceName); if(!devinfo->deviceName->compare("SDCTRL")) SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[1].address,*devinfo->deviceName); emit this->addAHBdevice(devinfo); } i+=32; j+=8; } } }