1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

rename generic_driver to linux_driver

Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
This commit is contained in:
Pascal Bauer 2024-10-11 14:57:47 +02:00 committed by Niklas Eiling
parent 125c30cd32
commit f8b8b7af29
5 changed files with 3 additions and 95 deletions

View file

@ -1,52 +0,0 @@
/* Implementation of driver interface for Linux/Unix based operation system drivers.
*
* Author: Pascal Bauer <pascal.bauer@rwth-aachen.de>
*
* SPDX-FileCopyrightText: 2023-2024 Pascal Bauer <pascal.bauer@rwth-aachen.de>
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <filesystem>
#include <fstream>
#include <iostream>
#include <villas/kernel/devices/driver.hpp>
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

View file

@ -49,4 +49,4 @@ public:
} // namespace devices
} // namespace kernel
} // namespace villas
} // namespace villas

View file

@ -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

View file

@ -1,40 +0,0 @@
/* LinuxDriver
*
* Author: Pascal Bauer <pascal.bauer@rwth-aachen.de>
*
* SPDX-FileCopyrightText: 2023-2024 Pascal Bauer <pascal.bauer@rwth-aachen.de>
* SPDX-License-Identifier: Apache-2.0
*/
#include <villas/kernel/devices/generic_driver.hpp>
#include <villas/kernel/devices/device.hpp>
#include <villas/utils.hpp>
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);
}

View file

@ -6,7 +6,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <villas/kernel/devices/generic_driver.hpp>
#include <villas/kernel/devices/linux_driver.hpp>
#include <villas/kernel/devices/platform_device.hpp>
#include <villas/utils.hpp>