ChimeraTK-DeviceAccess  03.18.00
GenericMuxedInterruptDistributor.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 #include "../NDRegisterAccessor.h"
5 #include "../RegisterPath.h"
7 
8 #include <bitset>
9 
10 namespace ChimeraTK::async {
11 
13  ISR = 0, // Interrupt Status Register
14  IER, // Interrupt Enable Register
15  MER, // Master Enable Register,
16  MIE, // Master Interrupt Enable Functionally equivalent to MER
17  GIE, // Global Interrupt Enable, Functionally equivalent to MER
18  ICR, // Interrupt Clear Register
19  IAR, // Interrupt Acknowledge Register
20  IPR, // Interrupt Pending Register =ISR & IER, a convenience feature for software.
21  SIE, // Set Interrupt Enable
22  CIE, // Clear Interrupt Enable
23  IMaskR, // Interrupt Mask Register. IMR Acronym Collision. Temporarily not allowed. See
24  IModeR, // Interrupt Mode Register. IMR Acronym Collision, defined in the standard but not allowed; REMOVE?
25  IVR, // defined in the standard but not allowed; REMOVE?
26  ILR, // defined in the standard but not allowed; REMOVE?
27  IVAR, // defined in the standard but not allowed; REMOVE?
28  IVEAR, // defined in the standard but not allowed; REMOVE?
29  OPTION_CODE_COUNT, // used for counting how many valid enums there are here & setting list lengths
31  };
32 
33  /********************************************************************************************************************/
34 
36  public:
37  explicit GenericMuxedInterruptDistributor(const boost::shared_ptr<SubDomain<std::nullptr_t>>& parent,
38  const std::string& registerPath, std::bitset<(ulong)GmidOptionCode::OPTION_CODE_COUNT> optionRegisterSettings);
40 
44  void handle(VersionNumber version) override;
45 
46  void activate(VersionNumber version) override;
47 
53  static std::unique_ptr<GenericMuxedInterruptDistributor> create(std::string const& description, // THE JSON SNIPPET
54  const boost::shared_ptr<SubDomain<std::nullptr_t>>& parent);
55 
56  protected:
59  bool _hasMer;
60  uint32_t _activeInterrupts{0}; // like a local copy of IER
61 
62  boost::shared_ptr<NDRegisterAccessor<uint32_t>> _isr;
63  boost::shared_ptr<NDRegisterAccessor<uint32_t>> _ier; // May point to IER or Imaskr
64  boost::shared_ptr<NDRegisterAccessor<uint32_t>> _icr; // May point to ICR, IAR, or ISR, which act identically
65  boost::shared_ptr<NDRegisterAccessor<uint32_t>> _mer; // May point to MER, MIE, or GIE, all act identically.
66  // We can have at most 1 of {MIE, GIE, MER}
67  boost::shared_ptr<NDRegisterAccessor<uint32_t>> _sie; // We either have both SIE or CIE or neither.
68  boost::shared_ptr<NDRegisterAccessor<uint32_t>> _cie;
69 
70  RegisterPath _path; // just a string path, with the added overwritten / operator etc.
71 
77  void clearInterruptsFromMask(uint32_t mask);
78 
79  inline void clearOneInterrupt(uint32_t ithInterrupt);
80 
81  inline void clearAllInterrupts();
82 
83  inline void clearAllEnabledInterrupts();
84 
89  void disableInterruptsFromMask(uint32_t mask);
90 
91  inline void disableOneInterrupt(uint32_t ithInterrupt);
92 
97  void enableInterruptsFromMask(uint32_t mask);
98 
99  inline void enableOneInterrupt(uint32_t ithInterrupt);
100 
101  void activateSubDomain(SubDomain<std::nullptr_t>& subDomain, VersionNumber const& version) override;
102  };
103 
104 } // namespace ChimeraTK::async
ChimeraTK::async::GenericMuxedInterruptDistributor::_path
RegisterPath _path
Definition: GenericMuxedInterruptDistributor.h:70
ChimeraTK::async::GIE
@ GIE
Definition: GenericMuxedInterruptDistributor.h:17
ChimeraTK::async::GenericMuxedInterruptDistributor::clearAllEnabledInterrupts
void clearAllEnabledInterrupts()
Definition: GenericMuxedInterruptDistributor.cc:560
ChimeraTK::async::ILR
@ ILR
Definition: GenericMuxedInterruptDistributor.h:26
ChimeraTK::async::MER
@ MER
Definition: GenericMuxedInterruptDistributor.h:15
ChimeraTK::async::OPTION_CODE_COUNT
@ OPTION_CODE_COUNT
Definition: GenericMuxedInterruptDistributor.h:29
ChimeraTK::async::IModeR
@ IModeR
Definition: GenericMuxedInterruptDistributor.h:24
ChimeraTK::async::GenericMuxedInterruptDistributor
Definition: GenericMuxedInterruptDistributor.h:35
ChimeraTK::async::SIE
@ SIE
Definition: GenericMuxedInterruptDistributor.h:21
ChimeraTK::async::GenericMuxedInterruptDistributor::_mer
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _mer
Definition: GenericMuxedInterruptDistributor.h:65
ChimeraTK::async::SubDomain
Send backend-specific asynchronous data to different distributors:
Definition: MuxedInterruptDistributor.h:23
ChimeraTK::async::ICR
@ ICR
Definition: GenericMuxedInterruptDistributor.h:18
ChimeraTK::async::GenericMuxedInterruptDistributor::_activeInterrupts
uint32_t _activeInterrupts
Definition: GenericMuxedInterruptDistributor.h:60
ChimeraTK::async
Definition: design_AsyncNDRegisterAcessor_and_NumericAddressedBackend.dox:1
MuxedInterruptDistributor.h
ChimeraTK::async::GenericMuxedInterruptDistributor::_ierIsReallyImaskr
bool _ierIsReallyImaskr
Definition: GenericMuxedInterruptDistributor.h:57
ChimeraTK::async::GenericMuxedInterruptDistributor::_icr
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _icr
Definition: GenericMuxedInterruptDistributor.h:64
ChimeraTK::async::GenericMuxedInterruptDistributor::clearOneInterrupt
void clearOneInterrupt(uint32_t ithInterrupt)
Definition: GenericMuxedInterruptDistributor.cc:550
ChimeraTK::async::INVALID_OPTION_CODE
@ INVALID_OPTION_CODE
Definition: GenericMuxedInterruptDistributor.h:30
ChimeraTK::async::GenericMuxedInterruptDistributor::GenericMuxedInterruptDistributor
GenericMuxedInterruptDistributor(const boost::shared_ptr< SubDomain< std::nullptr_t >> &parent, const std::string &registerPath, std::bitset<(ulong) GmidOptionCode::OPTION_CODE_COUNT > optionRegisterSettings)
Definition: GenericMuxedInterruptDistributor.cc:436
ChimeraTK::async::GenericMuxedInterruptDistributor::clearInterruptsFromMask
void clearInterruptsFromMask(uint32_t mask)
In mask, 1 bits clear the corresponding registers, 0 bits do nothing.
Definition: GenericMuxedInterruptDistributor.cc:540
ChimeraTK::async::GenericMuxedInterruptDistributor::activateSubDomain
void activateSubDomain(SubDomain< std::nullptr_t > &subDomain, VersionNumber const &version) override
Function to activate a (new) single SubDomain if the MuxedInterruptDistributor is already active.
Definition: GenericMuxedInterruptDistributor.cc:717
ChimeraTK::async::GenericMuxedInterruptDistributor::enableInterruptsFromMask
void enableInterruptsFromMask(uint32_t mask)
For each bit in mask that is a 1, the corresponding interrupt gets enabled, and the internal copy of ...
Definition: GenericMuxedInterruptDistributor.cc:595
ChimeraTK::async::GenericMuxedInterruptDistributor::_cie
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _cie
Definition: GenericMuxedInterruptDistributor.h:68
ChimeraTK::async::GenericMuxedInterruptDistributor::_ier
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _ier
Definition: GenericMuxedInterruptDistributor.h:63
ChimeraTK::async::GenericMuxedInterruptDistributor::create
static std::unique_ptr< GenericMuxedInterruptDistributor > create(std::string const &description, const boost::shared_ptr< SubDomain< std::nullptr_t >> &parent)
Create parses the json configuration snippet 'description', and calls the constructor.
Definition: GenericMuxedInterruptDistributor.cc:664
ChimeraTK::async::GenericMuxedInterruptDistributor::enableOneInterrupt
void enableOneInterrupt(uint32_t ithInterrupt)
Definition: GenericMuxedInterruptDistributor.cc:631
ChimeraTK::async::GenericMuxedInterruptDistributor::~GenericMuxedInterruptDistributor
~GenericMuxedInterruptDistributor() override
Definition: GenericMuxedInterruptDistributor.cc:524
ChimeraTK::async::GenericMuxedInterruptDistributor::activate
void activate(VersionNumber version) override
Definition: GenericMuxedInterruptDistributor.cc:680
ChimeraTK::async::GenericMuxedInterruptDistributor::_haveSieAndCie
bool _haveSieAndCie
Definition: GenericMuxedInterruptDistributor.h:58
ChimeraTK::async::GenericMuxedInterruptDistributor::clearAllInterrupts
void clearAllInterrupts()
Definition: GenericMuxedInterruptDistributor.cc:555
ChimeraTK::async::GenericMuxedInterruptDistributor::handle
void handle(VersionNumber version) override
Handle gets called when a trigger comes in.
Definition: GenericMuxedInterruptDistributor.cc:636
ChimeraTK::async::MuxedInterruptDistributor
Interface base class for interrupt controller handlers.
Definition: MuxedInterruptDistributor.h:56
ChimeraTK::async::IVAR
@ IVAR
Definition: GenericMuxedInterruptDistributor.h:27
ChimeraTK::async::GenericMuxedInterruptDistributor::_sie
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _sie
Definition: GenericMuxedInterruptDistributor.h:67
ChimeraTK::async::IVEAR
@ IVEAR
Definition: GenericMuxedInterruptDistributor.h:28
ChimeraTK::async::CIE
@ CIE
Definition: GenericMuxedInterruptDistributor.h:22
ChimeraTK::async::MIE
@ MIE
Definition: GenericMuxedInterruptDistributor.h:16
ChimeraTK::async::GenericMuxedInterruptDistributor::_isr
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _isr
Definition: GenericMuxedInterruptDistributor.h:62
ChimeraTK::async::IPR
@ IPR
Definition: GenericMuxedInterruptDistributor.h:20
ChimeraTK::async::GmidOptionCode
GmidOptionCode
Definition: GenericMuxedInterruptDistributor.h:12
ChimeraTK::RegisterPath
Class to store a register path name.
Definition: RegisterPath.h:16
ChimeraTK::VersionNumber
Class for generating and holding version numbers without exposing a numeric representation.
Definition: VersionNumber.h:23
ChimeraTK::async::GenericMuxedInterruptDistributor::_hasMer
bool _hasMer
Definition: GenericMuxedInterruptDistributor.h:59
ChimeraTK::async::GenericMuxedInterruptDistributor::disableOneInterrupt
void disableOneInterrupt(uint32_t ithInterrupt)
Definition: GenericMuxedInterruptDistributor.cc:590
ChimeraTK::async::IVR
@ IVR
Definition: GenericMuxedInterruptDistributor.h:25
ChimeraTK::async::IMaskR
@ IMaskR
Definition: GenericMuxedInterruptDistributor.h:23
ChimeraTK::async::IAR
@ IAR
Definition: GenericMuxedInterruptDistributor.h:19
ChimeraTK::async::GenericMuxedInterruptDistributor::disableInterruptsFromMask
void disableInterruptsFromMask(uint32_t mask)
Disables each interrupt corresponding to the 1 bits in mask, and updates _activeInterrupts.
Definition: GenericMuxedInterruptDistributor.cc:565
ChimeraTK::async::ISR
@ ISR
Definition: GenericMuxedInterruptDistributor.h:13
ChimeraTK::async::IER
@ IER
Definition: GenericMuxedInterruptDistributor.h:14