00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef HWIRQSYSTEM
00027 #define HWIRQSYSTEM
00028
00029 #include <vector>
00030
00031 #include "hardware.h"
00032 #include "funktor.h"
00033 #include "printable.h"
00034 #include "avrdevice.h"
00035 #include "traceval.h"
00036
00038 extern bool enableIRQStatistic;
00039
00040 #ifndef SWIG
00041
00042 class IrqStatisticEntry {
00043
00044 public:
00045 SystemClockOffset flagSet;
00046 SystemClockOffset flagCleared;
00047 SystemClockOffset handlerStarted;
00048 SystemClockOffset handlerFinished;
00049
00050 SystemClockOffset setClear;
00051 SystemClockOffset setStarted;
00052 SystemClockOffset setFinished;
00053 SystemClockOffset startedFinished;
00054
00055
00056 IrqStatisticEntry():
00057 flagSet(0),
00058 flagCleared(0),
00059 handlerStarted(0),
00060 handlerFinished(0),
00061 setClear(0),
00062 setStarted(0),
00063 setFinished(0),
00064 startedFinished(0) {}
00065 void CalcDiffs();
00066 };
00067
00068 class IrqStatisticPerVector {
00069
00070 protected:
00071 IrqStatisticEntry long_SetClear;
00072 IrqStatisticEntry short_SetClear;
00073
00074 IrqStatisticEntry long_SetStarted;
00075 IrqStatisticEntry short_SetStarted;
00076
00077 IrqStatisticEntry long_SetFinished;
00078 IrqStatisticEntry short_SetFinished;
00079
00080 IrqStatisticEntry long_StartedFinished;
00081 IrqStatisticEntry short_StartedFinished;
00082
00083 friend std::ostream& operator<<(std::ostream &os, const IrqStatisticPerVector &ispv);
00084
00085 public:
00086
00087 IrqStatisticEntry actual;
00088 IrqStatisticEntry next;
00089
00090 void CalculateStatistic();
00091 void CheckComplete();
00092
00093 IrqStatisticPerVector();
00094 };
00095
00096 std::ostream& operator<<(std::ostream &, const IrqStatisticEntry&);
00097 std::ostream& operator<<(std::ostream &, const IrqStatisticPerVector&);
00098
00099 class IrqStatistic: public Printable {
00100
00101 protected:
00102 AvrDevice *core;
00103
00104 public:
00105 std::map<unsigned int, IrqStatisticPerVector> entries;
00106 IrqStatistic(AvrDevice *);
00107 void operator()();
00108
00109 virtual ~IrqStatistic() {}
00110
00111 friend std::ostream& operator<<(std::ostream &, const IrqStatistic&);
00112 };
00113
00114 std::ostream& operator<<(std::ostream &, const IrqStatistic&);
00115
00116 #endif // ifndef SWIG
00117
00118 class HWIrqSystem: public TraceValueRegister {
00119
00120 protected:
00121 int bytesPerVector;
00122 int vectorTableSize;
00123 HWSreg *status;
00124 std::vector<TraceValue*> irqTrace;
00125
00127 std::map<unsigned int, Hardware *> irqPartnerList;
00128 AvrDevice *core;
00129 IrqStatistic irqStatistic;
00130 std::vector<const Hardware*> debugInterruptTable;
00131
00132 public:
00133 HWIrqSystem (AvrDevice* _core, int bytes_per_vector, int number_of_vectors);
00134
00136 unsigned int GetNewPc(unsigned int &vector_index);
00137 void SetIrqFlag(Hardware *, unsigned int vector_index);
00138 void ClearIrqFlag(unsigned int vector_index);
00139 void IrqHandlerStarted(unsigned int vector_index);
00140 void IrqHandlerFinished(unsigned int vector_index);
00142 void DebugVerifyInterruptVector(unsigned int vector_index, const Hardware* source);
00143 void DebugDumpTable();
00144 };
00145
00146 #ifndef SWIG
00147
00148 class IrqFunktor: public Funktor {
00149
00150 protected:
00151 HWIrqSystem *irqSystem;
00152 void (HWIrqSystem::*fp)(unsigned int);
00153 unsigned int vectorNo;
00154
00155 public:
00156 IrqFunktor(HWIrqSystem *i, void (HWIrqSystem::*_fp)(unsigned int), unsigned int _vector):
00157 irqSystem(i),
00158 fp(_fp),
00159 vectorNo(_vector) {}
00160 void operator()() { (irqSystem->*fp)(vectorNo); }
00161 Funktor* clone() { return new IrqFunktor(*this); }
00162 };
00163
00164 #endif // ifndef SWIG
00165
00166 #endif
00167