##// END OF EJS Templates
Improved AHB plugn'play decoding.
jeandet -
r64:c92c4a05386a default
parent child
Show More
@@ -1,15 +1,15
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4
4
5 SUBDIRS = \
5 SUBDIRS = \
6 ahbuartplugin \
6 ahbuartplugin \
7 ambaplugin \
7 ambaplugin \
8 APBUARTPLUGIN \
8 APBUARTPLUGIN \
9 dsu3plugin \
9 dsu3plugin \
10 genericrwplugin \
10 genericrwplugin \
11 memctrlrplugin \
11 memctrlrplugin \
12 memcheckplugin
12 memcheckplugin
13 unix:SUBDIRS += spwplugin
13
14
14 OTHER_FILES += SocExplorer-plugins.spec
15 OTHER_FILES += SocExplorer-plugins.spec
15 #unix:SUBDIRS += spwplugin
@@ -1,74 +1,95
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "ahbdevicelist.h"
22 #include "ahbdevicelist.h"
23
23 #include "ahbpluginui.h"
24
24
25
25
26 ahbdevicelist::ahbdevicelist(QWidget *parent):QTableWidget(parent)
26 ahbdevicelist::ahbdevicelist(QWidget *parent):QTableWidget(parent)
27 {
27 {
28 this->setColumnCount(7);
28 this->setColumnCount(7);
29 this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("BAR1")<<tr("BAR2")<<tr("BAR3")<<tr("Vendor ID")<<tr("Product ID"));
29 this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("BAR1")<<tr("BAR2")<<tr("BAR3")<<tr("Vendor ID")<<tr("Product ID"));
30 }
30 }
31
31
32 void ahbdevicelist::clearAHBdevicesList()
32 void ahbdevicelist::clearAHBdevicesList()
33 {
33 {
34 this->clear();
34 this->clear();
35 this->setRowCount(0);
35 this->setRowCount(0);
36 this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("BAR1")<<tr("BAR2")<<tr("BAR3")<<tr("Vendor ID")<<tr("Product ID"));
36 this->setHorizontalHeaderLabels(QStringList() << tr("Device Name")<<tr("BAR0")<<tr("BAR1")<<tr("BAR2")<<tr("BAR3")<<tr("Vendor ID")<<tr("Product ID"));
37 }
37 }
38
38
39 QString decodeType(int type)
40 {
41 switch (type) {
42 case AHB_PLUGNPLAY_APB_IO_SPACE:
43 return "APB IO space";
44 break;
45 case AHB_PLUGNPLAY_MEMORY_SPACE:
46 return "Memory space";
47 break;
48 case AHB_PLUGNPLAY_AHB_IO_SPACE:
49 return "AHB IO space";
50 break;
51 default:
52 return "Unknown type";
53 break;
54 }
55 }
56
39 void ahbdevicelist::addAHBdevice(ahbdeviceInfo* device)
57 void ahbdevicelist::addAHBdevice(ahbdeviceInfo* device)
40 {
58 {
41 if(this->rowCount()==0)
59 if(this->rowCount()==0)
42 {
60 {
43 this->setRowCount(1);
61 this->setRowCount(1);
44 }
62 }
45 else
63 else
46 {
64 {
47 this->insertRow(this->rowCount());
65 this->insertRow(this->rowCount());
48 }
66 }
49
67
50 this->ahbdevices.append(device);
68 this->ahbdevices.append(device);
51 QTableWidgetItem *newItem = new QTableWidgetItem(*device->deviceName);
69 QTableWidgetItem *newItem = new QTableWidgetItem(*device->deviceName);
52 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
70 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
53 this->setItem(this->rowCount()-1, 0, newItem);
71 this->setItem(this->rowCount()-1, 0, newItem);
54
72
55 for(int i=0;i<4;i++)
73 for(int i=0;i<4;i++)
56 {
74 {
57 if(device->BAR[i].size!=0)
75 if(device->BAR[i].size!=0)
58 {
76 {
59 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));
77 newItem = new QTableWidgetItem("0x" + QString::number(device->BAR[i].address, 16)
78 +" -> 0x"+ QString::number(device->BAR[i].address + device->BAR[i].size-1, 16)
79 +" size = "+device->barAdressSize(i)
80 +" "+ decodeType(device->BAR[i].type));
60 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
81 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
61 this->setItem(this->rowCount()-1, i+1, newItem);
82 this->setItem(this->rowCount()-1, i+1, newItem);
62 }
83 }
63
84
64 }
85 }
65
86
66 newItem = new QTableWidgetItem("0x" + QString::number(device->VID , 16));
87 newItem = new QTableWidgetItem("0x" + QString::number(device->VID , 16));
67 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
88 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
68 this->setItem(this->rowCount()-1, 5, newItem);
89 this->setItem(this->rowCount()-1, 5, newItem);
69 newItem = new QTableWidgetItem("0x" + QString::number(device->PID , 16));
90 newItem = new QTableWidgetItem("0x" + QString::number(device->PID , 16));
70 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
91 newItem->setFlags(newItem->flags() &~ Qt::ItemIsEditable);
71 this->setItem(this->rowCount()-1, 6, newItem);
92 this->setItem(this->rowCount()-1, 6, newItem);
72 this->resizeColumnsToContents();
93 this->resizeColumnsToContents();
73
94
74 }
95 }
@@ -1,90 +1,111
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "ahbpluginui.h"
22 #include "ahbpluginui.h"
23 #include <socexplorerengine.h>
23 #include <socexplorerengine.h>
24
24
25 ahbPluginUi::ahbPluginUi(socexplorerplugin *plugin, QWidget *parent) :
25 ahbPluginUi::ahbPluginUi(socexplorerplugin *plugin, QWidget *parent) :
26 QWidget(parent)
26 QWidget(parent)
27 {
27 {
28 this->mainlayout = new QHBoxLayout;
28 this->mainlayout = new QHBoxLayout;
29 this->scanBp = new QPushButton(tr("Scan AHB"));
29 this->scanBp = new QPushButton(tr("Scan AHB"));
30 this->deviceslst = new ahbdevicelist;
30 this->deviceslst = new ahbdevicelist;
31 this->mainlayout->addWidget(this->deviceslst);
31 this->mainlayout->addWidget(this->deviceslst);
32 this->mainlayout->addWidget(this->scanBp);
32 this->mainlayout->addWidget(this->scanBp);
33 this->setLayout(this->mainlayout);
33 this->setLayout(this->mainlayout);
34 this->_plugin = plugin;
34 this->_plugin = plugin;
35 connect(this,SIGNAL(addAHBdevice(ahbdeviceInfo*)),this->deviceslst,SLOT(addAHBdevice(ahbdeviceInfo*)));
35 connect(this,SIGNAL(addAHBdevice(ahbdeviceInfo*)),this->deviceslst,SLOT(addAHBdevice(ahbdeviceInfo*)));
36 connect(this,SIGNAL(clearAHBdevicesList()),this->deviceslst,SLOT(clearAHBdevicesList()));
36 connect(this,SIGNAL(clearAHBdevicesList()),this->deviceslst,SLOT(clearAHBdevicesList()));
37 connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAHB()));
37 connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAHB()));
38 }
38 }
39
39
40
40
41
41
42 ahbdeviceInfo* ahbPluginUi::extractInfos(int *pnpregs)
42 ahbdeviceInfo* ahbPluginUi::extractInfos(unsigned int *pnpregs)
43 {
43 {
44 AHBbarreg BAR[4];
44 AHBbarreg BAR[4];
45
45
46 int VID;
46 int VID;
47 int PID;
47 int PID;
48 for(int i=0;i<4;i++)
48 for(int i=0;i<4;i++)
49 {
49 {
50 BAR[i].address = pnpregs[i+4] & 0xfff00000;
50 unsigned int addr=(pnpregs[i+4] & 0xfff00000)>>20;
51 BAR[i].size = (pnpregs[i+4] & 0x0000fff0)<<16;
51 unsigned int mask=(pnpregs[i+4] & 0x0FFF0)>>4;
52 BAR[i].type = (unsigned char)(pnpregs[i+4]&0x0f);
53 printf("%x\n",addr);
54 BAR[i].size = 0;
55 BAR[i].address = 0;
56 switch ((int)(BAR[i].type))
57 {
58 case AHB_PLUGNPLAY_APB_IO_SPACE:
59 break;
60 case AHB_PLUGNPLAY_MEMORY_SPACE:
61 BAR[i].address = addr<<20;
62 BAR[i].size = (mask)<<20;
63 break;
64 case AHB_PLUGNPLAY_AHB_IO_SPACE:
65 BAR[i].address = 0xfff00000 + (addr<<8);
66 BAR[i].size = (mask)<<8;
67 break;
68 default:
69 break;
70 }
71
52 if(BAR[i].size!=0)
72 if(BAR[i].size!=0)
53 BAR[i].size = (((-1^BAR[i].size)|BAR[i].address)-BAR[i].address)+1;
73 BAR[i].size = (((-1^BAR[i].size)|BAR[i].address)-BAR[i].address)+1;
54 BAR[i].cacheable = (bool)((pnpregs[i+4]&0x00010000)>>16);
74 BAR[i].cacheable = (bool)((pnpregs[i+4]&0x00010000)>>16);
55 BAR[i].prefectchable = (bool)((pnpregs[i+4]&0x00020000)>>17);
75 BAR[i].prefectchable = (bool)((pnpregs[i+4]&0x00020000)>>17);
56 BAR[i].type = (unsigned char)(pnpregs[i+4]&0xf);
57 }
76 }
58
77
59 VID = (pnpregs[0]>>24)&0xff;
78 VID = (pnpregs[0]>>24)&0xff;
60 PID = (pnpregs[0]>>12)&0xfff;
79 PID = (pnpregs[0]>>12)&0xfff;
61 QString devname = SocExplorerEngine::getDevName(VID,PID);
80 QString devname = SocExplorerEngine::getDevName(VID,PID);
62 return new ahbdeviceInfo(devname,BAR[0],BAR[1],BAR[2],BAR[3],VID,PID);
81 return new ahbdeviceInfo(devname,BAR[0],BAR[1],BAR[2],BAR[3],VID,PID);
63 }
82 }
64
83
65
84
66 void ahbPluginUi::scanAHB()
85 void ahbPluginUi::scanAHB()
67 {
86 {
68 unsigned int size = (AHB_PLUGNPLAY_SLAVE_STOP - AHB_PLUGNPLAY_MASTER_START)/4;
87 unsigned int size = (AHB_PLUGNPLAY_SLAVE_STOP - AHB_PLUGNPLAY_MASTER_START)/4;
69 int j=0;
88 int j=0;
70 unsigned long long i = AHB_PLUGNPLAY_MASTER_START;
89 unsigned long long i = AHB_PLUGNPLAY_MASTER_START;
71 int pnpregs[size];
90 int pnpregs[size];
72 emit this->clearAHBdevicesList();
91 emit this->clearAHBdevicesList();
73 if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size)
92 if( this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)AHB_PLUGNPLAY_MASTER_START)==size)
74 {
93 {
75 while(i<AHB_PLUGNPLAY_SLAVE_STOP)
94 while(i<AHB_PLUGNPLAY_SLAVE_STOP)
76 {
95 {
77 if(pnpregs[j]!=0)
96 if(pnpregs[j]!=0)
78 {
97 {
79 ahbdeviceInfo* devinfo=this->extractInfos(pnpregs+j);
98 ahbdeviceInfo* devinfo=this->extractInfos((unsigned int*)(pnpregs+j));
80 if(!devinfo->deviceName->compare("DSU3"))
99 if(!devinfo->deviceName->compare("DSU3"))
81 SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[0].address,*devinfo->deviceName);
100 SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[0].address,*devinfo->deviceName);
101 if(!devinfo->deviceName->compare("SDCTRL"))
102 SocExplorerEngine::addEnumDevice(this->_plugin,devinfo->VID,devinfo->PID,devinfo->BAR[1].address,*devinfo->deviceName);
82 emit this->addAHBdevice(devinfo);
103 emit this->addAHBdevice(devinfo);
83 }
104 }
84 i+=32;
105 i+=32;
85 j+=8;
106 j+=8;
86 }
107 }
87 }
108 }
88 }
109 }
89
110
90
111
@@ -1,58 +1,64
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef AHBPLUGINUI_H
22 #ifndef AHBPLUGINUI_H
23 #define AHBPLUGINUI_H
23 #define AHBPLUGINUI_H
24
24
25 #include <QWidget>
25 #include <QWidget>
26 #include <QHBoxLayout>
26 #include <QHBoxLayout>
27 #include <QPushButton>
27 #include <QPushButton>
28 #include "ahbdevicelist.h"
28 #include "ahbdevicelist.h"
29 #include <socexplorerplugin.h>
29 #include <socexplorerplugin.h>
30 #define AHB_PLUGNPLAY_MASTER_START ((unsigned int)(0xFFFFF000))
30 #define AHB_PLUGNPLAY_MASTER_START ((unsigned int)(0xFFFFF000))
31 #define AHB_PLUGNPLAY_MASTER_STOP ((unsigned int)(0xFFFFF800))
31 #define AHB_PLUGNPLAY_MASTER_STOP ((unsigned int)(0xFFFFF800))
32 #define AHB_PLUGNPLAY_SLAVE_START ((unsigned int)(0xFFFFF800))
32 #define AHB_PLUGNPLAY_SLAVE_START ((unsigned int)(0xFFFFF800))
33 #define AHB_PLUGNPLAY_SLAVE_STOP ((unsigned int)(0xFFFFFFFC))
33 #define AHB_PLUGNPLAY_SLAVE_STOP ((unsigned int)(0xFFFFFFFC))
34
34 /*0001 = APB I/O space
35 0010 = AHB Memory space
36 0011 = AHB I/O space
37 */
38 #define AHB_PLUGNPLAY_APB_IO_SPACE 0x01
39 #define AHB_PLUGNPLAY_MEMORY_SPACE 0x02
40 #define AHB_PLUGNPLAY_AHB_IO_SPACE 0x03
35
41
36 class ahbPluginUi : public QWidget
42 class ahbPluginUi : public QWidget
37 {
43 {
38 Q_OBJECT
44 Q_OBJECT
39 public:
45 public:
40 explicit ahbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0);
46 explicit ahbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0);
41 ahbdeviceInfo* extractInfos(int* pnpregs);
47 ahbdeviceInfo* extractInfos(unsigned int* pnpregs);
42 public slots:
48 public slots:
43 void scanAHB();
49 void scanAHB();
44 signals:
50 signals:
45 void addAHBdevice(ahbdeviceInfo* device);
51 void addAHBdevice(ahbdeviceInfo* device);
46 void clearAHBdevicesList();
52 void clearAHBdevicesList();
47 unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address);
53 unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address);
48 unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address);
54 unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address);
49 private:
55 private:
50 QHBoxLayout* mainlayout;
56 QHBoxLayout* mainlayout;
51 QPushButton* scanBp;
57 QPushButton* scanBp;
52 ahbdevicelist* deviceslst;
58 ahbdevicelist* deviceslst;
53 socexplorerplugin* _plugin;
59 socexplorerplugin* _plugin;
54
60
55
61
56 };
62 };
57
63
58 #endif // AHBPLUGINUI_H
64 #endif // AHBPLUGINUI_H
@@ -1,99 +1,104
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "apbpluginui.h"
22 #include "apbpluginui.h"
23 #include <stdint.h>
23 #include <stdint.h>
24 #include <socexplorerengine.h>
24 #include <socexplorerengine.h>
25
25
26 apbPluginUi::apbPluginUi(socexplorerplugin *plugin, QWidget *parent) :
26 apbPluginUi::apbPluginUi(socexplorerplugin *plugin, QWidget *parent) :
27 QWidget(parent)
27 QWidget(parent)
28 {
28 {
29 this->setWindowTitle(tr("APB Driver"));
29 this->setWindowTitle(tr("APB Driver"));
30 this->mainlayout = new QHBoxLayout;
30 this->mainlayout = new QHBoxLayout;
31 this->scanBp = new QPushButton(tr("Scan APB"));
31 this->scanBp = new QPushButton(tr("Scan APB"));
32 this->deviceslst = new apbdevicelist;
32 this->deviceslst = new apbdevicelist;
33 this->mainlayout->addWidget(this->deviceslst);
33 this->mainlayout->addWidget(this->deviceslst);
34 this->mainlayout->addWidget(this->scanBp);
34 this->mainlayout->addWidget(this->scanBp);
35 this->setLayout(this->mainlayout);
35 this->setLayout(this->mainlayout);
36 this->_plugin = plugin;
36 this->_plugin = plugin;
37 connect(this,SIGNAL(addAPBdevice(apbdeviceInfo*)),this->deviceslst,SLOT(addAPBdevice(apbdeviceInfo*)));
37 connect(this,SIGNAL(addAPBdevice(apbdeviceInfo*)),this->deviceslst,SLOT(addAPBdevice(apbdeviceInfo*)));
38 connect(this,SIGNAL(clearAPBdevicesList()),this->deviceslst,SLOT(clearAPBdevicesList()));
38 connect(this,SIGNAL(clearAPBdevicesList()),this->deviceslst,SLOT(clearAPBdevicesList()));
39 connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAPB()));
39 connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAPB()));
40 }
40 }
41
41
42 void apbPluginUi::lockScanBp()
42 void apbPluginUi::lockScanBp()
43 {
43 {
44 this->scanBp->setEnabled(false);
44 this->scanBp->setEnabled(false);
45 }
45 }
46
46
47
47
48 void apbPluginUi::unlockScanBp()
48 void apbPluginUi::unlockScanBp()
49 {
49 {
50 this->scanBp->setEnabled(true);
50 this->scanBp->setEnabled(true);
51 }
51 }
52
52
53
53
54
54
55 apbdeviceInfo* apbPluginUi::extractInfos(int *pnpregs)
55 apbdeviceInfo* apbPluginUi::extractInfos(int *pnpregs)
56 {
56 {
57 APBbarreg BAR[1];
57 APBbarreg BAR[1];
58
58
59 int VID;
59 int VID;
60 int PID;
60 int PID;
61 for(int i=0;i<1;i++)
61 for(int i=0;i<1;i++)
62 {
62 {
63 BAR[i].address = ((uint32_t)(pnpregs[i+1] & 0xfff00000)>>12)+ APB_BUS_START;
63 BAR[i].address = ((uint32_t)(pnpregs[i+1] & 0xfff00000)>>12)+ APB_BUS_START;
64 BAR[i].size = ((pnpregs[i+1] & 0x00000ff0)>>4 )+1;
64 BAR[i].size = ((pnpregs[i+1] & 0x00000ff0)>>4 )+1;
65 BAR[i].type = (unsigned char)(pnpregs[i+1]&0xf);
65 BAR[i].type = (unsigned char)(pnpregs[i+1]&0xf);
66 }
66 }
67
67
68 VID = (pnpregs[0]>>24)&0xff;
68 VID = (pnpregs[0]>>24)&0xff;
69 PID = (pnpregs[0]>>12)&0xfff;
69 PID = (pnpregs[0]>>12)&0xfff;
70 QString devname = SocExplorerEngine::getDevName(VID,PID);
70 QString devname = SocExplorerEngine::getDevName(VID,PID);
71 return new apbdeviceInfo(devname,BAR[0],VID,PID);
71 return new apbdeviceInfo(devname,BAR[0],VID,PID);
72 }
72 }
73
73
74 void apbPluginUi::scanAPB()
74 void apbPluginUi::scanAPB()
75 {
75 {
76 this->lockScanBp();
76 this->lockScanBp();
77 unsigned int size = (APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START)/4;
77 unsigned int size = (APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START)/4;
78 int j=0;
78 int j=0;
79 unsigned long long i = APB_PLUGNPLAY_START;
79 unsigned long long i = APB_PLUGNPLAY_START;
80 int pnpregs[size];
80 int pnpregs[size];
81 emit this->clearAPBdevicesList();
81 emit this->clearAPBdevicesList();
82 this->devList.clear();
82 if(this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)APB_PLUGNPLAY_START)==size)
83 if(this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)APB_PLUGNPLAY_START)==size)
83 {
84 {
84 while(i<APB_PLUGNPLAY_STOP)
85 while(i<APB_PLUGNPLAY_STOP)
85 {
86 {
86 if(pnpregs[j]!=0)
87 if(pnpregs[j]!=0)
87 {
88 {
88 apbdeviceInfo* devinfos=this->extractInfos(pnpregs+j);
89 apbdeviceInfo* devinfos=this->extractInfos(pnpregs+j);
89 SocExplorerEngine::addEnumDevice(this->_plugin,devinfos->VID,devinfos->PID,devinfos->BAR[0].address,devinfos->deviceName);
90 SocExplorerEngine::addEnumDevice(this->_plugin,devinfos->VID,devinfos->PID,devinfos->BAR[0].address,devinfos->deviceName);
90 emit this->addAPBdevice(devinfos);
91 if(!this->devList.contains(devinfos->BAR[0].address))
92 {
93 this->devList.append(devinfos->BAR[0].address);
94 emit this->addAPBdevice(devinfos);
95 }
91 }
96 }
92 i+=8;
97 i+=8;
93 j+=2;
98 j+=2;
94 if(pnpregs[0]==pnpregs[j]&&pnpregs[1]==pnpregs[j+1])break;
99 // if(pnpregs[0]!=0&&pnpregs[0]==pnpregs[j]&&pnpregs[1]==pnpregs[j+1])break;
95 }
100 }
96 }
101 }
97 this->unlockScanBp();
102 this->unlockScanBp();
98 }
103 }
99
104
@@ -1,59 +1,60
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef APBPLUGINUI_H
22 #ifndef APBPLUGINUI_H
23 #define APBPLUGINUI_H
23 #define APBPLUGINUI_H
24
24
25 #include <QWidget>
25 #include <QWidget>
26 #include <QHBoxLayout>
26 #include <QHBoxLayout>
27 #include <QPushButton>
27 #include <QPushButton>
28 #include "apbdevicelist.h"
28 #include "apbdevicelist.h"
29 #include <socexplorerplugin.h>
29 #include <socexplorerplugin.h>
30
30
31 #define APB_BUS_START ((unsigned int)(0x80000000))
31 #define APB_BUS_START ((unsigned int)(0x80000000))
32 #define APB_PLUGNPLAY_START ((unsigned int)(0x800FF000))
32 #define APB_PLUGNPLAY_START ((unsigned int)(0x800FF000))
33 #define APB_PLUGNPLAY_STOP ((unsigned int)(0x800FFFFF))
33 #define APB_PLUGNPLAY_STOP ((unsigned int)(0x800FFFFF))
34
34
35
35
36 class apbPluginUi : public QWidget
36 class apbPluginUi : public QWidget
37 {
37 {
38 Q_OBJECT
38 Q_OBJECT
39 public:
39 public:
40 explicit apbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0);
40 explicit apbPluginUi(socexplorerplugin* plugin,QWidget *parent = 0);
41 void lockScanBp();
41 void lockScanBp();
42 void unlockScanBp();
42 void unlockScanBp();
43 apbdeviceInfo* extractInfos(int* pnpregs);
43 apbdeviceInfo* extractInfos(int* pnpregs);
44
44
45 signals:
45 signals:
46 void addAPBdevice(apbdeviceInfo* device);
46 void addAPBdevice(apbdeviceInfo* device);
47 void clearAPBdevicesList();
47 void clearAPBdevicesList();
48 unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address);
48 unsigned int WriteSig(unsigned int* Value,unsigned int count,unsigned int address);
49 unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address);
49 unsigned int ReadSig(unsigned int* Value,unsigned int count,unsigned int address);
50 public slots:
50 public slots:
51 void scanAPB();
51 void scanAPB();
52 private:
52 private:
53 QHBoxLayout* mainlayout;
53 QHBoxLayout* mainlayout;
54 QPushButton* scanBp;
54 QPushButton* scanBp;
55 apbdevicelist* deviceslst;
55 apbdevicelist* deviceslst;
56 socexplorerplugin* _plugin;
56 socexplorerplugin* _plugin;
57 QList<int> devList;
57 };
58 };
58
59
59 #endif // APBPLUGINUI_H
60 #endif // APBPLUGINUI_H
@@ -1,63 +1,63
1 #
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
3 #
4 #-------------------------------------------------
4 #-------------------------------------------------
5
5
6 CONFIG += socexplorerplugin
6 CONFIG += socexplorerplugin
7 CONFIG += dll
7 CONFIG += dll
8 CONFIG -= static
8 CONFIG -= static
9 VERSION=0.2.0
9 VERSION=0.2.0
10 TARGET = ambaplugin #$${DEBUG_EXT}
10 TARGET = ambaplugin
11 DEFINES += PLUGIN=ambaplugin
11 DEFINES += PLUGIN=ambaplugin
12 DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\"
12 DEFINES += PLUGINHEADER="\"\\\"ambaplugin.h"\\\"\"
13 DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\"
13 DEFINES += driver_Name="\"\\\"AMBA_PLUGIN"\\\"\"
14 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
14 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@lpp.polytechnique.fr"\\\"\"
15 DEFINES += driver_Description="\"\\\"This driver handles the Gaisler AMBA plugn' play system."\\\"\"
15 DEFINES += driver_Description="\"\\\"This driver handles the Gaisler AMBA plugn' play system."\\\"\"
16 DEFINES += driver_can_be_root=0
16 DEFINES += driver_can_be_root=0
17 DEFINES += driver_can_be_child=1
17 DEFINES += driver_can_be_child=1
18 DEFINES += driver_VID=0
18 DEFINES += driver_VID=0
19 DEFINES += driver_PID=0
19 DEFINES += driver_PID=0
20
20
21 INCLUDEPATH += \
21 INCLUDEPATH += \
22 $${PWD}
22 $${PWD}
23
23
24 HEADERS += \
24 HEADERS += \
25 ambaplugin.h \
25 ambaplugin.h \
26 AHB/ahbpluginui.h \
26 AHB/ahbpluginui.h \
27 AHB/ahbdevicelist.h \
27 AHB/ahbdevicelist.h \
28 APB/apbpluginui.h \
28 APB/apbpluginui.h \
29 APB/apbdevicelist.h \
29 APB/apbdevicelist.h \
30 ambapluginui.h
30 ambapluginui.h
31
31
32
32
33 SOURCES += \
33 SOURCES += \
34 ambaplugin.cpp \
34 ambaplugin.cpp \
35 AHB/ahbpluginui.cpp \
35 AHB/ahbpluginui.cpp \
36 AHB/ahbdevicelist.cpp \
36 AHB/ahbdevicelist.cpp \
37 APB/apbpluginui.cpp \
37 APB/apbpluginui.cpp \
38 APB/apbdevicelist.cpp \
38 APB/apbdevicelist.cpp \
39 ambapluginui.cpp
39 ambapluginui.cpp
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
50
51
51
52
52
53
53
54
54
55
55
56
56
57
57
58
58
59
59
60
60
61
61
62
62
63
63
General Comments 0
You need to be logged in to leave comments. Login now