Skip to content

Commit eb07e0f

Browse files
committed
cross probing demo
1 parent b66f5a5 commit eb07e0f

10 files changed

Lines changed: 511 additions & 0 deletions

File tree

plugins/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
!bitorder_propagation/**/*
44
!boolean_influence*
55
!boolean_influence/**/*
6+
!cross_probing*
7+
!cross_probing/**/*
68
!dataflow_analysis*
79
!dataflow_analysis/**/*
810
!gate_libraries*
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
option(PL_CROSS_PROBING "PL_CROSS_PROBING" OFF)
2+
3+
if(PL_CROSS_PROBING OR BUILD_ALL_PLUGINS)
4+
5+
find_package(Qt5 COMPONENTS Widgets Network REQUIRED)
6+
7+
file(GLOB_RECURSE CROSS_PROBING_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
8+
file(GLOB_RECURSE CROSS_PROBING_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
9+
10+
qt5_wrap_cpp(MOC_INC ${CROSS_PROBING_INC})
11+
12+
hal_add_plugin(cross_probing
13+
SHARED
14+
HEADER ${CROSS_PROBING_INC}
15+
SOURCES ${CROSS_PROBING_SRC} ${MOC_INC}
16+
LINK_LIBRARIES PUBLIC gui Qt5::Widgets Qt5::Network QuaZip::QuaZip
17+
)
18+
endif()
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// MIT License
2+
//
3+
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4+
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5+
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6+
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
#pragma once
27+
#include "hal_core/plugin_system/gui_extension_interface.h"
28+
#include "hal_core/plugin_system/plugin_interface_base.h"
29+
30+
#define SECRET_PASSWORD "test12345"
31+
32+
/**
33+
* @brief Header file for the cross probing plugin. This plugin is used by to control some HAL GUI features from external tool
34+
*
35+
*/
36+
37+
namespace hal
38+
{
39+
extern Netlist* gNetlist;
40+
41+
class GuiExtensionCrossProbing;
42+
class CrossProbingServer;
43+
44+
class PLUGIN_API CrossProbingPlugin : public BasePluginInterface
45+
{
46+
GuiExtensionCrossProbing* m_gui_extension;
47+
CrossProbingServer* m_server;
48+
49+
public:
50+
std::string get_name() const override;
51+
std::string get_version() const override;
52+
void initialize() override;
53+
54+
CrossProbingPlugin();
55+
56+
void on_load() override;
57+
void on_unload() override;
58+
59+
std::set<std::string> get_dependencies() const override;
60+
61+
void open_popup();
62+
};
63+
64+
class GuiExtensionCrossProbing : public GuiExtensionInterface
65+
{
66+
public:
67+
CrossProbingPlugin* m_parent;
68+
69+
GuiExtensionCrossProbing();
70+
71+
std::vector<ContextMenuContribution> get_context_contribution(const Netlist* nl, const std::vector<u32>& mods, const std::vector<u32>& gates, const std::vector<u32>& nets) override;
72+
73+
std::vector<PluginParameter> get_parameter() const override;
74+
75+
void set_parameter(const std::vector<PluginParameter>& params) override;
76+
77+
/**
78+
* Register function to indicate work progress when busy
79+
* @param pif Progress Indicator Function to register
80+
*/
81+
static std::function<void(int, const std::string&)> s_progress_indicator_function;
82+
virtual void register_progress_indicator(std::function<void(int, const std::string&)> pif) override;
83+
};
84+
} // namespace hal
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// MIT License
2+
//
3+
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4+
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5+
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6+
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
#pragma once
27+
28+
#include <QDialog>
29+
#include <QLabel>
30+
#include <QLocalSocket>
31+
32+
namespace hal {
33+
class CrossProbingControl : public QDialog
34+
{
35+
Q_OBJECT
36+
37+
private Q_SLOTS:
38+
void testButtonClicked();
39+
void socketCanSend();
40+
void socketCanRead();
41+
public:
42+
CrossProbingControl(QWidget* parent=nullptr);
43+
44+
QLabel* mStatus;
45+
QLocalSocket* mSocket;
46+
QByteArray mCurrentCommand;
47+
};
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// MIT License
2+
//
3+
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4+
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5+
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6+
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
26+
#pragma once
27+
28+
#include <QLocalServer>
29+
#include <QObject>
30+
#include <QString>
31+
32+
namespace hal {
33+
class CrossProbingServer : public QObject {
34+
Q_OBJECT
35+
36+
private Q_SLOTS:
37+
void receiveCommand();
38+
public:
39+
CrossProbingServer(QObject* parent = nullptr);
40+
~CrossProbingServer();
41+
42+
private:
43+
QLocalServer* mServer;
44+
QString mReturnMessage;
45+
46+
bool handleCommand(QByteArray cmd);
47+
};
48+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "cross_probing/cross_probing.h"
2+
#include "cross_probing/cross_probing_server.h"
3+
4+
namespace hal
5+
{
6+
extern std::unique_ptr<BasePluginInterface> create_plugin_instance()
7+
{
8+
return std::make_unique<CrossProbingPlugin>();
9+
}
10+
11+
CrossProbingPlugin::CrossProbingPlugin()
12+
{
13+
m_gui_extension = nullptr;
14+
}
15+
16+
std::string CrossProbingPlugin::get_name() const
17+
{
18+
return std::string("cross_probing");
19+
}
20+
21+
std::string CrossProbingPlugin::get_version() const
22+
{
23+
return std::string("0.1");
24+
}
25+
26+
void CrossProbingPlugin::on_load()
27+
{
28+
m_gui_extension = new GuiExtensionCrossProbing;
29+
m_gui_extension->m_parent = this;
30+
m_extensions.push_back(m_gui_extension);
31+
m_server = new CrossProbingServer;
32+
}
33+
34+
void CrossProbingPlugin::on_unload()
35+
{
36+
delete_extension(m_gui_extension);
37+
delete m_server;
38+
}
39+
40+
void CrossProbingPlugin::initialize()
41+
{
42+
}
43+
44+
std::set<std::string> CrossProbingPlugin::get_dependencies() const
45+
{
46+
std::set<std::string> retval;
47+
retval.insert("hal_gui");
48+
return retval;
49+
}
50+
} // namespace hal
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include "cross_probing/cross_probing_control.h"
2+
#include <QPushButton>
3+
#include <QVBoxLayout>
4+
5+
const char* externalCommands[] = {
6+
"<SetSelectionFocus> \n"
7+
" <modules>3</modules> \n"
8+
"</SetSelectionFocus> \n",
9+
10+
"<SetSelectionFocus> \n"
11+
" <gates>16,15,14,13,12</gates> \n"
12+
" <nets>29,28,27,26,25,8,7,6,5,4</nets> \n"
13+
"</SetSelectionFocus> \n",
14+
15+
"<compound>"
16+
" <CreateObject compound=\"0\" id=\"6\" type=\"Module\"> \n"
17+
" <objectname>InputModule</objectname> \n"
18+
" <parentid>1</parentid> \n"
19+
" <linkedid>0</linkedid> \n"
20+
" </CreateObject> \n"
21+
" <AddItemsToObject compound=\"1\" id=\"6\" type=\"Module\"> \n"
22+
" <gates>16,15,14,13,12</gates> \n"
23+
" </AddItemsToObject> \n"
24+
"</compound> \n",
25+
26+
"<MoveNode id=\"6\" type=\"Module\"> \n"
27+
" <context>1</context> \n"
28+
" <to>0,2</to> \n"
29+
"</MoveNode> \n",
30+
31+
"<SetSelectionFocus id=\"6\" type=\"Module\"> \n"
32+
" <modules>6</modules> \n"
33+
"</SetSelectionFocus> \n",
34+
35+
nullptr};
36+
37+
int commandCounter = 0;
38+
39+
namespace hal {
40+
CrossProbingControl::CrossProbingControl(QWidget *parent)
41+
: QDialog(parent)
42+
{
43+
setAttribute(Qt::WA_DeleteOnClose);
44+
setWindowTitle("Fake External Application");
45+
setMinimumSize(QSize(640,480));
46+
QVBoxLayout* layout = new QVBoxLayout(this);
47+
QPushButton* testBut = new QPushButton("test",this);
48+
connect(testBut, &QPushButton::clicked, this, &CrossProbingControl::testButtonClicked);
49+
layout->addWidget(testBut);
50+
mStatus = new QLabel("Press test button for first action", this);
51+
layout->addWidget(mStatus);
52+
mSocket = new QLocalSocket(this);
53+
connect(mSocket, &QLocalSocket::connected, this, &CrossProbingControl::socketCanSend, Qt::QueuedConnection);
54+
connect(mSocket, &QLocalSocket::readyRead, this, &CrossProbingControl::socketCanRead, Qt::QueuedConnection);
55+
}
56+
57+
void CrossProbingControl::testButtonClicked()
58+
{
59+
if (!externalCommands[commandCounter]) {
60+
mStatus->setText("No more test actions");
61+
return;
62+
}
63+
64+
mCurrentCommand = externalCommands[commandCounter++];
65+
mSocket->abort();
66+
mSocket->connectToServer("hal_action_pipe");
67+
}
68+
69+
void CrossProbingControl::socketCanSend()
70+
{
71+
mSocket->write(mCurrentCommand);
72+
mSocket->flush();
73+
}
74+
75+
void CrossProbingControl::socketCanRead()
76+
{
77+
QByteArray response = mSocket->readAll();
78+
mStatus->setText(QString::fromUtf8(response));
79+
mSocket->close();
80+
}
81+
}

0 commit comments

Comments
 (0)