From e957e6c24a849632a70c46d6e7808280c4673cdb Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Thu, 21 Nov 2024 01:01:10 +0100 Subject: [PATCH 1/2] add device_ip matcher Signed-off-by: Pascal Bauer --- .../kernel/devices/device_ip_matcher.hpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 common/include/villas/kernel/devices/device_ip_matcher.hpp diff --git a/common/include/villas/kernel/devices/device_ip_matcher.hpp b/common/include/villas/kernel/devices/device_ip_matcher.hpp new file mode 100644 index 000000000..154264492 --- /dev/null +++ b/common/include/villas/kernel/devices/device_ip_matcher.hpp @@ -0,0 +1,40 @@ +/* Matcher for IP devices in an OS devicetree and ips on a fpga board. + * Matching based on adress prefix in device name and ip memoryaddress + * + * Author: Pascal Bauer + * + * SPDX-FileCopyrightText: 2023-2024 Pascal Bauer + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include + +class DeviceIpMatcher { +private: + std::vector devices; + std::list> ips; + +public: + DeviceIpMatcher(std::vector devices, + std::list> ips) + : devices(devices), ips(ips) {} + + std::vector, + villas::kernel::devices::IpDevice>> + match() const { + std::vector, + villas::kernel::devices::IpDevice>> + pairs; + for (auto device : devices) { + for (auto ip : ips) { + if (ip->getBaseaddr() == device.addr()) { + pairs.push_back(std::make_pair(ip, device)); + } + } + } + return pairs; + } +}; \ No newline at end of file From b5c256486fdb583d84cde02c147197236febe938 Mon Sep 17 00:00:00 2001 From: IgnoreWarnings <119685519+IgnoreWarnings@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:48:47 -0500 Subject: [PATCH 2/2] Update common/include/villas/kernel/devices/device_ip_matcher.hpp Co-authored-by: Niklas Eiling Signed-off-by: IgnoreWarnings <119685519+IgnoreWarnings@users.noreply.github.com> --- common/include/villas/kernel/devices/device_ip_matcher.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/include/villas/kernel/devices/device_ip_matcher.hpp b/common/include/villas/kernel/devices/device_ip_matcher.hpp index 154264492..dbb7c5df2 100644 --- a/common/include/villas/kernel/devices/device_ip_matcher.hpp +++ b/common/include/villas/kernel/devices/device_ip_matcher.hpp @@ -1,5 +1,5 @@ /* Matcher for IP devices in an OS devicetree and ips on a fpga board. - * Matching based on adress prefix in device name and ip memoryaddress + * Matching based on address prefix in device name and ip memory address * * Author: Pascal Bauer *