1 /*
2  * Simulator of microcontrollers (sim.src/itsrccl.h)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  *
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9 
10 /* This file is part of microcontroller simulator: ucsim.
11 
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16 
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27 
28 #ifndef SIM_ITSRCCL_HEADER
29 #define SIM_ITSRCCL_HEADER
30 
31 #include "pobjcl.h"
32 #include "stypes.h"
33 
34 #include "uccl.h"
35 #include "memcl.h"
36 
37 
38 /*
39  * Represents source of interrupt
40  */
41 
42 class cl_it_src: public /*cl_base*/cl_hw
43 {
44  private:
45   class cl_uc *uc;
46  protected:
47   class cl_memory_cell *ie_cell;
48   class cl_memory_cell *src_cell;
49 public:
50   int poll_priority;
51   int    nuof;	   // Number of IT to check priority
52   t_mem  ie_mask;  // Mask in IE register
53   t_mem  src_mask; // Mask of source bit in src_reg
54   t_addr addr;     // Address of service routine
55   bool   clr_bit;  // Request bit must be cleared when IT accepted
56   bool   active;   // Acceptance can be disabled
57   bool   indirect; // address comes from a vector table from `addr'
58 
59   cl_it_src(cl_uc  *Iuc,
60 	    int    Inuof,
61 	    class  cl_memory_cell *Iie_cell,
62 	    t_mem  Iie_mask,
63 	    class  cl_memory_cell *Isrc_cell,
64 	    t_mem  Isrc_mask,
65 	    t_addr Iaddr,
66 	    bool   Iclr_bit,
67 	    bool   Iindirect,
68 	    const  char *Iname,
69 	    int    apoll_priority);
70   virtual ~cl_it_src(void);
71   virtual int init(void);
72 
73           bool is_active(void);
74   virtual void set_active_status(bool Aactive);
75   virtual void activate(void);
76   virtual void deactivate(void);
77 
78   virtual bool enabled(void);
79   virtual bool pending(void);
80   virtual void clear(void);
81 
82   virtual void write(class cl_memory_cell *cell, t_mem *val);
83   virtual t_mem read(class cl_memory_cell *cell);
84 };
85 
86 
87 class cl_irqs: public cl_sorted_list
88 {
89 public:
90   cl_irqs(t_index alimit, t_index adelta);
91   virtual void *key_of(void *item);
92   virtual int compare(void *key1, void *key2);
93 };
94 
95 
96 /*
97  * This class is used to follow levels of accepted interrupts
98  * It used on a stack of active interrupt services (it_levels of cl_uc)
99  */
100 
101 class it_level: public cl_base
102 {
103 public:
104   int level;
105   uint addr;
106   uint PC;
107   class cl_it_src *source;
108 public:
109   it_level(int alevel, uint aaddr, uint aPC, class cl_it_src *is);
110 };
111 
112 
113 #endif
114 
115 /* End of itsrccl.h */
116