1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/common/include/villas/kernel/devices/platform_device.hpp
Pascal Bauer 297fbc511c fix formatting
Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
2025-01-28 17:49:54 +01:00

51 lines
1.6 KiB
C++

/* Platform bus based Linux/Unix device.
*
* 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 <villas/kernel/devices/device.hpp>
#include <villas/kernel/devices/driver.hpp>
namespace villas {
namespace kernel {
namespace devices {
class PlatformDevice : public Device {
private:
static constexpr char PROBE_DEFAULT[] = "/sys/bus/platform/drivers_probe";
static constexpr char OVERRIDE_DEFAULT[] = "driver_override";
private:
const std::filesystem::path m_path;
const std::filesystem::path m_probe_path;
const std::filesystem::path m_override_path;
public:
PlatformDevice(const std::filesystem::path path)
: PlatformDevice(path, std::filesystem::path(PROBE_DEFAULT),
path / std::filesystem::path(OVERRIDE_DEFAULT)){};
PlatformDevice(const std::filesystem::path path,
const std::filesystem::path probe_path,
const std::filesystem::path override_path)
: m_path(path), m_probe_path(probe_path),
m_override_path(override_path){};
// Implement device interface
std::optional<std::unique_ptr<Driver>> driver() const override;
std::optional<int> iommu_group() const override;
std::string name() const override;
std::filesystem::path override_path() const override;
std::filesystem::path path() const override;
void probe() const override;
};
} // namespace devices
} // namespace kernel
} // namespace villas