ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
InterruptVector.h
Go to the documentation of this file.
1 
53 #ifndef ETISS_INCLUDE_INTERRUPTVECTOR_H_
54 #define ETISS_INCLUDE_INTERRUPTVECTOR_H_
55 
56 #include "etiss/Misc.h"
57 #include "etiss/jit/types.h"
58 #include <list>
59 #include <mutex>
60 #include <set>
61 #include <vector>
62 
63 namespace etiss
64 {
65 
70 {
71  public:
72  virtual ~InterruptVector();
76  virtual void setBit(unsigned bit, bool state) = 0;
80  virtual bool getBit(unsigned bit) const = 0;
84  virtual unsigned width() const = 0;
88  virtual bool isActive() const;
92  virtual void clear();
93 
95 };
96 
97 template <typename INT>
103 {
104  public:
105  typedef typename std::vector<INT *> Vector;
110  {
111  if (vector_.size() > mask.size())
112  {
113  vector_.resize(mask.size());
114  etiss::log(etiss::ERROR, "MappedInterruptVector: the interrupt and mask vectors must have equal size.");
115  }
116  if (vector_.size() < mask.size())
117  {
118  mask.resize(vector_.size());
119  etiss::log(etiss::ERROR, "MappedInterruptVector: the interrupt and mask vectors must have equal size.");
120  }
121  }
123  virtual void setBit(unsigned bit, bool state)
124  {
125  unsigned o = bit % (sizeof(INT) * 8);
126  unsigned i = (bit - o) / (sizeof(INT) * 8);
127  if (i < vector_.size())
128  {
129  INT mask = ((INT)1) << o;
130  *vector_[i] = (*vector_[i] & ~mask) | (state ? mask : 0);
131  }
132  // std::cout << "etiss::InterruptVector::setBit called i=" << std::dec << i << "
133  // vector[i]=" << std::hex << *vector_[i] << " mask[i]=" << *mask_[i] << std::dec <<
134  // std::endl;
135  }
136  virtual bool getBit(unsigned bit) const
137  {
138  unsigned o = bit % (sizeof(INT) * 8);
139  unsigned i = (bit - o) / (sizeof(INT) * 8);
140  INT mask = ((INT)1) << o;
141  if (i < vector_.size())
142  {
143  return ((*vector_[i] & mask) & (*mask_[i] & mask)) != 0;
144  }
145  return false;
146  }
147  virtual unsigned width() const { return (unsigned)vector_.size() * sizeof(INT); }
148  virtual bool isActive() const
149  {
150  for (unsigned i = 0; i < vector_.size(); i++)
151  {
152  if (*vector_[i] & *mask_[i])
153  return true;
154  }
155  return false;
156  }
157  virtual void clear()
158  {
159  for (unsigned i = 0; i < vector_.size(); i++)
160  {
161  *vector_[i] = (INT)0;
162  }
163  }
164 
165  private:
168 };
169 
170 } // namespace etiss
171 
172 #endif
general configuration and logging
interface to set interrupt bits
virtual void clear()
sets every bit to false
virtual unsigned width() const =0
number of interrupt bits
virtual bool isActive() const
virtual bool getBit(unsigned bit) const =0
get the bit of an interrupt line
virtual void setBit(unsigned bit, bool state)=0
set the bit of an interrupt line to state (true = raised)
template implementation of an InterruptVector that uses integer variables to store interrupt bit valu...
virtual bool isActive() const
virtual void clear()
sets every bit to false
std::vector< INT * > Vector
virtual void setBit(unsigned bit, bool state)
set the bit of an interrupt line to state (true = raised)
virtual bool getBit(unsigned bit) const
get the bit of an interrupt line
MappedInterruptVector(Vector vec, Vector mask)
pass two equally long integer pointer vectors that will be used for interrupt bit vectors and masks
virtual unsigned width() const
number of interrupt bits
uint64_t INT
Definition: Fault.h:83
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53
@ ERROR
Definition: Misc.h:127
void log(Verbosity level, std::string msg)
write log message at the given level.
Definition: Misc.cpp:125