aec8c97fd71824691617d405b69fd8ed98920e5a
[fw/sdcc] / sim / ucsim / sim.src / itsrc.cc
1 /*
2  * Simulator of microcontrollers (itsrc.cc)
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 #include "ddconfig.h"
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include "i_string.h"
33
34 #include "itsrccl.h"
35 #include "pobjcl.h"
36 #include "stypes.h"
37
38
39 /*
40  * Interrupt source
41  ******************************************************************************
42  */
43
44 cl_it_src::cl_it_src(uchar Iie_mask,
45                      uchar Isrc_reg,
46                      uchar Isrc_mask,
47                      uint  Iaddr,
48                      bool  Iclr_bit,
49                      char  *Iname,
50                      int   apoll_priority):
51   cl_base()
52 {
53   poll_priority= apoll_priority;
54   ie_mask = Iie_mask;
55   src_reg = Isrc_reg;
56   src_mask= Isrc_mask;
57   addr    = Iaddr;
58   clr_bit = Iclr_bit;
59   if (Iname != NULL)
60     set_name(Iname);
61   else
62     set_name("unknown");
63   active= DD_TRUE;
64 }
65
66 cl_it_src::~cl_it_src(void) {}
67
68 bool
69 cl_it_src::is_active(void)
70 {
71   return(active);
72 }
73
74 void
75 cl_it_src::set_active_status(bool Aactive)
76 {
77   active= Aactive;
78 }
79
80 void
81 cl_it_src::activate(void)
82 {
83   set_active_status(DD_TRUE);
84 }
85
86 void
87 cl_it_src::deactivate(void)
88 {
89   set_active_status(DD_FALSE);
90 }
91
92
93 /*
94  */
95
96 cl_irqs::cl_irqs(t_index alimit, t_index adelta):
97   cl_sorted_list(alimit, adelta)
98 {
99   Duplicates= DD_TRUE;
100 }
101
102 void *
103 cl_irqs::key_of(void *item)
104 {
105   class cl_it_src *itsrc= (class cl_it_src *)item;
106   return(&itsrc->poll_priority);
107 }
108
109 int
110 cl_irqs::compare(void *key1, void *key2)
111 {
112   int *k1= (int*)key1, *k2= (int*)key2;
113
114   if (*k1 == *k2)
115     return(0);
116   else if (*k1 < *k2)
117     return(-1);
118   return(1);
119 }
120
121
122 /*
123  * Interrupt level
124  ******************************************************************************
125  */
126
127 it_level::it_level(int alevel, uint aaddr, uint aPC, class cl_it_src *is):
128   cl_base()
129 {
130   level = alevel;
131   addr  = aaddr;
132   PC    = aPC;
133   source= is;
134 }
135
136
137
138 /* End of itsrc.cc */