ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
XdmaBackend.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include "CtrlIntf.h"
6#include "DmaIntf.h"
7#include "EventFile.h"
9
10#include <boost/core/noncopyable.hpp>
11
12#include <atomic>
13#include <optional>
14#include <vector>
15
16namespace ChimeraTK {
17
18 class XdmaBackend : public NumericAddressedBackend, private boost::noncopyable {
19 private:
20 static constexpr size_t _maxDmaChannels = 4;
21 static constexpr size_t _maxInterrupts = 16;
22
23 std::optional<CtrlIntf> _ctrlIntf;
24 std::vector<DmaIntf> _dmaChannels;
25 std::array<std::unique_ptr<EventFile>, _maxInterrupts> _eventFiles;
26
27 const std::string _devicePath;
28
29 XdmaIntfAbstract& intfFromBar(uint64_t bar);
30
31 public:
32 explicit XdmaBackend(std::string devicePath, const std::string& mapFileName = "",
33 const std::string& dataConsistencyKeyDescriptor = "");
34 ~XdmaBackend() override = default;
35
36 void open() override;
37 void closeImpl() override;
38 bool isOpen() override;
39
40 void dump(const int32_t* data, size_t nbytes);
41 void read(uint64_t bar, uint64_t address, int32_t* data, size_t sizeInBytes) override;
42 void write(uint64_t bar, uint64_t address, const int32_t* data, size_t sizeInBytes) override;
43 std::future<void> activateSubscription(
44 uint32_t interruptNumber, boost::shared_ptr<async::DomainImpl<std::nullptr_t>> asyncDomain) override;
45
46 std::string readDeviceInfo() override;
47
48 static boost::shared_ptr<DeviceBackend> createInstance(
49 std::string address, std::map<std::string, std::string> parameters);
50 };
51
52} // namespace ChimeraTK
Base class for address-based device backends (e.g.
void dump(const int32_t *data, size_t nbytes)
static boost::shared_ptr< DeviceBackend > createInstance(std::string address, std::map< std::string, std::string > parameters)
void open() override
Open the device.
void closeImpl() override
All backends derrived from NumericAddressedBackend must implement closeImpl() instead of close.
std::string readDeviceInfo() override
Return a device information string containing hardware details like the firmware version number or th...
~XdmaBackend() override=default
std::future< void > activateSubscription(uint32_t interruptNumber, boost::shared_ptr< async::DomainImpl< std::nullptr_t > > asyncDomain) override
Activate/create the subscription for a given interrupt (for instance by starting the according interr...
bool isOpen() override
Return whether a device has been opened or not.