diff --git a/common/include/villas/kernel/devices/generic_driver.hpp b/common/include/villas/kernel/devices/generic_driver.hpp deleted file mode 100644 index 71dbce8d7..000000000 --- a/common/include/villas/kernel/devices/generic_driver.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* Implementation of driver interface for Linux/Unix based operation system drivers. - * - * Author: Pascal Bauer - * - * SPDX-FileCopyrightText: 2023-2024 Pascal Bauer - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include -#include -#include - -namespace villas { -namespace kernel { -namespace devices { - -class LinuxDriver : public Driver { -private: - static constexpr char BIND_DEFAULT[] = "bind"; - static constexpr char UNBIND_DEFAULT[] = "unbind"; - -public: - const std::filesystem::path path; - -private: - const std::filesystem::path bind_path; - const std::filesystem::path unbind_path; - -public: - LinuxDriver(const std::filesystem::path path) - : LinuxDriver(path, path / std::filesystem::path(BIND_DEFAULT), - path / std::filesystem::path(UNBIND_DEFAULT)){}; - - LinuxDriver(const std::filesystem::path path, - const std::filesystem::path bind_path, - const std::filesystem::path unbind_path) - : path(path), bind_path(bind_path), unbind_path(unbind_path){}; - -public: - void attach(const Device &device) const override; - void bind(const Device &device) const override; - std::string name() const override; - void override(const Device &device) const override; - void unbind(const Device &device) const override; -}; - -} // namespace devices -} // namespace kernel -} // namespace villas \ No newline at end of file diff --git a/common/include/villas/kernel/devices/linux_driver.hpp b/common/include/villas/kernel/devices/linux_driver.hpp index 46cbb1d6d..1d4fe9802 100644 --- a/common/include/villas/kernel/devices/linux_driver.hpp +++ b/common/include/villas/kernel/devices/linux_driver.hpp @@ -49,4 +49,4 @@ public: } // namespace devices } // namespace kernel -} // namespace villas \ No newline at end of file +} // namespace villas diff --git a/common/lib/CMakeLists.txt b/common/lib/CMakeLists.txt index 4c43567f0..74581897c 100644 --- a/common/lib/CMakeLists.txt +++ b/common/lib/CMakeLists.txt @@ -39,8 +39,8 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL Linux) target_sources(villas-common PRIVATE - kernel/devices/generic_driver.cpp kernel/devices/ip_device.cpp + kernel/devices/linux_driver.cpp kernel/devices/pci_device.cpp kernel/devices/platform_device.cpp kernel/vfio_device.cpp diff --git a/common/lib/kernel/devices/generic_driver.cpp b/common/lib/kernel/devices/generic_driver.cpp deleted file mode 100644 index 68afa4368..000000000 --- a/common/lib/kernel/devices/generic_driver.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* LinuxDriver - * - * Author: Pascal Bauer - * - * SPDX-FileCopyrightText: 2023-2024 Pascal Bauer - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include -#include - -using villas::kernel::devices::Device, villas::kernel::devices::LinuxDriver; -using villas::utils::write_to_file; - -void LinuxDriver::attach(const Device &device) const { - if (device.driver().has_value()) { - device.driver().value()->unbind(device); - } - this->override(device); - device.probe(); -} - -void LinuxDriver::bind(const Device &device) const { - write_to_file(device.name(), this->bind_path); -} - -std::string LinuxDriver::name() const { - size_t pos = path.u8string().rfind('/'); - return path.u8string().substr(pos + 1); -} - -void LinuxDriver::override(const Device &device) const { - write_to_file(this->name(), device.override_path()); -} - -void LinuxDriver::unbind(const Device &device) const { - write_to_file(device.name(), this->unbind_path); -} diff --git a/common/lib/kernel/devices/platform_device.cpp b/common/lib/kernel/devices/platform_device.cpp index 5a6d5fac9..e1f3610c6 100644 --- a/common/lib/kernel/devices/platform_device.cpp +++ b/common/lib/kernel/devices/platform_device.cpp @@ -6,7 +6,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include #include