ChimeraTK-DeviceAccess  03.18.00
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 
16 namespace 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
ChimeraTK::XdmaBackend::read
void read(uint64_t bar, uint64_t address, int32_t *data, size_t sizeInBytes) override
Read function to be implemented by backends.
Definition: XdmaBackend.cc:95
ChimeraTK::XdmaBackend
Definition: XdmaBackend.h:18
ChimeraTK::XdmaBackend::open
void open() override
Open the device.
Definition: XdmaBackend.cc:18
ChimeraTK::XdmaBackend::closeImpl
void closeImpl() override
All backends derrived from NumericAddressedBackend must implement closeImpl() instead of close.
Definition: XdmaBackend.cc:50
ChimeraTK::XdmaBackend::write
void write(uint64_t bar, uint64_t address, const int32_t *data, size_t sizeInBytes) override
Write function to be implemented by backends.
Definition: XdmaBackend.cc:106
ChimeraTK::XdmaBackend::~XdmaBackend
~XdmaBackend() override
Definition: XdmaBackend.cc:16
ChimeraTK::XdmaIntfAbstract
Definition: XdmaIntfAbstract.h:10
NumericAddressedBackend.h
ChimeraTK::NumericAddressedBackend
Base class for address-based device backends (e.g.
Definition: NumericAddressedBackend.h:20
CtrlIntf.h
ChimeraTK::XdmaBackend::XdmaBackend
XdmaBackend(std::string devicePath, std::string mapFileName="")
Definition: XdmaBackend.cc:13
DmaIntf.h
EventFile.h
ChimeraTK::async::DomainImpl
Definition: DomainImpl.h:15
ChimeraTK::XdmaBackend::dump
void dump(const int32_t *data, size_t nbytes)
ChimeraTK::XdmaBackend::createInstance
static boost::shared_ptr< DeviceBackend > createInstance(std::string address, std::map< std::string, std::string > parameters)
Definition: XdmaBackend.cc:152
ChimeraTK::XdmaBackend::readDeviceInfo
std::string readDeviceInfo() override
Return a device information string containing hardware details like the firmware version number or th...
Definition: XdmaBackend.cc:139
ChimeraTK::XdmaBackend::activateSubscription
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...
Definition: XdmaBackend.cc:117
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::XdmaBackend::isOpen
bool isOpen() override
Return whether a device has been opened or not.
Definition: XdmaBackend.cc:57