simulavr  1.1.0
timerirq.h
Go to the documentation of this file.
1  /*
2  ****************************************************************************
3  *
4  * simulavr - A simulator for the Atmel AVR family of microcontrollers.
5  * Copyright (C) 2001, 2002, 2003 Klaus Rudolph
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  ****************************************************************************
22  *
23  * $Id$
24  */
25 
26 #ifndef TIMERIRQ
27 #define TIMERIRQ
28 #include <string>
29 #include <vector>
30 #include "hardware.h"
31 #include "irqsystem.h"
32 #include "avrdevice.h"
33 #include "rwmem.h"
34 #include "traceval.h"
35 
36 class TimerIRQRegister;
37 
39 
42 class IRQLine {
43 
44  protected:
45  friend class TimerIRQRegister;
46 
47  int irqvector;
48  std::string name;
50 
51  public:
52  IRQLine();
54  IRQLine(const std::string& name, int irqvector);
56  void fireInterrupt(void);
57  bool active();
58 };
59 
62 
63  private:
65  std::vector<IRQLine> lines;
66  std::map<std::string, int> name2line;
67  std::map<int, int> vector2line;
68  unsigned char irqmask;
69  unsigned char irqflags;
70  unsigned char bitmask;
71 
72  public:
75 
76  TimerIRQRegister(AvrDevice* core, HWIrqSystem* irqsys, int regidx = -1);
77  void registerLine(int idx, IRQLine* irq);
78  void registerLine(int idx, const IRQLine& irq);
79  IRQLine* getLine(const std::string& name);
80  void fireInterrupt(int irqvector);
81 
82  virtual void ClearIrqFlag(unsigned int vector);
83  virtual void Reset(void);
84 
85  virtual unsigned char set_from_reg(const IOSpecialReg* reg, unsigned char nv);
86  virtual unsigned char get_from_client(const IOSpecialReg* reg, unsigned char v);
87 };
88 
89 #endif // TIMERIRQ
Basic AVR device, contains the core functionality.
Definition: avrdevice.h:66
unsigned char bitmask
mask for used bits in registers
Definition: timerirq.h:70
std::vector< IRQLine > lines
list with IRQ lines
Definition: timerirq.h:65
HWIrqSystem * irqsystem
pointer to irq system
Definition: timerirq.h:64
std::map< int, int > vector2line
mapping IRQ vector to index
Definition: timerirq.h:67
int irqvector
the IRQ vector number in interrupt table, starting with 0
Definition: timerirq.h:47
unsigned char irqmask
mask register value;
Definition: timerirq.h:68
Represents a timer interrupt line, Frontend for timer interrupts.
Definition: timerirq.h:42
std::string name
name of this IRQ line
Definition: timerirq.h:48
Interface class to connect hardware units to control registers.
Definition: rwmem.h:398
IOSpecialReg tifr_reg
the TIFRx register
Definition: timerirq.h:74
TimerIRQRegister * irqreg
pointer to irq registers, where this line is hold
Definition: timerirq.h:49
Build a register for TraceValue&#39;s.
Definition: traceval.h:442
IRQLine()
Definition: timerirq.cpp:30
void fireInterrupt(void)
inform interrupt system, that an interrupt occured
Definition: timerirq.cpp:46
Provices flag and mask register for timer interrupts and connects irq lines to irqsystem.
Definition: timerirq.h:61
unsigned char irqflags
flag register value;
Definition: timerirq.h:69
bool active()
Definition: timerirq.cpp:42
friend class TimerIRQRegister
Definition: timerirq.h:45
std::map< std::string, int > name2line
mapping IRQ line name to index
Definition: timerirq.h:66
IOSpecialReg timsk_reg
the TIMSKx register
Definition: timerirq.h:73