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, std::string mapFileName = "");
33 ~XdmaBackend() override;
34
35 void open() override;
36 void closeImpl() override;
37 bool isOpen() override;
38
39 void dump(const int32_t* data, size_t nbytes);
40 void read(uint64_t bar, uint64_t address, int32_t* data, size_t sizeInBytes) override;
41 void write(uint64_t bar, uint64_t address, const int32_t* data, size_t sizeInBytes) override;
42 std::future<void> activateSubscription(
43 uint32_t interruptNumber, boost::shared_ptr<async::DomainImpl<std::nullptr_t>> asyncDomain) override;
44
45 std::string readDeviceInfo() override;
46
47 static boost::shared_ptr<DeviceBackend> createInstance(
48 std::string address, std::map<std::string, std::string> parameters);
49 };
50
51} // 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...
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.