# HG changeset patch # User jeandet # Date 2014-02-26 21:35:15 # Node ID 2d12462f4460549746487fd4d8fbe1984fc13e07 # Parent 0000000000000000000000000000000000000000 First init /!\ outdated spwplugin! diff --git a/.hgignore b/.hgignore new file mode 100644 --- /dev/null +++ b/.hgignore @@ -0,0 +1,3 @@ +syntax: glob +*.pro.user +*.o diff --git a/APBUARTPLUGIN/APBUARTPLUGIN.cpp b/APBUARTPLUGIN/APBUARTPLUGIN.cpp new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/APBUARTPLUGIN.cpp @@ -0,0 +1,185 @@ +/*------------------------------------------------------------------------------ -- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#include "APBUARTPLUGIN.h" +#include + + +ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent) +{ + this->UI = new ApbUartPluginUi(); + this->setWindowTitle(tr("APBUART")); + this->setWidget((QWidget*)this->UI); + this->useLoopBack = false; + connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(int))); + connect(this,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString))); + connect(&this->loopBackTimer,SIGNAL(timeout()),this,SLOT(uartReadout())); +} + + +ApbUartPlugin::~ApbUartPlugin() +{ + +} + +void ApbUartPlugin::closeMe() +{ + emit this->closePlugin(this); +} + +void ApbUartPlugin::postInstantiationTrigger() +{ + if(this->isEnabled()) + { + this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); + loopbackChangeState(Qt::Checked); + } +} + +void ApbUartPlugin::loopbackChangeState(int state) +{ + if(state==Qt::Checked) + { + enableLoopback(); + } + else + { + disableLoopback(); + } +} + +void ApbUartPlugin::uartReadout() +{ + if(this->isEnabled() && parent!=NULL) + { + if(this->useLoopBack) + { + if(this->baseAddress()!=-1) + { + unsigned int status_reg,data; + char ch; + QString printdata=""; + parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG); + while ((status_reg&4)==0) { + parent->Read(&data,1,this->baseAddress()+APB_UART_FIFO_DEBUG_REG); + ch = (char)(0xff & data); + printdata+=ch; + parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG); + } + if(printdata!="") + emit apbUartTextReceived(printdata); + } + else + { + this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); + this->enableLoopback(); + } + } + } +} + +void ApbUartPlugin::activate(bool flag) +{ + this->setEnabled(flag); + emit this->activateSig(flag); + if(this->isEnabled()) + {this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); + + loopbackChangeState(Qt::Checked); + } +} + +void ApbUartPlugin::activateScan(bool flag) +{ + if(flag) + this->loopBackTimer.start(100); + else + this->loopBackTimer.stop(); +} + +int ApbUartPlugin::enableLoopback() +{ + + this->useLoopBack = true; + this->loopBackTimer.start(100); + SocExplorerEngine::message(this,"Set FiFo debug mode mode"); + if(parent==NULL) + { + SocExplorerEngine::message(this,"Can't set FiFo debug mode no parent driver accessible"); + return -1; + } + if(this->baseAddress()==-1) + { + this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); + if(this->baseAddress()==-1) + return -1; + } + unsigned int ctrl_reg= 0x843; + parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); + return 0; +} + +int ApbUartPlugin::disableLoopback() +{ + SocExplorerEngine::message(this,"Disable FiFo debug mode mode"); + if(parent==NULL) + { + SocExplorerEngine::message(this,"Can't disable FiFo debug mode no parent driver accessible"); + return -1; + } + if(this->baseAddress()==-1) + { + this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0)); + if(this->baseAddress()==-1) + return -1; + } + unsigned int ctrl_reg; + this->loopBackTimer.stop(); + /* Firts get Control reg value*/ + parent->Read(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); + ctrl_reg = ctrl_reg & (~(1<<11)); + parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG); + this->useLoopBack = false; + return 0; +} + + +unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(parent!=NULL) + return parent->Read(Value,count,address); + return 0; +} + + +unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address) +{ + if(parent!=NULL) + return parent->Write(Value,count,address); + return 0; +} + + + + + + + + diff --git a/APBUARTPLUGIN/APBUARTPLUGIN.h b/APBUARTPLUGIN/APBUARTPLUGIN.h new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/APBUARTPLUGIN.h @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef APBUARTPLUGIN_H +#define APBUARTPLUGIN_H +#include +#include +#include +#include + +#include +#include +#include + +#define APB_UART_DATA_REG 0x0 +#define APB_UART_STATUS_REG 0x4 +#define APB_UART_CONTROL_REG 0x8 +#define APB_UART_SCALE_REG 0xC +#define APB_UART_FIFO_DEBUG_REG 0x10 + + +class ApbUartPlugin : public socexplorerplugin +{ + Q_OBJECT +public: + explicit ApbUartPlugin(QWidget *parent = 0); + ~ApbUartPlugin(); + int VID(){return driver_VID;} + int PID(){return driver_PID;} + +public slots: + unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); + void closeMe(); + void postInstantiationTrigger(); + void loopbackChangeState( int state ); + void uartReadout(); + void activateScan(bool flag); + void activate(bool flag); +signals: + void apbUartTextReceived(QString text); +private: + ApbUartPluginUi* UI; + bool useLoopBack; + QTimer loopBackTimer; + int enableLoopback(); + int disableLoopback(); +}; + +#endif // APBUARTPLUGIN_H + diff --git a/APBUARTPLUGIN/APBUARTPLUGIN.pro b/APBUARTPLUGIN/APBUARTPLUGIN.pro new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/APBUARTPLUGIN.pro @@ -0,0 +1,69 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin +win32:CONFIG += dll +win32:CONFIG -= static + +CONFIG(debug, debug|release) { + DEBUG_EXT = _d +} else { + DEBUG_EXT = +} + +TARGET = ApbUartPlugin$${DEBUG_EXT} + +DEFINES += PLUGIN=ApbUartPlugin +DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\" +DEFINES += driver_Name="\"\\\"APB UART PLUGIN"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" +DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" +DEFINES += driver_Description="\"\\\"This plugin provides a terminal widget connected to Gaisler\'s APBUART with or without loop-back mode."\\\"\" +DEFINES += driver_can_be_root=0 +DEFINES += driver_can_be_child=1 +DEFINES += driver_VID=1 +DEFINES += driver_PID=0x0c + + + +INCLUDEPATH += \ + $${PWD} + +HEADERS += \ + APBUARTPLUGIN.h \ + apbuartpluginui.h \ + apbuartcfg.h \ + apbuartterminal.h + + +SOURCES += \ + APBUARTPLUGIN.cpp \ + apbuartpluginui.cpp \ + apbuartcfg.cpp \ + apbuartterminal.cpp + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/APBUARTPLUGIN/apbuartcfg.cpp b/APBUARTPLUGIN/apbuartcfg.cpp new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/apbuartcfg.cpp @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#include "apbuartcfg.h" + +ApbUartCfg::ApbUartCfg(QWidget *parent) : + QWidget(parent) +{ + this->mainLayout = new QGridLayout(this); + this->loopbackChkBx = new QCheckBox(tr("Enable loopback"),this); + this->loopbackChkBx->setChecked(true); + this->mainLayout->addWidget(this->loopbackChkBx); + this->setLayout(this->mainLayout); + connect(this->loopbackChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); +} diff --git a/APBUARTPLUGIN/apbuartcfg.h b/APBUARTPLUGIN/apbuartcfg.h new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/apbuartcfg.h @@ -0,0 +1,46 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef APBUARTCFG_H +#define APBUARTCFG_H + +#include +#include +#include +#include + +class ApbUartCfg : public QWidget +{ + Q_OBJECT +public: + explicit ApbUartCfg(QWidget *parent = 0); + +signals: + void loopbackChkBxStateChanged( int state ); +public slots: + +private: + QCheckBox* loopbackChkBx; + QGridLayout* mainLayout; + +}; + +#endif // APBUARTCFG_H diff --git a/APBUARTPLUGIN/apbuartpluginui.cpp b/APBUARTPLUGIN/apbuartpluginui.cpp new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/apbuartpluginui.cpp @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#include "apbuartpluginui.h" + +ApbUartPluginUi::ApbUartPluginUi(QWidget *parent) : + QTabWidget(parent) +{ + this->terminal = new ApbUartTerminal(this); + this->cfg = new ApbUartCfg(this); + + this->addTab(this->cfg,"Config"); + this->addTab(this->terminal,"terminal"); + connect(this->cfg,SIGNAL(loopbackChkBxStateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int))); + connect(this,SIGNAL(apbUartTextReceived(QString)),this->terminal,SIGNAL(apbUartTextReceived(QString))); +} diff --git a/APBUARTPLUGIN/apbuartpluginui.h b/APBUARTPLUGIN/apbuartpluginui.h new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/apbuartpluginui.h @@ -0,0 +1,51 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef APBUARTPLUGINUI_H +#define APBUARTPLUGINUI_H + +#include "apbuartcfg.h" +#include +#include +#include +#include +#include +#include +#include +#include "apbuartterminal.h" + +class ApbUartPluginUi : public QTabWidget +{ + Q_OBJECT +public: + explicit ApbUartPluginUi(QWidget *parent = 0); + +signals: + void loopbackChkBxStateChanged( int state ); + void apbUartTextReceived(QString text); +public slots: + +private: + ApbUartCfg* cfg; + ApbUartTerminal* terminal; +}; + +#endif // APBUARTPLUGINUI_H diff --git a/APBUARTPLUGIN/apbuartterminal.cpp b/APBUARTPLUGIN/apbuartterminal.cpp new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/apbuartterminal.cpp @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#include "apbuartterminal.h" + +ApbUartTerminal::ApbUartTerminal(QWidget *parent) : + QTextEdit(parent) +{ + connect(this,SIGNAL(apbUartTextReceived(QString)),this,SLOT(append(QString))); +} diff --git a/APBUARTPLUGIN/apbuartterminal.h b/APBUARTPLUGIN/apbuartterminal.h new file mode 100644 --- /dev/null +++ b/APBUARTPLUGIN/apbuartterminal.h @@ -0,0 +1,41 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef APBUARTTERMINAL_H +#define APBUARTTERMINAL_H + +#include +#include + + +class ApbUartTerminal : public QTextEdit +{ + Q_OBJECT +public: + explicit ApbUartTerminal(QWidget *parent = 0); + +signals: + void apbUartTextReceived(QString text); +public slots: + +}; + +#endif // APBUARTTERMINAL_H diff --git a/SocExplorer_Plugins.pro b/SocExplorer_Plugins.pro new file mode 100644 --- /dev/null +++ b/SocExplorer_Plugins.pro @@ -0,0 +1,12 @@ +TEMPLATE = subdirs +CONFIG += ordered + + +SUBDIRS = \ + ahbuartplugin \ + ambaplugin \ + APBUARTPLUGIN \ + dsu3plugin \ + genericrwplugin \ + memctrlrplugin \ + spwplugin diff --git a/ahbuartplugin/ahbuartplugin.cpp b/ahbuartplugin/ahbuartplugin.cpp new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartplugin.cpp @@ -0,0 +1,459 @@ +/*------------------------------------------------------------------------------ +-- 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 +#include "ahbuartplugin.h" +#include +#include +#include +#include +#include +#include +#include "ahbuartpywrapper.h" +#include +#include +#include +#include + +ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false) +{ + this->port =(rs232port_t)NULL; + this->portMutex = new QMutex(QMutex::Recursive); + this->UI = new ahbUartPluginUI(); + this->setWidget((QWidget*)this->UI); + this->setWindowTitle(tr("AHB UART")); + QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool))); + QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int))); + this->pyObject = new ahbuartPywrapper(this); + QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(open(QString,int)),this,SLOT(open(QString,int))); + QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(close()),this,SLOT(close())); + QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint))); + QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList)),this,SLOT(WriteBytes(uint,QList))); + QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList())); + this->portListcompleter = NULL; + this->scanDone = false; + updatePortList(); +} + + +ahbuartplugin::~ahbuartplugin() +{ + if(this->port!=(rs232port_t)NULL) + { + rs232close(this->port); + this->port = (rs232port_t)NULL; + } + this->UI->close(); + this->UI->~ahbUartPluginUI(); +} + + +void ahbuartplugin::closeMe() +{ + if(this->port!=(rs232port_t)NULL) + { + rs232close(this->port); + this->port = (rs232port_t)NULL; + } + emit this->closePlugin(this); +} + +int ahbuartplugin::registermenu(QMainWindow *menuHolder) +{ + this->menu = menuHolder->menuBar()->addMenu(tr("&AHB UART")); + this->closeAction = this->menu->addAction(tr("Close plugin")); + QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); + return 1; +} + + + + +bool ahbuartplugin::checkConnection() +{ + QTime timeout; + char test[5] ={(char)0x80,(char)0x80,(char)0,(char)0,(char)0}; + char test2[1024]; + int writen =0; + int read = 0; + timeout.start(); + SocExplorerEngine::message(this,"Check connection",2); + while(writen!=5) + { + writen+=rs232write(this->port,test+writen,5-writen); + if(timeout.elapsed()>1000) + { + SocExplorerEngine::message(this,"Can't write any data on serial port",2); + return false; + } + } + timeout.restart(); + while(read!=4) + { + read += rs232read(this->port,test2,4-read); + if(timeout.elapsed()>1000) break; + } + if(read>0) + { + SocExplorerEngine::message(this,"Connection Ok",2); + return true; + } + else + { + SocExplorerEngine::message(this,"Connection Error",2); + return false; + } + +} + +void ahbuartplugin::connectPort(QString PortName, int baudrate) +{ + QTime timeout; + SocExplorerEngine::message(this,"Try to connect to port "+PortName,2); + timeout.start(); + if(this->port==(rs232port_t)NULL) + { + SocExplorerEngine::message(this,"Open port "+PortName,2); + this->port=rs232open((char*)PortName.toStdString().c_str()); + } + if(this->port!=badPortValue) + { + SocExplorerEngine::message(this,"Port opened "+PortName,2); + SocExplorerEngine::message(this,"Configure port "+PortName,2); + rs232setup(this->port,8,baudrate,rs232parityNo,rs232OneStop); + char test[7] ={(char)0x55,(char)0x51,(char)0x80,(char)0x80,(char)0x0,(char)0x0,(char)0x14}; + char test2[1024]; + SAFEWRITE(test,1,timeout,2000,return); + SAFEWRITE((test+1),1,timeout,2000,return); + APPENDTOLOG(QString("Flush port ")); + rs232read(this->port,test2,512); + int read = 0; + for(int i=0;i<10;i++) + { + SocExplorerEngine::message(this,"Send test patern :0x55,0x55,0x80,0x80,0x0,0x0,0x14",2); + SAFEWRITE(test+2,5,timeout,2000,return); + SocExplorerEngine::message(this,"Read Result",2); + read=rs232read(this->port,test2+read,16); + SocExplorerEngine::message(this,QString("Get ") + QString::number(read) + " bytes",2); + if(read>0) + { + SocExplorerEngine::message(this,"Flush port ",2); + while(rs232read(this->port,test2,1)>0); + this->Connected = true; + SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2); + emit this->activate(true); + if(this->scanDone==false) + { + socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); + this->scanDone=true; + } + break; + } + } + } + else + { + SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); + this->port = (rs232port_t)NULL; + this->Connected = false; + emit this->activateSig(false); + return; + } + if(this->Connected == false) + { + SocExplorerEngine::message(this,QString("Port not opened ")+PortName,2); + rs232close(this->port); + this->port = (rs232port_t)NULL; + emit this->activateSig(false); + } + +} + +bool ahbuartplugin::open(QString PortName,int baudrate) +{ + if(this->port!=(rs232port_t)NULL) + this->close(); + this->UI->setconfig(PortName,baudrate); + this->connectPort(PortName,baudrate); + return (this->port!=(rs232port_t)NULL); +} + +void ahbuartplugin::close() +{ + if(this->port!=(rs232port_t)NULL) + { + rs232close(this->port); + this->port = (rs232port_t)NULL; + this->Connected = false; + emit this->activateSig(false); + } +} + +void ahbuartplugin::togglePort(QString PortName,int baudrate) +{ + if(this->port!=(rs232port_t)NULL) + { + this->close(); + } + else + { + this->connectPort(PortName,baudrate); + } +} + + +unsigned int ahbuartplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) +{ + QTime timeout; + timeout.start(); + unsigned int read=0; + unsigned int cnt=count; + unsigned int nextUpdateTrig=0,updateStep=512; + SocExplorerEngine::message(this,QString("Read ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); + if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) + { + if(!this->portMutex->tryLock()) + return 0; + if(!this->checkConnection()) + { + this->Connected = false; + emit this->activateSig(false); + this->portMutex->unlock(); + return 0; + } + QProgressBar* progress=NULL; + if(cnt>128) + progress= SocExplorerEngine::getProgressBar("Reading on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); + char CMD[5]; + char* result = (char*)malloc(count*4); + while(count>32) + { + CMD[0] = 0x80 | (32-1); + CMD[1] = (char)((address>>24)&0xFF); + CMD[2] = (char)((address>>16)&0xFF); + CMD[3] = (char)((address>>8)&0xFF); + CMD[4] = (char)((address)&0xFF); +// APENDTABLETOLOG(CMD,5,logmessage,"Write CMD : "); + SAFEWRITE(CMD,5,timeout,1000,return 0); + SAFEREAD(result+((cnt-count)*4),32*4,timeout,1000,return 0); +// APENDTABLETOLOG((result+((cnt-count)*4)),32*4,logmessage, QString("Get ") + QString::number(32*4) + " Bytes : "); + count-=32; + address+=32*4; + if(cnt>128) + { + + if((cnt-count)>=nextUpdateTrig) + { + progress->setValue(cnt-count); + qApp->processEvents(); + nextUpdateTrig+=updateStep; + } + } + } + if(count>0) + { + CMD[0] = 0x80 | (count-1); + CMD[1] = (char)((address>>24)&0xFF); + CMD[2] = (char)((address>>16)&0xFF); + CMD[3] = (char)((address>>8)&0xFF); + CMD[4] = (char)((address)&0xFF); + SAFEWRITE(CMD,5,timeout,1000,return 0); + SAFEREAD(result+((cnt-count)*4),(count*4),timeout,1000,return 0); +// APENDTABLETOLOG((result+((cnt-count)*4)),(count*4),logmessage, QString("Get ") + QString::number(32*4) + " Bytes : "); + } + if(cnt>128) + { + progress->setValue(cnt-count); + qApp->processEvents(); + } + for(int i=0;(unsigned int)i128) + SocExplorerEngine::deleteProgressBar(progress); + free(result); + this->portMutex->unlock(); + } + return read/4; +} + +unsigned int ahbuartplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) +{ + QTime timeout; + timeout.start(); + unsigned int writen=0; + unsigned int nextUpdateTrig=0,updateStep=512; + SocExplorerEngine::message(this,QString("Write ")+ QString::number(count) + QString(" words @0x")+ QString::number(address,16),2); + if((this->port!= badPortValue)||(this->port!=(rs232port_t)NULL)) + { + if(!this->portMutex->tryLock()) + return 0; + if(!this->checkConnection()) + { + emit this->activateSig(false); + this->Connected = false; + this->portMutex->unlock(); + return 0; + } + QProgressBar* progress = NULL; + if(count>128) + progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); + int offset = 0; + char* CMD= (char*)malloc((32*4)+5); + while(count>32) + { + writen=0; + CMD[0] = 0xC0 | (32-1); + CMD[1] = (char)(((unsigned int)address>>24)&0xFF); + CMD[2] = (char)(((unsigned int)address>>16)&0xFF); + CMD[3] = (char)(((unsigned int)address>>8)&0xFF); + CMD[4] = (char)(((unsigned int)address)&0xFF); + for(int i=0;i<32;i++) + { + CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); + CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); + CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); + CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); + } + SAFEWRITE(CMD,((32*4)+5),timeout,1000,return 0); + writen+=32; + count-=32; + offset+=32; + address+=32*4; + if(offset>=nextUpdateTrig && progress!=NULL) + { + progress->setValue(offset); + qApp->processEvents(); + nextUpdateTrig +=updateStep; + } + + } + if(count>0) + { + CMD[0] = 0xC0 | (count-1); + CMD[1] = (char)(((unsigned int)address>>24)&0xFF); + CMD[2] = (char)(((unsigned int)address>>16)&0xFF); + CMD[3] = (char)(((unsigned int)address>>8)&0xFF); + CMD[4] = (char)(((unsigned int)address)&0xFF); + for(int i=0;(unsigned int) i<(count);i++) + { + CMD[(i*4)+5] = (char)(((unsigned int)Value[i+offset]>>24)&0xFF); + CMD[(i*4)+6] = (char)(((unsigned int)Value[i+offset]>>16)&0xFF); + CMD[(i*4)+7] = (char)(((unsigned int)Value[i+offset]>>8)&0xFF); + CMD[(i*4)+8] = (char)(((unsigned int)Value[i+offset])&0xFF); + } + SAFEWRITE(CMD,((count*4)+5),timeout,1000,return 0); + writen+=count; + } + if(progress!=NULL) + { + progress->setValue(writen); + qApp->processEvents(); + SocExplorerEngine::deleteProgressBar(progress); + } + free(CMD); + this->portMutex->unlock(); + return writen; + } + return 0; +} + + + + +void ahbuartplugin::updatePortList() +{ + if(this->portListcompleter==(QCompleter*)NULL) + { + this->portListcompleter=new QCompleter(this); + this->portListcompleter->setCaseSensitivity(Qt::CaseInsensitive); + this->portListcompleterModel = new QStringListModel(this); + this->portListcompleter->setModel(this->portListcompleterModel); + this->UI->setCompleter(this->portListcompleter); + } + rs232portslist_t* portlist = rs232getportlist(); + rs232portslist_t* portlistenum = portlist; + QStringList wordList; + while(portlistenum!=NULL) + { + wordList << portlistenum->name; + portlistenum = portlistenum->next; + } + rs232deleteportlist(portlist); + this->portListcompleterModel->setStringList(wordList); +} + +QVariantList ahbuartplugin::ReadBytes(unsigned int address, unsigned int count) +{ + unsigned int data[(count/4)+1]; + QVariantList result; + this->Read(data,(count/4)+1,address); + for(unsigned int i = 0;i>24)))); + result.append(QVariant((int)(0x0FF&(data[i]>>16)))); + result.append(QVariant((int)(0x0FF&(data[i]>>8)))); + result.append(QVariant((int)(0x0FF&(data[i])))); + } + + for(int i=0;i<(count%4);i++) + { + result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8))))); + } + + return result; +} + +void ahbuartplugin::WriteBytes(unsigned int address, QList dataList) +{ + unsigned int data[dataList.count()/4]; + for(int i = 0;i<(dataList.count()/4);i++) + { + data[i] = 0x0FF & ((unsigned int)dataList.at(4*i).toUInt()); + data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+1).toUInt())); + data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+2).toUInt())); + data[i] = (data[i]<<8) + (0x0FF & ((unsigned int)dataList.at((4*i)+3).toUInt())); + } + this->Write(data,dataList.count()/4,address); +} + + + + + + + + + + + + + + + + + diff --git a/ahbuartplugin/ahbuartplugin.h b/ahbuartplugin/ahbuartplugin.h new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartplugin.h @@ -0,0 +1,133 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef AHBUARTPLUGIN_H +#define AHBUARTPLUGIN_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ahbuartpluginui.h" + +#ifdef WinRs232 + #include "librs232/RS232.h" +#else + #include + #undef debug +#endif + + + + +#define APPENDTOLOG(message) this->UI->appendToLogFile(QTime::currentTime().toString() +":" + QString::number(QTime::currentTime().msec()) + ": " + message) + +#define APENDTABLETOLOG(table,size,Qstr,message) \ + Qstr.clear();\ + Qstr+=message;\ + for(int __i__tbllog__=0;(unsigned int)__i__tbllog__port,((data)+__writen__),((count)-__writen__)); \ + if((timer).elapsed()>(timeout)) \ + {\ + APPENDTOLOG(QString("Timeout error while writing"));\ + this->port = (rs232port_t)NULL; \ + this->Connected = false; \ + emit this->activateSig(false); \ + error; \ + } \ + } \ + break;\ +} + + +#define SAFEREAD(data,count,timer,timeout,error) \ +unsigned int __read__=0; \ +(timer).restart(); \ + while(__read__ != (count)) \ +{ \ + __read__+=rs232read(this->port,((data)+__read__),((count)-__read__)); \ + if((timer).elapsed()>(timeout)) \ + { \ + APPENDTOLOG(QString("Timeout error while reading"));\ + this->Connected = false; \ + emit this->activateSig(false); \ + this->portMutex->unlock(); \ + error; \ + } \ +} \ + + + +class ahbuartplugin : public socexplorerplugin +{ + Q_OBJECT +public: + ahbuartplugin(QWidget *parent = 0); + ~ahbuartplugin(); + int registermenu(QMainWindow *menuHolder); + int VID(){return driver_VID;} + int PID(){return driver_PID;} + +public slots: + void togglePort(QString PortName,int baudrate); + unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); + void closeMe(); + void close(); + bool open(QString PortName,int baudrate); + void updatePortList(); + QVariantList ReadBytes(unsigned int address,unsigned int count); + void WriteBytes(unsigned int address,QList dataList); +signals: + void setProgressValue(int progress); +private: + bool scanDone; + QProgressDialog* progress; + QLayout * mainLayout; + ahbUartPluginUI* UI; + QMutex* portMutex; + rs232port_t port; + QCompleter *portListcompleter; + QStringListModel *portListcompleterModel; + void connectPort(QString PortName,int baudrate); + bool checkConnection(); + +}; + +#endif // AHBUARTPLUGIN_H diff --git a/ahbuartplugin/ahbuartplugin.pro b/ahbuartplugin/ahbuartplugin.pro new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartplugin.pro @@ -0,0 +1,80 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin +TEMPLATE = lib +CONFIG += dll +CONFIG -= static +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"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" +DEFINES += driver_Version="\"\\\"1.3.2"\\\"\" +DEFINES += driver_Description="\"\\\"Gaisler's AHBUART driver, gives master access to AHB bus."\\\"\" +DEFINES += driver_can_be_root=1 +DEFINES += driver_can_be_child=0 +DEFINES += driver_VID=0 +DEFINES += driver_PID=0 + + + +win32:LIBS += $${PWD}/librs232/bin/librs232-2.1.a +unix:LIBS += -lrs232-2.1 + + +INCLUDEPATH += \ + $${PWD} + + +HEADERS += \ + ahbuartplugin.h \ + ahbuartpluginui.h \ + ahbuartpywrapper.h \ + ahbuartpywrapper.h + + + +win32:HEADERS+=librs232/RS232.h +win32:INCLUDEPATH+=librs232 + +SOURCES += \ + ahbuartplugin.cpp \ + ahbuartpluginui.cpp \ + ahbuartpywrapper.cpp + + +OTHER_FILES += \ + librs232/bin/librs232-1.0-1.dll + +FORMS += \ + ahbuartpluginui.ui + + + + + + + + + + + + + + + + + + + + + + diff --git a/ahbuartplugin/ahbuartpluginui.cpp b/ahbuartplugin/ahbuartpluginui.cpp new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartpluginui.cpp @@ -0,0 +1,124 @@ +/*------------------------------------------------------------------------------ +-- 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 "ahbuartpluginui.h" +#include "ui_ahbuartpluginui.h" + +ahbUartPluginUI::ahbUartPluginUI(QWidget *parent) : + QWidget(parent), + ui(new Ui::ahbUartPluginUI) +{ + ui->setupUi(this); + connect(ui->OpenPort,SIGNAL(clicked()),this,SLOT(connectPort())); + connect(ui->PortspeedSlider,SIGNAL(valueChanged(int)),ui->baurateLCD,SLOT(display(int))); + connect(ui->logFileChooseBp,SIGNAL(clicked()),this,SLOT(chooseLogFile())); + connect(this,SIGNAL(setLogFileName(QString)),this->ui->logFileName,SLOT(setText(QString))); + connect(ui->rescanPorts,SIGNAL(clicked()),this,SIGNAL(rescanPorts())); + this->logFile = new QFile(); +} + +void ahbUartPluginUI::connectPort() +{ + emit this->connectPortsig(ui->PortName->text(),ui->PortspeedSlider->value()); +} + +void ahbUartPluginUI::setConnected(bool connected) +{ + if(connected == true) + { + ui->OpenPort->setText(tr("Close port")); + } + else + ui->OpenPort->setText(tr("Open port")); +} + + +ahbUartPluginUI::~ahbUartPluginUI() +{ + delete ui; +} + + +void ahbUartPluginUI::chooseLogFile() +{ + if(this->logFile->isOpen()) + this->logFile->close(); + this->logFile->setFileName(QFileDialog::getSaveFileName(this,tr("Open Log file"),QDir::homePath(), tr("Log Files (*.txt *.log)"))); + if(this->logFile->open(QIODevice::WriteOnly)) + { + this->logFileStrm = new QTextStream(this->logFile); + emit this->setLogFileName(this->logFile->fileName()); + } +} + +void ahbUartPluginUI::setconfig(QString PortName, int baudrate) +{ + this->ui->PortName->setText(PortName); + this->ui->PortspeedSlider->setValue(baudrate); +} + + +void ahbUartPluginUI::logFileEnDisable(int state) +{ + if(state==Qt::Checked) + { + this->logFileEn = true; + } + else if(state==Qt::Unchecked) + { + this->logFileEn = false; + } +} + +bool ahbUartPluginUI::islogfileenable() +{ + return this->logFileEn; +} + +void ahbUartPluginUI::appendToLogFile(const QString & text) +{ + if(this->logFileEn && this->logFile->isOpen()) + { + *(this->logFileStrm) << text << endl; + } +} + +void ahbUartPluginUI::setCompleter(QCompleter *completer) +{ + this->ui->PortName->setCompleter(completer); +} + +void ahbUartPluginUI::closeEvent(QCloseEvent *event) +{ + if(this->logFile->isOpen()) + { + this->logFileStrm->flush(); + this->logFile->waitForBytesWritten(3000); + this->logFile->close(); + } + event->accept(); +} + + + + + + diff --git a/ahbuartplugin/ahbuartpluginui.h b/ahbuartplugin/ahbuartpluginui.h new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartpluginui.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef AHBUARTPLUGINUI_H +#define AHBUARTPLUGINUI_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { + class ahbUartPluginUI; +} + +class ahbUartPluginUI : public QWidget +{ + Q_OBJECT + +public: + explicit ahbUartPluginUI(QWidget *parent = 0); + ~ahbUartPluginUI(); + bool islogfileenable(); + void appendToLogFile(const QString & text); + void closeEvent(QCloseEvent *event); + void setCompleter(QCompleter* completer); +public slots: + void setConnected(bool connected); + void connectPort(); + void chooseLogFile(); + void logFileEnDisable(int state); + void setconfig(QString PortName,int baudrate); + +signals: + void connectPortsig(QString PortName,int baudrate); + void setLogFileName(QString FileName); + void rescanPorts(); +private: + Ui::ahbUartPluginUI *ui; + QFile* logFile; + QTextStream* logFileStrm; + bool logFileEn; +}; + +#endif // AHBUARTPLUGINUI_H + + + + + diff --git a/ahbuartplugin/ahbuartpluginui.ui b/ahbuartplugin/ahbuartpluginui.ui new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartpluginui.ui @@ -0,0 +1,111 @@ + + + ahbUartPluginUI + + + + 0 + 0 + 947 + 279 + + + + Form + + + + + + 3000000 + + + 9600 + + + 1 + + + 921600 + + + Qt::Horizontal + + + + + + + + + + Open Port + + + + + + + Enable Logs + + + + + + + Choose file + + + + + + + SCAN + + + + + + + Port Name + + + + + + + Port Speed + + + + + + + + + + + + + + + 75 + true + + + + 7 + + + 7 + + + QLCDNumber::Flat + + + + + + + + diff --git a/ahbuartplugin/ahbuartpywrapper.cpp b/ahbuartplugin/ahbuartpywrapper.cpp new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartpywrapper.cpp @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------------ +-- 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 "ahbuartpywrapper.h" +#include +#include +#include +#include +#include + +ahbuartPywrapper::ahbuartPywrapper(socexplorerplugin *parent) : + genericPySysdriver(parent) +{ +} diff --git a/ahbuartplugin/ahbuartpywrapper.h b/ahbuartplugin/ahbuartpywrapper.h new file mode 100644 --- /dev/null +++ b/ahbuartplugin/ahbuartpywrapper.h @@ -0,0 +1,23 @@ +#ifndef AHBUARTPYWRAPPER_H +#define AHBUARTPYWRAPPER_H +#include +#include + +class ahbuartPywrapper : public genericPySysdriver +{ + Q_OBJECT +public: + explicit ahbuartPywrapper(socexplorerplugin *parent = 0); + +signals: + bool open(QString PortName,int baudrate); + void close(); + QVariantList ReadBytes(unsigned int address,unsigned int count); + void WriteBytes(unsigned int address,QList dataList); +public slots: +// bool dumpMemory(unsigned int address,unsigned int count,QString file); +// bool memSet(unsigned int address,int value, unsigned int count); +// bool loadbin(unsigned int address,QString file); +}; + +#endif // AHBUARTPYWRAPPER_H diff --git a/ahbuartplugin/librs232/RS232.h b/ahbuartplugin/librs232/RS232.h new file mode 100644 --- /dev/null +++ b/ahbuartplugin/librs232/RS232.h @@ -0,0 +1,52 @@ +// SOPSUYSI_RS232.h +#ifndef RS232_H +#define RS232_H +//#define debug + +#define badPortValue -1 +#define rs232noerr 0 +typedef int rs232port_t; +typedef int rs232speed_t; +typedef enum {rs232OneStop,rs232One5Stop,rs232TwoStop}rs232stop; +typedef enum {rs232parityNo,rs232parityOdd,rs232parityEven}rs232parity; + +#ifdef __cplusplus +extern "C" { +#endif +typedef struct rs232portslist_t +{ + char* name; + struct rs232portslist_t* next; +}rs232portslist_t; +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus + #define rs232extern extern "C" +#else + #define rs232extern extern +#endif +rs232extern rs232port_t rs232open(char* psPortName); +rs232extern rs232portslist_t* rs232getportlist(); +rs232extern void rs232deleteportlist(rs232portslist_t* list); +rs232extern int rs232close(rs232port_t fd); +rs232extern int rs232setup(rs232port_t fd, int ChSize, int BaudeRate, rs232parity Parity, rs232stop NbStop); +rs232extern int rs232write(rs232port_t fd,char *psWrite, int WriteBufferSize); +rs232extern int rs232read(rs232port_t fd,char *psRead, int ReadBufferSize); +rs232extern int rs232setparity(rs232port_t fd, rs232parity Parity); +rs232extern int rs232setnbstop(rs232port_t fd, rs232stop NbStop); +rs232extern int rs232setcsize(rs232port_t fd, int ChSize); +rs232extern int rs232setbaudrate(rs232port_t fd, int baudrate); +rs232extern int rs232setRTS(rs232port_t fd); +rs232extern int rs232clearRTS(rs232port_t fd); +rs232extern int rs232setDTR(rs232port_t fd); +rs232extern int rs232clearDTR(rs232port_t fd); +rs232extern int rs232saferead(rs232port_t fd,char* data,int count ); +rs232extern int rs232safewrite(rs232port_t fd,char* data,int count); + +#endif + + + diff --git a/ahbuartplugin/librs232/bin/librs232-2.1.a b/ahbuartplugin/librs232/bin/librs232-2.1.a new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0e82aeec19aa8d53ad83642f99d91f60ac7614ae GIT binary patch literal 17492 zc%1EAdw5jUwcmTrJWeu`2P8rW0VWb25%QS4NFc$GWI!-LOu|C}!z7u+X(uz|%$bDX z3k)DBO@-Fls#sh5xNU7e`K)cRRBjY2&~g=TZS_`L(c+_5tVpR3Y~`-C_t|^SNrFm0 zzx&-k?tD!4TEDgS+H0--IQ#5#hTLjjwBx#k$whAS$5UG6DK0IYS61P67c<28*X=H? ztkkKE$%K$hLL8yb^4k`P26}y(zti6l?(|1|(SX)Z%wS9lM@U;VR#IBh(G`pM{hc}& zj`%}D5DdrsI^FHpBH^eO48$}Y>GTKvntucs^K0=)f^PT4JEPEM0ujy#KGbgT1o)0v zV6#x~164ss{XXGg%-7`~!5THeNONn848iYg<>hX7*}USCVh{UU>?tm;C@VvGWx43TMw&$MbEiVcct%-iq2}MDk&pklN%6+Q zPM_xc1ie~PJY3iwi+zF`*#de+WoGPpO301y-K22d!tABj6?rO5dXwS%mStqSpjTRK z!m{A2f~_y=_NdS+D>vy)fv;N`!(REkPYQ$URaBZV<(j_Zax$E6! zg_VURZs@R5PqC-MJ$tdgGaU7~mj^;i)^K5gr?9J|q&VMQ(4)me{+e!o$R7=K0E=_E z21dUYi1$RIVRu2dyI^IByP(Uzsly-90^v~1T~Gi6*w^EZ#Ucgm@h%vM1vp@9$_OAj1>hVkr=e&3l_zq9lSHBz2iDxlvu2ecqkU=4*5IXfsh8g zjTIJ0>^hiS?vcV^IMmH)mD35p>Og0-{)iuGhMQ|sRr0)T)!G@3w+B(*+7%4@K*wce z6$NgwaW}9&q2uTbHN&Z>lhyQz5JDbtIu`;<*dj*w5VD&3X%fRTaJ0}5Q&ZqCrF`hX zza{nc^WC$d>+&z6=eS)vd~xw~l1JcgDx(ln8CBR70O$GVqw|Dxo4bd7jI$J7Qt0T> zXq=&z3+WhUr*Z)u{H)YVE7QTbX&I%nPA_dtXY!bK0(xm@I$65+=FcX*bTFMMW7^rK zmq|>gVwC)Lg7N#?OuZI#ik6pATLdz_pV-jHrK1$)tYDBk4_Anqgt|Oc;K8R?T%qO{I^3xKSRAw zB@Z$A=CmDWf!KQPG0^YYKbNNMILY_{1^Km>v>nef{skNI`>bg@o?v`hD)JkX(sn$| z_-Q%F506jV@g2rLSb_YO8EHH2VElcHkgu&w+p&%Dw?vR9SN3iK`T(Qv>1_eVYXfGRLV6bi6LbReYnAj?K~w$Xfk{s#y>qvod;2HZWdFuL zPawV1z{ypYlKoq@O(nhKx1KA0H=j%zo^j&Z_s`pgpDZAMJG6V~Vb=Sr248I%IF+}{ zs~&F1!{v!UnYo3R=?X7hI^;tg=8!g%40%ruuFpf~t?7V)!6&^Z$&=n!;rkkVU*~QNd0z(68>wI% zef2)8tphJr;U&?_*5DAi0<^B;HWzA5eIjAUozPp^6o$E{Uytt_X%F?$A}Mmhi!~IVq-%?Wl792 zbh8TSV98+p$NKxtQ^x*=Xv-j42vuu^7#nOa8iG7M})*IY76n_!(YB%SVx2GA}<7><*b>Jo!#oW0>n%*|4 z=>bFUo8o=T81HA>{^^Tu-;nRCE+*eQy?+Jam|e{BY-sOoV|xRqD)sqaKD6rWU~8Uh z*Q)fx-n07Rl1}(M27$V3l?w{1X!7j9sZ729jvkWz_gULpv-)5sP>`1DU8~exH@S9g zNPlyQSjPBz!{$O}-r%Zd4|`9V8iLhQm_G^Y#NcD}X=o+?kd{60SE{)O&Yh1Rcm!Ky z&C;jy55-@D8Q~e$=Y;<(6EF_vzh{_v^oBCZBbHzK{?PK1gN=DE=G6r}vVM$5)6k{l*p7$}=l21M2o+7=&p*8-DM3NTQ*mNHaEhOWnZ(hxq&D*oB><*2F~0#5AUwzEiJX1ZhDQkv=-HoaLUxIy>aD= zC2dWu&BR)vf;r`iMJpN_y~K7S-2kkkt)ae-e4LU)LLSnt|JoxSsDT$PX{Id;EhJZ(R$3OeTEKS0`Q7>5WJYFBbk6SYcc8F zEZw{DfG=u?epne|c8GnpUSk~k9q;MsFCq4Pj*TO#+Slxdk=pC;B=*bb=K*!8Yr~<& zKo7CcVSK8JQ7~XG1Jc#He$C&4CyMq0+6Kt@WW2|)7cwS8ZPCJ!x_}lV_9BL4qD3B1 zF~z}o2{XwN4?`xXhNw#zG*R`2b)8ZMWU1a>jRR#2n3QndL+s_uxoo1~2(nkuSJ-fZ zZRqmWrOUl5SGBf~OnW6gi{q-<@9SI|(x9p@*c#~ZhvP6ZtMn0u!q%`RCClSMEf5I? z{Lt`xp14su&<`=qhvRzz(@@nlczAjtGu2GVHCicQr-rGd6U7vPeIfNg0EQDL^TCpx zox$SqF)S?(^-b&+enyLj(TF7>=CnGJx4sGq6um zLwKm*$UuP=R=5+OoQBGdOeE7yC+@VW957k~y5n%$O{;K$6-w;%o!*97plzTsz6)yH zb}3$w(np`=(>$g)h_=uO&D%0sQ;&g;W4b>@U7Qbe9Hxe3Bu?6C6=f=!;8tcA-cEZ&GVyrn$PWT687_j{WU_)8ep8Ug?w`h zOdcY%L~mo_pq*d5veEk9JHUL_4*;_40U0LIEoJ*qc9W20+3_#{`VbRDlLY;F7`K_mcrjmi@F7hELu$5`=I8AalEEYKNX*dV`vxz zvzQZigW;@J?tkucG|>tnmyUXzL+?0|M968-dWuy>Zc2dAJ2BH&z;}A5zn91Iwbzo+ z=G9Xm^~?aFU&n~LL2F7^AR5!4J9-Gc3vFyhFcS6ma_nxz@H8WDnS~#8exEhOgx^Ks z>sWzJCi*>0nhm})Ft9tJLK^z^<1SFk#=wfOyJxNj!4RZka}p1cR+5>WI`$=j%_Htj zfPGg_nG$bg$+pCOU|}9e9tX)&y0#_Wi9(x#8(r)QOAH209cba0;2KcRYE1zrX5rfY zF4UYo2R9-lf2;>%^e4kmyMU#(CK(2Yj-FttB$vHl;Wp;H0mLig-%btem8eisPgg%QGB4y9MTZ(W3Ef&vyo;d@-Wa9+F>lZ1)nb)E4heY&0 z)4HEolM;c=&I4$xd#;!hCUh7C7(9Z zmoWAdp#3?Pv^1BVw3jexNs!FBBXsitoAkEA59xU(Ugw!;otg#ZpGSDJraH&Of+G*^x0Q$BObX%ow@9Vy?r0)b8 zPgv=P+gy6m2l0${Dhl?x%cp#o1duDWh_G*q2>^4aT6@N6l|bJ>V3 z5-lfWep?$JUcjAeTLiCAPQnUyy#osi@DE&}cS2E(SLm7^UoaT%AnFRdamRhYf@7H9 znwS>ti1d@BQtW!%1uQ^<*IyWeopVU*BFQ%}FJCcPAg^gomk&B8!F_$dX@rqQxkYq)p%^m<#EJ^zunuI&0F>3^%JV&SuaU zZ!>tDA=PaO^-P-~;7gp4q6uXNWMU!pWMH0Zv%Xe02`gmTh$q7WdxuF*iUOE041qjO zHv40$mXq)VD^Dp)uuyaA;H?y_q2jbJz*fkTwWkiW+#L1*oXbhr7AG1JP29L=+hLM>?=~70_&LvATiXhAR#z0JATm}^h_h=3$zgjm5xw$q| zKn00jK(??f!Gdc==ub0UHBtCeZ0;IUlb%Emp{Wv^97M>LmL*uQTxPJ$#$|b#-dz<2 zGr-O(Gg+-P)`O+b2_($lL>@vaI#$g*T3{nMHmYZ`qQ>0oTxFp-AP!!RJI-38dNsau zg12pp*-I9C#BCe72l#v0t0zrZ+|S4sEFR=277uY$)WI7grv>d4--qQdEG9AD8mwYa zlYp!ibB$jz@fs`+e!S*HM#r1>;Qb0yU5&+~I{c_^0YbV$m}mpOgIn!L)DqGz3*SG2 z6pKDaUWLV7+-9TD#Cxo7Fmbbt9M}|vXYe;rKBt(oX^>kDa_bm!)gV{Lkh=_W*BJ72 zgFIcxTYx__0t@JvAqRLL@Q&_!Jvg__Y7WC7w;JR!4BV#s^*RTv_+-~y-ypXd>R`L zk9Ia}UxMOIPL83eV!4lrTd;VwMPQR0ymPP&JD8>G zp}5gu>Kucnie()Ww_tIlBhdp$`?v@Tzd?j_4;P{R%?|T=2=<*0ea+H$y^wpfALJw! z*E8}eEc!W$#mx>==ZrM9+<|YbCBLCywvlP#z+V`EOvtE##&0kJ!md+~6})cNV*?V4 zZpVlY5)s(pE;m9hy{}nMi{OoV3z(heX5EgVcko&E$d@0hO_nKq#p*D;$cl8A z!dIdl@LdXD z5&eba;`2pz@%RlHIlX= z{o>7Q{%8_DZA@Hv9a;hs@J@dhXWM;n^AYRh3G44 zbF!Ml@o8bsJs2<}2Mx17rR3=>OKhzcTih|0_|a z-`{JwJac|=dHBEwT{YM4DY#teU)J{Eip$EB&4mm59#eC!gwNGK-gY2X6j!IuuZgcN zCKfBT7ups7t%~cUGU4Q-%dTvU4>VqJ&5qsOcd9kD$ zxLny(xN(QzYL&i1C28%B-z%F`_xZS*tEAqlTwkc9S9_Jv+HWeEYl~J?d2YY@w%mdv z?iVy~fQxhU*TjcpiTS}EF$ms0g0Cg~F+-lt zi)ROmQq}F2x)fW(fMRJ({?#Ecy9n+Yq@Fn57kbwu{|Z#+3cLCtw6MGQHieme zDmh_yu`}VXIDa+9wayTi@If4d3O(-*Wx#6L$gB#RLihNm(3N@B&jgL_xA68CoARn3 z;0e83SY8*&yb3*W4tF6v@tXy4dM5PhFi%S%Q9Xu4)j5|Ym_%K1P{rytT%hhEb6xSO zuQ(bK?fP}UgnZv8$WMHNT%6O4l;4gAfdns^|3>+5KkVd3l)t~5Nq$TDIkBBgwg_n{ zQ1h9z8K?z}+9)XvsA@*tV-a=dD*SNMj<2keGDiIZsB%VST7|USDx}*a_JG8!Hi6Bt zNj-_(E3x;0s$kR-=#P1f`ktgJ9YT7igZG@BJSnMnB{fqO)Jce=hDC(eUVIvi@7u!d z9+M6eo>wQi8zP#+sF!VmO0^5BL{c|P>W7lL$sz3BC8?iE>X@Yd3#jR=#%YO7Q3ZCX zDzNpE`kX5IEiSPyO6nm=9hFwzmXtL~P+5|ik|b)BOUx^&6;kSxShvJ(kksvx`hlb# zPZFL!EwPkjLCuj=nWR=qsykV<)-S1>lSOuSN^D4CUz6BgiG5FE4@k=oOX(jZ_NQdN zmOIH?vc`K-`k|C2JB2jeDWtO{wNO&4CACdbdu82ylKQEX9&`$?j!EpKq|QldhD%U2 zE@7q4CF(Xx>?)~ujg$r@7IBG)Zjm*%OXRVF!L)pe75_?8cZ%S%>s-UJzs!>ugNo|wVK}o%yD%$-( zQpss@_DCu>P4-Nhh|(ja^CeX;sVk)3Dp~h-N$r<Xp=-4eS)V*4cau*8l_>{*GOme^T|UFcVN^8Qc%#PyQG z-q}LQn4d2YzO!aJ47r!^y>$Y4fbiXQ0>KxuhfT=igzuOW2>wE6*kVNR=M$$*$lnRy z-zE?T!-{DHF(g%6EzhBuM%GFM;$^ zzT- header file. */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERMIOS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WINDOWS_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "rs232" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "alexis.jeandet@lpp.polytechnique.fr" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "librs232" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "librs232 2.1.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "rs232" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://www.lpp.fr" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.1.0" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "2.1.0" + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ diff --git a/ambaplugin/AHB/ahbdevicelist.cpp b/ambaplugin/AHB/ahbdevicelist.cpp new file mode 100644 --- /dev/null +++ b/ambaplugin/AHB/ahbdevicelist.cpp @@ -0,0 +1,74 @@ +/*------------------------------------------------------------------------------ +-- 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 "ahbdevicelist.h" + + + +ahbdevicelist::ahbdevicelist(QWidget *parent):QTableWidget(parent) +{ + this->setColumnCount(7); + this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<clear(); + this->setRowCount(0); + this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<rowCount()==0) + { + this->setRowCount(1); + } + else + { + this->insertRow(this->rowCount()); + } + + this->ahbdevices.append(device); + QTableWidgetItem *newItem = new QTableWidgetItem(*device->deviceName); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, 0, newItem); + + for(int i=0;i<4;i++) + { + if(device->BAR[i].size!=0) + { + newItem = new QTableWidgetItem("0x" + QString::number(device->BAR[i].address, 16)+" -> 0x"+ QString::number(device->BAR[i].address + device->BAR[i].size-1, 16)+" size = "+device->barAdressSize(i)); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, i+1, newItem); + } + + } + + newItem = new QTableWidgetItem("0x" + QString::number(device->VID , 16)); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, 5, newItem); + newItem = new QTableWidgetItem("0x" + QString::number(device->PID , 16)); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, 6, newItem); + this->resizeColumnsToContents(); + +} diff --git a/ambaplugin/AHB/ahbdevicelist.h b/ambaplugin/AHB/ahbdevicelist.h new file mode 100644 --- /dev/null +++ b/ambaplugin/AHB/ahbdevicelist.h @@ -0,0 +1,104 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef AHBDEVICELIST_H +#define AHBDEVICELIST_H +#include +#include +#include + +typedef struct +{ + unsigned int address; + unsigned int size; + unsigned char type; + bool prefectchable; + bool cacheable; + +}AHBbarreg; + +class ahbdeviceInfo +{ +public: + ahbdeviceInfo() + { + } + + ahbdeviceInfo(const QString deviceName,AHBbarreg BAR0,AHBbarreg BAR1, AHBbarreg BAR2,AHBbarreg BAR3,int VID,int PID) + { + this->deviceName = new QString(deviceName); + this->BAR[0]=BAR0; + this->BAR[1]=BAR1; + this->BAR[2]=BAR2; + this->BAR[3]=BAR3; + this->VID = VID; + this->PID = PID; + } + QString barAdressSize(int barIndex) + { + int k=0; + unsigned int size=this->BAR[barIndex].size; + while(size>=1024){size=size>>10;k++;} + switch(k) + { + case 0: + return (QString::number(size, 10) + "B"); + break; + case 1: + return (QString::number(size, 10) + "kB"); + break; + case 2: + return (QString::number(size, 10) + "MB"); + break; + case 3: + return (QString::number(size, 10) + "GB"); + break; + case 4: + return (QString::number(size, 10) + "TB"); + break; + default: + return (QString::number(this->BAR[barIndex].size, 10) + "B"); + break; + } + } + QString* deviceName; + AHBbarreg BAR[4]; + int VID; + int PID; +}; + +class ahbdevicelist: public QTableWidget +{ + Q_OBJECT +public: + explicit ahbdevicelist(QWidget * parent = 0); + +public slots: + void addAHBdevice(ahbdeviceInfo* device); + void clearAHBdevicesList(); + +private: + QList ahbdevices; + + +}; + +#endif // AHBDEVICELIST_H diff --git a/ambaplugin/AHB/ahbpluginui.cpp b/ambaplugin/AHB/ahbpluginui.cpp new file mode 100644 --- /dev/null +++ b/ambaplugin/AHB/ahbpluginui.cpp @@ -0,0 +1,90 @@ +/*------------------------------------------------------------------------------ +-- 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 + +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(iextractInfos(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; + } + } +} + + diff --git a/ambaplugin/AHB/ahbpluginui.h b/ambaplugin/AHB/ahbpluginui.h new file mode 100644 --- /dev/null +++ b/ambaplugin/AHB/ahbpluginui.h @@ -0,0 +1,59 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef AHBPLUGINUI_H +#define AHBPLUGINUI_H + +#include +#include +#include +#include "ahbdevicelist.h" +#include +#define AHB_PLUGNPLAY_MASTER_START ((unsigned int)(0xFFFFF000)) +#define AHB_PLUGNPLAY_MASTER_STOP ((unsigned int)(0xFFFFF800)) +#define AHB_PLUGNPLAY_SLAVE_START ((unsigned int)(0xFFFFF800)) + +#define AHB_PLUGNPLAY_SLAVE_STOP ((unsigned int)(0xFFFFFFFC)) + + +class ahbPluginUi : public QWidget +{ + Q_OBJECT +public: + explicit ahbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0); + ahbdeviceInfo* extractInfos(int* pnpregs); +public slots: + void scanAHB(); +signals: + void addAHBdevice(ahbdeviceInfo* device); + void clearAHBdevicesList(); + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); +private: + QHBoxLayout* mainlayout; + QPushButton* scanBp; + ahbdevicelist* deviceslst; + socexplorerplugin* _plugin; + + +}; + +#endif // AHBPLUGINUI_H diff --git a/ambaplugin/APB/apbdevicelist.cpp b/ambaplugin/APB/apbdevicelist.cpp new file mode 100644 --- /dev/null +++ b/ambaplugin/APB/apbdevicelist.cpp @@ -0,0 +1,74 @@ +/*------------------------------------------------------------------------------ +-- 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 "apbdevicelist.h" + + + +apbdevicelist::apbdevicelist(QWidget *parent):QTableWidget(parent) +{ + this->setColumnCount(4); + this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<clear(); + this->setRowCount(0); + this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<rowCount()==0) + { + this->setRowCount(1); + } + else + { + this->insertRow(this->rowCount()); + } + + this->apbdevices.append(device); + QTableWidgetItem *newItem = new QTableWidgetItem(device->deviceName); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, 0, newItem); + + for(int i=0;i<1;i++) + { + if(device->BAR[i].size!=0) + { + newItem = new QTableWidgetItem("0x" + QString::number(device->BAR[i].address, 16)+" -> 0x"+ QString::number(device->BAR[i].address + device->BAR[i].size-1, 16)+" size = "+device->barAdressSize(i)); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, i+1, newItem); + } + + } + + newItem = new QTableWidgetItem("0x" + QString::number(device->VID , 16)); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, 2, newItem); + newItem = new QTableWidgetItem("0x" + QString::number(device->PID , 16)); + newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable); + this->setItem(this->rowCount()-1, 3, newItem); + this->resizeColumnsToContents(); + +} diff --git a/ambaplugin/APB/apbdevicelist.h b/ambaplugin/APB/apbdevicelist.h new file mode 100644 --- /dev/null +++ b/ambaplugin/APB/apbdevicelist.h @@ -0,0 +1,99 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef APBDEVICELIST_H +#define APBDEVICELIST_H +#include +#include +#include + +typedef struct +{ + unsigned int address; + unsigned int size; + unsigned char type; + +}APBbarreg; + +class apbdeviceInfo +{ +public: + apbdeviceInfo() + { + } + + apbdeviceInfo(const QString deviceName,APBbarreg BAR0,int VID,int PID) + { + this->deviceName = deviceName; + this->BAR[0]=BAR0; + this->VID = VID; + this->PID = PID; + } + QString barAdressSize(int barIndex) + { + int k=0; + unsigned int size=this->BAR[barIndex].size; + while(size>=1024){size=size>>10;k++;} + switch(k) + { + case 0: + return (QString::number(size, 10) + "B"); + break; + case 1: + return (QString::number(size, 10) + "kB"); + break; + case 2: + return (QString::number(size, 10) + "MB"); + break; + case 3: + return (QString::number(size, 10) + "GB"); + break; + case 4: + return (QString::number(size, 10) + "TB"); + break; + default: + return (QString::number(this->BAR[barIndex].size, 10) + "B"); + break; + } + } + QString deviceName; + APBbarreg BAR[1]; + int VID; + int PID; +}; + +class apbdevicelist: public QTableWidget +{ + Q_OBJECT +public: + explicit apbdevicelist(QWidget * parent = 0); + +public slots: + void addAPBdevice(apbdeviceInfo* device); + void clearAPBdevicesList(); + +private: + QList apbdevices; + + +}; + +#endif // APBDEVICELIST_H diff --git a/ambaplugin/APB/apbpluginui.cpp b/ambaplugin/APB/apbpluginui.cpp new file mode 100644 --- /dev/null +++ b/ambaplugin/APB/apbpluginui.cpp @@ -0,0 +1,99 @@ +/*------------------------------------------------------------------------------ +-- 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 "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(); +} + diff --git a/ambaplugin/APB/apbpluginui.h b/ambaplugin/APB/apbpluginui.h new file mode 100644 --- /dev/null +++ b/ambaplugin/APB/apbpluginui.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef APBPLUGINUI_H +#define APBPLUGINUI_H + +#include +#include +#include +#include "apbdevicelist.h" +#include + +#define APB_BUS_START ((unsigned int)(0x80000000)) +#define APB_PLUGNPLAY_START ((unsigned int)(0x800FF000)) + +#define APB_PLUGNPLAY_STOP ((unsigned int)(0x800FF000+(512*8))) + + +class apbPluginUi : public QWidget +{ + Q_OBJECT +public: + explicit apbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0); + void lockScanBp(); + void unlockScanBp(); + apbdeviceInfo* extractInfos(int* pnpregs); + +signals: + void addAPBdevice(apbdeviceInfo* device); + void clearAPBdevicesList(); + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); +public slots: + void scanAPB(); +private: + QHBoxLayout* mainlayout; + QPushButton* scanBp; + apbdevicelist* deviceslst; + socexplorerplugin* _plugin; +}; + +#endif // APBPLUGINUI_H diff --git a/ambaplugin/ambaplugin.cpp b/ambaplugin/ambaplugin.cpp new file mode 100644 --- /dev/null +++ b/ambaplugin/ambaplugin.cpp @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2012, 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 "ambaplugin.h" + + +ambaplugin::ambaplugin(QWidget *parent):socexplorerplugin(parent,true) +{ + this->UI = new ambaPluginUI(this); + this->setWindowTitle(tr("AMBA Driver")); + this->setWidget((QWidget*)this->UI); + connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); + connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); + connect(this,SIGNAL(activateSig(bool)),this,SLOT(activatePlugin(bool))); +} + + +ambaplugin::~ambaplugin() +{ + +} + + +void ambaplugin::closeMe() +{ + emit this->closePlugin(this); +} + +void ambaplugin::postInstantiationTrigger() +{ + if(this->parent->isConnected()) + { + this->UI->scanAll(); + } +} + +void ambaplugin::activatePlugin(bool flag) +{ + if(flag) + { + this->UI->scanAll(); + } +} + +int ambaplugin::registermenu(QMainWindow *menuHolder) +{ + this->menu = menuHolder->menuBar()->addMenu(tr("&ambaplugin")); + this->closeAction = this->menu->addAction(tr("Close plugin")); + QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); + return 1; +} + + + +unsigned int ambaplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(parent!=NULL) + return parent->Read(Value,count,address); + return 0; +} + +unsigned int ambaplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) +{ + if(parent!=NULL) + return parent->Write(Value,count,address); + return 0; +} + + + + + + + + diff --git a/ambaplugin/ambaplugin.h b/ambaplugin/ambaplugin.h new file mode 100644 --- /dev/null +++ b/ambaplugin/ambaplugin.h @@ -0,0 +1,56 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2012, 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 +----------------------------------------------------------------------------*/ +#ifndef ambaplugin_H +#define ambaplugin_H +#include +#include +#include +#include +#include "ambapluginui.h" +#include + + + +class ambaplugin : public socexplorerplugin +{ + Q_OBJECT +public: + explicit ambaplugin(QWidget *parent = 0); + ~ambaplugin(); + int registermenu(QMainWindow *menuHolder); + int VID(){return driver_VID;} + int PID(){return driver_PID;} + +public slots: + unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); + void closeMe(); + void postInstantiationTrigger(); + void activatePlugin(bool flag); +signals: + +private: + ambaPluginUI* UI; +}; + +#endif // ambaplugin_H + diff --git a/ambaplugin/ambaplugin.pro b/ambaplugin/ambaplugin.pro new file mode 100644 --- /dev/null +++ b/ambaplugin/ambaplugin.pro @@ -0,0 +1,68 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin +CONFIG += dll +CONFIG -= static +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"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" +DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" +DEFINES += driver_Description="\"\\\"This driver handles the Gaisler AMBA plugn' play system."\\\"\" +DEFINES += driver_can_be_root=0 +DEFINES += driver_can_be_child=1 +DEFINES += driver_VID=0 +DEFINES += driver_PID=0 + +INCLUDEPATH += \ + $${PWD} + +HEADERS += \ + ambaplugin.h \ + AHB/ahbpluginui.h \ + AHB/ahbdevicelist.h \ + APB/apbpluginui.h \ + APB/apbdevicelist.h \ + ambapluginui.h + + +SOURCES += \ + ambaplugin.cpp \ + AHB/ahbpluginui.cpp \ + AHB/ahbdevicelist.cpp \ + APB/apbpluginui.cpp \ + APB/apbdevicelist.cpp \ + ambapluginui.cpp + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ambaplugin/ambapluginui.cpp b/ambaplugin/ambapluginui.cpp new file mode 100644 --- /dev/null +++ b/ambaplugin/ambapluginui.cpp @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2012, 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 "ambapluginui.h" + +ambaPluginUI::ambaPluginUI(socexplorerplugin *plugin, QWidget *parent) : + QWidget(parent) +{ + this->mainLayout=new QGridLayout(); + this->ahbPlugin=new ahbPluginUi(plugin); + this->apbPlugin=new apbPluginUi(plugin); + this->mainLayout->addWidget(this->ahbPlugin,0,0,1,-1); + this->mainLayout->addWidget(this->apbPlugin,1,0,1,-1); + this->setLayout(this->mainLayout); + connect(this->ahbPlugin,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); + connect(this->ahbPlugin,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); + connect(this->apbPlugin,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); + connect(this->apbPlugin,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); +} + +void ambaPluginUI::scanAll() +{ + this->ahbPlugin->scanAHB(); + this->apbPlugin->scanAPB(); +} diff --git a/ambaplugin/ambapluginui.h b/ambaplugin/ambapluginui.h new file mode 100644 --- /dev/null +++ b/ambaplugin/ambapluginui.h @@ -0,0 +1,49 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2012, 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 +----------------------------------------------------------------------------*/ +#ifndef AMBAPLUGINUI_H +#define AMBAPLUGINUI_H + +#include +#include +#include +#include +#include "AHB/ahbpluginui.h" +#include "APB/apbpluginui.h" + +class ambaPluginUI : public QWidget +{ + Q_OBJECT +public: + explicit ambaPluginUI(socexplorerplugin* plugin,QWidget *parent = 0); + +signals: + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); +public slots: + void scanAll(); +private: + QGridLayout* mainLayout; + ahbPluginUi* ahbPlugin; + apbPluginUi* apbPlugin; +}; + +#endif // AMBAPLUGINUI_H diff --git a/dsu3plugin/dsu3plugin.cpp b/dsu3plugin/dsu3plugin.cpp new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3plugin.cpp @@ -0,0 +1,226 @@ +/*------------------------------------------------------------------------------ +-- 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 "dsu3plugin.h" +#include +#include +#include "dsu3pluginpywrapper.h" +#include + +dsu3plugin::dsu3plugin(QWidget *parent):socexplorerplugin(parent,false) +{ + this->UI = new dsu3pluginui(); + this->setWindowTitle(tr("DSU3 Driver")); + 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())); + connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); + connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); + connect(this->UI,SIGNAL(run()),this,SLOT(run())); + connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); +} + + +dsu3plugin::~dsu3plugin() +{ + +} + + +void dsu3plugin::openFile() +{ + QString filename = QFileDialog::getOpenFileName(this,tr("Open elf File"), QDir::homePath(), tr("Elf Files (*)")); + if(filename!="") + { + this->openFile(filename); + } +} + +void dsu3plugin::openFile(QString fileName) +{ + 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) + 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); + + //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()<<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); + + //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; +} + +bool dsu3plugin::flashTarget() +{ + 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); +} + +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); +} + +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;i0;i--) + { + buff[sizeInt] = (buff[sizeInt]<<8) + (0x0FF & ((unsigned int)buffch[size-i])); + } + sizeInt++; + } + 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++) + { + 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); + } + } +} + + +unsigned int dsu3plugin::Write(unsigned int *Value,unsigned int count,unsigned int address) +{ + 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) + { + memset((void*)buffer,value,count*sizeof(unsigned int)); + parent->Write(buffer,count,address); + free(buffer ); + return true; + } + 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; +} diff --git a/dsu3plugin/dsu3plugin.h b/dsu3plugin/dsu3plugin.h new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3plugin.h @@ -0,0 +1,61 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2012, 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 +----------------------------------------------------------------------------*/ +#ifndef DSU3PLUGIN_H +#define DSU3PLUGIN_H +#include "dsu3pluginui.h" +#include +#include +#include +#include +#include +#include "elfparser.h" +#include +#include + +typedef QList uIntlist; + +class dsu3plugin : public socexplorerplugin +{ + Q_OBJECT +public: + explicit dsu3plugin(QWidget *parent = 0); + ~dsu3plugin(); + bool memSet(unsigned int address, int value, unsigned int count); +public slots: + unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); + void openFile(); + void openFile(QString fileName); + bool configureTarget(); + bool flashTarget(); + void run(); +signals: + void updateInfo(elfparser* parser); +private: + void WriteRegs(uIntlist Values, unsigned int address); + void writeSection(int index); + void writeSection(const QString& name); + dsu3pluginui* UI; + elfparser* elfparserInst; +}; + +#endif // DSU3PLUGIN_H diff --git a/dsu3plugin/dsu3plugin.pro b/dsu3plugin/dsu3plugin.pro new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3plugin.pro @@ -0,0 +1,75 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin + +TEMPLATE = lib + +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} + +DEFINES += PLUGIN=dsu3plugin +DEFINES += PLUGINHEADER="\"\\\"dsu3plugin.h"\\\"\" +DEFINES += driver_Name="\"\\\"dsu3plugin"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" +DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" +DEFINES += driver_Description="\"\\\"DSU driver, works with GAISLER's DSU3 unit."\\\"\" +DEFINES += driver_can_be_root=0 +DEFINES += driver_can_be_child=1 +DEFINES += driver_VID=0x00 +DEFINES += driver_PID=0x00 + + +INCLUDEPATH += \ + $${PWD} + + + +HEADERS += \ + dsu3plugin.h \ + dsu3pluginui.h \ + dsu3pluginpywrapper.h + +SOURCES += \ + dsu3plugin.cpp \ + dsu3pluginui.cpp \ + dsu3pluginpywrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dsu3plugin/dsu3pluginpywrapper.cpp b/dsu3plugin/dsu3pluginpywrapper.cpp new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3pluginpywrapper.cpp @@ -0,0 +1,6 @@ +#include "dsu3pluginpywrapper.h" + +dsu3pluginPywrapper::dsu3pluginPywrapper(socexplorerplugin *parent) : + genericPySysdriver(parent) +{ +} diff --git a/dsu3plugin/dsu3pluginpywrapper.h b/dsu3plugin/dsu3pluginpywrapper.h new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3pluginpywrapper.h @@ -0,0 +1,19 @@ +#ifndef DSU3PLUGINPYWRAPPER_H +#define DSU3PLUGINPYWRAPPER_H +#include + +class dsu3pluginPywrapper : public genericPySysdriver +{ + Q_OBJECT +public: + explicit dsu3pluginPywrapper(socexplorerplugin *parent = 0); + +signals: + bool openFile(QString fileName); + bool loadFile(); + bool run(); +public slots: + +}; + +#endif // DSU3PLUGINPYWRAPPER_H diff --git a/dsu3plugin/dsu3pluginui.cpp b/dsu3plugin/dsu3pluginui.cpp new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3pluginui.cpp @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2013, 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 + +dsu3pluginui::dsu3pluginui(QWidget *parent) + :QWidget(parent) +{ + this->openFileQpb = new QPushButton(tr("Open File")); + this->flashTargetQpb = new QPushButton(tr("Flash Target")); + this->runQpb = new QPushButton(tr("Run")); + this->mainLayout = new QGridLayout(); + this->elfInfoWdgtInst = new elfInfoWdgt; + this->mainLayout->addWidget(this->openFileQpb,0,0,1,1); + this->mainLayout->addWidget(this->flashTargetQpb,0,1,1,1); + this->mainLayout->addWidget(this->runQpb,0,2,1,1); + this->mainLayout->addWidget(this->elfInfoWdgtInst,1,0,1,-1); + this->setLayout(this->mainLayout); + connect(this->openFileQpb,SIGNAL(clicked()),this,SIGNAL(openFile())); + connect(this->flashTargetQpb,SIGNAL(clicked()),this,SIGNAL(flashTarget())); + connect(this->runQpb,SIGNAL(clicked()),this,SIGNAL(run())); + connect(this,SIGNAL(updateInfo(elfparser*)),this->elfInfoWdgtInst,SLOT(updateInfo(elfparser*))); + +} + + + + + + + + + + + diff --git a/dsu3plugin/dsu3pluginui.h b/dsu3plugin/dsu3pluginui.h new file mode 100644 --- /dev/null +++ b/dsu3plugin/dsu3pluginui.h @@ -0,0 +1,58 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2012, 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 +----------------------------------------------------------------------------*/ +#ifndef DSU3PLUGINUI_H +#define DSU3PLUGINUI_H + +#include +#include +#include +#include +#include +#include +#include +#include "elfinfowdgt.h" + +class dsu3pluginui : public QWidget +{ + Q_OBJECT +public: + explicit dsu3pluginui(QWidget *parent = 0); + +public slots: + +signals: + void openFile(); + void updateInfo(elfparser* parser); + bool flashTarget(); + void run(); +private: + QGridLayout* mainLayout; + QPushButton* openFileQpb; + QPushButton* flashTargetQpb; + QPushButton* runQpb; + elfInfoWdgt* elfInfoWdgtInst; + +}; + +#endif // DSU3PLUGINUI_H + + diff --git a/genericrwplugin/genericrwplugin.cpp b/genericrwplugin/genericrwplugin.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwplugin.cpp @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------------ +-- 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 "genericrwplugin.h" +#include "genericrwpluginpywrapper.h" +genericrwplugin::genericrwplugin(QWidget *parent):socexplorerplugin(parent,false) +{ + this->UI = new genericrwpluginUi(); + this->setWindowTitle(tr("Generic Driver")); + this->setWidget((QWidget*)this->UI); + connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); + connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); + this->pyObject = new genericRWpluginPyWrapper(this); + //QObject::connect(this->pyObject,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); + //QObject::connect(this->pyObject,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); + QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(refresh()),this->UI,SIGNAL(refresh())); + QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setAddress(quint32)),this->UI,SIGNAL(setAddress(quint32))); + QObject::connect(((genericRWpluginPyWrapper*)this->pyObject),SIGNAL(setLength(quint32)),this->UI,SIGNAL(setLength(quint32))); +} + +genericrwplugin::~genericrwplugin() +{} + +int genericrwplugin::registermenu(QMainWindow *menuHolder) +{ + this->menu = menuHolder->menuBar()->addMenu(tr("&Generic RW Driver")); + this->closeAction = this->menu->addAction(tr("Close plugin")); + QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); + return 1; +} + +unsigned int genericrwplugin::Write(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(parent!=NULL) + return parent->Write(Value,count,address); + return 0; +} + +unsigned int genericrwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(parent!=NULL) + return parent->Read(Value,count,address); + return 0; +} diff --git a/genericrwplugin/genericrwplugin.h b/genericrwplugin/genericrwplugin.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwplugin.h @@ -0,0 +1,56 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef GENERICRWPLUGIN_H +#define GENERICRWPLUGIN_H +#include "genericrwpluginui.h" +#include +#include +#include +#include + + + +#include + +#define AHB_PLUGNPLAY_MASTER_START 0xFFFFF000 +#define AHB_PLUGNPLAY_MASTER_STOP 0xFFFFF800 +#define AHB_PLUGNPLAY_SLAVE_START 0xFFFFF800 +#define AHB_PLUGNPLAY_SLAVE_STOP 0xFFFFFFFC + + +class genericrwplugin : public socexplorerplugin +{ + Q_OBJECT +public: + explicit genericrwplugin(QWidget *parent = 0); + ~genericrwplugin(); + int registermenu(QMainWindow *menuHolder); +public slots: + unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); +signals: + +private: + genericrwpluginUi* UI; +}; + +#endif // GENERICRWPLUGIN_H diff --git a/genericrwplugin/genericrwplugin.pro b/genericrwplugin/genericrwplugin.pro new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwplugin.pro @@ -0,0 +1,59 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin +CONFIG += dll +CONFIG -= static + +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"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" +DEFINES += driver_Version="\"\\\"1.1.0"\\\"\" +DEFINES += driver_Description="\"\\\"Generic plugin, gives you R/W access to any memory area."\\\"\" +DEFINES += driver_can_be_root=0 +DEFINES += driver_can_be_child=1 +DEFINES += driver_VID=0 +DEFINES += driver_PID=0 + + +INCLUDEPATH += \ + $${PWD} + +#LIBS +=-llppmoncommon$${DEBUG_EXT} + +HEADERS += \ + genericrwplugin.h \ + genericrwpluginui.h \ + rw_task.h \ + tasklist.h \ + taskeditor.h \ + memeditor.h \ + genericrwpluginpywrapper.h + +SOURCES += \ + genericrwplugin.cpp \ + genericrwpluginui.cpp \ + rw_task.cpp \ + tasklist.cpp \ + taskeditor.cpp \ + memeditor.cpp \ + genericrwpluginpywrapper.cpp + + + + + + + + + + diff --git a/genericrwplugin/genericrwpluginpywrapper.cpp b/genericrwplugin/genericrwpluginpywrapper.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwpluginpywrapper.cpp @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2014, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#include "genericrwpluginpywrapper.h" + +genericRWpluginPyWrapper::genericRWpluginPyWrapper(socexplorerplugin *parent) : + genericPySysdriver(parent) +{ +} diff --git a/genericrwplugin/genericrwpluginpywrapper.h b/genericrwplugin/genericrwpluginpywrapper.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwpluginpywrapper.h @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the LPPMON Software +-- Copyright (C) 2014, 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@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef GENERICRWPLUGINPYWRAPPER_H +#define GENERICRWPLUGINPYWRAPPER_H +#include +class genericRWpluginPyWrapper : public genericPySysdriver +{ + Q_OBJECT +public: + explicit genericRWpluginPyWrapper(socexplorerplugin *parent = 0); + +signals: + void refresh(); + void setAddress(quint32 address); + void setLength(quint32 length); + +public slots: + +}; + +#endif // GENERICRWPLUGINPYWRAPPER_H diff --git a/genericrwplugin/genericrwpluginui.cpp b/genericrwplugin/genericrwpluginui.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwpluginui.cpp @@ -0,0 +1,41 @@ +/*------------------------------------------------------------------------------ +-- 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 "genericrwplugin.h" + +genericrwpluginUi::genericrwpluginUi(QWidget *parent) : + QWidget(parent) +{ + + this->mainlayout = new QHBoxLayout; + this->tabWdgt = new QTabWidget; + this->mainlayout->addWidget(this->tabWdgt); + this->memEditorWdgt = new memEditor; + this->tabWdgt->addTab(this->memEditorWdgt,tr("Memory editor")); + this->setLayout(this->mainlayout); + connect(this->memEditorWdgt,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); + connect(this->memEditorWdgt,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); + connect(this,SIGNAL(refresh()),this->memEditorWdgt,SLOT(readMemSlt())); + connect(this,SIGNAL(setAddress(quint32)),this->memEditorWdgt,SLOT(setAddress(quint32))); + connect(this,SIGNAL(setLength(quint32)),this->memEditorWdgt,SLOT(setLength(quint32))); + +} + diff --git a/genericrwplugin/genericrwpluginui.h b/genericrwplugin/genericrwpluginui.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/genericrwpluginui.h @@ -0,0 +1,55 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef AHBPLUGINUI_H +#define AHBPLUGINUI_H + +#include +#include +#include +#include +#include "tasklist.h" +#include "memeditor.h" +#include + + +class genericrwpluginUi : public QWidget +{ + Q_OBJECT +public: + explicit genericrwpluginUi(QWidget *parent = 0); + +signals: + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); + void refresh(); + void setAddress(quint32 address); + void setLength(quint32 length); + +private: + QSplitter* verticalSpliter; + QHBoxLayout* mainlayout; + QTabWidget* tabWdgt; + memEditor* memEditorWdgt; + +}; + +#endif // AHBPLUGINUI_H diff --git a/genericrwplugin/memeditor.cpp b/genericrwplugin/memeditor.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/memeditor.cpp @@ -0,0 +1,98 @@ +/*------------------------------------------------------------------------------ +-- 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 "memeditor.h" +#include "malloc.h" + +memEditor::memEditor(QWidget *parent) : + QWidget(parent) +{ + this->verticalSpliter = new QSplitter; + this->ctrlWidget = new QWidget; + this->verticalSpliter->setOrientation(Qt::Horizontal); + this->mainLayout = new QHBoxLayout; + this->ctrlLayout = new QVBoxLayout; + this->hexEditor = new QHexEdit; + this->addressSpnBx = new QHexSpinBox; + this->SizeWidget = new MemSizeWdgt(256); + this->readMemQPb = new QPushButton(tr("Read Mem")); + this->writeMemQPb = new QPushButton(tr("Write Mem")); + this->ctrlLayout->addWidget(this->addressSpnBx); + this->ctrlLayout->addWidget(this->SizeWidget); + this->ctrlLayout->addWidget(this->readMemQPb); + this->ctrlLayout->addWidget(this->writeMemQPb); + this->ctrlWidget->setLayout(this->ctrlLayout); + this->verticalSpliter->addWidget(this->hexEditor); + this->verticalSpliter->addWidget(this->ctrlWidget); + this->mainLayout->addWidget(this->verticalSpliter); + this->setLayout(this->mainLayout); + connect(this->readMemQPb,SIGNAL(clicked()),this,SLOT(readMemSlt())); + connect(this->writeMemQPb,SIGNAL(clicked()),this,SLOT(writeMemSlt())); + this->SizeWidget->setMaximum(16384); +} + +void memEditor::writeMemSlt() +{ + + QByteArray data = this->hexEditor->data(); + unsigned int length = data.length()/4; + unsigned int* buffer=(unsigned int*)malloc(length*sizeof(int)); + unsigned int address = this->hexEditor->addressOffset(); + for(int i=0;(unsigned int)iWriteSig(buffer,length,address); + free(buffer); +} + +void memEditor::setAddress(quint32 address) +{ + this->addressSpnBx->setValue(address); +} + +void memEditor::setLength(quint32 length) +{ + this->SizeWidget->setSizeValue(length); +} + +void memEditor::readMemSlt() +{ + this->SizeWidget->updateSizeValue(); + unsigned int size = this->SizeWidget->getsize()/4; + unsigned int buffer[16384]; + unsigned char buffChar[16384*4]; + unsigned int address = this->addressSpnBx->value(); + if((emit this->ReadSig(buffer,size,address&(-4)))==size) + { + for(int i=0;(unsigned int)i>24)&0xFF; + buffChar[(4*i)+1]=(buffer[i]>>16)&0xFF; + buffChar[(4*i)+2]=(buffer[i]>>8)&0xFF; + buffChar[(4*i)+3]=(buffer[i])&0xFF; + } + QByteArray data = QByteArray((char*)buffChar,size*4); + this->hexEditor->setData(data); + this->hexEditor->setAddressOffset(address&(-4)); + this->addressSpnBx->setValue(address&(-4)); + } +} diff --git a/genericrwplugin/memeditor.h b/genericrwplugin/memeditor.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/memeditor.h @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef MEMEDITOR_H +#define MEMEDITOR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class memEditor : public QWidget +{ + Q_OBJECT +public: + explicit memEditor(QWidget *parent = 0); + +signals: + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); + +public slots: + void readMemSlt(); + void writeMemSlt(); + void setAddress(quint32 address); + void setLength(quint32 length); +private: + QWidget* ctrlWidget; + QSplitter* verticalSpliter; + QHBoxLayout* mainLayout; + QVBoxLayout* ctrlLayout; + QHexEdit* hexEditor; + QHexSpinBox* addressSpnBx; + QPushButton* readMemQPb; + QPushButton* writeMemQPb; + MemSizeWdgt* SizeWidget; +}; + +#endif // MEMEDITOR_H diff --git a/genericrwplugin/rw_task.cpp b/genericrwplugin/rw_task.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/rw_task.cpp @@ -0,0 +1,26 @@ +/*------------------------------------------------------------------------------ +-- 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 "rw_task.h" + +RW_Task::RW_Task() +{ +} diff --git a/genericrwplugin/rw_task.h b/genericrwplugin/rw_task.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/rw_task.h @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef RW_TASK_H +#define RW_TASK_H +#include + + +typedef enum {readTask,writeTask}taskTypeT; + +class RW_Task +{ +public: + RW_Task(); + taskTypeT taskType; + +private: + QString dataStr; + unsigned int* data; + unsigned int length; + unsigned int address; + +}; + +#endif // RW_TASK_H diff --git a/genericrwplugin/taskeditor.cpp b/genericrwplugin/taskeditor.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/taskeditor.cpp @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------------ +-- 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 "taskeditor.h" + +taskEditor::taskEditor(QWidget *parent) : + QWidget(parent) +{ +} diff --git a/genericrwplugin/taskeditor.h b/genericrwplugin/taskeditor.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/taskeditor.h @@ -0,0 +1,39 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef TASKEDITOR_H +#define TASKEDITOR_H + +#include + +class taskEditor : public QWidget +{ + Q_OBJECT +public: + explicit taskEditor(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // TASKEDITOR_H diff --git a/genericrwplugin/tasklist.cpp b/genericrwplugin/tasklist.cpp new file mode 100644 --- /dev/null +++ b/genericrwplugin/tasklist.cpp @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------------ +-- 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 "tasklist.h" + +tasklist::tasklist(QWidget *parent) : + QTableWidget(parent) +{ +} diff --git a/genericrwplugin/tasklist.h b/genericrwplugin/tasklist.h new file mode 100644 --- /dev/null +++ b/genericrwplugin/tasklist.h @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef TASKLIST_H +#define TASKLIST_H + +#include +#include + +class tasklist : public QTableWidget +{ + Q_OBJECT +public: + explicit tasklist(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // TASKLIST_H diff --git a/memctrlrplugin/genericmemoryspacecheck.cpp b/memctrlrplugin/genericmemoryspacecheck.cpp new file mode 100644 --- /dev/null +++ b/memctrlrplugin/genericmemoryspacecheck.cpp @@ -0,0 +1,61 @@ +#include "genericmemoryspacecheck.h" + +genericmemoryspacecheck::genericmemoryspacecheck( const QString Name, unsigned int baseAddress, unsigned int size,QWidget *parent): + QWidget(parent) +{ + this->mainLayout = new QVBoxLayout; + this->secondLayout = new QHBoxLayout; + this->MemoryName = new QLabel(Name); + this->AddrQHspBx = new QHexSpinBox; + this->AddrQHspBx->setValue(baseAddress); + this->MemSize=new MemSizeWdgt(size); + this->LaunchtestQPB = new QPushButton(tr("Start Test")); + this->result = new QLabel(tr("Test result: Start test")); + this->mainLayout->addWidget(this->MemoryName); + this->secondLayout->addWidget(this->AddrQHspBx); + this->secondLayout->addWidget(this->MemSize); + this->secondLayout->addWidget(this->LaunchtestQPB); + this->mainLayout->addLayout(this->secondLayout); + this->mainLayout->addWidget(this->result); + this->setLayout(this->mainLayout); + connect(this->LaunchtestQPB,SIGNAL(clicked()),this,SLOT(launchTestSlt())); +} + + +bool genericmemoryspacecheck::launchTest(genericmemoryspacecheck* instance,unsigned int baseAddress,unsigned int size) +{ + unsigned int* dataLocal = (unsigned int*)malloc(size); + unsigned int* dataOnBoard = (unsigned int*)malloc(size); + bool res=true; + for(int i=0;(unsigned int)i<(size>>2);i++) + { + dataLocal[i]= (0xFFFF&rand())+(rand()<<16); + } + emit instance->WriteSig(dataLocal,size>>2,baseAddress); + emit instance->ReadSig(dataOnBoard,size>>2,baseAddress); + for(int i=0;(unsigned int)i<(size>>2);i++) + { + if(dataLocal[i]!=dataOnBoard[i]) + res=false; + } + + free(dataLocal); + free(dataOnBoard); + return res; +} + + +void genericmemoryspacecheck::launchTestSlt() +{ + this->result->setText(tr("Test result: Pending")); + if(this->launchTest(this,this->AddrQHspBx->value(),this->MemSize->getsize())) + this->result->setText(tr("Test result: Success")); + else + this->result->setText(tr("Test result: failed")); +} + + + + + + diff --git a/memctrlrplugin/genericmemoryspacecheck.h b/memctrlrplugin/genericmemoryspacecheck.h new file mode 100644 --- /dev/null +++ b/memctrlrplugin/genericmemoryspacecheck.h @@ -0,0 +1,36 @@ +#ifndef GENERICMEMORYSPACECHECK_H +#define GENERICMEMORYSPACECHECK_H + +#include +#include +#include +#include +#include +#include +#include + + +class genericmemoryspacecheck : public QWidget +{ + Q_OBJECT +public: + explicit genericmemoryspacecheck(const QString Name,unsigned int baseAddress,unsigned int size,QWidget *parent = 0); + static bool launchTest(genericmemoryspacecheck* instance,unsigned int baseAddress,unsigned int size); + +signals: + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); +public slots: + void launchTestSlt(); +private: + QVBoxLayout* mainLayout; + QHBoxLayout* secondLayout; + QLabel* MemoryName; + QHexSpinBox* AddrQHspBx; + MemSizeWdgt* MemSize; + QPushButton* LaunchtestQPB; + QLabel* result; + +}; + +#endif // GENERICMEMORYSPACECHECK_H diff --git a/memctrlrplugin/memctrlrplugin.cpp b/memctrlrplugin/memctrlrplugin.cpp new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrplugin.cpp @@ -0,0 +1,86 @@ +/*------------------------------------------------------------------------------ +-- 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 "memctrlrplugin.h" +#include "memctrlrpywrapper.h" + +memctrlrplugin::memctrlrplugin(QWidget *parent):socexplorerplugin(parent,false) +{ + this->UI = new memctrlrPluginUi(); + this->setWindowTitle(tr("Memctrlr Driver")); + this->setWidget((QWidget*)this->UI); + connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); + connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); + this->pyObject = new memctrlrPyWrapper(this); + connect(this->pyObject,SIGNAL(launchTest(uint,uint)),this,SLOT(launchTest(uint,uint))); +} + +memctrlrplugin::~memctrlrplugin() +{} + +int memctrlrplugin::registermenu(QMainWindow *menuHolder) +{ + this->menu = menuHolder->menuBar()->addMenu(tr("&Memory Controler")); + this->closeAction = this->menu->addAction(tr("Close plugin")); + QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); + return 1; +} + +unsigned int memctrlrplugin::Write(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(parent) + return parent->Write(Value,count,address); + return 0; +} + +unsigned int memctrlrplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(parent) + return parent->Read(Value,count,address); + return 0; +} + + +bool memctrlrplugin::launchTest(unsigned int baseAddress,unsigned int size) +{ + if(parent==NULL)return false; + unsigned int* dataLocal = (unsigned int*)malloc(size); + unsigned int* dataOnBoard = (unsigned int*)malloc(size); + bool res=true; + for(int i=0;(unsigned int)i<(size>>2);i++) + { + dataLocal[i]= (0xFFFF&rand())+(rand()<<16); + } + parent->Write(dataLocal,size>>2,baseAddress); + parent->Read(dataOnBoard,size>>2,baseAddress); + for(int i=0;(unsigned int)i<(size>>2);i++) + { + if(dataLocal[i]!=dataOnBoard[i]) + res=false; + } + + free(dataLocal); + free(dataOnBoard); + return res; +} + + + diff --git a/memctrlrplugin/memctrlrplugin.h b/memctrlrplugin/memctrlrplugin.h new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrplugin.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef MEMCTRLRPLUGIN_H +#define MEMCTRLRPLUGIN_H +#include "memctrlrpluginui.h" +#include +#include +#include +#include + + +#include + +class memctrlrplugin : public socexplorerplugin +{ + Q_OBJECT +public: + explicit memctrlrplugin(QWidget *parent = 0); + ~memctrlrplugin(); + int registermenu(QMainWindow *menuHolder); +public slots: + unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); + bool launchTest(unsigned int baseAddress,unsigned int size); +signals: + +private: + memctrlrPluginUi* UI; +}; + +#endif // MEMCTRLRPLUGIN_H diff --git a/memctrlrplugin/memctrlrplugin.pro b/memctrlrplugin/memctrlrplugin.pro new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrplugin.pro @@ -0,0 +1,73 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin +CONFIG += dll +CONFIG -= static + +CONFIG(debug, debug|release) { + DEBUG_EXT = _d +} else { + DEBUG_EXT = +} + +TARGET = memctrlrplugin$${DEBUG_EXT} +DEFINES += PLUGIN=memctrlrplugin +DEFINES += PLUGINHEADER="\"\\\"memctrlrplugin.h"\\\"\" +DEFINES += driver_Name="\"\\\"MemControler"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\" +DEFINES += driver_Version="\"\\\"1.0.1"\\\"\" +DEFINES += driver_Description="\"\\\"Memory controler driver, works with ESA's LEON2 memory controler."\\\"\" +DEFINES += driver_can_be_root=0 +DEFINES += driver_can_be_child=1 +DEFINES += driver_VID=0x04 +DEFINES += driver_PID=0x0f + +#LIBS +=-llppmoncommon + +INCLUDEPATH += \ + $${PWD} + +HEADERS += \ + memctrlrplugin.h \ + memctrlrpluginui.h \ + memorycheck.h \ + genericmemoryspacecheck.h \ + memctrlrpywrapper.h + +SOURCES += \ + memctrlrplugin.cpp \ + memctrlrpluginui.cpp \ + memorycheck.cpp \ + genericmemoryspacecheck.cpp \ + memctrlrpywrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/memctrlrplugin/memctrlrpluginui.cpp b/memctrlrplugin/memctrlrpluginui.cpp new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrpluginui.cpp @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------------ +-- 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 "memctrlrpluginui.h" + +memctrlrPluginUi::memctrlrPluginUi(QWidget *parent) : + QWidget(parent) +{ + this->mainlayout = new QHBoxLayout; + this->memorycheckWdgt = new memorycheck; + this->tabWdgt = new QTabWidget; + this->tabWdgt->addTab(this->memorycheckWdgt,QString(tr("Memory Check"))); + this->mainlayout->addWidget(this->tabWdgt); + this->setLayout(this->mainlayout); + connect(this->memorycheckWdgt,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); + connect(this->memorycheckWdgt,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); +} + diff --git a/memctrlrplugin/memctrlrpluginui.h b/memctrlrplugin/memctrlrpluginui.h new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrpluginui.h @@ -0,0 +1,49 @@ +/*------------------------------------------------------------------------------ +-- 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 +----------------------------------------------------------------------------*/ +#ifndef MEMCTRLRPLUGINUI_H +#define MEMCTRLRPLUGINUI_H + +#include +#include +#include +#include +#include "memorycheck.h" + + +class memctrlrPluginUi : public QWidget +{ + Q_OBJECT +public: + explicit memctrlrPluginUi(QWidget *parent = 0); + +signals: + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); + +private: + QHBoxLayout* mainlayout; + QTabWidget* tabWdgt; + memorycheck* memorycheckWdgt; + +}; + +#endif diff --git a/memctrlrplugin/memctrlrpywrapper.cpp b/memctrlrplugin/memctrlrpywrapper.cpp new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrpywrapper.cpp @@ -0,0 +1,6 @@ +#include "memctrlrpywrapper.h" + +memctrlrPyWrapper::memctrlrPyWrapper(socexplorerplugin *parent) : + genericPySysdriver(parent) +{ +} diff --git a/memctrlrplugin/memctrlrpywrapper.h b/memctrlrplugin/memctrlrpywrapper.h new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memctrlrpywrapper.h @@ -0,0 +1,17 @@ +#ifndef MEMCTRLRPYWRAPPER_H +#define MEMCTRLRPYWRAPPER_H +#include + +class memctrlrPyWrapper : public genericPySysdriver +{ + Q_OBJECT +public: + explicit memctrlrPyWrapper(socexplorerplugin *parent = 0); + +signals: + bool launchTest(unsigned int baseAddress,unsigned int size); +public slots: + +}; + +#endif // MEMCTRLRPYWRAPPER_H diff --git a/memctrlrplugin/memorycheck.cpp b/memctrlrplugin/memorycheck.cpp new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memorycheck.cpp @@ -0,0 +1,16 @@ +#include "memorycheck.h" + +memorycheck::memorycheck(QWidget *parent) : + QWidget(parent) +{ + this->mainLayout = new QVBoxLayout; + this->ROMcheck=new genericmemoryspacecheck(QString("ROM"),0,512*1024*1024); + this->SRAMcheck =new genericmemoryspacecheck(QString("SRAM"),0x40000000,512*1024*1024); + this->mainLayout->addWidget(this->ROMcheck); + this->mainLayout->addWidget(this->SRAMcheck); + this->setLayout(this->mainLayout); + connect(this->ROMcheck,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); + connect(this->ROMcheck,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); + connect(this->SRAMcheck,SIGNAL(ReadSig(uint*,uint,uint)),this,SIGNAL(ReadSig(uint*,uint,uint))); + connect(this->SRAMcheck,SIGNAL(WriteSig(uint*,uint,uint)),this,SIGNAL(WriteSig(uint*,uint,uint))); +} diff --git a/memctrlrplugin/memorycheck.h b/memctrlrplugin/memorycheck.h new file mode 100644 --- /dev/null +++ b/memctrlrplugin/memorycheck.h @@ -0,0 +1,28 @@ +#ifndef MEMORYCHECK_H +#define MEMORYCHECK_H + +#include +#include +#include "genericmemoryspacecheck.h" +#include +#include + + +class memorycheck : public QWidget +{ + Q_OBJECT +public: + explicit memorycheck(QWidget *parent = 0); + +signals: + unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address); + unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address); +public slots: +private: + QVBoxLayout* mainLayout; + genericmemoryspacecheck* ROMcheck; + genericmemoryspacecheck* SRAMcheck; + +}; + +#endif // MEMORYCHECK_H diff --git a/spwplugin/abstractspwbridge.cpp b/spwplugin/abstractspwbridge.cpp new file mode 100644 --- /dev/null +++ b/spwplugin/abstractspwbridge.cpp @@ -0,0 +1,29 @@ +#include "abstractspwbridge.h" + +abstractSpwBridge::abstractSpwBridge(socexplorerplugin *parent) + :QObject((QObject*)parent) +{ + this->plugin = parent; +} + +QWidget *abstractSpwBridge::getGUI() +{ + return this->p_GUI; +} + +bool abstractSpwBridge::connectBridge() +{ + return false; +} + +bool abstractSpwBridge::disconnectBridge() +{ + return false; +} + + + + + + + diff --git a/spwplugin/abstractspwbridge.h b/spwplugin/abstractspwbridge.h new file mode 100644 --- /dev/null +++ b/spwplugin/abstractspwbridge.h @@ -0,0 +1,29 @@ +#ifndef ABSTRACTSPWBRIDGE_H +#define ABSTRACTSPWBRIDGE_H + +#include +#include +#define RMAP_MAX_XFER_SIZE 3000 //slightly less than 16kBytes +#include + +class abstractSpwBridge : public QObject +{ + Q_OBJECT +public: + explicit abstractSpwBridge(socexplorerplugin *parent); + QWidget *getGUI(); + +public slots: + virtual bool connectBridge(); + virtual bool disconnectBridge(); + virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; + virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; + virtual int pushRMAPPacket(char* packet,int size)=0; +protected: + socexplorerplugin* plugin; + QWidget* p_GUI; +private: + +}; + +#endif // ABSTRACTSPWBRIDGE_H diff --git a/spwplugin/spw.h b/spwplugin/spw.h new file mode 100644 --- /dev/null +++ b/spwplugin/spw.h @@ -0,0 +1,192 @@ +#ifndef SPW_H +#define SPW_H +#include + +/* +███████╗██████╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ███╗███╗ ███╗ ██████╗ ███╗ ██╗ +██╔════╝██╔══██╗██║ ██║ ██╔════╝██╔═══██╗████╗ ████║████╗ ████║██╔═══██╗████╗ ██║ +███████╗██████╔╝██║ █╗ ██║ ██║ ██║ ██║██╔████╔██║██╔████╔██║██║ ██║██╔██╗ ██║ +╚════██║██╔═══╝ ██║███╗██║ ██║ ██║ ██║██║╚██╔╝██║██║╚██╔╝██║██║ ██║██║╚██╗██║ +███████║██║ ╚███╔███╔╝ ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║╚██████╔╝██║ ╚████║ +╚══════╝╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ +*/ + +enum SPW_PROTOCOL_IDs{ + SPW_PROTO_ID_EXTEND =0, + SPW_PROTO_ID_RMAP = 1, + SPW_PROTO_ID_CCSDS = 2, + SPW_PROTO_ID_GOES_R = 238, + SPW_PROTO_ID_STUP = 239 +}; + +static const unsigned char SPW_CRCTable[] = { + 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, + 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, + 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69, + 0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67, + 0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d, + 0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43, + 0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51, + 0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f, + 0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05, + 0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b, + 0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19, + 0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17, + 0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d, + 0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33, + 0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21, + 0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f, + 0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95, + 0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b, + 0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89, + 0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87, + 0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad, + 0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3, + 0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1, + 0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf, + 0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5, + 0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb, + 0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9, + 0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7, + 0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd, + 0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3, + 0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1, + 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf +}; + +inline unsigned char _spw_CRC_(unsigned char INCR, unsigned char INBYTE) +{ + return SPW_CRCTable[INCR ^ INBYTE]; +} + +inline char spw_CRC(char* buffer, int size) +{ + unsigned char CRC = 0; + for(int i=0;i> 8); + buffer[6] = (char)(transactionID); + buffer[7] = 0; + buffer[8] = (char)(readAddress >> 24); + buffer[9] = (char)(readAddress >> 16); + buffer[10] = (char)(readAddress >> 8); + buffer[11] = (char)(readAddress); + buffer[12] = (char)(length >> 16); + buffer[13] = (char)(length >> 8); + buffer[14] = (char)(length); + buffer[15] = (char)spw_CRC(buffer,15); +} + +inline int RMAP_get_transactionID(char *packet) +{ + return ((((unsigned int)packet[5])<<8) + ((unsigned int)packet[6])); +} + + +/* + * Rmap Write command header: + * + * | Destination Logical Address | Protocol identifier | Packet type | Destination key | + * |-----------------------------|------------------------|------------------------|------------------------| + * | Source Logical Address | Transaction identifier | Transaction identifier | Extended write address | + * |-----------------------------|------------------------|------------------------|------------------------| + * | Write address MSB | Write address | Write address | Write address LSB | + * |-----------------------------|------------------------|------------------------|------------------------| + * | Data length MSB | Data length | Data length LSB | Header CRC | + * |-----------------------------|------------------------|------------------------|------------------------| + * | Data | (...) | Last data byte | Data CRC | + * |-----------------------------|------------------------|------------------------|------------------------| + * + * Packet type field: + * + * | msb + * | reserved = 0 | Comand = 1| Write = 1 | Verify data = 1 | Ack = 1 | Increment/ | Source Path | Source Path | + * | Don't Verify data = 0 | No Ack = 0 | No Inc. address | Address Length | Address Length | + * +*/ +#define RMAP_WRITE_HEADER_MIN_SZ 16 +#define RMAP_WRITE_PACKET_MIN_SZ(bytesCnt) (RMAP_WRITE_HEADER_MIN_SZ+bytesCnt+1) //header=16 + data + data CRC=1 + +inline void RMAP_build_tx_request_header(char destinationLogicalAddress, char destKey,char sourceLogicalAddress,uint16_t transactionID,int readAddress,int length,char *buffer) +{ + buffer[0] = destinationLogicalAddress; + buffer[1] = SPW_PROTO_ID_RMAP; + buffer[2] = 0b01101100; + buffer[3] = destKey; + buffer[4] = sourceLogicalAddress; + buffer[5] = (char)(transactionID >> 8); + buffer[6] = (char)(transactionID); + buffer[7] = 0; + buffer[8] = (char)(readAddress >> 24); + buffer[9] = (char)(readAddress >> 16); + buffer[10] = (char)(readAddress >> 8); + buffer[11] = (char)(readAddress); + buffer[12] = (char)(length >> 16); + buffer[13] = (char)(length >> 8); + buffer[14] = (char)(length); + buffer[15] = (char)spw_CRC(buffer,15); + buffer[16+length] = (char)spw_CRC(buffer+16,length); +} + +#endif // SPW_H diff --git a/spwplugin/spwplugin.cpp b/spwplugin/spwplugin.cpp new file mode 100644 --- /dev/null +++ b/spwplugin/spwplugin.cpp @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------------ +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ +#include "spwplugin.h" +#include "stardundeespw_usb.h" + + +spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true) +{ + Q_UNUSED(parent) + this->bridge = new stardundeeSPW_USB(this); + if(this->bridge->connectBridge()) + { + this->Connected = true; + emit this->activateSig(true); + } +} + + +spwplugin::~spwplugin() +{ + +} + + + +unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) +{ + if(Connected) + { + return bridge->Read(Value,count,address); + } + return 0; +} + +unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) +{ + if(Connected) + { + return bridge->Write(Value,count,address); + } + return 0; +} + + + + + + + + diff --git a/spwplugin/spwplugin.h b/spwplugin/spwplugin.h new file mode 100644 --- /dev/null +++ b/spwplugin/spwplugin.h @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------------ +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef spwplugin_H +#define spwplugin_H +#include +#include +#include +#include + +#include +#include + + +class spwplugin : public socexplorerplugin +{ + Q_OBJECT +public: + explicit spwplugin(QWidget *parent = 0); + ~spwplugin(); + /* You can implement the folowing function if you want to overwrite + * their default behavior + */ + /* + int registermenu(QMainWindow *menuHolder); + int isConnected(); + int connect(); + int VID(){return driver_VID;} + int PID(){return driver_PID;} + */ + +public slots: + unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); +signals: + +private: + abstractSpwBridge* bridge; + +}; + +#endif // spwplugin_H + diff --git a/spwplugin/spwplugin.pro b/spwplugin/spwplugin.pro new file mode 100644 --- /dev/null +++ b/spwplugin/spwplugin.pro @@ -0,0 +1,69 @@ +# +# Project created by QtCreator 2011-09-20T08:15:30 +# +#------------------------------------------------- + +CONFIG += socexplorerplugin +win32:CONFIG += dll +win32:CONFIG -= static +CONFIG(debug, debug|release) { + DEBUG_EXT = _d +} else { + DEBUG_EXT = +} +TARGET = spwplugin$${DEBUG_EXT} +DEFINES += PLUGIN=spwplugin +DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\" +DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\" +DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\" +DEFINES += driver_Version="\"\\\"0.0.1"\\\"\" +DEFINES += driver_Description="\"\\\"Driver description"\\\"\" +DEFINES += driver_can_be_root=1 +DEFINES += driver_can_be_child=0 +DEFINES += driver_VID=0 +DEFINES += driver_PID=0 + +STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/ + +LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \ + $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so + +INCLUDEPATH += \ + $${PWD} \ + $$STARTDUNDEEPATH/inc \ + +HEADERS += \ + spwplugin.h \ + stardundeespw_usb.h \ + abstractspwbridge.h \ + spw.h + + +SOURCES += \ + spwplugin.cpp \ + stardundeespw_usb.cpp \ + abstractspwbridge.cpp + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spwplugin/stardundeespw_usb.cpp b/spwplugin/stardundeespw_usb.cpp new file mode 100644 --- /dev/null +++ b/spwplugin/stardundeespw_usb.cpp @@ -0,0 +1,424 @@ +#include "stardundeespw_usb.h" +#include +#include + +stardundeeSPW_USB::stardundeeSPW_USB(socexplorerplugin *parent) : + abstractSpwBridge(parent) +{ + Q_UNUSED(parent) + this->manager = new stardundeeSPW_USB_Manager(parent); + this->manager->start(); +} + +bool stardundeeSPW_USB::connectBridge() +{ + return this->manager->connectBridge(); +} + +bool stardundeeSPW_USB::disconnectBridge() +{ + return this->manager->disconnectBridge(); +} + +int stardundeeSPW_USB::pushRMAPPacket(char *packet, int size) +{ + return this->manager->sendPacket(packet,size); +} + +unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address) +{ + //Add transactionID! + char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE)+1]; + writeBuffer[0]=1;//Link number + int transactionID = 0; + int written=0; + SocExplorerEngine::message(this->plugin,"Enter Write function"); + //Quite stupide loop, I guess that I always get the number of byte I asked for! + for(;count>=RMAP_MAX_XFER_SIZE;count-=RMAP_MAX_XFER_SIZE) + { + for(int i=0;i<(RMAP_MAX_XFER_SIZE);i++) + { + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char) ((unsigned int) Value[written+i]>>24); + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char) ((unsigned int) Value[written+i]>>16); + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char) ((unsigned int) Value[written+i]>>8); + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char) ((unsigned int) Value[written+i]); + } + RMAP_build_tx_request_header(254,2,1,transactionID,address+written,RMAP_MAX_XFER_SIZE*4,writeBuffer+1); + manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1); + written+=RMAP_MAX_XFER_SIZE; + } + if(count>0) + { + for(int i=0;i<((int)count);i++) + { + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+1] = (char) ((unsigned int) Value[written+i]>>24); + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+2] = (char) ((unsigned int) Value[written+i]>>16); + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char) ((unsigned int) Value[written+i]>>8); + writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char) ((unsigned int) Value[written+i]); + } + RMAP_build_tx_request_header(254,2,1,transactionID,address+written,count*4,writeBuffer+1); + manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1); + // QHexEdit* viewer = new QHexEdit(); + // viewer->setData(QByteArray(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4)+1)); + // viewer->show(); + written+=count; + } + return written; +} + +unsigned int stardundeeSPW_USB::Read(unsigned int *Value, unsigned int count, unsigned int address) +{ + //Add transactionID! + char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1]; + char* RMAP_AnswerBuffer; + requestBuffer[0]=1;//Link number + int transactionID = 0; + int read=0; +// SocExplorerEngine::message(this->plugin,"Enter read function"); + SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE)); + + //Quite stupide loop, I guess that I always get the number of byte I asked for! + while((int)count>=(int)RMAP_MAX_XFER_SIZE) + { + transactionID = manager->getRMAPtransactionID(); + SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID)); + RMAP_build_rx_request_header(254,2,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1); + manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); + int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); + for(int i=0;i<(len/4);i++) + { + Value[read+i]=((unsigned int)(RMAP_AnswerBuffer[i])<<24) + ((unsigned int)(RMAP_AnswerBuffer[i+1])<<16) + ((unsigned int)(RMAP_AnswerBuffer[i+2])<<8) + ((unsigned int)(RMAP_AnswerBuffer[i+3])); + } + free(RMAP_AnswerBuffer); + read+=RMAP_MAX_XFER_SIZE; + count-=RMAP_MAX_XFER_SIZE; + } + if((int)count>0) + { + transactionID = manager->getRMAPtransactionID(); + SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID)); + SocExplorerEngine::message(this->plugin,QString("Building request with:")); + SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16)); + SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4)); + SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13)); + RMAP_build_rx_request_header(254,2,1,transactionID,address+(read*4),count*4,requestBuffer+1); + manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1); + int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer); + for(int i=0;i<(len/4);i++) + { + Value[read+i]=((unsigned int)(RMAP_AnswerBuffer[i])<<24) + ((unsigned int)(RMAP_AnswerBuffer[i+1])<<16) + ((unsigned int)(RMAP_AnswerBuffer[i+2])<<8) + ((unsigned int)(RMAP_AnswerBuffer[i+3])); + } + free(RMAP_AnswerBuffer); + read+=count; + } + return read; +} + +stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *parent) + :QThread((QObject*)parent) +{ + this->handleMutex = new QMutex(QMutex::NonRecursive); + this->RMAP_AnswersSem = new QSemaphore(0); + this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); + this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); + this->plugin = parent; + connected = false; +} + +stardundeeSPW_USB_Manager::~stardundeeSPW_USB_Manager() +{ + this->terminate(); + while (!this->isFinished()) { + this->usleep(1000); + } +} + + +void stardundeeSPW_USB_Manager::run() +{ + USB_SPACEWIRE_PACKET_PROPERTIES properties; + USB_SPACEWIRE_ID pIdentifier=NULL; + USB_SPACEWIRE_STATUS stat; + SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread"); + char buffer[RMAP_MAX_XFER_SIZE*4]; + while (!this->isInterruptionRequested()) + { + if(this->connected) + { + handleMutex->lock(); + //SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets"); + if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01)) + { + SocExplorerEngine::message(this->plugin,"Got packet"); + stat = USBSpaceWire_ReadPackets(hDevice, buffer, RMAP_MAX_XFER_SIZE*4,1, 1, &properties, &pIdentifier); + if (stat == TRANSFER_SUCCESS) + { + if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET) + { + SocExplorerEngine::message(this->plugin,"It's a SPW packet"); + if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP) + { + SocExplorerEngine::message(this->plugin,"Got end of packet"); + if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet + { + SocExplorerEngine::message(this->plugin,"Got RMAP packet"); + SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len)); + char* packetbuffer = (char*)malloc(properties.len-13); + memcpy(packetbuffer,buffer+12,properties.len-13); + USBSpaceWire_FreeRead(hDevice, pIdentifier); + pIdentifier = NULL; + handleMutex->unlock(); + RMAP_Answer* packet=new RMAP_Answer(RMAP_get_transactionID(buffer+1),packetbuffer,properties.len); + RMAP_AnswersMtx->lock(); + RMAP_Answers.append(packet); + RMAP_AnswersMtx->unlock(); + RMAP_AnswersSem->release(); + } + else //any non-rmap packet will be pushed to the network + { + USBSpaceWire_FreeRead(hDevice, pIdentifier); + handleMutex->unlock(); + SocExplorerEngine::message(this->plugin,"Got SPW packet"); + } + } + else + { + SocExplorerEngine::message(this->plugin,"No EOP received"); + } + } + + } + else + { + USBSpaceWire_FreeRead(hDevice, pIdentifier); + handleMutex->unlock(); + } + } + else + { + USBSpaceWire_FreeRead(hDevice, pIdentifier); + handleMutex->unlock(); + } + } + else + { + sleep(1); + SocExplorerEngine::message(this->plugin,"Bridge not connected"); + } + usleep(1000); + // sleep(2); + } + SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread"); +} + +bool stardundeeSPW_USB_Manager::connectBridge() +{ + this->handleMutex->lock(); + int status; + U32 statusControl; + int brickNumber=0; + int linkNumber=1; + this->connected = false; + if (!USBSpaceWire_Open(&hDevice, brickNumber)) // Open the USB device + { + SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))"); + this->handleMutex->unlock(); + return false; + } + SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful"); + + USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode + CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration + CFGSpaceWire_SetRMAPDestinationKey(0x20); // Set the destination key expected by STAR-Dundee devices + + // Set the path and return path to the device + CFGSpaceWire_StackClear(); + CFGSpaceWire_AddrStackPush(0); + CFGSpaceWire_AddrStackPush(254); + CFGSpaceWire_RetAddrStackPush(254); + // set the base transmit rate to 100 MHz + status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff); + if (status != CFG_TRANSFER_SUCCESS) + { + SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate"); + return false; + } + else + { + SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz"); + } + + // read the link status + if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS) + { + SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber)); + return false; + } + else + { + SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber)); + + // Set the link status control register properties + CFGSpaceWire_LSEnableAutoStart(&statusControl, 1); + CFGSpaceWire_LSEnableStart(&statusControl, 1); + CFGSpaceWire_LSEnableDisabled(&statusControl, 0); + CFGSpaceWire_LSEnableTristate(&statusControl, 0); + CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz + + // Set the link status control register + if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS) + { + SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber)); + return false; + } + else + { + SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(linkNumber)); + } + } + + if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS) + { + SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface"); + return false; + } + else + { + SocExplorerEngine::message(this->plugin,"Device set to be an interface"); + } + + USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports + USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints + USBSpaceWire_SetTimeout(hDevice,1.0); + SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes"); + SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes"); + SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice))); + this->connected = true; + this->handleMutex->unlock(); + return true; +} + +bool stardundeeSPW_USB_Manager::disconnectBridge() +{ + this->handleMutex->lock(); + USBSpaceWire_Close(hDevice); // Close the device + SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0)); + USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports + this->handleMutex->unlock(); + return true; +} + +int stardundeeSPW_USB_Manager::getRMAPtransactionID() +{ + this->RMAP_pending_transaction_IDsMtx->lock(); + int ID=0; + bool found=true; + while(ID<65536) + { + for(int i=0;iRMAP_pending_transaction_IDsMtx->unlock(); + return ID; +} + +int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer) +{ + *buffer=NULL; + int count=0; + while (*buffer==NULL) + { + this->RMAP_AnswersMtx->lock(); + for(int i=0;itransactionID==transactionID) + { + this->RMAP_pending_transaction_IDsMtx->lock(); + for(int j=0;jRMAP_pending_transaction_IDsMtx->unlock(); + *buffer = RMAP_Answers[i]->data; + count = RMAP_Answers[i]->len; + RMAP_Answer* tmp=RMAP_Answers[i]; + RMAP_Answers.removeAt(i); + delete tmp; + } + } + this->RMAP_AnswersMtx->unlock(); + //if no answer found in the stack wait until a new packet is pushed + if(!buffer) + { + SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed"); + this->RMAP_AnswersSem->acquire(); + } + } + return count; +} + +bool stardundeeSPW_USB_Manager::sendPacket(char *packet, int size) +{ + USB_SPACEWIRE_STATUS result; + USB_SPACEWIRE_ID pIdentifier; + SocExplorerEngine::message(this->plugin,"Sending SPW packet"); + this->handleMutex->lock(); + result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier); + if (result != TRANSFER_SUCCESS) + { + SocExplorerEngine::message(this->plugin,"ERR sending the READ command "); + this->handleMutex->unlock(); + return false; + } + else + { + SocExplorerEngine::message(this->plugin,"Packet sent"); + USBSpaceWire_FreeSend(hDevice, pIdentifier); + } + this->handleMutex->unlock(); + return true; +} + +void stardundeeSPW_USB_Manager::pushRmapPacket(char *packet, int len) +{ + char* packetbuffer = (char*)malloc(len); + memcpy(packetbuffer,packet,len); + RMAP_Answer* RMPAPpacket=new RMAP_Answer(RMAP_get_transactionID(packetbuffer+1),packetbuffer,len); + RMAP_AnswersMtx->lock(); + RMAP_Answers.append(RMPAPpacket); + RMAP_AnswersMtx->unlock(); +} + + + + + + + + + + + + + + + + + + + + + + diff --git a/spwplugin/stardundeespw_usb.h b/spwplugin/stardundeespw_usb.h new file mode 100644 --- /dev/null +++ b/spwplugin/stardundeespw_usb.h @@ -0,0 +1,71 @@ +#ifndef STARDUNDEESPW_USB_H +#define STARDUNDEESPW_USB_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class RMAP_Answer +{ + public: + RMAP_Answer(int ID,char* data,int len) + { + transactionID = ID; + this->data = data; + this->len = len; + } + int transactionID; + char* data; + int len; +}; + +class stardundeeSPW_USB_Manager: public QThread +{ + Q_OBJECT +public: + explicit stardundeeSPW_USB_Manager(socexplorerplugin *parent = 0); + ~stardundeeSPW_USB_Manager(); + void run(); + bool connectBridge(); + bool disconnectBridge(); + int getRMAPtransactionID(); + int getRMAPanswer(int transactionID,char** buffer); + bool sendPacket(char* packet,int size); +private: + QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; + QSemaphore* RMAP_AnswersSem; + void pushRmapPacket(char* packet,int len); + star_device_handle hDevice; + socexplorerplugin* plugin; + bool connected; + char* SPWPacketBuff; + QList RMAP_Answers; + QList RMAP_pending_transaction_IDs; +}; + +class stardundeeSPW_USB : public abstractSpwBridge +{ + Q_OBJECT +public: + explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); + +signals: + +public slots: + bool connectBridge(); + bool disconnectBridge(); + int pushRMAPPacket(char* packet,int size); + unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); + unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); + +private: + stardundeeSPW_USB_Manager* manager; + +}; + +#endif // STARDUNDEESPW_USB_H