Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit e0c147c

Browse files
author
IgnoreWarnings
committed
add default Interrupt Controller to dma
1 parent 0fbf5a0 commit e0c147c

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

lib/core.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
/* FPGA IP component.
22
*
33
* Author: Steffen Vogel <post@steffenvogel.de>
4-
* SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power Systems, RWTH Aachen University
5-
* SPDX-License-Identifier: Apache-2.0
4+
* SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power
5+
* Systems, RWTH Aachen University SPDX-License-Identifier: Apache-2.0
66
*/
77

88
#include <memory>
99
#include <string>
1010
#include <utility>
1111

12+
#include <vector>
1213
#include <villas/exceptions.hpp>
1314
#include <villas/log.hpp>
1415
#include <villas/memory.hpp>
1516
#include <villas/utils.hpp>
1617

1718
#include <villas/fpga/card.hpp>
19+
#include <villas/fpga/platform_card.hpp>
1820
#include <villas/fpga/utils.hpp>
1921
#include <villas/fpga/vlnv.hpp>
2022

2123
#include <villas/fpga/core.hpp>
2224
#include <villas/fpga/ips/intc.hpp>
2325
#include <villas/fpga/ips/pcie.hpp>
26+
#include <villas/fpga/ips/platform_intc.hpp>
2427
#include <villas/fpga/ips/switch.hpp>
2528

2629
using namespace villas::fpga;
@@ -169,6 +172,35 @@ std::list<std::shared_ptr<Core>> CoreFactory::make(Card *card,
169172
logger->debug("IRQ: {} -> {}:{}", irqName, irqControllerName, num);
170173
ip->irqs[irqName] = {num, intc, ""};
171174
}
175+
} else if (!json_is_object(json_irqs) &&
176+
ip->getInstanceName().find("axi_dma_") != std::string::npos) {
177+
logger->warn("Dma json does not contain an interrupt Controller. A "
178+
"Platform Interrupt controller will be added");
179+
180+
// auto devices = dynamic_cast<PlatformCard*>(ip->card)->devices;
181+
// std::string nameToFind = "dma";
182+
// auto it = std::find_if(devices.begin(), devices.end(), [&](const
183+
// villas::kernel::vfio::Device& device) {
184+
// return device.get_name() == nameToFind;
185+
// });
186+
187+
std::vector<const char *> intc_names = {"mm2s_introut", "s2mm_introut"};
188+
189+
int num = 0;
190+
for (auto name : intc_names)
191+
{
192+
auto intc = new PlatformInterruptController();
193+
intc->id = id;
194+
intc->logger = villas::logging.get(id.getName());
195+
196+
const char *irqName = name;
197+
std::string irqControllerName = "PlatformInterruptController";
198+
199+
logger->debug("IRQ: {} -> {}:{}", irqName, irqControllerName, num);
200+
ip->irqs[irqName] = {num, intc, ""};
201+
202+
num++;
203+
}
172204
}
173205

174206
json_t *json_memory_view = json_object_get(json_ip, "memory-view");

0 commit comments

Comments
 (0)